summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-05-01 22:52:02 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-05-01 22:52:02 +0000
commit8a0adb85524d01b5a235a9ae95154cbc389d4cf8 (patch)
tree65016c1805b9442a72895d165f339bd2143c957e /service
parentab6d0d4b35673dcca253255362f048bce7370a4d (diff)
parent8d1925ab9cce5ad312987272bca1fb838c93de8c (diff)
WifiServiceImpl: add LOHS permission checks am: 2fd9436184
am: 8d1925ab9c Change-Id: I3f5b8977e41b9dc5d653b0b71711033bdf7aa91a
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java23
-rw-r--r--service/java/com/android/server/wifi/util/WifiPermissionsUtil.java12
2 files changed, 35 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 8cbeab225..656582c31 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -659,6 +659,10 @@ public class WifiServiceImpl extends IWifiManager.Stub {
"ConnectivityService");
}
+ private void enforceLocationPermission(String pkgName, int uid) {
+ mWifiPermissionsUtil.enforceLocationPermission(pkgName, uid);
+ }
+
/**
* see {@link android.net.wifi.WifiManager#setWifiEnabled(boolean)}
* @param enable {@code true} to enable, {@code false} to disable.
@@ -875,6 +879,20 @@ public class WifiServiceImpl extends IWifiManager.Stub {
*/
@Override
public WifiConfiguration 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();
+ final String pkgName = mContext.getOpPackageName();
+
+ enforceChangePermission();
+ enforceLocationPermission(pkgName, uid);
+ // also need to verify that Locations services are enabled.
+ if (mSettingsStore.getLocationModeSetting(mContext) == Settings.Secure.LOCATION_MODE_OFF) {
+ throw new SecurityException("Location mode is not enabled.");
+ }
+
+ mLog.trace("startLocalOnlyHotspot uid=%").c(uid).flush();
+
throw new UnsupportedOperationException("LocalOnlyHotspot is still in development");
}
@@ -886,6 +904,11 @@ public class WifiServiceImpl extends IWifiManager.Stub {
*/
@Override
public void stopLocalOnlyHotspot() {
+ // first check if the caller has permission to stop a local only hotspot
+ enforceChangePermission();
+ final int uid = Binder.getCallingUid();
+
+ mLog.trace("stopLocalOnlyHotspot uid=%").c(uid).flush();
throw new UnsupportedOperationException("LocalOnlyHotspot is still in development");
}
diff --git a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
index 8b687db81..90ec060d6 100644
--- a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
+++ b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
@@ -86,6 +86,18 @@ public class WifiPermissionsUtil {
}
/**
+ * Check and enforce Location permission.
+ *
+ * @param pkgName PackageName of the application requesting access
+ * @param uid The uid of the package
+ */
+ public void enforceLocationPermission(String pkgName, int uid) {
+ if (!checkCallersLocationPermission(pkgName, uid)) {
+ throw new SecurityException("UID " + uid + " does not have Location permission");
+ }
+ }
+
+ /**
* API to determine if the caller has permissions to get
* scan results.
* @param pkgName Packagename of the application requesting access