diff options
author | Doris Ling <dling@google.com> | 2018-04-26 22:29:12 +0000 |
---|---|---|
committer | Doris Ling <dling@google.com> | 2018-04-26 22:30:51 +0000 |
commit | bef13ac26de200570a6b5cfc1c679a54f5c436cb (patch) | |
tree | c7bb0b39b74e477d1c41eb6bce6bd47c3565e83b | |
parent | 7daee3fabb13a50a788fb2eb7aaec1f9ebc62efc (diff) |
Revert "WifiService: Return status from startScan()"
This reverts commit 7daee3fabb13a50a788fb2eb7aaec1f9ebc62efc.
Bug: 77297012
Change-Id: Iae02ea6b2dbe5a87849b0d00bbbb146a18e3b2f9
Reason: the change in the topic is breaking the build
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 28 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 30 |
2 files changed, 15 insertions, 43 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 61daadcd1..1a5e0e27d 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -601,14 +601,15 @@ public class WifiServiceImpl extends IWifiManager.Stub { } /** - * See {@link android.net.wifi.WifiManager#startScan} + * see {@link android.net.wifi.WifiManager#startScan} + * and {@link android.net.wifi.WifiManager#startCustomizedScan} * * @param packageName Package name of the app that requests wifi scan. */ @Override - public boolean startScan(String packageName) { + public void startScan(String packageName) { if (enforceChangePermission(packageName) != MODE_ALLOWED) { - return false; + return; } int callingUid = Binder.getCallingUid(); @@ -624,24 +625,19 @@ public class WifiServiceImpl extends IWifiManager.Stub { // be sent directly until b/31398592 is fixed. sendFailedScanBroadcast(); mScanPending = true; - return false; + return; } } - Mutable<Boolean> scanSuccess = new Mutable<>(); - boolean runWithScissorsSuccess = mWifiInjector.getWifiStateMachineHandler() - .runWithScissors(() -> { - scanSuccess.value = mScanRequestProxy.startScan(callingUid, packageName); - }, RUN_WITH_SCISSORS_TIMEOUT_MILLIS); - if (!runWithScissorsSuccess) { + boolean success = mWifiInjector.getWifiStateMachineHandler().runWithScissors(() -> { + if (!mScanRequestProxy.startScan(callingUid, packageName)) { + Log.e(TAG, "Failed to start scan"); + } + }, RUN_WITH_SCISSORS_TIMEOUT_MILLIS); + if (!success) { + // TODO: should return false here Log.e(TAG, "Failed to post runnable to start scan"); sendFailedScanBroadcast(); - return false; } - if (!scanSuccess.value) { - Log.e(TAG, "Failed to start scan"); - return false; - } - return true; } // Send a failed scan broadcast to indicate the current scan request failed. diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 6280ae1da..136d029d3 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -311,7 +311,6 @@ public class WifiServiceImplTest { when(mContext.getOpPackageName()).thenReturn(TEST_PACKAGE_NAME); when(mContext.checkPermission(eq(android.Manifest.permission.NETWORK_SETTINGS), anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED); - when(mScanRequestProxy.startScan(anyInt(), anyString())).thenReturn(true); ArgumentCaptor<SoftApCallback> softApCallbackCaptor = ArgumentCaptor.forClass(SoftApCallback.class); @@ -1023,18 +1022,6 @@ public class WifiServiceImplTest { } /** - * Ensure that we handle app ops check failure when handling scan request. - */ - @Test - public void testStartScanFailureAppOpsIgnored() { - setupWifiStateMachineHandlerForRunWithScissors(); - doReturn(AppOpsManager.MODE_IGNORED).when(mAppOpsManager) - .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), SCAN_PACKAGE_NAME); - assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME)); - verify(mScanRequestProxy, never()).startScan(Process.myUid(), SCAN_PACKAGE_NAME); - } - - /** * Ensure that we handle scan request failure when posting the runnable to handler fails. */ @Ignore @@ -1043,21 +1030,10 @@ public class WifiServiceImplTest { setupWifiStateMachineHandlerForRunWithScissors(); doReturn(false).when(mHandlerSpyForWsmRunWithScissors) .runWithScissors(any(), anyLong()); - assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME)); + mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME); verify(mScanRequestProxy, never()).startScan(Process.myUid(), SCAN_PACKAGE_NAME); } - /** - * Ensure that we handle scan request failure from ScanRequestProxy fails. - */ - @Test - public void testStartScanFailureFromScanRequestProxy() { - setupWifiStateMachineHandlerForRunWithScissors(); - when(mScanRequestProxy.startScan(anyInt(), anyString())).thenReturn(false); - assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME)); - verify(mScanRequestProxy).startScan(Process.myUid(), SCAN_PACKAGE_NAME); - } - static final String TEST_SSID = "Sid's Place"; static final String TEST_SSID_WITH_QUOTES = "\"" + TEST_SSID + "\""; static final String TEST_BSSID = "01:02:03:04:05:06"; @@ -2549,7 +2525,7 @@ public class WifiServiceImplTest { TestUtil.sendIdleModeChanged(mBroadcastReceiverCaptor.getValue(), mContext); // Send a scan request while the device is idle. - assertFalse(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME)); + mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME); // No scans must be made yet as the device is idle. verify(mScanRequestProxy, never()).startScan(Process.myUid(), SCAN_PACKAGE_NAME); @@ -2566,7 +2542,7 @@ public class WifiServiceImplTest { // Send another scan request. The device is not idle anymore, so it must be executed // immediately. - assertTrue(mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME)); + mWifiServiceImpl.startScan(SCAN_PACKAGE_NAME); verify(mScanRequestProxy).startScan(Process.myUid(), SCAN_PACKAGE_NAME); } |