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

Commit bea048f0 authored by Harshit Mahajan's avatar Harshit Mahajan
Browse files

Making rebootPromptAndWipeUserData a SystemApi

RescueParty performs factory reset as the last resort to recover the
device. RescueParty uses 'rebootPromptAndWipeUserData' to perform this
operation. Since RescueParty is moving to CrashRecovery module, we need
to make it an SystemApi. Also adding appropriate permissions to it.
More Details: go/v-crashrecovery-module-design-doc

Bug: 354693320
Test: m
Flag: android.crashrecovery.flags.enable_crashrecovery
Change-Id: I55fee6521ccfd6942b2550344f5d0e39bb6da23d
parent 4f2db854
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11160,6 +11160,7 @@ package android.os {
    method @RequiresPermission(android.Manifest.permission.RECOVERY) public static void processPackage(android.content.Context, java.io.File, android.os.RecoverySystem.ProgressListener) throws java.io.IOException;
    method @Deprecated @RequiresPermission(android.Manifest.permission.RECOVERY) public static void rebootAndApply(@NonNull android.content.Context, @NonNull String, @NonNull String) throws java.io.IOException;
    method @RequiresPermission(anyOf={android.Manifest.permission.RECOVERY, android.Manifest.permission.REBOOT}) public static int rebootAndApply(@NonNull android.content.Context, @NonNull String, boolean) throws java.io.IOException;
    method @FlaggedApi("android.crashrecovery.flags.enable_crashrecovery") @RequiresPermission(android.Manifest.permission.RECOVERY) public static void rebootPromptAndWipeUserData(@NonNull android.content.Context, @NonNull String) throws java.io.IOException;
    method @RequiresPermission(allOf={android.Manifest.permission.RECOVERY, android.Manifest.permission.REBOOT}) public static void rebootWipeAb(android.content.Context, java.io.File, String) throws java.io.IOException;
    method @RequiresPermission(android.Manifest.permission.RECOVERY) public static void scheduleUpdateOnBoot(android.content.Context, java.io.File) throws java.io.IOException;
    method @Deprecated public static boolean verifyPackageCompatibility(java.io.File) throws java.io.IOException;
+20 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.os;

import static android.view.Display.DEFAULT_DISPLAY;

import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -1170,11 +1171,27 @@ public class RecoverySystem {
        return removedSubsCount.get() == subscriptionInfos.size();
    }

    /** {@hide} */
    public static void rebootPromptAndWipeUserData(Context context, String reason)
    /**
     * Reboot into recovery and prompt for wiping the device.
     *
     * This is used as last resort in case the device is not recoverable using
     * other recovery steps. This first checks if fs-checkpoint is available, in
     * which case we commit the checkpoint, otherwise it performs the reboot in
     * recovery mode and shows user prompt for wiping the device.
     *
     * @param context      the context to use.
     * @param reason       the reason to wipe.
     *
     * @throws IOException if something goes wrong.
     *
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.RECOVERY)
    @FlaggedApi(android.crashrecovery.flags.Flags.FLAG_ENABLE_CRASHRECOVERY)
    public static void rebootPromptAndWipeUserData(@NonNull Context context, @NonNull String reason)
            throws IOException {
        boolean checkpointing = false;
        boolean needReboot = false;
        IVold vold = null;
        try {
            vold = IVold.Stub.asInterface(ServiceManager.checkService("vold"));