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

Commit bb8a385f authored by Robert Berry's avatar Robert Berry Committed by Android (Google) Code Review
Browse files

Merge "Add #getTransportFlags to BackupDataOutput"

parents 9543d6eb 39194c05
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -6893,6 +6893,7 @@ package android.app.backup {
    method public void onRestore(android.app.backup.BackupDataInput, long, android.os.ParcelFileDescriptor) throws java.io.IOException;
    method public void onRestoreFile(android.os.ParcelFileDescriptor, long, java.io.File, int, long, long) throws java.io.IOException;
    method public void onRestoreFinished();
    field public static final int FLAG_CLIENT_SIDE_ENCRYPTION_ENABLED = 1; // 0x1
    field public static final int TYPE_DIRECTORY = 2; // 0x2
    field public static final int TYPE_FILE = 1; // 0x1
  }
@@ -6920,6 +6921,7 @@ package android.app.backup {
  public class BackupDataOutput {
    method public long getQuota();
    method public int getTransportFlags();
    method public int writeEntityData(byte[], int) throws java.io.IOException;
    method public int writeEntityHeader(java.lang.String, int) throws java.io.IOException;
  }
@@ -6945,6 +6947,7 @@ package android.app.backup {
  public class FullBackupDataOutput {
    method public long getQuota();
    method public int getTransportFlags();
  }
  public abstract class RestoreObserver {
+1 −0
Original line number Diff line number Diff line
@@ -569,6 +569,7 @@ package android.app.backup {
    method public long getCurrentRestoreSet();
    method public int getNextFullRestoreDataChunk(android.os.ParcelFileDescriptor);
    method public int getRestoreData(android.os.ParcelFileDescriptor);
    method public int getTransportFlags();
    method public int initializeDevice();
    method public boolean isAppEligibleForBackup(android.content.pm.PackageInfo, boolean);
    method public java.lang.String name();
+9 −3
Original line number Diff line number Diff line
@@ -49,11 +49,13 @@ oneway interface IBackupAgent {
     *
     * @param callbackBinder Binder on which to indicate operation completion,
     *        passed here as a convenience to the agent.
     *
     * @param transportFlags Flags with additional information about the transport.
     */
    void doBackup(in ParcelFileDescriptor oldState,
            in ParcelFileDescriptor data,
            in ParcelFileDescriptor newState,
            long quotaBytes, int token, IBackupManager callbackBinder);
            long quotaBytes, int token, IBackupManager callbackBinder, int transportFlags);

    /**
     * Restore an entire data snapshot to the application.
@@ -100,13 +102,17 @@ oneway interface IBackupAgent {
     *
     * @param callbackBinder Binder on which to indicate operation completion,
     *        passed here as a convenience to the agent.
     *
     * @param transportFlags Flags with additional information about transport.
     */
    void doFullBackup(in ParcelFileDescriptor data, long quotaBytes, int token, IBackupManager callbackBinder);
    void doFullBackup(in ParcelFileDescriptor data, long quotaBytes, int token,
            IBackupManager callbackBinder, int transportFlags);

    /**
     * Estimate how much data a full backup will deliver
     */
    void doMeasureFullBackup(long quotaBytes, int token, IBackupManager callbackBinder);
    void doMeasureFullBackup(long quotaBytes, int token, IBackupManager callbackBinder,
            int transportFlags);

    /**
     * Tells the application agent that the backup data size exceeded current transport quota.
+22 −6
Original line number Diff line number Diff line
@@ -143,6 +143,17 @@ public abstract class BackupAgent extends ContextWrapper {
    /** @hide */
    public static final int TYPE_SYMLINK = 3;

    /**
     * Flag for {@link BackupDataOutput#getTransportFlags()} and
     * {@link FullBackupDataOutput#getTransportFlags()} only.
     *
     * <p>The transport has client-side encryption enabled. i.e., the user's backup has been
     * encrypted with a key known only to the device, and not to the remote storage solution. Even
     * if an attacker had root access to the remote storage provider they should not be able to
     * decrypt the user's backup data.
     */
    public static final int FLAG_CLIENT_SIDE_ENCRYPTION_ENABLED = 1;

    Handler mHandler = null;

    Handler getHandler() {
@@ -920,12 +931,14 @@ public abstract class BackupAgent extends ContextWrapper {
        public void doBackup(ParcelFileDescriptor oldState,
                ParcelFileDescriptor data,
                ParcelFileDescriptor newState,
                long quotaBytes, int token, IBackupManager callbackBinder) throws RemoteException {
                long quotaBytes, int token, IBackupManager callbackBinder, int transportFlags)
                throws RemoteException {
            // Ensure that we're running with the app's normal permission level
            long ident = Binder.clearCallingIdentity();

            if (DEBUG) Log.v(TAG, "doBackup() invoked");
            BackupDataOutput output = new BackupDataOutput(data.getFileDescriptor(), quotaBytes);
            BackupDataOutput output = new BackupDataOutput(
                    data.getFileDescriptor(), quotaBytes, transportFlags);

            try {
                BackupAgent.this.onBackup(oldState, output, newState);
@@ -999,7 +1012,7 @@ public abstract class BackupAgent extends ContextWrapper {

        @Override
        public void doFullBackup(ParcelFileDescriptor data,
                long quotaBytes, int token, IBackupManager callbackBinder) {
                long quotaBytes, int token, IBackupManager callbackBinder, int transportFlags) {
            // Ensure that we're running with the app's normal permission level
            long ident = Binder.clearCallingIdentity();

@@ -1010,7 +1023,8 @@ public abstract class BackupAgent extends ContextWrapper {
            waitForSharedPrefs();

            try {
                BackupAgent.this.onFullBackup(new FullBackupDataOutput(data, quotaBytes));
                BackupAgent.this.onFullBackup(new FullBackupDataOutput(
                        data, quotaBytes, transportFlags));
            } catch (IOException ex) {
                Log.d(TAG, "onFullBackup (" + BackupAgent.this.getClass().getName() + ") threw", ex);
                throw new RuntimeException(ex);
@@ -1044,10 +1058,12 @@ public abstract class BackupAgent extends ContextWrapper {
            }
        }

        public void doMeasureFullBackup(long quotaBytes, int token, IBackupManager callbackBinder) {
        public void doMeasureFullBackup(long quotaBytes, int token, IBackupManager callbackBinder,
                int transportFlags) {
            // Ensure that we're running with the app's normal permission level
            final long ident = Binder.clearCallingIdentity();
            FullBackupDataOutput measureOutput = new FullBackupDataOutput(quotaBytes);
            FullBackupDataOutput measureOutput =
                    new FullBackupDataOutput(quotaBytes, transportFlags);

            waitForSharedPrefs();
            try {
+22 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.app.backup;

import android.annotation.SystemApi;
import android.os.ParcelFileDescriptor;

import java.io.FileDescriptor;
import java.io.IOException;

@@ -62,7 +63,10 @@ import java.io.IOException;
 * @see BackupAgent
 */
public class BackupDataOutput {
    final long mQuota;

    private final long mQuota;
    private final int mTransportFlags;

    long mBackupWriter;

    /**
@@ -71,14 +75,20 @@ public class BackupDataOutput {
     * @hide */
    @SystemApi
    public BackupDataOutput(FileDescriptor fd) {
        this(fd, -1);
        this(fd, /*quota=*/ -1, /*transportFlags=*/ 0);
    }

    /** @hide */
    @SystemApi
    public BackupDataOutput(FileDescriptor fd, long quota) {
        this(fd, quota, /*transportFlags=*/ 0);
    }

    /** @hide */
    public BackupDataOutput(FileDescriptor fd, long quota, int transportFlags) {
        if (fd == null) throw new NullPointerException();
        mQuota = quota;
        mTransportFlags = transportFlags;
        mBackupWriter = ctor(fd);
        if (mBackupWriter == 0) {
            throw new RuntimeException("Native initialization failed with fd=" + fd);
@@ -95,6 +105,16 @@ public class BackupDataOutput {
        return mQuota;
    }

    /**
     * Returns flags with additional information about the backup transport. For supported flags see
     * {@link android.app.backup.BackupAgent}
     *
     * @see FullBackupDataOutput#getTransportFlags()
     */
    public int getTransportFlags() {
        return mTransportFlags;
    }

    /**
     * Mark the beginning of one record in the backup data stream. This must be called before
     * {@link #writeEntityData}.
Loading