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

Commit 063180fa authored by Ruslan Tkhakokhov's avatar Ruslan Tkhakokhov
Browse files

[Multi-user] Pass userId on backup agent creation

Bug: 123349308
Test: 1) atest RunBackupFrameworksServicesRoboTests
         2) atest CtsBackupTestCases
         3) atest CtsBackupHostTestCases
         4) atest GtsBackupTestCases
         5) atest GtsBackupHostTestCases
         6) Manual: Go through kv/full backup/restore for system/secondary users
	    and verify that userId is passed correctly to the backup agents.

Change-Id: Iea747394163d9e473bce4fea890a01e2e4bfefbd

Mostly the same as the older ag/5267584 with the same purpose which didn't get
merget.
parent ad0db6fc
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -652,10 +652,11 @@ public final class ActivityThread extends ClientTransactionHandler {
        ApplicationInfo appInfo;
        CompatibilityInfo compatInfo;
        int backupMode;
        int userId;
        public String toString() {
            return "CreateBackupAgentData{appInfo=" + appInfo
                    + " backupAgent=" + appInfo.backupAgentName
                    + " mode=" + backupMode + "}";
                    + " mode=" + backupMode + " userId=" + userId + "}";
        }
    }

@@ -870,11 +871,12 @@ public final class ActivityThread extends ClientTransactionHandler {
        }

        public final void scheduleCreateBackupAgent(ApplicationInfo app,
                CompatibilityInfo compatInfo, int backupMode) {
                CompatibilityInfo compatInfo, int backupMode, int userId) {
            CreateBackupAgentData d = new CreateBackupAgentData();
            d.appInfo = app;
            d.compatInfo = compatInfo;
            d.backupMode = backupMode;
            d.userId = userId;

            sendMessage(H.CREATE_BACKUP_AGENT, d);
        }
@@ -3630,7 +3632,7 @@ public final class ActivityThread extends ClientTransactionHandler {
                    context.setOuterContext(agent);
                    agent.attach(context);

                    agent.onCreate();
                    agent.onCreate(UserHandle.of(data.userId));
                    binder = agent.onBind();
                    mBackupAgents.put(packageName, agent);
                } catch (Exception e) {
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ oneway interface IApplicationThread {
    void profilerControl(boolean start, in ProfilerInfo profilerInfo, int profileType);
    void setSchedulingGroup(int group);
    void scheduleCreateBackupAgent(in ApplicationInfo app, in CompatibilityInfo compatInfo,
            int backupMode);
            int backupMode, int userId);
    void scheduleDestroyBackupAgent(in ApplicationInfo app,
            in CompatibilityInfo compatInfo);
    void scheduleOnNewActivityOptions(IBinder token, in Bundle options);
+1 −1
Original line number Diff line number Diff line
@@ -465,7 +465,7 @@ public class TransactionParcelTests {

        @Override
        public void scheduleCreateBackupAgent(ApplicationInfo applicationInfo,
                CompatibilityInfo compatibilityInfo, int i) throws RemoteException {
                CompatibilityInfo compatibilityInfo, int i, int userId) throws RemoteException {
        }

        @Override
+3 −3
Original line number Diff line number Diff line
@@ -4818,7 +4818,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            try {
                thread.scheduleCreateBackupAgent(backupTarget.appInfo,
                        compatibilityInfoForPackage(backupTarget.appInfo),
                        backupTarget.backupMode);
                        backupTarget.backupMode, backupTarget.userId);
            } catch (Exception e) {
                Slog.wtf(TAG, "Exception thrown creating backup agent in " + app, e);
                badApp = true;
@@ -13673,7 +13673,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        + app.packageName + ": " + e);
            }
            BackupRecord r = new BackupRecord(app, backupMode);
            BackupRecord r = new BackupRecord(app, backupMode, userId);
            ComponentName hostingName =
                    (backupMode == ApplicationThreadConstants.BACKUP_MODE_INCREMENTAL)
                            ? new ComponentName(app.packageName, app.backupAgentName)
@@ -13709,7 +13709,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                if (DEBUG_BACKUP) Slog.v(TAG_BACKUP, "Agent proc already running: " + proc);
                try {
                    proc.thread.scheduleCreateBackupAgent(app,
                            compatibilityInfoForPackage(app), backupMode);
                            compatibilityInfoForPackage(app), backupMode, userId);
                } catch (RemoteException e) {
                    // Will time out on the backup manager side
                }
+3 −1
Original line number Diff line number Diff line
@@ -28,14 +28,16 @@ final class BackupRecord {
    
    String stringName;                     // cached toString() output
    final ApplicationInfo appInfo;         // information about BackupAgent's app
    final int userId;                      // user for which backup is performed
    final int backupMode;                  // full backup / incremental / restore
    ProcessRecord app;                     // where this agent is running or null

    // ----- Implementation -----

    BackupRecord(ApplicationInfo _appInfo, int _backupMode) {
    BackupRecord(ApplicationInfo _appInfo, int _backupMode, int _userId) {
        appInfo = _appInfo;
        backupMode = _backupMode;
        userId = _userId;
    }

    public String toString() {