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

Commit 9e50c50f authored by Ruslan Tkhakokhov's avatar Ruslan Tkhakokhov
Browse files

Use correct backup mode for k/v restore

When creating BackupAgent for k/v restore, use BACKUP_MODE_RESTORE
instead of BACKUP_MODE_INCREMENTAL, otherwise we can't differentiate
between backup and restore operations. See
https://b.corp.google.com/issues/272302093#comment5 for more context.

Bug: 272302093
Test: 1. atest CtsBackupTestCases CtsBackupHostTestCases (covers
         functional testing of kv / full and backup / restore.
      2. Update BackupAgent.java to print operationType param in
	 onCreate() -> run backup and restore of 'android' (kv) and
	 'com.android.wallpaperbackup' (full) and verify operationType
	 is always set correctly.

Change-Id: I82c88ffaea639d8fb69b6c56a9fec0756ca45528
parent 30b6c196
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -397,7 +397,7 @@ public class FullRestoreEngine extends RestoreEngine {
                            setUpPipes();
                            mAgent = mBackupManagerService.bindToAgentSynchronous(mTargetApp,
                                    FullBackup.KEY_VALUE_DATA_TOKEN.equals(info.domain)
                                            ? ApplicationThreadConstants.BACKUP_MODE_INCREMENTAL
                                            ? ApplicationThreadConstants.BACKUP_MODE_RESTORE
                                            : ApplicationThreadConstants.BACKUP_MODE_RESTORE_FULL,
                                    mBackupEligibilityRules.getBackupDestination());
                            mAgentPackage = pkg;
+1 −1
Original line number Diff line number Diff line
@@ -677,7 +677,7 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask {
        // Good to go!  Set up and bind the agent...
        mAgent = backupManagerService.bindToAgentSynchronous(
                mCurrentPackage.applicationInfo,
                ApplicationThreadConstants.BACKUP_MODE_INCREMENTAL,
                ApplicationThreadConstants.BACKUP_MODE_RESTORE,
                mBackupEligibilityRules.getBackupDestination());
        if (mAgent == null) {
            Slog.w(TAG, "Can't find backup agent for " + packageName);
+3 −3
Original line number Diff line number Diff line
@@ -4598,8 +4598,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            boolean isRestrictedBackupMode = false;
            if (backupTarget != null && backupTarget.appInfo.packageName.equals(processName)) {
                isRestrictedBackupMode = backupTarget.appInfo.uid >= FIRST_APPLICATION_UID
                        && ((backupTarget.backupMode == BackupRecord.RESTORE)
                                || (backupTarget.backupMode == BackupRecord.RESTORE_FULL)
                        && ((backupTarget.backupMode == BackupRecord.RESTORE_FULL)
                                || (backupTarget.backupMode == BackupRecord.BACKUP_FULL));
            }
@@ -13382,7 +13381,8 @@ public class ActivityManagerService extends IActivityManager.Stub
            BackupRecord r = new BackupRecord(app, backupMode, targetUserId, backupDestination);
            ComponentName hostingName =
                    (backupMode == ApplicationThreadConstants.BACKUP_MODE_INCREMENTAL)
                    (backupMode == ApplicationThreadConstants.BACKUP_MODE_INCREMENTAL
                            || backupMode == ApplicationThreadConstants.BACKUP_MODE_RESTORE)
                            ? new ComponentName(app.packageName, app.backupAgentName)
                            : new ComponentName("android", "FullBackupAgent");