Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 312e7803 authored by Annie Meng's avatar Annie Meng
Browse files

[Multi-user] Clear calling identity for backup activation

As part of bmgr activate, if the user is unlocked then we attempt to
start the backup service for them. However, as part of initialization,
AMS enforces the system uid so clear calling identity before starting
the service (as we have the shell uid).

Bug: 123572171
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest TrampolineTest
3) Manual: Unlock secondary user -> bmgr activate -> no exception thrown
and service started

Change-Id: I441491e19d9f3c9b49b5778d51ae5331230b129b
parent 7f2d1a73
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -332,7 +332,14 @@ public class Trampoline extends IBackupManager.Stub {
                // If the user is unlocked, we can start the backup service for it. Otherwise we
                // will start the service when the user is unlocked as part of its unlock callback.
                if (getUserManager().isUserUnlocked(userId)) {
                    // Clear calling identity as initialization enforces the system identity but we
                    // can be coming from shell.
                    long oldId = Binder.clearCallingIdentity();
                    try {
                        startServiceForUser(userId);
                    } finally {
                        Binder.restoreCallingIdentity(oldId);
                    }
                }
            } else {
                try {