summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Fabianowski <bartfab@google.com>2016-05-30 15:30:56 +0200
committerBartosz Fabianowski <bartfab@google.com>2016-06-16 09:25:51 +0200
commita3e8570867c26322499d306f118427f77a561ee5 (patch)
tree45ed8271e8bac3d06c93a82def9569be31f15110
parent9ec065de4d3f323bbda2da034ff414d9d045b48c (diff)
downloadwifi-nougat-dev.tar.gz
Allow connecting to WiFi networks via Quick Settingsnougat-dev
System UI acts on behalf of the current foreground user and should thus be allowed to connect to WiFi networks, even if it actually runs as user 0. BUG=28799309 Change-Id: I50c3bdf30c9a1fd7780b47cac3f8ff3d0fb34f36
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 01281f115..402cbe54c 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -990,6 +990,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
private final BackupManagerProxy mBackupManagerProxy;
+ private int mSystemUiUid = -1;
+
public WifiStateMachine(Context context, FrameworkFacade facade, Looper looper,
UserManager userManager, WifiInjector wifiInjector,
BackupManagerProxy backupManagerProxy,
@@ -1201,6 +1203,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
intent.putExtra(WifiManager.EXTRA_SCAN_AVAILABLE, WIFI_STATE_DISABLED);
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
+ try {
+ mSystemUiUid = mContext.getPackageManager().getPackageUidAsUser("com.android.systemui",
+ PackageManager.MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM);
+ } catch (PackageManager.NameNotFoundException e) {
+ loge("Unable to resolve SystemUI's UID.");
+ }
+
mVerboseLoggingLevel = mFacade.getIntegerSetting(
mContext, Settings.Global.WIFI_VERBOSE_LOGGING_ENABLED, 0);
updateLoggingLevel();
@@ -5808,9 +5817,11 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
mWifiConfigManager.removeNetworksForUser(message.arg1);
break;
case WifiManager.CONNECT_NETWORK:
- // Only the current foreground user can modify networks.
+ // Only the current foreground user and System UI (which runs as user 0 but acts
+ // on behalf of the current foreground user) can modify networks.
if (!mWifiConfigManager.isCurrentUserProfile(
- UserHandle.getUserId(message.sendingUid))) {
+ UserHandle.getUserId(message.sendingUid)) &&
+ message.sendingUid != mSystemUiUid) {
loge("Only the current foreground user can modify networks "
+ " currentUserId=" + mWifiConfigManager.getCurrentUserId()
+ " sendingUserId=" + UserHandle.getUserId(message.sendingUid));