OSDN Git Service

Add whitelist in ResetAppsHelper
authorSunny Shao <sunnyshao@google.com>
Fri, 12 Jul 2019 05:41:06 +0000 (13:41 +0800)
committerSunny Shao <sunnyshao@google.com>
Fri, 12 Jul 2019 07:43:18 +0000 (15:43 +0800)
Add "com.android.systemui" into the whitelist and skip the clear data.

Fixes: 137037930
Test: manual test
Change-Id: Ie2f527309f9159babe79636a69ff13fe3ceb64d9

res/values/config.xml
src/com/android/settings/applications/manageapplications/ResetAppsHelper.java

index a4a85ba..bb67f01 100755 (executable)
 
     <!-- "Show work policy info" intent action. TODO(b/134391103): Replace with final SystemAPI intent when it's available. -->
     <string name="config_work_policy_info_intent_action" translatable="false"/>
+
+    <!-- Reset application package name -->
+    <string-array name="config_reset_app_package_name" translatable="false">
+        <item>com.android.systemui</item>
+    </string-array>
 </resources>
index 92c0958..1fe0d01 100644 (file)
@@ -37,6 +37,7 @@ import androidx.appcompat.app.AlertDialog;
 
 import com.android.settings.R;
 
+import java.util.Arrays;
 import java.util.List;
 
 public class ResetAppsHelper implements DialogInterface.OnClickListener,
@@ -109,10 +110,17 @@ public class ResetAppsHelper implements DialogInterface.OnClickListener,
         AsyncTask.execute(new Runnable() {
             @Override
             public void run() {
-                List<ApplicationInfo> apps = mPm.getInstalledApplications(
+                final List<ApplicationInfo> apps = mPm.getInstalledApplications(
                         PackageManager.GET_DISABLED_COMPONENTS);
+                final List<String> whiteList = Arrays.asList(
+                        mContext.getResources().getStringArray(
+                                R.array.config_reset_app_package_name));
+
                 for (int i = 0; i < apps.size(); i++) {
                     ApplicationInfo app = apps.get(i);
+                    if (whiteList.contains(app.packageName)) {
+                        continue;
+                    }
                     try {
                         mNm.clearData(app.packageName, app.uid, false);
                     } catch (android.os.RemoteException ex) {