From 47e065442edc108d4bb38f9daaa7cdb3fff26b49 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 12 Mar 2015 15:45:39 +0100 Subject: [PATCH] Do not manually call onChange() (fix NPE) If the AppDetails activity has been destroyed by the system during an application installation/remove, it is recreated once it should be displayed again (this behavior can be forced by enabling "Don't keep activities" in Android developer options). In onCreate(), it passes its instance of myInstallerCallback to an Installer. In onActivityResult() (which is called before onResume()), this installer calls a method (onSuccess() or onError()) on this callback. The implementation of these methods (the anonymous inner class assigned to myInstallerCallback) dereference myAppObserver, which is still null, because it will be initialized in onResume(), so a NullPointerException is thrown. However, the problem is not only that myAppObserver.onChange() is called when myAppObserver is null, but that it should not be called manually at all: it is a ContentObserver, so it is automatically called when registered to the content resolver. As a consequence, this callback was called twice. Removing these calls fix both problems. Should fix issue #135 https://gitlab.com/fdroid/fdroidclient/issues/135 --- F-Droid/src/org/fdroid/fdroid/AppDetails.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/F-Droid/src/org/fdroid/fdroid/AppDetails.java b/F-Droid/src/org/fdroid/fdroid/AppDetails.java index 8199391bb..915b029f0 100644 --- a/F-Droid/src/org/fdroid/fdroid/AppDetails.java +++ b/F-Droid/src/org/fdroid/fdroid/AppDetails.java @@ -924,7 +924,6 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A } setSupportProgressBarIndeterminateVisibility(false); - myAppObserver.onChange(); } }); } @@ -936,7 +935,6 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A @Override public void run() { setSupportProgressBarIndeterminateVisibility(false); - myAppObserver.onChange(); } }); } else { @@ -944,7 +942,6 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A @Override public void run() { setSupportProgressBarIndeterminateVisibility(false); - myAppObserver.onChange(); Log.e(TAG, "Installer aborted with errorCode: " + errorCode);