summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Erik Kline <ek@google.com> 2017-04-18 14:22:25 +0900
committer Erik Kline <ek@google.com> 2017-04-18 15:22:49 +0900
commitceb54c63dc7af8f11ec9eac4993a43b9e788ee2f (patch)
tree74e834d060f19d5875fcbce895582966fb478f95
parent6d033475b307ae95d0e733a3be9260525aa2879d (diff)
Switch to WifiManager.{start,stop}SoftAp()
Test: as follows - built - flashed - booted - "runtest frameworks-net" passes Bug: 31466854 Change-Id: I730d029128a14b936c111ae159b9708d935f4656
-rw-r--r--services/core/java/com/android/server/connectivity/Tethering.java3
-rw-r--r--tests/net/java/com/android/server/connectivity/TetheringTest.java9
2 files changed, 5 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java
index 460d5f9f1db8..1ed0c408e99b 100644
--- a/services/core/java/com/android/server/connectivity/Tethering.java
+++ b/services/core/java/com/android/server/connectivity/Tethering.java
@@ -413,7 +413,8 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
mWifiTetherRequested = enable;
final WifiManager wifiManager =
(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_MASTER_ERROR;
diff --git a/tests/net/java/com/android/server/connectivity/TetheringTest.java b/tests/net/java/com/android/server/connectivity/TetheringTest.java
index e527d57f7367..35f3fcf1ee3b 100644
--- a/tests/net/java/com/android/server/connectivity/TetheringTest.java
+++ b/tests/net/java/com/android/server/connectivity/TetheringTest.java
@@ -183,8 +183,6 @@ public class TetheringTest {
@Test
public void workingLocalOnlyHotspot() throws Exception {
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
- when(mWifiManager.setWifiApEnabled(any(WifiConfiguration.class), anyBoolean()))
- .thenReturn(true);
// Emulate externally-visible WifiManager effects, causing the
// per-interface state machine to start up, and telling us that
@@ -234,13 +232,12 @@ public class TetheringTest {
@Test
public void workingWifiTethering() throws Exception {
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
- when(mWifiManager.setWifiApEnabled(any(WifiConfiguration.class), anyBoolean()))
- .thenReturn(true);
+ when(mWifiManager.startSoftAp(any(WifiConfiguration.class))).thenReturn(true);
// Emulate pressing the WiFi tethering button.
mTethering.startTethering(ConnectivityManager.TETHERING_WIFI, null, false);
mLooper.dispatchAll();
- verify(mWifiManager, times(1)).setWifiApEnabled(null, true);
+ verify(mWifiManager, times(1)).startSoftAp(null);
verifyNoMoreInteractions(mWifiManager);
verifyNoMoreInteractions(mConnectivityManager);
verifyNoMoreInteractions(mNMService);
@@ -286,7 +283,7 @@ public class TetheringTest {
// Emulate pressing the WiFi tethering button.
mTethering.stopTethering(ConnectivityManager.TETHERING_WIFI);
mLooper.dispatchAll();
- verify(mWifiManager, times(1)).setWifiApEnabled(null, false);
+ verify(mWifiManager, times(1)).stopSoftAp();
verifyNoMoreInteractions(mWifiManager);
verifyNoMoreInteractions(mConnectivityManager);
verifyNoMoreInteractions(mNMService);