OSDN Git Service

Fix issue #7178865: Selecting an app from Settings > Apps>...
authorDianne Hackborn <hackbod@google.com>
Tue, 18 Sep 2012 19:04:00 +0000 (12:04 -0700)
committerDianne Hackborn <hackbod@google.com>
Tue, 18 Sep 2012 19:04:00 +0000 (12:04 -0700)
...all crashes on a secondary user

Change-Id: I977932bce3ea2816e4c9d1002488b658a96e3986

src/com/android/settings/applications/InstalledAppDetails.java

index 907bf53..2284b91 100644 (file)
@@ -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
         }