Skip to content

Do not manually call onChange() (fix NPE)

Romain Vimont requested to merge rom1v/fdroidclient:npe_135 into master

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 (closed) #135 (closed)

Merge request reports