Merge "Revert "Revert "WifiManager: Return status from startScan()""" into pi-dev

This commit is contained in:
Roshan Pius
2018-04-28 00:09:03 +00:00
committed by Android (Google) Code Review
3 changed files with 14 additions and 3 deletions

View File

@@ -85,7 +85,7 @@ interface IWifiManager
boolean disableNetwork(int netId, String packageName);
void startScan(String packageName);
boolean startScan(String packageName);
List<ScanResult> getScanResults(String callingPackage);

View File

@@ -1635,8 +1635,7 @@ public class WifiManager {
public boolean startScan(WorkSource workSource) {
try {
String packageName = mContext.getOpPackageName();
mService.startScan(packageName);
return true;
return mService.startScan(packageName);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}

View File

@@ -1070,4 +1070,16 @@ i * Verify that a call to cancel WPS immediately returns a failure.
fail("setWifiApConfiguration should rethrow Exceptions from WifiService");
} catch (SecurityException e) { }
}
/**
* Check the call to startScan calls WifiService.
*/
@Test
public void testStartScan() throws Exception {
when(mWifiService.startScan(TEST_PACKAGE_NAME)).thenReturn(true);
assertTrue(mWifiManager.startScan());
when(mWifiService.startScan(TEST_PACKAGE_NAME)).thenReturn(false);
assertFalse(mWifiManager.startScan());
}
}