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

Commit a95cd4e5 authored by Christopher Tate's avatar Christopher Tate Committed by Android Git Automerger
Browse files

am bc835105: Merge "Reify the transport lookup/selection API" into lmp-dev

* commit 'bc835105066725fecfe378bfdd13c2262908457f':
  Reify the transport lookup/selection API
parents 6a3a2d5a bcc48b6c
Loading
Loading
Loading
Loading
+137 −3
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.app.backup;
package android.app.backup;


import android.annotation.SystemApi;
import android.app.backup.RestoreSession;
import android.app.backup.RestoreSession;
import android.app.backup.IBackupManager;
import android.app.backup.IBackupManager;
import android.app.backup.IRestoreSession;
import android.app.backup.IRestoreSession;
@@ -114,7 +115,7 @@ public class BackupManager {
            try {
            try {
                sService.dataChanged(packageName);
                sService.dataChanged(packageName);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.d(TAG, "dataChanged(pkg) couldn't connect");
                Log.e(TAG, "dataChanged(pkg) couldn't connect");
            }
            }
        }
        }
    }
    }
@@ -150,7 +151,7 @@ public class BackupManager {
                    result = session.restorePackage(mContext.getPackageName(), observer);
                    result = session.restorePackage(mContext.getPackageName(), observer);
                }
                }
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.w(TAG, "restoreSelf() unable to contact service");
                Log.e(TAG, "restoreSelf() unable to contact service");
            } finally {
            } finally {
                if (session != null) {
                if (session != null) {
                    session.endRestoreSession();
                    session.endRestoreSession();
@@ -176,9 +177,142 @@ public class BackupManager {
                    session = new RestoreSession(mContext, binder);
                    session = new RestoreSession(mContext, binder);
                }
                }
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.w(TAG, "beginRestoreSession() couldn't connect");
                Log.e(TAG, "beginRestoreSession() couldn't connect");
            }
            }
        }
        }
        return session;
        return session;
    }
    }

    // system APIs start here

    /**
     * Enable/disable the backup service entirely.  When disabled, no backup
     * or restore operations will take place.  Data-changed notifications will
     * still be observed and collected, however, so that changes made while the
     * mechanism was disabled will still be backed up properly if it is enabled
     * at some point in the future.
     *
     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
     *
     * @hide
     */
    @SystemApi
    public void setBackupEnabled(boolean isEnabled) {
        checkServiceBinder();
        if (sService != null) {
            try {
                sService.setBackupEnabled(isEnabled);
            } catch (RemoteException e) {
                Log.e(TAG, "setBackupEnabled() couldn't connect");
            }
        }
    }

    /**
     * Report whether the backup mechanism is currently enabled.
     *
     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
     *
     * @hide
     */
    @SystemApi
    public boolean isBackupEnabled() {
        if (sService != null) {
            try {
                return sService.isBackupEnabled();
            } catch (RemoteException e) {
                Log.e(TAG, "isBackupEnabled() couldn't connect");
            }
        }
        return false;
    }

    /**
     * Identify the currently selected transport.  Callers must hold the
     * android.permission.BACKUP permission to use this method.
     * @return The name of the currently active backup transport.  In case of
     *   failure or if no transport is currently active, this method returns {@code null}.
     *
     * @hide
     */
    @SystemApi
    public String getCurrentTransport() {
        checkServiceBinder();
        if (sService != null) {
            try {
                return sService.getCurrentTransport();
            } catch (RemoteException e) {
                Log.e(TAG, "getCurrentTransport() couldn't connect");
            }
        }
        return null;
    }

    /**
     * Request a list of all available backup transports' names.  Callers must
     * hold the android.permission.BACKUP permission to use this method.
     *
     * @hide
     */
    @SystemApi
    public String[] listAllTransports() {
        checkServiceBinder();
        if (sService != null) {
            try {
                return sService.listAllTransports();
            } catch (RemoteException e) {
                Log.e(TAG, "listAllTransports() couldn't connect");
            }
        }
        return null;
    }

    /**
     * Specify the current backup transport.  Callers must hold the
     * android.permission.BACKUP permission to use this method.
     *
     * @param transport The name of the transport to select.  This should be one
     *   of the names returned by {@link #listAllTransports()}.
     * @return The name of the previously selected transport.  If the given transport
     *   name is not one of the currently available transports, no change is made to
     *   the current transport setting and the method returns null.
     *
     * @hide
     */
    @SystemApi
    public String selectBackupTransport(String transport) {
        checkServiceBinder();
        if (sService != null) {
            try {
                return sService.selectBackupTransport(transport);
            } catch (RemoteException e) {
                Log.e(TAG, "selectBackupTransport() couldn't connect");
            }
        }
        return null;
    }

    /**
     * Schedule an immediate backup attempt for all pending key/value updates.  This
     * is primarily intended for transports to use when they detect a suitable
     * opportunity for doing a backup pass.  If there are no pending updates to
     * be sent, no action will be taken.  Even if some updates are pending, the
     * transport will still be asked to confirm via the usual requestBackupTime()
     * method.
     *
     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
     *
     * @hide
     */
    @SystemApi
    public void backupNow() {
        checkServiceBinder();
        if (sService != null) {
            try {
                sService.backupNow();
            } catch (RemoteException e) {
                Log.e(TAG, "backupNow() couldn't connect");
            }
        }
    }
}
}
+2 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.app.backup;
package android.app.backup;


import android.annotation.SystemApi;
import android.content.Intent;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInfo;
import android.os.IBinder;
import android.os.IBinder;
@@ -30,6 +31,7 @@ import com.android.internal.backup.IBackupTransport;
 *
 *
 * @hide
 * @hide
 */
 */
@SystemApi
public class BackupTransport {
public class BackupTransport {
    // Zero return always means things are okay.  If returned from
    // Zero return always means things are okay.  If returned from
    // getNextFullRestoreDataChunk(), it means that no data could be delivered at
    // getNextFullRestoreDataChunk(), it means that no data could be delivered at
+2 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.app.backup;
package android.app.backup;


import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;


@@ -28,6 +29,7 @@ import android.os.Parcelable;
 *
 *
 * @hide
 * @hide
 */
 */
@SystemApi
public class RestoreDescription implements Parcelable {
public class RestoreDescription implements Parcelable {
    private final String mPackageName;
    private final String mPackageName;
    private final int mDataType;
    private final int mDataType;
+2 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.app.backup;
package android.app.backup;


import android.annotation.SystemApi;
import android.app.backup.RestoreObserver;
import android.app.backup.RestoreObserver;
import android.app.backup.RestoreSet;
import android.app.backup.RestoreSet;
import android.app.backup.IRestoreObserver;
import android.app.backup.IRestoreObserver;
@@ -30,6 +31,7 @@ import android.util.Log;
 * Interface for managing a restore session.
 * Interface for managing a restore session.
 * @hide
 * @hide
 */
 */
@SystemApi
public class RestoreSession {
public class RestoreSession {
    static final String TAG = "RestoreSession";
    static final String TAG = "RestoreSession";


+2 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.app.backup;
package android.app.backup;


import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;


@@ -25,6 +26,7 @@ import android.os.Parcelable;
 *
 *
 * @hide
 * @hide
 */
 */
@SystemApi
public class RestoreSet implements Parcelable {
public class RestoreSet implements Parcelable {
    /**
    /**
     * Name of this restore set.  May be user generated, may simply be the name
     * Name of this restore set.  May be user generated, may simply be the name
Loading