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

Commit 39ede62c authored by Ruslan Tkhakokhov's avatar Ruslan Tkhakokhov Committed by Android (Google) Code Review
Browse files

Merge "Update eligibility rules for adb backup"

parents dd6308ca 735cbd5a
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -205,13 +205,16 @@ public class BackupManager {
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({
        OperationType.BACKUP,
        OperationType.MIGRATION
        OperationType.MIGRATION,
        OperationType.ADB_BACKUP,
    })
    public @interface OperationType {
        // A regular backup / restore operation.
        // A backup / restore to / from an off-device location, e.g. cloud.
        int BACKUP = 0;
        // A full migration: all app data for non-system apps is eligible.
        // A direct transfer to another device.
        int MIGRATION = 1;
        // Backup via adb, data saved on the host machine.
        int ADB_BACKUP = 3;
    }

    private Context mContext;
+8 −0
Original line number Diff line number Diff line
@@ -4131,6 +4131,14 @@ public abstract class PackageManager {
     */
    public static final int UNSTARTABLE_REASON_INSUFFICIENT_STORAGE = 2;

    /**
     * A manifest property to control app's participation in {@code adb backup}. Should only
     * be used by system / privileged apps.
     *
     * @hide
     */
    public static final String PROPERTY_ALLOW_ADB_BACKUP = "android.backup.ALLOW_ADB_BACKUP";

    /** {@hide} */
    public int getUserId() {
        return UserHandle.myUserId();
+1 −1
Original line number Diff line number Diff line
@@ -10,5 +10,5 @@ java_library_static {
    defaults: ["platform_service_defaults"],
    srcs: [":services.backup-sources"],
    libs: ["services.core"],
    static_libs: ["backuplib"],
    static_libs: ["backuplib", "app-compat-annotations"],
}
+3 −1
Original line number Diff line number Diff line
@@ -3030,9 +3030,11 @@ public class UserBackupManagerService {
            }
            Slog.i(TAG, addUserIdToLogMessage(mUserId, "Beginning adb backup..."));

            BackupEligibilityRules eligibilityRules = getEligibilityRulesForOperation(
                    OperationType.ADB_BACKUP);
            AdbBackupParams params = new AdbBackupParams(fd, includeApks, includeObbs,
                    includeShared, doWidgets, doAllApps, includeSystem, compress, doKeyValue,
                    pkgList, mScheduledBackupEligibility);
                    pkgList, eligibilityRules);
            final int token = generateRandomIntegerToken();
            synchronized (mAdbBackupRestoreConfirmations) {
                mAdbBackupRestoreConfirmations.put(token, params);
+6 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static com.android.server.backup.BackupPasswordManager.PBKDF_FALLBACK;
import static com.android.server.backup.UserBackupManagerService.BACKUP_FILE_HEADER_MAGIC;
import static com.android.server.backup.UserBackupManagerService.BACKUP_FILE_VERSION;

import android.app.backup.BackupManager;
import android.app.backup.IFullBackupRestoreObserver;
import android.content.pm.PackageManagerInternal;
import android.os.ParcelFileDescriptor;
@@ -104,11 +105,13 @@ public class PerformAdbRestoreTask implements Runnable {
                return;
            }

            BackupEligibilityRules eligibilityRules = new BackupEligibilityRules(
                    mBackupManagerService.getPackageManager(),
                    LocalServices.getService(PackageManagerInternal.class),
                    mBackupManagerService.getUserId(), BackupManager.OperationType.ADB_BACKUP);
            FullRestoreEngine mEngine = new FullRestoreEngine(mBackupManagerService, null,
                    mObserver, null, null, true, 0 /*unused*/, true,
                    BackupEligibilityRules.forBackup(mBackupManagerService.getPackageManager(),
                                    LocalServices.getService(PackageManagerInternal.class),
                                    mBackupManagerService.getUserId()));
                    eligibilityRules);
            FullRestoreEngineThread mEngineThread = new FullRestoreEngineThread(mEngine,
                    tarInputStream);
            mEngineThread.run();
Loading