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

Commit 40bf2b0f authored by Annie Meng's avatar Annie Meng Committed by Android (Google) Code Review
Browse files

Merge "DO NOT MERGE Update references to backup/restore agent timeouts" into pi-dev

parents c931a9f3 f77cae61
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -215,13 +215,6 @@ public class BackupManagerService implements BackupManagerServiceInterface {
    // Timeout interval for deciding that a bind or clear-data has taken too long
    private static final long TIMEOUT_INTERVAL = 10 * 1000;

    // Timeout intervals for agent backup & restore operations
    public static final long TIMEOUT_BACKUP_INTERVAL = 30 * 1000;
    public static final long TIMEOUT_FULL_BACKUP_INTERVAL = 5 * 60 * 1000;
    public static final long TIMEOUT_SHARED_BACKUP_INTERVAL = 30 * 60 * 1000;
    public static final long TIMEOUT_RESTORE_INTERVAL = 60 * 1000;
    public static final long TIMEOUT_RESTORE_FINISHED_INTERVAL = 30 * 1000;

    // User confirmation timeout for a full backup/restore operation.  It's this long in
    // order to give them time to enter the backup password.
    private static final long TIMEOUT_FULL_CONFIRMATION = 60 * 1000;
@@ -232,6 +225,7 @@ public class BackupManagerService implements BackupManagerServiceInterface {
    private static final int BUSY_BACKOFF_FUZZ = 1000 * 60 * 60 * 2;  // two hours

    private BackupManagerConstants mConstants;
    private BackupAgentTimeoutParameters mAgentTimeoutParameters;
    private Context mContext;
    private PackageManager mPackageManager;
    private IPackageManager mPackageManagerBinder;
@@ -315,6 +309,10 @@ public class BackupManagerService implements BackupManagerServiceInterface {
        return mConstants;
    }

    public BackupAgentTimeoutParameters getAgentTimeoutParameters() {
        return mAgentTimeoutParameters;
    }

    public Context getContext() {
        return mContext;
    }
@@ -856,6 +854,10 @@ public class BackupManagerService implements BackupManagerServiceInterface {
        // require frequent starting and stopping.
        mConstants.start();

        mAgentTimeoutParameters = new
                BackupAgentTimeoutParameters(mBackupHandler, mContext.getContentResolver());
        mAgentTimeoutParameters.start();

        // Set up the various sorts of package tracking we do
        mFullBackupScheduleFile = new File(mBaseStateDir, "fb-schedule");
        initPackageTracking();
@@ -3407,7 +3409,7 @@ public class BackupManagerService implements BackupManagerServiceInterface {
            }
            mActiveRestoreSession = new ActiveRestoreSession(this, packageName, transport);
            mBackupHandler.sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT,
                    TIMEOUT_RESTORE_INTERVAL);
                    mAgentTimeoutParameters.getRestoreAgentTimeoutMillis());
        }
        return mActiveRestoreSession;
    }
+3 −0
Original line number Diff line number Diff line
@@ -191,4 +191,7 @@ public interface BackupManagerServiceInterface {
  void dump(FileDescriptor fd, PrintWriter pw, String[] args);

  IBackupManager getBackupManagerBinder();

  // Gets access to the backup/restore agent timeout parameters.
  BackupAgentTimeoutParameters getAgentTimeoutParameters();
}
+7 −4
Original line number Diff line number Diff line
@@ -4,8 +4,8 @@ import static android.os.ParcelFileDescriptor.MODE_CREATE;
import static android.os.ParcelFileDescriptor.MODE_READ_ONLY;
import static android.os.ParcelFileDescriptor.MODE_READ_WRITE;
import static android.os.ParcelFileDescriptor.MODE_TRUNCATE;

import static com.android.server.backup.BackupManagerService.OP_TYPE_BACKUP_WAIT;
import static com.android.server.backup.BackupManagerService.TIMEOUT_BACKUP_INTERVAL;

import android.app.ApplicationThreadConstants;
import android.app.IBackupAgent;
@@ -59,6 +59,7 @@ public class KeyValueAdbBackupEngine {
    private ParcelFileDescriptor mSavedState;
    private ParcelFileDescriptor mBackupData;
    private ParcelFileDescriptor mNewState;
    private final BackupAgentTimeoutParameters mAgentTimeoutParameters;

    public KeyValueAdbBackupEngine(OutputStream output, PackageInfo packageInfo,
            BackupManagerServiceInterface backupManagerService, PackageManager packageManager,
@@ -81,6 +82,7 @@ public class KeyValueAdbBackupEngine {
                pkg + BACKUP_KEY_VALUE_NEW_STATE_FILENAME_SUFFIX);

        mManifestFile = new File(mDataDir, BackupManagerService.BACKUP_MANIFEST_FILENAME);
        mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters();
    }

    public void backupOnePackage() throws IOException {
@@ -148,8 +150,9 @@ public class KeyValueAdbBackupEngine {
    // Return true on backup success, false otherwise
    private boolean invokeAgentForAdbBackup(String packageName, IBackupAgent agent) {
        int token = mBackupManagerService.generateRandomIntegerToken();
        long kvBackupAgentTimeoutMillis = mAgentTimeoutParameters.getKvBackupAgentTimeoutMillis();
        try {
            mBackupManagerService.prepareOperationTimeout(token, TIMEOUT_BACKUP_INTERVAL, null,
            mBackupManagerService.prepareOperationTimeout(token, kvBackupAgentTimeoutMillis, null,
                    OP_TYPE_BACKUP_WAIT);

            // Start backup and wait for BackupManagerService to get callback for success or timeout
@@ -231,14 +234,14 @@ public class KeyValueAdbBackupEngine {
    }

    private void writeBackupData() throws IOException {

        int token = mBackupManagerService.generateRandomIntegerToken();
        long kvBackupAgentTimeoutMillis = mAgentTimeoutParameters.getKvBackupAgentTimeoutMillis();

        ParcelFileDescriptor[] pipes = null;
        try {
            pipes = ParcelFileDescriptor.createPipe();

            mBackupManagerService.prepareOperationTimeout(token, TIMEOUT_BACKUP_INTERVAL, null,
            mBackupManagerService.prepareOperationTimeout(token, kvBackupAgentTimeoutMillis, null,
                    OP_TYPE_BACKUP_WAIT);

            // We will have to create a runnable that will read the manifest and backup data we
+6 −6
Original line number Diff line number Diff line
@@ -25,9 +25,6 @@ import static com.android.server.backup.BackupManagerService.MORE_DEBUG;
import static com.android.server.backup.BackupManagerService.OP_TYPE_BACKUP_WAIT;
import static com.android.server.backup.BackupManagerService.SHARED_BACKUP_AGENT_PACKAGE;
import static com.android.server.backup.BackupManagerService.TAG;
import static com.android.server.backup.BackupManagerService.TIMEOUT_FULL_BACKUP_INTERVAL;
import static com.android.server.backup.BackupManagerService
        .TIMEOUT_SHARED_BACKUP_INTERVAL;

import android.app.ApplicationThreadConstants;
import android.app.IBackupAgent;
@@ -45,8 +42,9 @@ import android.util.Slog;
import android.util.StringBuilderPrinter;

import com.android.server.AppWidgetBackupBridge;
import com.android.server.backup.BackupRestoreTask;
import com.android.server.backup.BackupAgentTimeoutParameters;
import com.android.server.backup.BackupManagerService;
import com.android.server.backup.BackupRestoreTask;
import com.android.server.backup.utils.FullBackupUtils;

import java.io.BufferedOutputStream;
@@ -75,6 +73,7 @@ public class FullBackupEngine {
    private final long mQuota;
    private final int mOpToken;
    private final int mTransportFlags;
    private final BackupAgentTimeoutParameters mAgentTimeoutParameters;

    class FullBackupRunner implements Runnable {

@@ -137,8 +136,8 @@ public class FullBackupEngine {
                final boolean isSharedStorage =
                        mPackage.packageName.equals(SHARED_BACKUP_AGENT_PACKAGE);
                final long timeout = isSharedStorage ?
                        TIMEOUT_SHARED_BACKUP_INTERVAL :
                        TIMEOUT_FULL_BACKUP_INTERVAL;
                        mAgentTimeoutParameters.getSharedBackupAgentTimeoutMillis() :
                        mAgentTimeoutParameters.getFullBackupAgentTimeoutMillis();

                if (DEBUG) {
                    Slog.d(TAG, "Calling doFullBackup() on " + mPackage.packageName);
@@ -180,6 +179,7 @@ public class FullBackupEngine {
        mQuota = quota;
        mOpToken = opToken;
        mTransportFlags = transportFlags;
        mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters();
    }

    public int preflightCheck() throws RemoteException {
+6 −2
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.server.backup.fullbackup;
import static com.android.server.backup.BackupManagerService.MORE_DEBUG;
import static com.android.server.backup.BackupManagerService.OP_TYPE_BACKUP_WAIT;
import static com.android.server.backup.BackupManagerService.TAG;
import static com.android.server.backup.BackupManagerService.TIMEOUT_FULL_BACKUP_INTERVAL;

import android.app.backup.IBackupManager;
import android.content.ComponentName;
@@ -33,6 +32,7 @@ import android.os.UserHandle;
import android.util.Slog;

import com.android.internal.backup.IObbBackupService;
import com.android.server.backup.BackupAgentTimeoutParameters;
import com.android.server.backup.BackupManagerService;
import com.android.server.backup.utils.FullBackupUtils;

@@ -46,10 +46,12 @@ public class FullBackupObbConnection implements ServiceConnection {

    private BackupManagerService backupManagerService;
    volatile IObbBackupService mService;
    private final BackupAgentTimeoutParameters mAgentTimeoutParameters;

    public FullBackupObbConnection(BackupManagerService backupManagerService) {
        this.backupManagerService = backupManagerService;
        mService = null;
        mAgentTimeoutParameters = backupManagerService.getAgentTimeoutParameters();
    }

    public void establish() {
@@ -75,8 +77,10 @@ public class FullBackupObbConnection implements ServiceConnection {
        try {
            pipes = ParcelFileDescriptor.createPipe();
            int token = backupManagerService.generateRandomIntegerToken();
            long fullBackupAgentTimeoutMillis =
                    mAgentTimeoutParameters.getFullBackupAgentTimeoutMillis();
            backupManagerService.prepareOperationTimeout(
                    token, TIMEOUT_FULL_BACKUP_INTERVAL, null, OP_TYPE_BACKUP_WAIT);
                    token, fullBackupAgentTimeoutMillis, null, OP_TYPE_BACKUP_WAIT);
            mService.backupObbs(pkg.packageName, pipes[1], token,
                    backupManagerService.getBackupManagerBinder());
            FullBackupUtils.routeSocketDataToOutput(pipes[0], out);
Loading