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

Commit 8fe7b59a authored by Bernardo Rufino's avatar Bernardo Rufino
Browse files

Add null check for full-backup task

The backup-already-running code-path leaves the field null.

Bug: 112359186
Test: atest KeyValueBackupTaskTest
Test: 1. adb shell bmgr backupnow --all &>/dev/null&
      2. adb shell bmgr backupnow com.google.android.apps.backupapp
      3. Verify it finishes and no error

Change-Id: I6880c4e7752b943608d41c946e8d18d46cd9da38
parent 75f73f07
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -756,7 +756,9 @@ public class KeyValueBackupTask implements BackupRestoreTask, Runnable {
            BackupObserverUtils.sendBackupFinished(mObserver, BackupManager.ERROR_BACKUP_CANCELLED);
        } else {
            mListener.onFinished(callerLogString);
            if (mFullBackupTask != null) {
                mFullBackupTask.unregisterTask();
            }
            switch (mStatus) {
                case BackupTransport.TRANSPORT_OK:
                case BackupTransport.TRANSPORT_QUOTA_EXCEEDED:
+11 −0
Original line number Diff line number Diff line
@@ -1584,6 +1584,17 @@ public class KeyValueBackupTaskTest {
                new RuntimeException().toString());
    }

    @Test
    public void testRunTask_whenBackupRunning_doesNotThrow() throws Exception {
        TransportMock transportMock = setUpInitializedTransport(mTransport);
        when(mBackupManagerService.isBackupOperationInProgress()).thenReturn(true);
        KeyValueBackupTask task =
                createKeyValueBackupTask(
                        transportMock.transportClient, mTransport.transportDirName);

        runTask(task);
    }

    private void runTask(KeyValueBackupTask task) {
        // Pretend we are not on the main-thread to prevent RemoteCall from complaining
        mShadowMainLooper.setCurrentThread(false);