[MultiUser] Ensure sysyuig activities use user 0
Use packagename to determine if intent is in the same package and which
user should be used when launching the activity.
Bug: 229730387
Test: Manual on device
Change-Id: I1f1033dc875899567edd42a6fc67f9e6124fce73
Merged-In: I1f1033dc875899567edd42a6fc67f9e6124fce73
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index ae5b8d8..447bc0e 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -725,4 +725,10 @@
<item>@*android:string/status_bar_alarm_clock</item>
<item>@*android:string/status_bar_call_strength</item>
</string-array>
+
+ <!-- Packages of SystemUI -->
+ <string-array name="system_ui_packages" translatable="false">
+ <item>com.android.keyguard</item>
+ <item>com.android.systemui</item>
+ </string-array>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java
index 5e81b5d..dfde8ea 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java
@@ -4509,9 +4509,12 @@
* @return UserHandle
*/
private UserHandle getActivityUserHandle(Intent intent) {
- if (intent.getComponent() != null
- && mContext.getPackageName().equals(intent.getComponent().getPackageName())) {
- return new UserHandle(UserHandle.myUserId());
+ String[] packages = mContext.getResources().getStringArray(R.array.system_ui_packages);
+ for (String pkg : packages) {
+ if (intent.getComponent() == null) break;
+ if (pkg.equals(intent.getComponent().getPackageName())) {
+ return new UserHandle(UserHandle.myUserId());
+ }
}
return UserHandle.CURRENT;
}