Fixes crash from selecting uninstalled app info from recents.
- when the package is uninstalled, also remove it from the recent tasks - move retrieveAppEntry() from onCreate() to getPreferenceControllers() so that if the package info is invalid, do not create any controllers, as the activity will be finished anyway. Change-Id: Ibbfa16e3d1f941a0a200e78ec73a06ca8511f82b Fixes: 72656345 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -162,13 +162,12 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
mUserManager = (UserManager) activity.getSystemService(Context.USER_SERVICE);
|
||||
mPm = activity.getPackageManager();
|
||||
|
||||
retrieveAppEntry();
|
||||
startListeningToPackageRemove();
|
||||
|
||||
if (!ensurePackageInfoAvailable(activity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
startListeningToPackageRemove();
|
||||
|
||||
mForceStopOptionsMenuController =
|
||||
new ForceStopOptionsMenuController(activity, this /* parent */, mDpm,
|
||||
mMetricsFeatureProvider, getLifecycle());
|
||||
@@ -205,6 +204,10 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
|
||||
retrieveAppEntry();
|
||||
if (mPackageInfo == null) {
|
||||
return null;
|
||||
}
|
||||
final String packageName = getPackageName();
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
final Lifecycle lifecycle = getLifecycle();
|
||||
@@ -262,9 +265,6 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
ApplicationsState.AppEntry getAppEntry() {
|
||||
if (mAppEntry == null) {
|
||||
retrieveAppEntry();
|
||||
}
|
||||
return mAppEntry;
|
||||
}
|
||||
|
||||
@@ -273,9 +273,6 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
}
|
||||
|
||||
PackageInfo getPackageInfo() {
|
||||
if (mAppEntry == null) {
|
||||
retrieveAppEntry();
|
||||
}
|
||||
return mPackageInfo;
|
||||
}
|
||||
|
||||
@@ -361,7 +358,12 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)
|
||||
.execute((Object) null);
|
||||
}
|
||||
// continue with following operations
|
||||
if (!refreshUi()) {
|
||||
onPackageRemoved();
|
||||
} else {
|
||||
startListeningToPackageRemove();
|
||||
}
|
||||
break;
|
||||
case REQUEST_REMOVE_DEVICE_ADMIN:
|
||||
if (!refreshUi()) {
|
||||
setIntentAndFinish(true, true);
|
||||
@@ -622,7 +624,8 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
return mPackageName;
|
||||
}
|
||||
|
||||
private void retrieveAppEntry() {
|
||||
@VisibleForTesting
|
||||
void retrieveAppEntry() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity == null) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user