diff --git a/app/src/main/java/org/fdroid/fdroid/AppDetails2.java b/app/src/main/java/org/fdroid/fdroid/AppDetails2.java index a2fbf06cb..3019ace1e 100644 --- a/app/src/main/java/org/fdroid/fdroid/AppDetails2.java +++ b/app/src/main/java/org/fdroid/fdroid/AppDetails2.java @@ -765,18 +765,29 @@ public class AppDetails2 extends AppCompatActivity installApk(apkToInstall); } + /** + * Uninstall the app from the current screen. Since there are many ways + * to uninstall an app, including from Google Play, {@code adb uninstall}, + * or Settings -> Apps, this method cannot ever be sure that the app isn't + * already being uninstalled. So it needs to check that we can actually + * get info on the installed app, otherwise, just call it interrupted and + * quit. + * + * @see issue #1435 + */ @Override public void uninstallApk() { Apk apk = app.installedApk; if (apk == null) { - // TODO ideally, app would be refreshed immediately after install, then this - // workaround would be unnecessary - unless it is a media file apk = app.getMediaApkifInstalled(getApplicationContext()); if (apk == null) { // When the app isn't a media file - the above workaround refers to this. apk = app.getInstalledApk(this); if (apk == null) { - throw new IllegalStateException("Couldn't find installed apk for " + app.packageName); + Log.d(TAG, "Couldn't find installed apk for " + app.packageName); + Toast.makeText(this, R.string.uninstall_error_unknown, Toast.LENGTH_SHORT).show(); + uninstallReceiver.onReceive(this, new Intent(Installer.ACTION_UNINSTALL_INTERRUPTED)); + return; } } app.installedApk = apk;