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

Commit 5e81097a authored by Prameet Shah's avatar Prameet Shah
Browse files

Make sure the full-data backup queue is properly set up on startup

Ensure UserBackupoManagerService.readFullBackupSchedule() returns
non-null container object, instead of a null object. The other areas of
the code assume that the object is valid.

Bug: 269674005
Test: 1. (Manual) Happy case:
         Verified device does not crash when the schedule file version
         is the same as the expected value.
      2. (Manual) Corrupted case:
         Verified device does not crash when the schedule file version
         is forced to NOT match the expected value. An exception was
         thrown, and caught by the corresponding catch block. The
         corrupted file is deleted, and a new one is created.
      3. atest PerformFullTransportBackupTaskTest

Change-Id: I6c28e40f164023ea23e0aebc1aa1c2d564d9ed10
parent dde6cf2a
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import static com.android.server.backup.internal.BackupHandler.MSG_RUN_CLEAR;
import static com.android.server.backup.internal.BackupHandler.MSG_RUN_RESTORE;
import static com.android.server.backup.internal.BackupHandler.MSG_SCHEDULE_BACKUP_PACKAGE;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
@@ -973,6 +974,7 @@ public class UserBackupManagerService {
                /* scheduler */ null);
    }

    @NonNull
    private ArrayList<FullBackupEntry> readFullBackupSchedule() {
        boolean changed = false;
        ArrayList<FullBackupEntry> schedule = null;
@@ -986,11 +988,11 @@ public class UserBackupManagerService {
                 DataInputStream in = new DataInputStream(bufStream)) {
                int version = in.readInt();
                if (version != SCHEDULE_FILE_VERSION) {
                    Slog.e(
                            TAG,
                            addUserIdToLogMessage(
                                    mUserId, "Unknown backup schedule version " + version));
                    return null;
                    // The file version doesn't match the expected value.
                    // Since this is within a "try" block, this exception will be treated like
                    // any other exception, and caught below.
                    throw new IllegalArgumentException("Unknown backup schedule version "
                            + version);
                }

                final int numPackages = in.readInt();