summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Kline <ek@google.com>2017-04-20 15:50:19 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-04-20 15:50:19 +0000
commit11fdd1769b51e643220910f3630d1fb31bf92153 (patch)
tree5bc7297d5d0c7c372ed095dafa7a0a6c570ce4df
parent6af3dd0fc3d15749161833fe7e1834161263990b (diff)
parent275edcb940f1fb0aba53f19b87fe76d6fd8538a0 (diff)
Merge "Switch to WifiManager.{start,stop}SoftAp()"
am: 275edcb940 Change-Id: I697bf530da9786da4ed1405ac8b44b7bc4d097a6
-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 a8cd06899bc2..3ae0e2065b7b 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 47630e28b372..b2c1244af708 100644
--- a/tests/net/java/com/android/server/connectivity/TetheringTest.java
+++ b/tests/net/java/com/android/server/connectivity/TetheringTest.java
@@ -223,8 +223,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
@@ -272,13 +270,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);
@@ -322,7 +319,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);