the current app is not always available when requesting uninstall
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. closes #1435
This commit is contained in:
parent
be560f7179
commit
862e985cc4
@ -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 <a href="https://gitlab.com/fdroid/fdroidclient/issues/1435">issue #1435</a>
|
||||
*/
|
||||
@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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user