Offset 19, 60 lines modifiedOffset 19, 64 lines modified
19 import·android.util.Log;19 import·android.util.Log;
20 import·android.net.ip.IpServer;20 import·android.net.ip.IpServer;
21 import·android.os.Looper;21 import·android.os.Looper;
22 import·java.util.ArrayList;22 import·java.util.ArrayList;
23 import·com.android.networkstack.tethering.util.State;23 import·com.android.networkstack.tethering.util.State;
24 import·com.android.networkstack.tethering.util.StateMachine;24 import·com.android.networkstack.tethering.util.StateMachine;
  
25 class·Tethering$TetherMainSM·extends·StateMachine25 class·Tethering$TetherMasterSM·extends·StateMachine
26 {26 {
27 ····static·final·int·CMD_CLEAR_ERROR·=·6;27 ····static·final·int·CMD_CLEAR_ERROR·=·6;
28 ····static·final·int·CMD_RETRY_UPSTREAM·=·4;28 ····static·final·int·CMD_RETRY_UPSTREAM·=·4;
29 ····static·final·int·CMD_UPSTREAM_CHANGED·=·3;29 ····static·final·int·CMD_UPSTREAM_CHANGED·=·3;
30 ····static·final·int·EVENT_IFACE_SERVING_STATE_ACTIVE·=·1;30 ····static·final·int·EVENT_IFACE_SERVING_STATE_ACTIVE·=·1;
31 ····static·final·int·EVENT_IFACE_SERVING_STATE_INACTIVE·=·2;31 ····static·final·int·EVENT_IFACE_SERVING_STATE_INACTIVE·=·2;
32 ····static·final·int·EVENT_IFACE_UPDATE_LINKPROPERTIES·=·7;32 ····static·final·int·EVENT_IFACE_UPDATE_LINKPROPERTIES·=·7;
33 ····static·final·int·EVENT_UPSTREAM_CALLBACK·=·5;33 ····static·final·int·EVENT_UPSTREAM_CALLBACK·=·5;
34 ····static·final·int·EVENT_UPSTREAM_PERMISSION_CHANGED·=·8;34 ····static·final·int·EVENT_UPSTREAM_PERMISSION_CHANGED·=·8;
35 ····private·final·IPv6TetheringCoordinator·mIPv6TetheringCoordinator;35 ····private·final·IPv6TetheringCoordinator·mIPv6TetheringCoordinator;
36 ····private·final·State·mInitialState;36 ····private·final·State·mInitialState;
37 ····private·final·ArrayList·mNotifyList;37 ····private·final·ArrayList·mNotifyList;
38 ····private·final·Tethering$TetherMainSM$OffloadWrapper·mOffload;38 ····private·final·Tethering$TetherMasterSM$OffloadWrapper·mOffload;
39 ····private·final·State·mSetDnsForwardersErrorState;39 ····private·final·State·mSetDnsForwardersErrorState;
40 ····private·final·State·mSetIpForwardingDisabledErrorState;40 ····private·final·State·mSetIpForwardingDisabledErrorState;
41 ····private·final·State·mSetIpForwardingEnabledErrorState;41 ····private·final·State·mSetIpForwardingEnabledErrorState;
42 ····private·final·State·mStartTetheringErrorState;42 ····private·final·State·mStartTetheringErrorState;
43 ····private·final·State·mStopTetheringErrorState;43 ····private·final·State·mStopTetheringErrorState;
44 ····private·final·State·mTetherModeAliveState;44 ····private·final·State·mTetherModeAliveState;
45 ····final·/*·synthetic·*/·Tethering·this$0;45 ····final·/*·synthetic·*/·Tethering·this$0;
46 ····46 ····
47 ····Tethering$TetherMainSM(final·Tethering·this$0,·final·String·s,·final·Looper·looper,·final·TetheringDependencies·tetheringDependencies)·{47 ····Tethering$TetherMasterSM(final·Tethering·this$0,·final·String·s,·final·Looper·looper,·final·TetheringDependencies·tetheringDependencies)·{
48 ········this.this$0·=·this$0;48 ········this.this$0·=·this$0;
49 ········super(s,·looper);49 ········super(s,·looper);
50 ········this.mInitialState·=·(State)new·Tethering$TetherMainSM$InitialState(this);50 ········this.mInitialState·=·(State)new·Tethering$TetherMasterSM$InitialState(this);
51 ········this.mTetherModeAliveState·=·(State)new·Tethering$TetherMainSM$TetherModeAliveState(this);51 ········this.mTetherModeAliveState·=·(State)new·Tethering$TetherMasterSM$TetherModeAliveState(this);
52 ········this.mSetIpForwardingEnabledErrorState·=·(State)new·Tethering$TetherMainSM$SetIpForwardingEnabledErrorState(this);52 ········this.mSetIpForwardingEnabledErrorState·=·(State)new·Tethering$TetherMasterSM$SetIpForwardingEnabledErrorState(this);
53 ········this.mSetIpForwardingDisabledErrorState·=·(State)new·Tethering$TetherMainSM$SetIpForwardingDisabledErrorState(this);53 ········this.mSetIpForwardingDisabledErrorState·=·(State)new·Tethering$TetherMasterSM$SetIpForwardingDisabledErrorState(this);
54 ········this.mStartTetheringErrorState·=·(State)new·Tethering$TetherMainSM$StartTetheringErrorState(this);54 ········this.mStartTetheringErrorState·=·(State)new·Tethering$TetherMasterSM$StartTetheringErrorState(this);
55 ········this.mStopTetheringErrorState·=·(State)new·Tethering$TetherMainSM$StopTetheringErrorState(this);55 ········this.mStopTetheringErrorState·=·(State)new·Tethering$TetherMasterSM$StopTetheringErrorState(this);
56 ········this.mSetDnsForwardersErrorState·=·(State)new·Tethering$TetherMainSM$SetDnsForwardersErrorState(this);56 ········this.mSetDnsForwardersErrorState·=·(State)new·Tethering$TetherMasterSM$SetDnsForwardersErrorState(this);
57 ········this.addState(this.mInitialState);57 ········this.addState(this.mInitialState);
58 ········this.addState(this.mTetherModeAliveState);58 ········this.addState(this.mTetherModeAliveState);
59 ········this.addState(this.mSetIpForwardingEnabledErrorState);59 ········this.addState(this.mSetIpForwardingEnabledErrorState);
60 ········this.addState(this.mSetIpForwardingDisabledErrorState);60 ········this.addState(this.mSetIpForwardingDisabledErrorState);
61 ········this.addState(this.mStartTetheringErrorState);61 ········this.addState(this.mStartTetheringErrorState);
62 ········this.addState(this.mStopTetheringErrorState);62 ········this.addState(this.mStopTetheringErrorState);
63 ········this.addState(this.mSetDnsForwardersErrorState);63 ········this.addState(this.mSetDnsForwardersErrorState);
64 ········final·ArrayList·mNotifyList·=·new·ArrayList();64 ········final·ArrayList·mNotifyList·=·new·ArrayList();
65 ········this.mNotifyList·=·mNotifyList;65 ········this.mNotifyList·=·mNotifyList;
66 ········this.mIPv6TetheringCoordinator·=·tetheringDependencies.getIPv6TetheringCoordinator(mNotifyList,·Tethering.access$600(this$0));66 ········this.mIPv6TetheringCoordinator·=·tetheringDependencies.getIPv6TetheringCoordinator(mNotifyList,·Tethering.access$600(this$0));
67 ········this.mOffload·=·new·Tethering$TetherMainSM$OffloadWrapper(this);67 ········this.mOffload·=·new·Tethering$TetherMasterSM$OffloadWrapper(this);
68 ········this.setInitialState(this.mInitialState);68 ········this.setInitialState(this.mInitialState);
69 ····}69 ····}
70 ····70 ····
 71 ····private·void·addUpstreamPrefixes(final·UpstreamNetworkState·upstreamNetworkState)·{
 72 ········Tethering.access$4300(this.this$0).updateUpstreamPrefix(upstreamNetworkState.network,·upstreamNetworkState.linkProperties);
 73 ····}
 74 ····
71 ····private·void·handleInterfaceServingStateActive(int·n,·final·IpServer·ipServer)·{75 ····private·void·handleInterfaceServingStateActive(int·n,·final·IpServer·ipServer)·{
72 ········if·(this.mNotifyList.indexOf(ipServer)·<·0)·{76 ········if·(this.mNotifyList.indexOf(ipServer)·<·0)·{
73 ············this.mNotifyList.add(ipServer);77 ············this.mNotifyList.add(ipServer);
74 ············this.mIPv6TetheringCoordinator.addActiveDownstream(ipServer,·n);78 ············this.mIPv6TetheringCoordinator.addActiveDownstream(ipServer,·n);
75 ········}79 ········}
76 ········final·int·n2·=·2;80 ········final·int·n2·=·2;
77 ········if·(n·==·n2)·{81 ········if·(n·==·n2)·{
Offset 116, 14 lines modifiedOffset 120, 18 lines modified
116 ············}120 ············}
117 ············else·{121 ············else·{
118 ················Tethering.access$4200(this.this$0).updateInterfaceIpState(ipServer.interfaceName(),·-1);122 ················Tethering.access$4200(this.this$0).updateInterfaceIpState(ipServer.interfaceName(),·-1);
119 ············}123 ············}
120 ········}124 ········}
121 ····}125 ····}
122 ····126 ····
 127 ····private·void·removeUpstreamPrefixes(final·UpstreamNetworkState·upstreamNetworkState)·{
 128 ········Tethering.access$4300(this.this$0).removeUpstreamPrefix(upstreamNetworkState.network);
 129 ····}
 130 ····
123 ····protected·void·chooseUpstreamType(final·boolean·b)·{131 ····protected·void·chooseUpstreamType(final·boolean·b)·{
124 ········Tethering.access$3500(this.this$0);132 ········Tethering.access$3500(this.this$0);
125 ········final·TetheringConfiguration·access$000·=·Tethering.access$000(this.this$0);133 ········final·TetheringConfiguration·access$000·=·Tethering.access$000(this.this$0);
126 ········UpstreamNetworkState·upstreamNetwork;134 ········UpstreamNetworkState·upstreamNetwork;
127 ········if·(access$000.chooseUpstreamAutomatically)·{135 ········if·(access$000.chooseUpstreamAutomatically)·{
128 ············upstreamNetwork·=·Tethering.access$3600(this.this$0).getCurrentPreferredUpstream();136 ············upstreamNetwork·=·Tethering.access$3600(this.this$0).getCurrentPreferredUpstream();
129 ········}137 ········}
Offset 164, 19 lines modifiedOffset 172, 19 lines modified
164 ············return;172 ············return;
165 ········}173 ········}
166 ········final·UpstreamNetworkState·upstreamNetworkState·=·(UpstreamNetworkState)o;174 ········final·UpstreamNetworkState·upstreamNetworkState·=·(UpstreamNetworkState)o;
167 ········final·int·n·=·3;175 ········final·int·n·=·3;
168 ········final·int·n2·=·2;176 ········final·int·n2·=·2;
169 ········if·(equals·!=·n2)·{177 ········if·(equals·!=·n2)·{
170 ············if·(equals·==·n)·{178 ············if·(equals·==·n)·{
171 ················Tethering.access$4300(this.this$0).removeUpstreamPrefix(upstreamNetworkState.network);179 ················this.removeUpstreamPrefixes(upstreamNetworkState);
172 ············}180 ············}
173 ········}181 ········}
174 ········else·{182 ········else·{
175 ············Tethering.access$4300(this.this$0).updateUpstreamPrefix(upstreamNetworkState);183 ············this.addUpstreamPrefixes(upstreamNetworkState);
176 ········}184 ········}
177 ········if·(upstreamNetworkState·!=·null·&&·Tethering.access$3900(this.this$0,·upstreamNetworkState))·{185 ········if·(upstreamNetworkState·!=·null·&&·Tethering.access$3900(this.this$0,·upstreamNetworkState))·{
178 ············if·(equals·!=·1)·{186 ············if·(equals·!=·1)·{
179 ················if·(equals·!=·n2)·{187 ················if·(equals·!=·n2)·{
180 ····················if·(equals·!=·n)·{188 ····················if·(equals·!=·n)·{
181 ························final·SharedLog·access$600·=·Tethering.access$600(this.this$0);189 ························final·SharedLog·access$600·=·Tethering.access$600(this.this$0);
182 ························o·=·new·StringBuilder();190 ························o·=·new·StringBuilder();
Offset 299, 29 lines modifiedOffset 307, 29 lines modified
299 ············this.handleNewUpstreamNetworkState(upstreamNetworkState);307 ············this.handleNewUpstreamNetworkState(upstreamNetworkState);
300 ········}308 ········}
301 ········else·if·(Tethering.access$4000(this.this$0)·==·null)·{309 ········else·if·(Tethering.access$4000(this.this$0)·==·null)·{
302 ············this.handleNewUpstreamNetworkState(null);310 ············this.handleNewUpstreamNetworkState(null);
303 ········}311 ········}
304 ····}312 ····}
305 ····313 ····
306 ····protected·boolean·turnOffMainTetherSettings()·{314 ····protected·boolean·turnOffMasterTetherSettings()·{
307 ········try·{315 ········try·{
308 ············final·Tethering·this$0·=·this.this$0;316 ············final·Tethering·this$0·=·this.this$0;
309 ············try·{317 ············try·{
310 ················final·INetd·access$400·=·Tethering.access$400(this$0);318 ················final·INetd·access$400·=·Tethering.access$400(this$0);
311 ················try·{319 ················try·{
312 ····················access$400.tetherStop();320 ····················access$400.tetherStop();
313 ····················try·{321 ····················try·{
314 ························final·Tethering·this$2·=·this.this$0;322 ························final·Tethering·this$2·=·this.this$0;
315 ························try·{323 ························try·{
316 ····························final·INetd·access$401·=·Tethering.access$400(this$2);324 ····························final·INetd·access$401·=·Tethering.access$400(this$2);
317 ····························try·{325 ····························try·{
318 ································access$401.ipfwdDisableForwarding(Tethering.access$3400());326 ································access$401.ipfwdDisableForwarding(Tethering.access$3400());
319 ································this.transitionTo((IState)this.mInitialState);327 ································this.transitionTo((IState)this.mInitialState);
320 ································Tethering.access$600(this.this$0).log("SET·main·tether·settings:·OFF");328 ································Tethering.access$600(this.this$0).log("SET·master·tether·settings:·OFF");
321 ································return·true;329 ································return·true;
322 ····························}330 ····························}
323 ····························catch·(RemoteException·|·ServiceSpecificException·ex3)·{331 ····························catch·(RemoteException·|·ServiceSpecificException·ex3)·{
324 ································final·Exception·ex;332 ································final·Exception·ex;
325 ································Tethering.access$600(this.this$0).e(ex);333 ································Tethering.access$600(this.this$0).e(ex);
326 ································this.transitionTo((IState)this.mSetIpForwardingDisabledErrorState);334 ································this.transitionTo((IState)this.mSetIpForwardingDisabledErrorState);
327 ································return·false;335 ································return·false;
Offset 343, 15 lines modifiedOffset 351, 15 lines modified
343 ············catch·(RemoteException·ex9)·{}351 ············catch·(RemoteException·ex9)·{}
344 ············catch·(ServiceSpecificException·ex10)·{}352 ············catch·(ServiceSpecificException·ex10)·{}
345 ········}353 ········}
346 ········catch·(RemoteException·ex11)·{}354 ········catch·(RemoteException·ex11)·{}
347 ········catch·(ServiceSpecificException·ex12)·{}355 ········catch·(ServiceSpecificException·ex12)·{}
348 ····}356 ····}
349 ····357 ····
350 ····protected·boolean·turnOnMainTetherSettings()·{358 ····protected·boolean·turnOnMasterTetherSettings()·{
351 ········final·TetheringConfiguration·access$000·=·Tethering.access$000(this.this$0);359 ········final·TetheringConfiguration·access$000·=·Tethering.access$000(this.this$0);
352 ········try·{360 ········try·{
353 ············final·Tethering·this$0·=·this.this$0;361 ············final·Tethering·this$0·=·this.this$0;
354 ············try·{362 ············try·{
355 ················final·INetd·access$2·=·Tethering.access$400(this$0);363 ················final·INetd·access$2·=·Tethering.access$400(this$0);
356 ················try·{364 ················try·{
357 ····················access$2.ipfwdEnableForwarding(Tethering.access$3400());365 ····················access$2.ipfwdEnableForwarding(Tethering.access$3400());
Offset 365, 57 lines modifiedOffset 373, 57 lines modified
365 ····················final·boolean·b·=·true;373 ····················final·boolean·b·=·true;
366 ····················try·{374 ····················try·{
367 ························final·Tethering·this$2·=·this.this$0;375 ························final·Tethering·this$2·=·this.this$0;
368 ························try·{376 ························try·{
369 ····························NetdUtils.tetherStart(Tethering.access$400(this$2),·b,·legacyDhcpRanges);377 ····························NetdUtils.tetherStart(Tethering.access$400(this$2),·b,·legacyDhcpRanges);
370 ························}378 ························}
371 ························catch·(RemoteException·|·ServiceSpecificException·ex3)·{379 ························catch·(RemoteException·|·ServiceSpecificException·ex3)·{
372 ····························final·Tethering$TetherMainSM·tethering$TetherMainSM·=·this;380 ····························final·Tethering$TetherMasterSM·tethering$TetherMasterSM·=·this;
373 ····························final·Tethering·this$3·=·tethering$TetherMainSM.this$0;381 ····························final·Tethering·this$3·=·tethering$TetherMasterSM.this$0;
374 ····························final·Tethering·tethering;382 ····························final·Tethering·tethering;
375 ····························final·Tethering·this$4·=·tethering·=·this$3;383 ····························final·Tethering·this$4·=·tethering·=·this$3;
376 ····························final·INetd·access$3·=·Tethering.access$400(tethering);384 ····························final·INetd·access$3·=·Tethering.access$400(tethering);
377 ····························final·INetd·netd;385 ····························final·INetd·netd;
378 ····························final·INetd·access$4·=·netd·=·access$3;386 ····························final·INetd·access$4·=·netd·=·access$3;
379 ····························netd.tetherStop();387 ····························netd.tetherStop();
380 ····························final·Tethering$TetherMainSM·tethering$TetherMainSM2·=·this;388 ····························final·Tethering$TetherMasterSM·tethering$TetherMasterSM2·=·this;
381 ····························final·Tethering·this$5·=·tethering$TetherMainSM2.this$0;389 ····························final·Tethering·this$5·=·tethering$TetherMasterSM2.this$0;
382 ····························final·Tethering·tethering2;390 ····························final·Tethering·tethering2;
383 ····························final·Tethering·this$6·=·tethering2·=·this$5;391 ····························final·Tethering·this$6·=·tethering2·=·this$5;
384 ····························final·INetd·access$5·=·Tethering.access$400(tethering2);392 ····························final·INetd·access$5·=·Tethering.access$400(tethering2);
385 ····························final·INetd·access$6·=·access$5;393 ····························final·INetd·access$6·=·access$5;
386 ····························final·boolean·b2·=·b;394 ····························final·boolean·b2·=·b;
387 ····························final·String[]·array·=·legacyDhcpRanges;395 ····························final·String[]·array·=·legacyDhcpRanges;
388 ····························NetdUtils.tetherStart(access$6,·b2,·array);396 ····························NetdUtils.tetherStart(access$6,·b2,·array);
389 ························}397 ························}
390 ····················}398 ····················}
391 ····················catch·(RemoteException·ex4)·{}399 ····················catch·(RemoteException·ex4)·{}
392 ····················catch·(ServiceSpecificException·ex5)·{}400 ····················catch·(ServiceSpecificException·ex5)·{}
393 ····················try·{401 ····················try·{
394 ························final·Tethering$TetherMainSM·tethering$TetherMainSM·=·this;402 ························final·Tethering$TetherMasterSM·tethering$TetherMasterSM·=·this;
395 ························final·Tethering·this$4;403 ························final·Tethering·this$4;
396 ························final·Tethering·this$3·=·this$4·=·tethering$TetherMainSM.this$0;404 ························final·Tethering·this$3·=·this$4·=·tethering$TetherMasterSM.this$0;
397 ························try·{405 ························try·{
398 ····························final·Tethering·tethering·=·this$4;406 ····························final·Tethering·tethering·=·this$4;
399 ····························final·INetd·access$4;407 ····························final·INetd·access$4;
400 ····························final·INetd·access$3·=·access$4·=·Tethering.access$400(tethering);408 ····························final·INetd·access$3·=·access$4·=·Tethering.access$400(tethering);
401 ····························try·{409 ····························try·{
402 ································final·INetd·netd·=·access$4;410 ································final·INetd·netd·=·access$4;
403 ································netd.tetherStop();411 ································netd.tetherStop();
404 ································final·Tethering$TetherMainSM·tethering$TetherMainSM2·=·this;412 ································final·Tethering$TetherMasterSM·tethering$TetherMasterSM2·=·this;
405 ································final·Tethering·this$6;413 ································final·Tethering·this$6;
406 ································final·Tethering·this$5·=·this$6·=·tethering$TetherMainSM2.this$0;414 ································final·Tethering·this$5·=·this$6·=·tethering$TetherMasterSM2.this$0;
407 ································try·{415 ································try·{
408 ····································final·Tethering·tethering2·=·this$6;416 ····································final·Tethering·tethering2·=·this$6;
409 ····································final·INetd·access$6;417 ····································final·INetd·access$6;
410 ····································final·INetd·access$5·=·access$6·=·Tethering.access$400(tethering2);418 ····································final·INetd·access$5·=·access$6·=·Tethering.access$400(tethering2);
411 ····································final·boolean·b2·=·b;419 ····································final·boolean·b2·=·b;
412 ····································final·String[]·array·=·legacyDhcpRanges;420 ····································final·String[]·array·=·legacyDhcpRanges;
413 ····································NetdUtils.tetherStart(access$6,·b2,·array);421 ····································NetdUtils.tetherStart(access$6,·b2,·array);
414 ····································Tethering.access$600(this.this$0).log("SET·main·tether·settings:·ON");422 ····································Tethering.access$600(this.this$0).log("SET·master·tether·settings:·ON");
415 ····································return·b;423 ····································return·b;
416 ································}424 ································}
417 ································catch·(RemoteException·|·ServiceSpecificException·ex6)·{425 ································catch·(RemoteException·|·ServiceSpecificException·ex6)·{
418 ····································final·Exception·ex;426 ····································final·Exception·ex;
419 ····································Tethering.access$600(this.this$0).e(ex);427 ····································Tethering.access$600(this.this$0).e(ex);
420 ····································this.transitionTo((IState)this.mStartTetheringErrorState);428 ····································this.transitionTo((IState)this.mStartTetheringErrorState);
421 ····································return·false;429 ····································return·false;