Merge "WifiManager: setWifiApEnabled always returns false" into oc-dev

This commit is contained in:
Rebecca Silberstein
2017-05-31 15:42:27 +00:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 12 deletions

View File

@@ -1802,25 +1802,25 @@ public class WifiManager {
} }
/** /**
* Start AccessPoint mode with the specified * This call will be deprecated and removed in an upcoming release. It is no longer used to
* configuration. If the radio is already running in * start WiFi Tethering. Please use {@link ConnectivityManager#startTethering(int, boolean,
* AP mode, update the new configuration * ConnectivityManager#OnStartTetheringCallback)} if
* Note that starting in access point mode disables station * the caller has proper permissions. Callers can also use the LocalOnlyHotspot feature for a
* mode operation * hotspot capable of communicating with co-located devices {@link
* WifiManager#startLocalOnlyHotspot(LocalOnlyHotspotCallback)}.
*
* @param wifiConfig SSID, security and channel details as * @param wifiConfig SSID, security and channel details as
* part of WifiConfiguration * part of WifiConfiguration
* @return {@code true} if the operation succeeds, {@code false} otherwise * @return {@code false}
* *
* @hide * @hide
*/ */
@SystemApi @SystemApi
public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) { public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
try { String packageName = mContext.getOpPackageName();
mService.setWifiApEnabled(wifiConfig, enabled);
return true; Log.w(TAG, packageName + " attempted call to setWifiApEnabled: enabled = " + enabled);
} catch (RemoteException e) { return false;
throw e.rethrowFromSystemServer();
}
} }
/** /**

View File

@@ -778,4 +778,13 @@ public class WifiManagerTest {
verify(mWifiService).stopWatchLocalOnlyHotspot(); verify(mWifiService).stopWatchLocalOnlyHotspot();
} }
/**
* Verify that calls to setWifiApEnabled return false.
*/
@Test
public void testSetWifiApEnabledReturnsFalse() throws Exception {
assertFalse(mWifiManager.setWifiApEnabled(null, true));
assertFalse(mWifiManager.setWifiApEnabled(null, false));
verify(mWifiService, never()).setWifiApEnabled(any(), anyBoolean());
}
} }