Commit a3e85708 authored by Bartosz Fabianowski's avatar Bartosz Fabianowski
Browse files

Allow connecting to WiFi networks via Quick Settings

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
parent 9ec065de
......@@ -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));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment