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

Commit b8bd9577 authored by Sarp Misoglu's avatar Sarp Misoglu Committed by Android (Google) Code Review
Browse files

Merge changes from topic "getBackupManagerMonitor"

* changes:
  Unhide BackupTransport#getBackupManagerMonitor()
  Ask transport for a monitor during restore
  Pass agent logs to monitor after package B&R
parents b7f72f05 c6215c0c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1470,6 +1470,7 @@ package android.app.backup {
  public class BackupManagerMonitor {
    ctor public BackupManagerMonitor();
    method public void onEvent(android.os.Bundle);
    field public static final String EXTRA_LOG_AGENT_LOGGING_RESULTS = "android.app.backup.extra.LOG_AGENT_LOGGING_RESULTS";
    field public static final String EXTRA_LOG_CANCEL_ALL = "android.app.backup.extra.LOG_CANCEL_ALL";
    field public static final String EXTRA_LOG_EVENT_CATEGORY = "android.app.backup.extra.LOG_EVENT_CATEGORY";
    field public static final String EXTRA_LOG_EVENT_ID = "android.app.backup.extra.LOG_EVENT_ID";
@@ -1488,6 +1489,7 @@ package android.app.backup {
    field public static final int LOG_EVENT_CATEGORY_AGENT = 2; // 0x2
    field public static final int LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY = 3; // 0x3
    field public static final int LOG_EVENT_CATEGORY_TRANSPORT = 1; // 0x1
    field public static final int LOG_EVENT_ID_AGENT_LOGGING_RESULTS = 52; // 0x34
    field public static final int LOG_EVENT_ID_APK_NOT_INSTALLED = 40; // 0x28
    field public static final int LOG_EVENT_ID_APP_HAS_NO_AGENT = 28; // 0x1c
    field public static final int LOG_EVENT_ID_BACKUP_DISABLED = 13; // 0xd
@@ -1562,6 +1564,7 @@ package android.app.backup {
    method public int finishBackup();
    method public void finishRestore();
    method public android.app.backup.RestoreSet[] getAvailableRestoreSets();
    method @Nullable public android.app.backup.BackupManagerMonitor getBackupManagerMonitor();
    method public long getBackupQuota(String, boolean);
    method public android.os.IBinder getBinder();
    method public long getCurrentRestoreSet();
+10 −8
Original line number Diff line number Diff line
@@ -129,6 +129,13 @@ public class BackupManagerMonitor {
   */
  public static final String EXTRA_LOG_OLD_VERSION = "android.app.backup.extra.LOG_OLD_VERSION";

  /**
   * ParcelableList: when we have an event of id LOG_EVENT_ID_AGENT_LOGGING_RESULTS we send a list
   * of {@link android.app.backup.BackupRestoreEventLogger.DataTypeResult}.
   */
  public static final String EXTRA_LOG_AGENT_LOGGING_RESULTS =
          "android.app.backup.extra.LOG_AGENT_LOGGING_RESULTS";

  // TODO complete this list with all log messages. And document properly.
  public static final int LOG_EVENT_ID_FULL_BACKUP_CANCEL = 4;
  public static final int LOG_EVENT_ID_ILLEGAL_KEY = 5;
@@ -171,15 +178,10 @@ public class BackupManagerMonitor {
  public static final int LOG_EVENT_ID_WIDGET_UNKNOWN_VERSION = 48;
  public static final int LOG_EVENT_ID_NO_PACKAGES = 49;
  public static final int LOG_EVENT_ID_TRANSPORT_IS_NULL = 50;

    /**
     * The transport returned {@link BackupTransport#TRANSPORT_NON_INCREMENTAL_BACKUP_REQUIRED}.
     */
  /** The transport returned {@link BackupTransport#TRANSPORT_NON_INCREMENTAL_BACKUP_REQUIRED}. */
  public static final int LOG_EVENT_ID_TRANSPORT_NON_INCREMENTAL_BACKUP_REQUIRED = 51;




  public static final int LOG_EVENT_ID_AGENT_LOGGING_RESULTS = 52;

  /**
   * This method will be called each time something important happens on BackupManager.
+0 −2
Original line number Diff line number Diff line
@@ -661,8 +661,6 @@ public class BackupTransport {
     *
     * <p>Backups requested from outside the framework may pass in a monitor with the request,
     * however backups initiated by the framework will call this method to retrieve one.
     *
     * @hide
     */
    @Nullable
    public BackupManagerMonitor getBackupManagerMonitor() {
+10 −2
Original line number Diff line number Diff line
@@ -23,11 +23,13 @@ import static com.android.server.backup.UserBackupManagerService.BACKUP_MANIFEST
import static com.android.server.backup.UserBackupManagerService.BACKUP_METADATA_FILENAME;
import static com.android.server.backup.UserBackupManagerService.SHARED_BACKUP_AGENT_PACKAGE;

import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ApplicationThreadConstants;
import android.app.IBackupAgent;
import android.app.backup.BackupTransport;
import android.app.backup.FullBackupDataOutput;
import android.app.backup.IBackupManagerMonitor;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -42,6 +44,7 @@ import com.android.server.backup.OperationStorage.OpType;
import com.android.server.backup.UserBackupManagerService;
import com.android.server.backup.remote.RemoteCall;
import com.android.server.backup.utils.BackupEligibilityRules;
import com.android.server.backup.utils.BackupManagerMonitorUtils;
import com.android.server.backup.utils.FullBackupUtils;

import java.io.File;
@@ -60,12 +63,13 @@ public class FullBackupEngine {
    private BackupRestoreTask mTimeoutMonitor;
    private IBackupAgent mAgent;
    private boolean mIncludeApks;
    private PackageInfo mPkg;
    private final PackageInfo mPkg;
    private final long mQuota;
    private final int mOpToken;
    private final int mTransportFlags;
    private final BackupAgentTimeoutParameters mAgentTimeoutParameters;
    private final BackupEligibilityRules mBackupEligibilityRules;
    @Nullable private final IBackupManagerMonitor mMonitor;

    class FullBackupRunner implements Runnable {
        private final @UserIdInt int mUserId;
@@ -193,7 +197,8 @@ public class FullBackupEngine {
            long quota,
            int opToken,
            int transportFlags,
            BackupEligibilityRules backupEligibilityRules) {
            BackupEligibilityRules backupEligibilityRules,
            IBackupManagerMonitor monitor) {
        this.backupManagerService = backupManagerService;
        mOutput = output;
        mPreflightHook = preflightHook;
@@ -208,6 +213,7 @@ public class FullBackupEngine {
                        backupManagerService.getAgentTimeoutParameters(),
                        "Timeout parameters cannot be null");
        mBackupEligibilityRules = backupEligibilityRules;
        mMonitor = monitor;
    }

    public int preflightCheck() throws RemoteException {
@@ -260,6 +266,8 @@ public class FullBackupEngine {
                    }
                    result = BackupTransport.TRANSPORT_OK;
                }

                BackupManagerMonitorUtils.monitorAgentLoggingResults(mMonitor, mPkg, mAgent);
            } catch (IOException e) {
                Slog.e(TAG, "Error backing up " + mPkg.packageName + ": " + e.getMessage());
                result = BackupTransport.AGENT_ERROR;
+2 −1
Original line number Diff line number Diff line
@@ -420,7 +420,8 @@ public class PerformAdbBackupTask extends FullBackupTask implements BackupRestor
                                Long.MAX_VALUE,
                                mCurrentOpToken,
                                /*transportFlags=*/ 0,
                                mBackupEligibilityRules);
                                mBackupEligibilityRules,
                                /* monitor= */ null);
                sendOnBackupPackage(isSharedStorage ? "Shared storage" : pkg.packageName);

                // Don't need to check preflight result as there is no preflight hook.
Loading