Merge "Fixes crash from selecting uninstalled app info from recents."

This commit is contained in:
TreeHugger Robot
2018-02-02 00:35:42 +00:00
committed by Android (Google) Code Review
2 changed files with 31 additions and 11 deletions

View File

@@ -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;