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

Commit ba49b199 authored by Ben Lin's avatar Ben Lin
Browse files

Allow configuration of which package to handle FACTORY_RESET intent.

Bug: 132997046
Test: Build
Change-Id: I640f79ac35e5646977771f0898767b8d129bf57c
parent 00d15123
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -4162,4 +4162,8 @@
         one bar higher than they actually are -->
    <bool name="config_inflateSignalStrength">false</bool>

    <!-- The package name for the vendor implementation of ACTION_FACTORY_RESET. For some vendors,
    the default implementation of ACTION_FACTORY_RESET does not work, so it is needed to re-route
    this intent to this package. This is being used in MasterClearReceiver.java. -->
    <string name="config_factoryResetPackage" translatable="false"></string>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -3812,4 +3812,5 @@

  <java-symbol type="string" name="config_defaultSupervisionProfileOwnerComponent" />
  <java-symbol type="bool" name="config_inflateSignalStrength" />
  <java-symbol type="string" name="config_factoryResetPackage" />
</resources>
+11 −5
Original line number Diff line number Diff line
@@ -16,16 +16,15 @@

package com.android.server;

import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.RecoverySystem;
import android.os.UserHandle;
import android.os.storage.StorageManager;
import android.provider.Settings;
import android.telephony.euicc.EuiccManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.Slog;
import android.view.WindowManager;
@@ -33,8 +32,6 @@ import android.view.WindowManager;
import com.android.internal.R;

import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class MasterClearReceiver extends BroadcastReceiver {
    private static final String TAG = "MasterClear";
@@ -58,6 +55,15 @@ public class MasterClearReceiver extends BroadcastReceiver {
                    + "Intent#EXTRA_FORCE_FACTORY_RESET should be used instead.");
        }

        final String factoryResetPackage = context
                .getString(com.android.internal.R.string.config_factoryResetPackage);
        if (Intent.ACTION_FACTORY_RESET.equals(intent.getAction())
                && !TextUtils.isEmpty(factoryResetPackage)) {
            intent.setPackage(factoryResetPackage).setComponent(null);
            context.sendBroadcastAsUser(intent, UserHandle.SYSTEM);
            return;
        }

        final boolean shutdown = intent.getBooleanExtra("shutdown", false);
        final String reason = intent.getStringExtra(Intent.EXTRA_REASON);
        mWipeExternalStorage = intent.getBooleanExtra(Intent.EXTRA_WIPE_EXTERNAL_STORAGE, false);