diff options
author | Roshan Pius <rpius@google.com> | 2017-03-21 21:30:20 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-21 21:30:20 +0000 |
commit | aa28ee3bcb3a23aaaadd264047eebd1aa81587ed (patch) | |
tree | 4a0fbae2c589322f3c5df170222a02107a8f380d | |
parent | 715be5e7538f3d0394de71a2c6a0e830f7322b26 (diff) | |
parent | 8e048dfa149e15cd7e0baf0d10ff4358e79e0dca (diff) |
Merge changes I0faf4cff,If7c3473b
am: 8e048dfa14
Change-Id: Ie2454f5a076e3639c4d4b8a4ad4504207d8f83fd
4 files changed, 47 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index b49268163..20f7ac5af 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -4682,6 +4682,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss @Override public void enter() { + if (!mWifiNative.removeAllNetworks()) { + loge("Failed to remove networks on entering connect mode"); + } + // Let the system know that wifi is available in client mode. setWifiState(WIFI_STATE_ENABLED); @@ -4691,7 +4695,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss // initialize network state setNetworkDetailedState(DetailedState.DISCONNECTED); - // Inform WifiConnectivityManager that Wifi is enabled mWifiConnectivityManager.setWifiEnabled(true); // Inform metrics that Wifi is Enabled (but not yet connected) @@ -4705,10 +4708,15 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss // Let the system know that wifi is not available since we are exiting client mode. mNetworkInfo.setIsAvailable(false); if (mNetworkAgent != null) mNetworkAgent.sendNetworkInfo(mNetworkInfo); + // Inform WifiConnectivityManager that Wifi is disabled mWifiConnectivityManager.setWifiEnabled(false); // Inform metrics that Wifi is being disabled (Toggled, airplane enabled, etc) mWifiMetrics.setWifiState(WifiMetricsProto.WifiLog.WIFI_DISABLED); + + if (!mWifiNative.removeAllNetworks()) { + loge("Failed to remove networks on exiting connect mode"); + } } @Override diff --git a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java index 6f3878cf4..c7004adf9 100644 --- a/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java +++ b/service/java/com/android/server/wifi/p2p/SupplicantP2pIfaceCallback.java @@ -463,6 +463,14 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub */ public void onStaAuthorized(byte[] srcAddress, byte[] p2pDeviceAddress) { logd("STA authorized on " + mInterface); + WifiP2pDevice device = new WifiP2pDevice(); + try { + device.deviceAddress = NativeUtil.macAddressFromByteArray(p2pDeviceAddress); + } catch (Exception e) { + Log.e(TAG, "Could not decode MAC address.", e); + return; + } + mMonitor.broadcastP2pApStaConnected(mInterface, device); } @@ -474,6 +482,14 @@ public class SupplicantP2pIfaceCallback extends ISupplicantP2pIfaceCallback.Stub */ public void onStaDeauthorized(byte[] srcAddress, byte[] p2pDeviceAddress) { logd("STA deauthorized on " + mInterface); + WifiP2pDevice device = new WifiP2pDevice(); + try { + device.deviceAddress = NativeUtil.macAddressFromByteArray(p2pDeviceAddress); + } catch (Exception e) { + Log.e(TAG, "Could not decode MAC address.", e); + return; + } + mMonitor.broadcastP2pApStaDisconnected(mInterface, device); } diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pMonitor.java b/service/java/com/android/server/wifi/p2p/WifiP2pMonitor.java index 37b4d6807..50fd9325f 100644 --- a/service/java/com/android/server/wifi/p2p/WifiP2pMonitor.java +++ b/service/java/com/android/server/wifi/p2p/WifiP2pMonitor.java @@ -506,4 +506,22 @@ public class WifiP2pMonitor { String iface, List<WifiP2pServiceResponse> services) { sendMessage(iface, P2P_SERV_DISC_RESP_EVENT, services); } + + /** + * Broadcast AP STA connection event. + * + * @param iface Name of iface on which this occurred. + */ + public void broadcastP2pApStaConnected(String iface, WifiP2pDevice device) { + sendMessage(iface, AP_STA_CONNECTED_EVENT, device); + } + + /** + * Broadcast AP STA disconnection event. + * + * @param iface Name of iface on which this occurred. + */ + public void broadcastP2pApStaDisconnected(String iface, WifiP2pDevice device) { + sendMessage(iface, AP_STA_DISCONNECTED_EVENT, device); + } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 4a331e3cb..5755d9c4e 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -820,6 +820,7 @@ public class WifiStateMachineTest { mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE); mLooper.dispatchAll(); + verify(mWifiNative).removeAllNetworks(); mLooper.startAutoDispatch(); assertTrue(mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true)); @@ -857,6 +858,7 @@ public class WifiStateMachineTest { mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE); mLooper.dispatchAll(); + verify(mWifiNative).removeAllNetworks(); mLooper.startAutoDispatch(); assertTrue(mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true)); @@ -893,6 +895,7 @@ public class WifiStateMachineTest { mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE); mLooper.dispatchAll(); + verify(mWifiNative).removeAllNetworks(); mLooper.startAutoDispatch(); assertFalse(mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true)); @@ -915,6 +918,7 @@ public class WifiStateMachineTest { mWsm.setOperationalMode(WifiStateMachine.CONNECT_MODE); mLooper.dispatchAll(); + verify(mWifiNative).removeAllNetworks(); mLooper.startAutoDispatch(); mWsm.syncEnableNetwork(mWsmAsyncChannel, 0, true); |