diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-05-01 22:38:45 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-05-01 22:38:45 +0000 |
commit | 909ad15e03f4145c444310498dcaf453bebf7f1f (patch) | |
tree | 84a90bf3de0876fd1dbc5db76747330357b0f9c8 | |
parent | 8d1925ab9cce5ad312987272bca1fb838c93de8c (diff) | |
parent | b09edccf2056d1106da4b901e1e8b26841a02a61 (diff) |
WifiServiceImpl: add tethering check for LOHS
am: b09edccf20
Change-Id: Ide41733117eeb58e3d2cbf810a8c05b083a29bc7
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 10 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 15 |
2 files changed, 25 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 656582c31..787287c84 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -893,6 +893,15 @@ public class WifiServiceImpl extends IWifiManager.Stub { mLog.trace("startLocalOnlyHotspot uid=%").c(uid).flush(); + // check current mode to see if we can start localOnlyHotspot + boolean apDisabled = + mWifiStateMachine.syncGetWifiApState() == WifiManager.WIFI_AP_STATE_DISABLED; + if (!apDisabled) { + // Tethering is enabled, cannot start LocalOnlyHotspot + mLog.trace("Cannot start localOnlyHotspot when WiFi Tethering is active."); + return null; + } + throw new UnsupportedOperationException("LocalOnlyHotspot is still in development"); } @@ -909,6 +918,7 @@ public class WifiServiceImpl extends IWifiManager.Stub { final int uid = Binder.getCallingUid(); mLog.trace("stopLocalOnlyHotspot uid=%").c(uid).flush(); + throw new UnsupportedOperationException("LocalOnlyHotspot is still in development"); } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 1553f3a7e..3c8c9f03a 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -25,6 +25,7 @@ import static com.android.server.wifi.WifiController.CMD_WIFI_TOGGLED; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; @@ -701,6 +702,7 @@ public class WifiServiceImplTest { // allow test to proceed without a permission check failure when(mSettingsStore.getLocationModeSetting(mContext)) .thenReturn(LOCATION_MODE_HIGH_ACCURACY); + when(mWifiStateMachine.syncGetWifiApState()).thenReturn(WifiManager.WIFI_AP_STATE_DISABLED); mWifiServiceImpl.startLocalOnlyHotspot(mAppMessenger, mAppBinder); } @@ -740,6 +742,19 @@ public class WifiServiceImplTest { } /** + * Only start LocalOnlyHotspot if we are not tethering. + */ + @Test + public void testHotspotDoesNotStartWhenAlreadyTethering() { + when(mSettingsStore.getLocationModeSetting(mContext)) + .thenReturn(LOCATION_MODE_HIGH_ACCURACY); + when(mWifiStateMachine.syncGetWifiApState()).thenReturn(WifiManager.WIFI_AP_STATE_ENABLED); + WifiConfiguration hotspotConfig = + mWifiServiceImpl.startLocalOnlyHotspot(mAppMessenger, mAppBinder); + assertNull(hotspotConfig); + } + + /** * Verify that the call to stopLocalOnlyHotspot throws the UnsupportedOperationException until * the implementation is complete. */ |