From fdc3a628a630eda6935f61442bb2d93f57f6d0be Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Tue, 7 Feb 2023 19:42:52 +0000 Subject: Backup SystemUI as system user Ensure the backup runs as the system user, to match SystemUI. Subsequent work for SystemUI will ensure that the data is corrected back up for the target user ID, which may be different than the system user. In the future, this will always be true. Bug: 261168533 Test: manual (backup and restore from settings) Change-Id: I38631c15f092355fe8f7b0afd1a69d3917685fdf --- .../core/java/com/android/server/am/ActivityManagerService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 1428fa853f2a..d78fe8628c60 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -12764,8 +12764,10 @@ public class ActivityManagerService extends IActivityManager.Stub // restored. This distinction is important for system-process packages that live in the // system user's process but backup/restore data for non-system users. // TODO (b/123688746): Handle all system-process packages with singleton check. - final int instantiatedUserId = - PLATFORM_PACKAGE_NAME.equals(packageName) ? UserHandle.USER_SYSTEM : targetUserId; + boolean useSystemUser = PLATFORM_PACKAGE_NAME.equals(packageName) + || getPackageManagerInternal().getSystemUiServiceComponent().getPackageName() + .equals(packageName); + final int instantiatedUserId = useSystemUser ? UserHandle.USER_SYSTEM : targetUserId; IPackageManager pm = AppGlobals.getPackageManager(); ApplicationInfo app = null; -- cgit v1.2.3-59-g8ed1b