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

This commit is contained in:
TreeHugger Robot
2018-04-26 21:14:46 +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); boolean disableNetwork(int netId, String packageName);
void startScan(String packageName); boolean startScan(String packageName);
List<ScanResult> getScanResults(String callingPackage); List<ScanResult> getScanResults(String callingPackage);

View File

@@ -1635,8 +1635,7 @@ public class WifiManager {
public boolean startScan(WorkSource workSource) { public boolean startScan(WorkSource workSource) {
try { try {
String packageName = mContext.getOpPackageName(); String packageName = mContext.getOpPackageName();
mService.startScan(packageName); return mService.startScan(packageName);
return true;
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); 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"); fail("setWifiApConfiguration should rethrow Exceptions from WifiService");
} catch (SecurityException e) { } } 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());
}
} }