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

Commit bf6655b3 authored by Shreyas Basarge's avatar Shreyas Basarge Committed by Android (Google) Code Review
Browse files

Merge "BackupManager#cancelBackups() API"

parents 7183b690 c3704427
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6892,6 +6892,7 @@ package android.app.backup {
    ctor public BackupManager(android.content.Context);
    method public void backupNow();
    method public android.app.backup.RestoreSession beginRestoreSession();
    method public void cancelBackups();
    method public void dataChanged();
    method public static void dataChanged(java.lang.String);
    method public long getAvailableRestoreToken(java.lang.String);
@@ -6908,6 +6909,7 @@ package android.app.backup {
    method public void setAutoRestore(boolean);
    method public void setBackupEnabled(boolean);
    field public static final int ERROR_AGENT_FAILURE = -1003; // 0xfffffc15
    field public static final int ERROR_BACKUP_CANCELLED = -2003; // 0xfffff82d
    field public static final int ERROR_BACKUP_NOT_ALLOWED = -2001; // 0xfffff82f
    field public static final int ERROR_PACKAGE_NOT_FOUND = -2002; // 0xfffff82e
    field public static final int ERROR_TRANSPORT_ABORTED = -1000; // 0xfffffc18
+24 −0
Original line number Diff line number Diff line
@@ -127,6 +127,11 @@ public final class Bmgr {
            return;
        }

        if ("cancel".equals(op)) {
            doCancel();
            return;
        }

        if ("whitelist".equals(op)) {
            doPrintWhitelist();
            return;
@@ -270,6 +275,8 @@ public final class Bmgr {
                return "Agent error";
            case BackupManager.ERROR_TRANSPORT_QUOTA_EXCEEDED:
                return "Size quota exceeded";
            case BackupManager.ERROR_BACKUP_CANCELLED:
                return "Backup Cancelled";
            default:
                return "Unknown error";
        }
@@ -361,6 +368,21 @@ public final class Bmgr {
        }
    }

    private void doCancel() {
        String arg = nextArg();
        if ("backups".equals(arg)) {
            try {
                mBmgr.cancelBackups();
            } catch (RemoteException e) {
                System.err.println(e.toString());
                System.err.println(BMGR_NOT_RUNNING_ERR);
            }
            return;
        }

        System.err.println("Unknown command.");
    }

    private void doTransport() {
        try {
            String which = nextArg();
@@ -721,6 +743,7 @@ public final class Bmgr {
        System.err.println("       bmgr wipe TRANSPORT PACKAGE");
        System.err.println("       bmgr fullbackup PACKAGE...");
        System.err.println("       bmgr backupnow --all|PACKAGE...");
        System.err.println("       bmgr cancel backups");
        System.err.println("");
        System.err.println("The 'backup' command schedules a backup pass for the named package.");
        System.err.println("Note that the backup pass will effectively be a no-op if the package");
@@ -780,5 +803,6 @@ public final class Bmgr {
        System.err.println("For each package it will run key/value or full data backup ");
        System.err.println("depending on the package's manifest declarations.");
        System.err.println("The data is sent via the currently active transport.");
        System.err.println("The 'cancel backups' command cancels all running backups.");
    }
}
+28 −0
Original line number Diff line number Diff line
@@ -88,6 +88,14 @@ public class BackupManager {
    @SystemApi
    public static final int ERROR_PACKAGE_NOT_FOUND = -2002;

    /**
     * The backup operation was cancelled.
     *
     * @hide
     */
    @SystemApi
    public static final int ERROR_BACKUP_CANCELLED = -2003;

    /**
     * The transport for some reason was not in a good state and
     * aborted the entire backup request. This is a transient
@@ -626,6 +634,26 @@ public class BackupManager {
        return -1;
    }

    /**
     * Cancel all running backups. After this call returns, no currently running backups will
     * interact with the selected transport.
     *
     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
     *
     * @hide
     */
    @SystemApi
    public void cancelBackups() {
        checkServiceBinder();
        if (sService != null) {
            try {
                sService.cancelBackups();
            } catch (RemoteException e) {
                Log.e(TAG, "cancelBackups() couldn't connect.");
            }
        }
    }

    /*
     * We wrap incoming binder calls with a private class implementation that
     * redirects them into main-thread actions.  This serializes the backup
+6 −0
Original line number Diff line number Diff line
@@ -386,4 +386,10 @@ interface IBackupManager {
     */
    int requestBackup(in String[] packages, IBackupObserver observer, IBackupManagerMonitor monitor,
        int flags);

    /**
     * Cancel all running backups. After this call returns, no currently running backups will
     * interact with the selected transport.
     */
    void cancelBackups();
}
+667 −309

File changed.

Preview size limit exceeded, changes collapsed.

Loading