From f4c8f6ee15d53757220a550ccbf3ae865e70975d Mon Sep 17 00:00:00 2001 From: Doris Ling Date: Thu, 4 Aug 2016 11:39:42 -0700 Subject: [PATCH] Fix app info crashes when package is uninstalled from terminal. Move start listening to the package removed intents to onCreate() and continue listening throughout the whole lifecycle of the activity so that if user unintall the package in the background, it will still be notified. Change-Id: I889b0ea3e1245be83750d73349ed3a0f85a51783 Fixes: 28671923 --- .../settings/applications/InstalledAppDetails.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index 6f3de3d55bd..3f422938b39 100755 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -166,7 +166,6 @@ public class InstalledAppDetails extends AppInfoBase private boolean mDisableAfterUninstall; private boolean mListeningToPackageRemove; - private boolean mUninstallRequested; // Used for updating notification preference. private final NotificationBackend mBackend = new NotificationBackend(); @@ -327,6 +326,7 @@ public class InstalledAppDetails extends AppInfoBase removePreference(KEY_DATA); } mBatteryHelper = new BatteryStatsHelper(getActivity(), true); + startListeningToPackageRemove(); } @Override @@ -340,7 +340,6 @@ public class InstalledAppDetails extends AppInfoBase if (mFinishing) { return; } - stopListeningToPackageRemove(); mState.requestSize(mPackageName, mUserId); AppItem app = new AppItem(mAppEntry.info.uid); app.addUid(mAppEntry.info.uid); @@ -357,9 +356,6 @@ public class InstalledAppDetails extends AppInfoBase @Override public void onPause() { getLoaderManager().destroyLoader(LOADER_CHART_DATA); - if (!mFinishing && !mUninstallRequested) { - startListeningToPackageRemove(); - } super.onPause(); } @@ -510,7 +506,7 @@ public class InstalledAppDetails extends AppInfoBase if (!refreshUi()) { setIntentAndFinish(true, true); } else { - mUninstallRequested = false; + startListeningToPackageRemove(); } break; } @@ -690,7 +686,7 @@ public class InstalledAppDetails extends AppInfoBase } private void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) { - mUninstallRequested = true; + stopListeningToPackageRemove(); // Create new intent to launch Uninstaller activity Uri packageURI = Uri.parse("package:"+packageName); Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI); @@ -780,7 +776,7 @@ public class InstalledAppDetails extends AppInfoBase String packageName = mAppEntry.info.packageName; if (v == mUninstallButton) { if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) { - mUninstallRequested = true; + stopListeningToPackageRemove(); Activity activity = getActivity(); Intent uninstallDAIntent = new Intent(activity, DeviceAdminAdd.class); uninstallDAIntent.putExtra(DeviceAdminAdd.EXTRA_DEVICE_ADMIN_PACKAGE_NAME,