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

Commit aa4b0179 authored by Cheng-Cheng Lo's avatar Cheng-Cheng Lo Committed by Android Build Coastguard Worker
Browse files

Disallow factory reset while in DSU mode

Bug: 430568718
Flag: EXEMPT CVE_FIX
Test: presubmit
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:72f795b3bcb0c98971f5f15689c9399c8160bfcb)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:156dac8a424208057390dd27f78307eab0281af0
Merged-In: I36afa074f16bb7ebf8b617de73dab3d4df5fb5dc
Change-Id: I36afa074f16bb7ebf8b617de73dab3d4df5fb5dc
parent 9adff3df
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.hardware.display.DisplayManager;
import android.os.image.DynamicSystemManager;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
@@ -933,9 +934,15 @@ public class RecoverySystem {
    public static void rebootWipeUserData(Context context, boolean shutdown, String reason,
            boolean force, boolean wipeEuicc, boolean keepMemtagMode) throws IOException {
        UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
        DynamicSystemManager dsuManager = (DynamicSystemManager)
                    context.getSystemService(Context.DYNAMIC_SYSTEM_SERVICE);
        if (!force && um.hasUserRestriction(UserManager.DISALLOW_FACTORY_RESET)) {
            throw new SecurityException("Wiping data is not allowed for this user.");
        }

        if (dsuManager.isInUse()) {
            throw new SecurityException("Wiping data is not allowed while in DSU mode.");
        }
        final ConditionVariable condition = new ConditionVariable();

        Intent intent = new Intent("android.intent.action.MASTER_CLEAR_NOTIFICATION");