summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-04-30 14:07:31 -0700
committerRebecca Silberstein <silberst@google.com>2017-05-01 11:51:28 -0700
commit0025465e311fe9504cd79610523a1b8171995acc (patch)
treebee866cfbe4c45d750c530000ee7f1f49a790553 /service
parentb09edccf2056d1106da4b901e1e8b26841a02a61 (diff)
WifiServiceImpl: update API for LOHS
Add a return code for disallowed tethering for the user. Since this needs to be a new failure mode, the return type for starting LOHS needed to change. Updated tests to reflect this as well. This CL will be part of a topic - there is a corresponding WifiManager change. Bug: 37073685 Test: frameworks/base/wifi/tests/runtests.sh Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: I22d1fcf755d1384d482bd03dbc9a6388dfa4d3db
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 787287c84..7ae8ee049 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -60,6 +60,7 @@ import android.net.wifi.WifiEnterpriseConfig;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiLinkLayerStats;
import android.net.wifi.WifiManager;
+import android.net.wifi.WifiManager.LocalOnlyHotspotCallback;
import android.net.wifi.WifiScanner;
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.os.AsyncTask;
@@ -865,12 +866,19 @@ public class WifiServiceImpl extends IWifiManager.Stub {
}
/**
+ * Method to start LocalOnlyHotspot. In this method, permissions, settings and modes are
+ * checked to verify that we can enter softapmode. This method returns
+ * {@link LocalOnlyHotspotCallback#REQUEST_REGISTERED} if we will attempt to start, otherwise,
+ * possible startup erros may include tethering being disallowed failure reason {@link
+ * LocalOnlyHotspotCallback#ERROR_TETHERING_DISALLOWED} or an incompatible mode failure reason
+ * {@link LocalOnlyHotspotCallback#ERROR_INCOMPATIBLE_MODE}.
+ *
* see {@link WifiManager#startLocalOnlyHotspot(LocalOnlyHotspotCallback)}
*
* @param messenger Messenger to send messages to the corresponding WifiManager.
* @param binder IBinder instance to allow cleanup if the app dies
*
- * @return WifiConfiguration generated temporary configuration for SoftAp mode.
+ * @return int return code for attempt to start LocalOnlyHotspot.
*
* @throws SecurityException if the caller does not have permission to start a Local Only
* Hotspot.
@@ -878,7 +886,7 @@ public class WifiServiceImpl extends IWifiManager.Stub {
* have an outstanding request.
*/
@Override
- public WifiConfiguration startLocalOnlyHotspot(Messenger messenger, IBinder binder) {
+ public int startLocalOnlyHotspot(Messenger messenger, IBinder binder) {
// first check if the caller has permission to start a local only hotspot
// need to check for WIFI_STATE_CHANGE and location permission
final int uid = Binder.getCallingUid();
@@ -891,6 +899,11 @@ public class WifiServiceImpl extends IWifiManager.Stub {
throw new SecurityException("Location mode is not enabled.");
}
+ // verify that tethering is not disabled
+ if (mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) {
+ return LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED;
+ }
+
mLog.trace("startLocalOnlyHotspot uid=%").c(uid).flush();
// check current mode to see if we can start localOnlyHotspot
@@ -899,7 +912,7 @@ public class WifiServiceImpl extends IWifiManager.Stub {
if (!apDisabled) {
// Tethering is enabled, cannot start LocalOnlyHotspot
mLog.trace("Cannot start localOnlyHotspot when WiFi Tethering is active.");
- return null;
+ return LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE;
}
throw new UnsupportedOperationException("LocalOnlyHotspot is still in development");