summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-04-02 22:12:48 -0700
committerRebecca Silberstein <silberst@google.com>2017-04-12 11:22:04 -0700
commitc90564bcec223b69abe7e31d9471aa20479b69e7 (patch)
tree1c1e8c1e28307fc842c3326ad0329e6d24fc6896 /service
parent7df23a4c0aee6166602225af8e7220395b349e52 (diff)
WifiServiceImpl: check calls to enable wifi
When the user has entered softap mode, apps should not be able to toggle wifi on. This leaves the user with unexpected behavior. This CL adds checks for softap mode to make sure only Settings and SysUI (Quick and QuickQuick settings) can toggle wifi on. Bug: 36358238 Test: manually Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Test: frameworks/base/wifi/tests/runtests.sh Test: wifi integration tests Change-Id: I114757324b529a43c411dc8a01afcb05a23489ee
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 61d74fead..e17720184 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -120,6 +120,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";
@@ -587,8 +591,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