Handle rotation (or refresh) before callback is received

Make sure we unregister the old receiver

Bug: 22160603
Change-Id: I798ca07dd65711caa4d3295b7ad811ca2fc69c1d
This commit is contained in:
Jason Monk
2015-06-29 14:42:25 -04:00
parent 52dce9d334
commit d0d7b924cb
3 changed files with 41 additions and 9 deletions

View File

@@ -157,6 +157,8 @@ public class InstalledAppDetails extends AppInfoBase
protected ProcStatsData mStatsManager;
protected ProcStatsPackageEntry mStats;
private BroadcastReceiver mPermissionReceiver;
private boolean handleDisableable(Button button) {
boolean disableable = false;
// Try to prevent the user from bricking their phone
@@ -312,6 +314,10 @@ public class InstalledAppDetails extends AppInfoBase
@Override
public void onDestroy() {
TrafficStats.closeQuietly(mStatsSession);
if (mPermissionReceiver != null) {
getContext().unregisterReceiver(mPermissionReceiver);
mPermissionReceiver = null;
}
super.onDestroy();
}
@@ -489,8 +495,11 @@ public class InstalledAppDetails extends AppInfoBase
// Update the preference summaries.
Activity context = getActivity();
mStoragePreference.setSummary(AppStorageSettings.getSummary(mAppEntry, context));
PermissionsSummaryHelper.getPermissionSummary(getContext(), mPackageName,
mPermissionCallback);
if (mPermissionReceiver != null) {
getContext().unregisterReceiver(mPermissionReceiver);
}
mPermissionReceiver = PermissionsSummaryHelper.getPermissionSummary(getContext(),
mPackageName, mPermissionCallback);
mLaunchPreference.setSummary(Utils.getLaunchByDeafaultSummary(mAppEntry, mUsbManager,
mPm, context));
mNotificationPreference.setSummary(getNotificationSummary(mAppEntry, context,
@@ -941,6 +950,10 @@ public class InstalledAppDetails extends AppInfoBase
= new PermissionsResultCallback() {
@Override
public void onPermissionSummaryResult(int[] counts, CharSequence[] groupLabels) {
if (getActivity() == null) {
return;
}
mPermissionReceiver = null;
final Resources res = getResources();
CharSequence summary = null;
boolean enabled = false;