diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-10-05 03:12:29 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-10-05 03:12:29 +0000 |
commit | 83e8a7ab59dc750f630bdd96a8e4773e4ca984ba (patch) | |
tree | 156e534e706d48543177d6f246a54d516a113b82 | |
parent | db68688e4eeeeceb9ab1b3bc422f77458fba2f24 (diff) | |
parent | 470817b13e56d915805729ab4f51075f3fa2ec15 (diff) |
Merge "Blame scan request from WifiManager.reconnect()" into oc-mr1-dev
4 files changed, 19 insertions, 17 deletions
diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java index 6bfce74db..458f73ae6 100644 --- a/service/java/com/android/server/wifi/WifiConnectivityManager.java +++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java @@ -31,6 +31,7 @@ import android.net.wifi.WifiScanner.ScanSettings; import android.os.Handler; import android.os.Looper; import android.os.Process; +import android.os.WorkSource; import android.util.LocalLog; import android.util.Log; @@ -215,7 +216,7 @@ public class WifiConnectivityManager { @Override public void onAlarm() { - startSingleScan(mIsFullBandScan); + startSingleScan(mIsFullBandScan, WIFI_WORK_SOURCE); } } @@ -795,7 +796,7 @@ public class WifiConnectivityManager { localLog("start a single scan from watchdogHandler"); scheduleWatchdogTimer(); - startSingleScan(true); + startSingleScan(true, WIFI_WORK_SOURCE); } } @@ -824,7 +825,7 @@ public class WifiConnectivityManager { } mLastPeriodicSingleScanTimeStamp = currentTimeStamp; - startSingleScan(isFullBandScan); + startSingleScan(isFullBandScan, WIFI_WORK_SOURCE); schedulePeriodicScanTimer(mPeriodicSingleScanInterval); // Set up the next scan interval in an exponential backoff fashion. @@ -851,7 +852,7 @@ public class WifiConnectivityManager { } // Start a single scan - private void startSingleScan(boolean isFullBandScan) { + private void startSingleScan(boolean isFullBandScan, WorkSource workSource) { if (!mWifiEnabled || !mWifiConnectivityManagerEnabled) { return; } @@ -876,7 +877,7 @@ public class WifiConnectivityManager { SingleScanListener singleScanListener = new SingleScanListener(isFullBandScan); - mScanner.startScan(settings, singleScanListener, WIFI_WORK_SOURCE); + mScanner.startScan(settings, singleScanListener, workSource); } // Start a periodic scan when screen is on @@ -1133,11 +1134,11 @@ public class WifiConnectivityManager { /** * Handler for on-demand connectivity scan */ - public void forceConnectivityScan() { - localLog("forceConnectivityScan"); + public void forceConnectivityScan(WorkSource workSource) { + localLog("forceConnectivityScan in request of " + workSource); mWaitForFullBandScanResults = true; - startSingleScan(true); + startSingleScan(true, workSource); } /** diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index bb995b7d1..c83f6c6bd 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -1421,7 +1421,7 @@ public class WifiServiceImpl extends IWifiManager.Stub { public void reconnect() { enforceChangePermission(); mLog.info("reconnect uid=%").c(Binder.getCallingUid()).flush(); - mWifiStateMachine.reconnectCommand(); + mWifiStateMachine.reconnectCommand(new WorkSource(Binder.getCallingUid())); } /** diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index e04d33e5b..bc1427891 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -1875,8 +1875,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss /** * Initiate a reconnection to AP */ - public void reconnectCommand() { - sendMessage(CMD_RECONNECT); + public void reconnectCommand(WorkSource workSource) { + sendMessage(CMD_RECONNECT, workSource); } /** @@ -4537,7 +4537,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mEnableAutoJoinWhenAssociated = allowed; if (!old_state && allowed && mScreenOn && getCurrentState() == mConnectedState) { - mWifiConnectivityManager.forceConnectivityScan(); + mWifiConnectivityManager.forceConnectivityScan(WIFI_WORK_SOURCE); } break; case CMD_SELECT_TX_POWER_SCENARIO: @@ -5160,7 +5160,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mPasspointManager.getMatchingOsuProviders((ScanResult) message.obj)); break; case CMD_RECONNECT: - mWifiConnectivityManager.forceConnectivityScan(); + WorkSource workSource = (WorkSource) message.obj; + mWifiConnectivityManager.forceConnectivityScan(workSource); break; case CMD_REASSOCIATE: lastConnectAttemptTimestamp = mClock.getWallClockMillis(); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index 5fb700720..4fabd9d1e 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -1178,7 +1178,7 @@ public class WifiConnectivityManagerTest { // Force a connectivity scan which enables WifiConnectivityManager // to wait for full band scan results. - mWifiConnectivityManager.forceConnectivityScan(); + mWifiConnectivityManager.forceConnectivityScan(WIFI_WORK_SOURCE); // No roaming because no full band scan results. verify(mWifiStateMachine, times(0)).startConnectToNetwork( @@ -1189,7 +1189,7 @@ public class WifiConnectivityManagerTest { // Force a connectivity scan which enables WifiConnectivityManager // to wait for full band scan results. - mWifiConnectivityManager.forceConnectivityScan(); + mWifiConnectivityManager.forceConnectivityScan(WIFI_WORK_SOURCE); // Roaming attempt because full band scan results are available. verify(mWifiStateMachine).startConnectToNetwork( @@ -1286,14 +1286,14 @@ public class WifiConnectivityManagerTest { // its blacklist expiration time hasn't reached yet. when(mClock.getElapsedSinceBootMillis()).thenReturn(SystemClock.elapsedRealtime() + WifiConnectivityManager.BSSID_BLACKLIST_EXPIRE_TIME_MS / 2); - mWifiConnectivityManager.forceConnectivityScan(); + mWifiConnectivityManager.forceConnectivityScan(WIFI_WORK_SOURCE); assertTrue(mWifiConnectivityManager.isBssidDisabled(bssid)); // Force another connectivity scan at BSSID_BLACKLIST_EXPIRE_TIME_MS from when the // BSSID was blacklisted. Verify that the blacklisted BSSId is freed. when(mClock.getElapsedSinceBootMillis()).thenReturn(SystemClock.elapsedRealtime() + WifiConnectivityManager.BSSID_BLACKLIST_EXPIRE_TIME_MS); - mWifiConnectivityManager.forceConnectivityScan(); + mWifiConnectivityManager.forceConnectivityScan(WIFI_WORK_SOURCE); // Verify the BSSID is no longer blacklisted. assertFalse(mWifiConnectivityManager.isBssidDisabled(bssid)); |