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

Commit 507e2c94 authored by Sergey Poromov's avatar Sergey Poromov Committed by Android (Google) Code Review
Browse files

Merge "Add BackupManager#isAppEligibleForBackup() method to Backup API."

parents e15b4f6d 94481960
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6293,6 +6293,7 @@ package android.app.backup {
    method public static void dataChanged(java.lang.String);
    method public long getAvailableRestoreToken(java.lang.String);
    method public java.lang.String getCurrentTransport();
    method public boolean isAppEligibleForBackup(java.lang.String);
    method public boolean isBackupEnabled();
    method public java.lang.String[] listAllTransports();
    method public int requestBackup(java.lang.String[], android.app.backup.BackupObserver);
@@ -6342,6 +6343,7 @@ package android.app.backup {
    method public int getNextFullRestoreDataChunk(android.os.ParcelFileDescriptor);
    method public int getRestoreData(android.os.ParcelFileDescriptor);
    method public int initializeDevice();
    method public boolean isAppEligibleForBackup(android.content.pm.PackageInfo, boolean);
    method public java.lang.String name();
    method public android.app.backup.RestoreDescription nextRestorePackage();
    method public int performBackup(android.content.pm.PackageInfo, android.os.ParcelFileDescriptor, int);
+23 −0
Original line number Diff line number Diff line
@@ -425,6 +425,29 @@ public class BackupManager {
        return 0;
    }

    /**
     * Ask the framework whether this app is eligible for backup.
     *
     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
     *
     * @param packageName The name of the package.
     * @return Whether this app is eligible for backup.
     *
     * @hide
     */
    @SystemApi
    public boolean isAppEligibleForBackup(String packageName) {
        checkServiceBinder();
        if (sService != null) {
            try {
                return sService.isAppEligibleForBackup(packageName);
            } catch (RemoteException e) {
                Log.e(TAG, "isAppEligibleForBackup(pkg) couldn't connect");
            }
        }
        return false;
    }
    
    /**
     * Request an immediate backup, providing an observer to which results of the backup operation
     * will be published. The Android backup system will decide for each package whether it will
+18 −0
Original line number Diff line number Diff line
@@ -482,6 +482,18 @@ public class BackupTransport {
                "Transport cancelFullBackup() not implemented");
    }

    /**
     * Ask the transport whether this app is eligible for backup.
     *
     * @param targetPackage The identity of the application.
     * @param isFullBackup If set, transport should check if app is eligible for full data backup,
     *   otherwise to check if eligible for key-value backup.
     * @return Whether this app is eligible for backup.
     */
    public boolean isAppEligibleForBackup(PackageInfo targetPackage, boolean isFullBackup) {
        return true;
    }

    // ------------------------------------------------------------------------------------
    // Full restore interfaces

@@ -658,6 +670,12 @@ public class BackupTransport {
            BackupTransport.this.cancelFullBackup();
        }

        @Override
        public boolean isAppEligibleForBackup(PackageInfo targetPackage, boolean isFullBackup)
                throws RemoteException {
            return BackupTransport.this.isAppEligibleForBackup(targetPackage, isFullBackup);
        }

        @Override
        public int getNextFullRestoreDataChunk(ParcelFileDescriptor socket) {
            return BackupTransport.this.getNextFullRestoreDataChunk(socket);
+10 −0
Original line number Diff line number Diff line
@@ -328,6 +328,16 @@ interface IBackupManager {
     */
    long getAvailableRestoreToken(String packageName);

    /**
     * Ask the framework whether this app is eligible for backup.
     *
     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
     *
     * @param packageName The name of the package.
     * @return Whether this app is eligible for backup.
     */
    boolean isAppEligibleForBackup(String packageName);

    /**
     * Request an immediate backup, providing an observer to which results of the backup operation
     * will be published. The Android backup system will decide for each package whether it will
+10 −1
Original line number Diff line number Diff line
@@ -239,6 +239,16 @@ interface IBackupTransport {
    int sendBackupData(int numBytes);
    void cancelFullBackup();

    /**
     * Ask the transport whether this app is eligible for backup.
     *
     * @param targetPackage The identity of the application.
     * @param isFullBackup If set, transport should check if app is eligible for full data backup,
     *   otherwise to check if eligible for key-value backup.
     * @return Whether this app is eligible for backup.
     */
    boolean isAppEligibleForBackup(in PackageInfo targetPackage, boolean isFullBackup);

    // full restore stuff

    /**
@@ -286,5 +296,4 @@ interface IBackupTransport {
     *    operation will immediately be finished with no further attempts to restore app data.
     */
    int abortFullRestore();

}
Loading