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

Commit 2af55bf3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[KV] Refactor sendDataToTransport() and finishTask()"

parents ad5d61a0 0830f642
Loading
Loading
Loading
Loading
+24 −10
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.content.pm.PackageInfo;
import android.util.EventLog;
import android.util.Slog;

import com.android.internal.annotations.VisibleForTesting;
import com.android.server.EventLogTags;
import com.android.server.backup.BackupManagerService;
import com.android.server.backup.DataChangedJournal;
@@ -49,10 +50,19 @@ import java.util.List;
 */
// TODO: In KeyValueBackupTaskTest, remove direct assertions on logcat, observer or monitor and
//       verify calls to this object. Add these and more assertions to the test of this class.
class KeyValueBackupReporter {
    private static final String TAG = "KeyValueBackupTask";
@VisibleForTesting
public class KeyValueBackupReporter {
    @VisibleForTesting
    static final String TAG = "KeyValueBackupTask";
    private static final boolean DEBUG = BackupManagerService.DEBUG;
    private static final boolean MORE_DEBUG = BackupManagerService.MORE_DEBUG || true;
    @VisibleForTesting
    static final boolean MORE_DEBUG = BackupManagerService.MORE_DEBUG || true;

    static void onNewThread(String threadName) {
        if (DEBUG) {
            Slog.d(TAG, "Spinning thread " + threadName);
        }
    }

    private final BackupManagerService mBackupManagerService;
    private final IBackupObserver mObserver;
@@ -61,7 +71,7 @@ class KeyValueBackupReporter {
    KeyValueBackupReporter(
            BackupManagerService backupManagerService,
            IBackupObserver observer,
            IBackupManagerMonitor monitor) {
            @Nullable IBackupManagerMonitor monitor) {
        mBackupManagerService = backupManagerService;
        mObserver = observer;
        mMonitor = monitor;
@@ -73,6 +83,10 @@ class KeyValueBackupReporter {
        return mMonitor;
    }

    IBackupObserver getObserver() {
        return mObserver;
    }

    void onSkipBackup() {
        if (DEBUG) {
            Slog.d(TAG, "Skipping backup since one is already in progress");
@@ -237,10 +251,6 @@ class KeyValueBackupReporter {
        }
    }

    void onTruncateDataError() {
        Slog.w(TAG, "Unable to roll back");
    }

    void onSendDataToTransport(String packageName) {
        if (MORE_DEBUG) {
            Slog.v(TAG, "Sending non-empty data to transport for " + packageName);
@@ -357,7 +367,7 @@ class KeyValueBackupReporter {
        return (packageInfo != null) ? packageInfo.packageName : "no_package_yet";
    }

    void onRevertBackup() {
    void onRevertTask() {
        if (MORE_DEBUG) {
            Slog.i(TAG, "Reverting backup queue, re-staging everything");
        }
@@ -391,6 +401,10 @@ class KeyValueBackupReporter {
        Slog.w(TAG, "Failed to query transport name for pending init: " + e);
    }

    /**
     * This is a bit different from {@link #onTaskFinished()}, it's only called if there is no
     * full-backup requests associated with the key-value task.
     */
    void onBackupFinished(int status) {
        BackupObserverUtils.sendBackupFinished(mObserver, status);
    }
@@ -399,7 +413,7 @@ class KeyValueBackupReporter {
        Slog.d(TAG, "Starting full backups for: " + pendingFullBackups);
    }

    void onKeyValueBackupFinished() {
    void onTaskFinished() {
        Slog.i(TAG, "K/V backup pass finished");
    }
}
Loading