summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-04-17 21:29:51 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-04-17 21:29:52 +0000
commit9598644f66920ee6c4c32ba5da4dbcb1080f09d2 (patch)
tree923c86ad960188965b18b06eabf549a5c95317c6 /service
parent5303b9cb6acc2149b454e8aad58f33d8df88ba78 (diff)
parent05d6ff7612ee795daf3a6fd0ee5a99e01c7a8685 (diff)
Merge changes I11475732,I8de27f2b into oc-dev
* changes: WifiServiceImpl: check calls to enable wifi WifiServiceImpl: test setWifiEnabled
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index c3e80705d..c6166cdb2 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -122,6 +122,10 @@ public class WifiServiceImpl extends IWifiManager.Stub {
private static final boolean DBG = true;
private static final boolean VDBG = false;
+ // Package names for Settings, QuickSettings and QuickQuickSettings
+ private static final String SYSUI_PACKAGE_NAME = "com.android.systemui";
+ private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
+
// Dumpsys argument to enable/disable disconnect on IP reachability failures.
private static final String DUMP_ARG_SET_IPREACH_DISCONNECT = "set-ipreach-disconnect";
private static final String DUMP_ARG_SET_IPREACH_DISCONNECT_ENABLED = "enabled";
@@ -590,8 +594,20 @@ public class WifiServiceImpl extends IWifiManager.Stub {
throws RemoteException {
enforceChangePermission();
Slog.d(TAG, "setWifiEnabled: " + enable + " pid=" + Binder.getCallingPid()
- + ", uid=" + Binder.getCallingUid());
- mLog.trace("setWifiEnabled uid=% enable=%").c(Binder.getCallingUid()).c(enable).flush();
+ + ", uid=" + Binder.getCallingUid() + ", package=" + packageName);
+ mLog.trace("setWifiEnabled package=% uid=% enable=%").c(packageName)
+ .c(Binder.getCallingUid()).c(enable).flush();
+
+ // If SoftAp is enabled, only Settings is allowed to toggle wifi
+ boolean apEnabled =
+ mWifiStateMachine.syncGetWifiApState() != WifiManager.WIFI_AP_STATE_DISABLED;
+ boolean isFromSettings =
+ packageName.equals(SYSUI_PACKAGE_NAME) || packageName.equals(SETTINGS_PACKAGE_NAME);
+ if (apEnabled && !isFromSettings) {
+ mLog.trace("setWifiEnabled SoftAp not disabled: only Settings can enable wifi").flush();
+ return false;
+ }
+
/*
* Caller might not have WRITE_SECURE_SETTINGS,
* only CHANGE_WIFI_STATE is enforced
@@ -663,7 +679,7 @@ public class WifiServiceImpl extends IWifiManager.Stub {
}
// null wifiConfig is a meaningful input for CMD_SET_AP
if (wifiConfig == null || isValid(wifiConfig)) {
- mWifiController.obtainMessage(CMD_SET_AP, enabled ? 1 : 0, 0, wifiConfig).sendToTarget();
+ mWifiController.sendMessage(CMD_SET_AP, enabled ? 1 : 0, 0, wifiConfig);
} else {
Slog.e(TAG, "Invalid WifiConfiguration");
}