Merge "Switch to WifiManager.{start,stop}SoftAp()"
This commit is contained in:
@@ -413,7 +413,8 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
|
|||||||
mWifiTetherRequested = enable;
|
mWifiTetherRequested = enable;
|
||||||
final WifiManager wifiManager =
|
final WifiManager wifiManager =
|
||||||
(WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
(WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||||
if (wifiManager.setWifiApEnabled(null /* use existing wifi config */, enable)) {
|
if ((enable && wifiManager.startSoftAp(null /* use existing wifi config */)) ||
|
||||||
|
(!enable && wifiManager.stopSoftAp())) {
|
||||||
return ConnectivityManager.TETHER_ERROR_NO_ERROR;
|
return ConnectivityManager.TETHER_ERROR_NO_ERROR;
|
||||||
}
|
}
|
||||||
return ConnectivityManager.TETHER_ERROR_MASTER_ERROR;
|
return ConnectivityManager.TETHER_ERROR_MASTER_ERROR;
|
||||||
|
|||||||
@@ -223,8 +223,6 @@ public class TetheringTest {
|
|||||||
@Test
|
@Test
|
||||||
public void workingLocalOnlyHotspot() throws Exception {
|
public void workingLocalOnlyHotspot() throws Exception {
|
||||||
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
|
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
|
||||||
when(mWifiManager.setWifiApEnabled(any(WifiConfiguration.class), anyBoolean()))
|
|
||||||
.thenReturn(true);
|
|
||||||
|
|
||||||
// Emulate externally-visible WifiManager effects, causing the
|
// Emulate externally-visible WifiManager effects, causing the
|
||||||
// per-interface state machine to start up, and telling us that
|
// per-interface state machine to start up, and telling us that
|
||||||
@@ -272,13 +270,12 @@ public class TetheringTest {
|
|||||||
@Test
|
@Test
|
||||||
public void workingWifiTethering() throws Exception {
|
public void workingWifiTethering() throws Exception {
|
||||||
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
|
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
|
||||||
when(mWifiManager.setWifiApEnabled(any(WifiConfiguration.class), anyBoolean()))
|
when(mWifiManager.startSoftAp(any(WifiConfiguration.class))).thenReturn(true);
|
||||||
.thenReturn(true);
|
|
||||||
|
|
||||||
// Emulate pressing the WiFi tethering button.
|
// Emulate pressing the WiFi tethering button.
|
||||||
mTethering.startTethering(ConnectivityManager.TETHERING_WIFI, null, false);
|
mTethering.startTethering(ConnectivityManager.TETHERING_WIFI, null, false);
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
verify(mWifiManager, times(1)).setWifiApEnabled(null, true);
|
verify(mWifiManager, times(1)).startSoftAp(null);
|
||||||
verifyNoMoreInteractions(mWifiManager);
|
verifyNoMoreInteractions(mWifiManager);
|
||||||
verifyNoMoreInteractions(mConnectivityManager);
|
verifyNoMoreInteractions(mConnectivityManager);
|
||||||
verifyNoMoreInteractions(mNMService);
|
verifyNoMoreInteractions(mNMService);
|
||||||
@@ -322,7 +319,7 @@ public class TetheringTest {
|
|||||||
// Emulate pressing the WiFi tethering button.
|
// Emulate pressing the WiFi tethering button.
|
||||||
mTethering.stopTethering(ConnectivityManager.TETHERING_WIFI);
|
mTethering.stopTethering(ConnectivityManager.TETHERING_WIFI);
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
verify(mWifiManager, times(1)).setWifiApEnabled(null, false);
|
verify(mWifiManager, times(1)).stopSoftAp();
|
||||||
verifyNoMoreInteractions(mWifiManager);
|
verifyNoMoreInteractions(mWifiManager);
|
||||||
verifyNoMoreInteractions(mConnectivityManager);
|
verifyNoMoreInteractions(mConnectivityManager);
|
||||||
verifyNoMoreInteractions(mNMService);
|
verifyNoMoreInteractions(mNMService);
|
||||||
|
|||||||
Reference in New Issue
Block a user