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

Commit 8cbd24dd authored by Daniel Rosenberg's avatar Daniel Rosenberg
Browse files

Make RescueParty not wipe if checkpointing

If we're checkpointing, we can roll back instead of wiping. If the
update was the problem, we will succeed. Otherwise, RescueParty will
catch the issue again and prompt the wipe later

Test: setprop persist.sys.enable_rescue 1
      Set device to not commit checkpoints
      vdc checkpoint StartCheckpoint 3
      reboot
      adb shell setprop debug.crash_system 1
      adb shell stop
      adb shell start
      Rescue Party causes reboot instead of wipe
      repeat without checkpointing to get wipe
Change-Id: Iba0263214baa7a0c3d5565b4393d03f975d8000a
parent 600799b8
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.storage.IStorageManager;
import android.provider.Settings;
import android.telephony.euicc.EuiccManager;
import android.text.TextUtils;
@@ -38,6 +39,8 @@ import android.util.Log;
import android.view.Display;
import android.view.WindowManager;

import com.android.internal.content.PackageHelper;

import libcore.io.Streams;

import java.io.ByteArrayInputStream;
@@ -854,6 +857,21 @@ public class RecoverySystem {
    /** {@hide} */
    public static void rebootPromptAndWipeUserData(Context context, String reason)
            throws IOException {
        boolean checkpointing = false;

        // If we are running in checkpointing mode, we should not prompt a wipe.
        // Checkpointing may save us. If it doesn't, we will wind up here again.
        try {
            IStorageManager storageManager = PackageHelper.getStorageManager();
            if (storageManager.needsCheckpoint()) {
                Log.i(TAG, "Rescue Party requested wipe. Aborting update instead.");
                storageManager.abortChanges("rescueparty", false);
            }
            return;
        } catch (RemoteException e) {
            Log.i(TAG, "Failed to handle with checkpointing. Continuing with wipe.");
        }

        String reasonArg = null;
        if (!TextUtils.isEmpty(reason)) {
            reasonArg = "--reason=" + sanitizeArg(reason);