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

Commit ed10409e 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:5bbc8047f8e0211e9503cf538b16a192c5f98866
Merged-In: I36afa074f16bb7ebf8b617de73dab3d4df5fb5dc
Change-Id: I36afa074f16bb7ebf8b617de73dab3d4df5fb5dc
parent 991998d5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -38,6 +38,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;
@@ -958,9 +959,15 @@ public class RecoverySystem {
    public static void rebootWipeUserData(Context context, boolean shutdown, String reason,
            boolean force, boolean wipeEuicc) 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");