| | | |
Offset 12, 36 lines modified | Offset 12, 32 lines modified |
12 | import·com.android.server.wifi.util.ApConfigUtil; | 12 | import·com.android.server.wifi.util.ApConfigUtil; |
13 | import·android.net.wifi.SoftApConfiguration$Builder; | 13 | import·android.net.wifi.SoftApConfiguration$Builder; |
14 | import·android.net.MacAddress; | 14 | import·android.net.MacAddress; |
15 | import·java.util.Locale; | 15 | import·java.util.Locale; |
16 | import·android.text.TextUtils; | 16 | import·android.text.TextUtils; |
17 | import·com.android.wifi.x.com.android.internal.util.IState; | 17 | import·com.android.wifi.x.com.android.internal.util.IState; |
18 | import·java.util.Iterator; | 18 | import·java.util.Iterator; |
19 | import·android.os.Handler; | |
20 | import·android.util.Log; | 19 | import·android.util.Log; |
21 | import·android.net.wifi.WifiClient; | 20 | import·android.net.wifi.WifiClient; |
22 | import·android.net.wifi.SoftApConfiguration; | 21 | import·android.net.wifi.SoftApConfiguration; |
23 | import·java.util.Collection; | 22 | import·java.util.Collection; |
24 | import·android.content.Context; | 23 | import·android.content.Context; |
25 | import·java.util.HashSet; | 24 | import·java.util.HashSet; |
26 | import·java.util.HashMap; | |
27 | import·java.util.ArrayList; | 25 | import·java.util.ArrayList; |
28 | import·android.os.Looper; | 26 | import·android.os.Looper; |
29 | import·android.net.wifi.WifiManager$SoftApCallback; | 27 | import·android.net.wifi.WifiManager$SoftApCallback; |
30 | import·java.util.Map; | |
31 | import·android.net.wifi.SoftApInfo; | 28 | import·android.net.wifi.SoftApInfo; |
32 | import·android.net.wifi.SoftApCapability; | 29 | import·android.net.wifi.SoftApCapability; |
33 | import·java.util.List; | 30 | import·java.util.List; |
34 | import·java.util.Set; | 31 | import·java.util.Set; |
35 | import·java.text.SimpleDateFormat; | 32 | import·java.text.SimpleDateFormat; |
| |
36 | public·class·SoftApManager·implements·ActiveModeManager | 33 | public·class·SoftApManager·implements·ActiveModeManager |
37 | { | 34 | { |
38 | ····private·static·final·SimpleDateFormat·FORMATTER; | 35 | ····private·static·final·SimpleDateFormat·FORMATTER; |
39 | ····static·final·long·SOFT_AP_PENDING_DISCONNECTION_CHECK_DELAY_MS·=·1000L; | |
40 | ····public·static·final·String·SOFT_AP_SEND_MESSAGE_TIMEOUT_TAG·=·"SoftApManager·Soft·AP·Send·Message·Timeout"; | 36 | ····public·static·final·String·SOFT_AP_SEND_MESSAGE_TIMEOUT_TAG·=·"SoftApManager·Soft·AP·Send·Message·Timeout"; |
41 | ····private·static·final·String·TAG·=·"SoftApManager"; | 37 | ····private·static·final·String·TAG·=·"SoftApManager"; |
42 | ····private·Set·mAllowedClientList; | 38 | ····private·Set·mAllowedClientList; |
43 | ····private·SoftApModeConfiguration·mApConfig; | 39 | ····private·SoftApModeConfiguration·mApConfig; |
44 | ····private·String·mApInterfaceName; | 40 | ····private·String·mApInterfaceName; |
45 | ····private·Set·mBlockedClientList; | 41 | ····private·Set·mBlockedClientList; |
46 | ····private·List·mConnectedClients; | 42 | ····private·List·mConnectedClients; |
Offset 52, 15 lines modified | Offset 48, 14 lines modified |
52 | ····private·long·mDefaultShutDownTimeoutMills; | 48 | ····private·long·mDefaultShutDownTimeoutMills; |
53 | ····private·boolean·mEverReportMetricsForMaxClient; | 49 | ····private·boolean·mEverReportMetricsForMaxClient; |
54 | ····private·final·FrameworkFacade·mFrameworkFacade; | 50 | ····private·final·FrameworkFacade·mFrameworkFacade; |
55 | ····private·boolean·mIfaceIsDestroyed; | 51 | ····private·boolean·mIfaceIsDestroyed; |
56 | ····private·boolean·mIfaceIsUp; | 52 | ····private·boolean·mIfaceIsUp; |
57 | ····private·boolean·mIsRandomizeBssid; | 53 | ····private·boolean·mIsRandomizeBssid; |
58 | ····private·final·ActiveModeManager$Listener·mModeListener; | 54 | ····private·final·ActiveModeManager$Listener·mModeListener; |
59 | ····Map·mPendingDisconnectClients; | |
60 | ····private·int·mRole; | 55 | ····private·int·mRole; |
61 | ····private·final·SarManager·mSarManager; | 56 | ····private·final·SarManager·mSarManager; |
62 | ····private·final·WifiManager$SoftApCallback·mSoftApCallback; | 57 | ····private·final·WifiManager$SoftApCallback·mSoftApCallback; |
63 | ····private·final·WifiNative$SoftApListener·mSoftApListener; | 58 | ····private·final·WifiNative$SoftApListener·mSoftApListener; |
64 | ····SoftApNotifier·mSoftApNotifier; | 59 | ····SoftApNotifier·mSoftApNotifier; |
65 | ····private·String·mStartTimestamp; | 60 | ····private·String·mStartTimestamp; |
66 | ····private·final·SoftApManager$SoftApStateMachine·mStateMachine; | 61 | ····private·final·SoftApManager$SoftApStateMachine·mStateMachine; |
Offset 74, 15 lines modified | Offset 69, 14 lines modified |
74 | ····static·{ | 69 | ····static·{ |
75 | ········FORMATTER·=·new·SimpleDateFormat("MM-dd·HH:mm:ss.SSS"); | 70 | ········FORMATTER·=·new·SimpleDateFormat("MM-dd·HH:mm:ss.SSS"); |
76 | ····} | 71 | ····} |
77 | ···· | 72 | ···· |
78 | ····public·SoftApManager(final·WifiContext·mContext,·final·Looper·looper,·final·FrameworkFacade·mFrameworkFacade,·final·WifiNative·mWifiNative,·final·String·mCountryCode,·final·ActiveModeManager$Listener·mModeListener,·final·WifiManager$SoftApCallback·mSoftApCallback,·final·WifiApConfigStore·mWifiApConfigStore,·final·SoftApModeConfiguration·softApModeConfiguration,·final·WifiMetrics·mWifiMetrics,·final·SarManager·mSarManager,·final·BaseWifiDiagnostics·mWifiDiagnostics)·{ | 73 | ····public·SoftApManager(final·WifiContext·mContext,·final·Looper·looper,·final·FrameworkFacade·mFrameworkFacade,·final·WifiNative·mWifiNative,·final·String·mCountryCode,·final·ActiveModeManager$Listener·mModeListener,·final·WifiManager$SoftApCallback·mSoftApCallback,·final·WifiApConfigStore·mWifiApConfigStore,·final·SoftApModeConfiguration·softApModeConfiguration,·final·WifiMetrics·mWifiMetrics,·final·SarManager·mSarManager,·final·BaseWifiDiagnostics·mWifiDiagnostics)·{ |
79 | ········this.mCurrentSoftApInfo·=·new·SoftApInfo(); | 74 | ········this.mCurrentSoftApInfo·=·new·SoftApInfo(); |
80 | ········this.mConnectedClients·=·new·ArrayList(); | 75 | ········this.mConnectedClients·=·new·ArrayList(); |
81 | ········this.mPendingDisconnectClients·=·new·HashMap(); | |
82 | ········boolean·mIsRandomizeBssid·=·false; | 76 | ········boolean·mIsRandomizeBssid·=·false; |
83 | ········this.mTimeoutEnabled·=·false; | 77 | ········this.mTimeoutEnabled·=·false; |
84 | ········final·int·n·=·-1; | 78 | ········final·int·n·=·-1; |
85 | ········this.mRole·=·n; | 79 | ········this.mRole·=·n; |
86 | ········this.mTargetRole·=·n; | 80 | ········this.mTargetRole·=·n; |
87 | ········this.mEverReportMetricsForMaxClient·=·false; | 81 | ········this.mEverReportMetricsForMaxClient·=·false; |
88 | ········this.mBlockedClientList·=·new·HashSet(); | 82 | ········this.mBlockedClientList·=·new·HashSet(); |
Offset 114, 28 lines modified | Offset 108, 15 lines modified |
114 | ········this.mWifiDiagnostics·=·mWifiDiagnostics; | 108 | ········this.mWifiDiagnostics·=·mWifiDiagnostics; |
115 | ········this.mStateMachine·=·new·SoftApManager$SoftApStateMachine(this,·looper); | 109 | ········this.mStateMachine·=·new·SoftApManager$SoftApStateMachine(this,·looper); |
116 | ········if·(softApConfiguration·!=·null)·{ | 110 | ········if·(softApConfiguration·!=·null)·{ |
117 | ············this.mBlockedClientList·=·new·HashSet(softApConfiguration.getBlockedClientList()); | 111 | ············this.mBlockedClientList·=·new·HashSet(softApConfiguration.getBlockedClientList()); |
118 | ············this.mAllowedClientList·=·new·HashSet(softApConfiguration.getAllowedClientList()); | 112 | ············this.mAllowedClientList·=·new·HashSet(softApConfiguration.getAllowedClientList()); |
119 | ············this.mTimeoutEnabled·=·softApConfiguration.isAutoShutdownEnabled(); | 113 | ············this.mTimeoutEnabled·=·softApConfiguration.isAutoShutdownEnabled(); |
120 | ········} | 114 | ········} |
121 | ········this.mDefaultShutDownTimeoutMills·=·this.mContext.getResources().getInteger(2131034147); | 115 | ········this.mDefaultShutDownTimeoutMills·=·this.mContext.getResources().getInteger(2131034144); |
122 | ····} | |
123 | ···· | |
124 | ····private·void·addClientToPendingDisconnectionList(final·WifiClient·wifiClient,·int·i)·{ | |
125 | ········final·StringBuilder·sb·=·new·StringBuilder(); | |
126 | ········sb.append("Fail·to·disconnect·client:·"); | |
127 | ········sb.append(wifiClient.getMacAddress()); | |
128 | ········sb.append(",·add·it·into·pending·list"); | |
129 | ········Log.d("SoftApManager",·sb.toString()); | |
130 | ········this.mPendingDisconnectClients.put(wifiClient,·i); | |
131 | ········final·Handler·handler·=·((StateMachine)this.mStateMachine).getHandler(); | |
132 | ········i·=·12; | |
133 | ········handler.removeMessages(i); | |
134 | ········((StateMachine)this.mStateMachine).sendMessageDelayed(i,·1000L); | |
135 | ····} | 116 | ····} |
136 | ···· | 117 | ···· |
137 | ····private·boolean·checkSoftApClient(final·SoftApConfiguration·softApConfiguration,·final·WifiClient·obj)·{ | 118 | ····private·boolean·checkSoftApClient(final·SoftApConfiguration·softApConfiguration,·final·WifiClient·obj)·{ |
138 | ········final·boolean·featuresSupported·=·this.mCurrentSoftApCapability.areFeaturesSupported((long)2); | 119 | ········final·boolean·featuresSupported·=·this.mCurrentSoftApCapability.areFeaturesSupported((long)2); |
139 | ········final·int·mEverReportMetricsForMaxClient·=·1; | 120 | ········final·int·mEverReportMetricsForMaxClient·=·1; |
140 | ········if·(!featuresSupported)·{ | 121 | ········if·(!featuresSupported)·{ |
141 | ············return·mEverReportMetricsForMaxClient·!=·0; | 122 | ············return·mEverReportMetricsForMaxClient·!=·0; |
Offset 144, 42 lines modified | Offset 125, 36 lines modified |
144 | ········final·String·s·=·"SoftApManager"; | 125 | ········final·String·s·=·"SoftApManager"; |
145 | ········if·(contains)·{ | 126 | ········if·(contains)·{ |
146 | ············final·StringBuilder·sb·=·new·StringBuilder(); | 127 | ············final·StringBuilder·sb·=·new·StringBuilder(); |
147 | ············sb.append("Force·disconnect·for·client:·"); | 128 | ············sb.append("Force·disconnect·for·client:·"); |
148 | ············sb.append(obj); | 129 | ············sb.append(obj); |
149 | ············sb.append("in·blocked·list"); | 130 | ············sb.append("in·blocked·list"); |
150 | ············Log.d(s,·sb.toString()); | 131 | ············Log.d(s,·sb.toString()); |
151 | ············if·(!this.mWifiNative.forceClientDisconnect(this.mApInterfaceName,·obj.getMacAddress(),·0))·{ | 132 | ············this.mWifiNative.forceClientDisconnect(this.mApInterfaceName,·obj.getMacAddress(),·0); |
152 | ················this.addClientToPendingDisconnectionList(obj,·0); | |
153 | ············} | |
154 | ············return·false; | 133 | ············return·false; |
155 | ········} | 134 | ········} |
156 | ········if·(softApConfiguration.isClientControlByUserEnabled()·&&·!this.mAllowedClientList.contains(obj.getMacAddress()))·{ | 135 | ········if·(softApConfiguration.isClientControlByUserEnabled()·&&·!this.mAllowedClientList.contains(obj.getMacAddress()))·{ |
157 | ············this.mSoftApCallback.onBlockedClientConnecting(obj,·0); | 136 | ············this.mSoftApCallback.onBlockedClientConnecting(obj,·0); |
158 | ············final·StringBuilder·sb2·=·new·StringBuilder(); | 137 | ············final·StringBuilder·sb2·=·new·StringBuilder(); |
159 | ············sb2.append("Force·disconnect·for·unauthorized·client:·"); | 138 | ············sb2.append("Force·disconnect·for·unauthorized·client:·"); |
160 | ············sb2.append(obj); | 139 | ············sb2.append(obj); |
161 | ············Log.d(s,·sb2.toString()); | 140 | ············Log.d(s,·sb2.toString()); |
162 | ············if·(!this.mWifiNative.forceClientDisconnect(this.mApInterfaceName,·obj.getMacAddress(),·0))·{ | 141 | ············this.mWifiNative.forceClientDisconnect(this.mApInterfaceName,·obj.getMacAddress(),·0); |
163 | ················this.addClientToPendingDisconnectionList(obj,·0); | |
164 | ············} | |
165 | ············return·false; | 142 | ············return·false; |
166 | ········} | 143 | ········} |
167 | ········int·a·=·this.mCurrentSoftApCapability.getMaxSupportedClients(); | 144 | ········int·a·=·this.mCurrentSoftApCapability.getMaxSupportedClients(); |
168 | ········if·(softApConfiguration.getMaxNumberOfClients()·>·0)·{ | 145 | ········if·(softApConfiguration.getMaxNumberOfClients()·>·0)·{ |
169 | ············a·=·Math.min(a,·softApConfiguration.getMaxNumberOfClients()); | 146 | ············a·=·Math.min(a,·softApConfiguration.getMaxNumberOfClients()); |
170 | ········} | 147 | ········} |
171 | ········if·(this.mConnectedClients.size()·>=·a)·{ | 148 | ········if·(this.mConnectedClients.size()·>=·a)·{ |
172 | ············final·StringBuilder·sb3·=·new·StringBuilder(); | 149 | ············final·StringBuilder·sb3·=·new·StringBuilder(); |
173 | ············sb3.append("No·more·room·for·new·client:"); | 150 | ············sb3.append("No·more·room·for·new·client:"); |
174 | ············sb3.append(obj); | 151 | ············sb3.append(obj); |
175 | ············Log.i(s,·sb3.toString()); | 152 | ············Log.i(s,·sb3.toString()); |
176 | ············if·(!this.mWifiNative.forceClientDisconnect(this.mApInterfaceName,·obj.getMacAddress(),·mEverReportMetricsForMaxClient))·{ | 153 | ············this.mWifiNative.forceClientDisconnect(this.mApInterfaceName,·obj.getMacAddress(),·mEverReportMetricsForMaxClient); |
177 | ················this.addClientToPendingDisconnectionList(obj,·mEverReportMetricsForMaxClient); | |
178 | ············} | |
179 | ············this.mSoftApCallback.onBlockedClientConnecting(obj,·mEverReportMetricsForMaxClient); | 154 | ············this.mSoftApCallback.onBlockedClientConnecting(obj,·mEverReportMetricsForMaxClient); |
180 | ············if·(!this.mEverReportMetricsForMaxClient)·{ | 155 | ············if·(!this.mEverReportMetricsForMaxClient)·{ |
181 | ················this.mWifiMetrics.noteSoftApClientBlocked(a); | 156 | ················this.mWifiMetrics.noteSoftApClientBlocked(a); |
182 | ················this.mEverReportMetricsForMaxClient·=·(mEverReportMetricsForMaxClient·!=·0); | 157 | ················this.mEverReportMetricsForMaxClient·=·(mEverReportMetricsForMaxClient·!=·0); |
183 | ············} | 158 | ············} |
184 | ············return·false; | 159 | ············return·false; |
185 | ········} | 160 | ········} |