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

Commit d8c41c66 authored by Cheng-Cheng Lo's avatar Cheng-Cheng Lo Committed by Android (Google) Code Review
Browse files

Merge "Disallow factory reset while in DSU mode" into udc-qpr-dev

parents 405a7e1c 65ca17eb
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 != null && 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");