diff options
author | Bartosz Fabianowski <bartfab@google.com> | 2016-06-17 01:42:55 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-06-17 01:42:55 +0000 |
commit | 895b3e2186362770b46d318cc011a0e502e1c961 (patch) | |
tree | df2f6ea7a78de48bdb398f6a34657a0accadbe40 | |
parent | b271c249debc3e0327354638a84a8daff33427ee (diff) | |
parent | a3e8570867c26322499d306f118427f77a561ee5 (diff) |
Allow connecting to WiFi networks via Quick Settings
am: a3e8570867
Change-Id: I46046d9292fa343d6fd7f01f41fd20b71337374e
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 15 |
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 799c21c03..4032c84a0 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(); @@ -5816,9 +5825,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)); |