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

Commit 72f795b3 authored by Cheng-Cheng Lo's avatar Cheng-Cheng Lo
Browse files

Disallow factory reset while in DSU mode

Bug: 430568718
Flag: EXEMPT CVE_FIX
Test: presubmit
Change-Id: I36afa074f16bb7ebf8b617de73dab3d4df5fb5dc
parent 226ba8cb
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -37,6 +37,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;
@@ -934,9 +935,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");