From 0fca4296ac08fcf42b58fac3a016ea068fcf6257 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Tue, 18 Sep 2012 12:04:00 -0700 Subject: [PATCH] Fix issue #7178865: Selecting an app from Settings > Apps>... ...all crashes on a secondary user Change-Id: I977932bce3ea2816e4c9d1002488b658a96e3986 --- .../applications/InstalledAppDetails.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java index 907bf53df43..2284b91a9cf 100644 --- a/src/com/android/settings/applications/InstalledAppDetails.java +++ b/src/com/android/settings/applications/InstalledAppDetails.java @@ -379,8 +379,6 @@ public class InstalledAppDetails extends Fragment @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); - - setHasOptionsMenu(true); mState = ApplicationsState.getInstance(getActivity().getApplication()); mSession = mState.newSession(this); @@ -393,6 +391,10 @@ public class InstalledAppDetails extends Fragment mSmsManager = ISms.Stub.asInterface(ServiceManager.getService("isms")); mCanBeOnSdCardChecker = new CanBeOnSdCardChecker(); + + retrieveAppEntry(); + + setHasOptionsMenu(true); } @Override @@ -452,6 +454,8 @@ public class InstalledAppDetails extends Fragment boolean showIt = true; if (mUpdatedSysApp) { showIt = false; + } else if (mAppEntry == null) { + showIt = false; } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) { showIt = false; } else if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) { @@ -549,10 +553,7 @@ public class InstalledAppDetails extends Fragment public void onRunningStateChanged(boolean running) { } - private boolean refreshUi() { - if (mMoveInProgress) { - return true; - } + private String retrieveAppEntry() { final Bundle args = getArguments(); String packageName = (args != null) ? args.getString(ARG_PACKAGE_NAME) : null; if (packageName == null) { @@ -563,7 +564,15 @@ public class InstalledAppDetails extends Fragment } } mAppEntry = mState.getEntry(packageName); - + return packageName; + } + + private boolean refreshUi() { + if (mMoveInProgress) { + return true; + } + final String packageName = retrieveAppEntry(); + if (mAppEntry == null) { return false; // onCreate must have failed, make sure to exit }