use of org.fdroid.fdroid.installer.Installer in project fdroidclient by f-droid.
the class AppDetailsActivity method uninstallApk.
/**
* 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) {
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) {
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;
}
Installer installer = InstallerFactory.create(this, apk);
Intent intent = installer.getUninstallScreen();
if (intent != null) {
// uninstall screen required
Utils.debugLog(TAG, "screen screen required");
startActivityForResult(intent, REQUEST_UNINSTALL_DIALOG);
return;
}
startUninstall();
}
use of org.fdroid.fdroid.installer.Installer in project fdroidclient by f-droid.
the class AppDetailsActivity method initiateInstall.
private void initiateInstall(Apk apk) {
Installer installer = InstallerFactory.create(this, apk);
Intent intent = installer.getPermissionScreen();
if (intent != null) {
// permission screen required
Utils.debugLog(TAG, "permission screen required");
startActivityForResult(intent, REQUEST_PERMISSION_DIALOG);
return;
}
InstallManagerService.queue(this, app, apk);
}
use of org.fdroid.fdroid.installer.Installer in project fdroidclient by f-droid.
the class AppDetails2 method initiateInstall.
private void initiateInstall(Apk apk) {
if (isAppDownloading()) {
Log.i(TAG, "Ignoring request to install " + apk.packageName + " version " + apk.versionName + ", as we are already downloading (either that or a different version).");
return;
}
Installer installer = InstallerFactory.create(this, apk);
Intent intent = installer.getPermissionScreen();
if (intent != null) {
// permission screen required
Utils.debugLog(TAG, "permission screen required");
startActivityForResult(intent, REQUEST_PERMISSION_DIALOG);
return;
}
startInstall(apk);
}
use of org.fdroid.fdroid.installer.Installer in project fdroidclient by f-droid.
the class AppDetails2 method uninstallApk.
@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);
}
}
app.installedApk = apk;
}
Installer installer = InstallerFactory.create(this, apk);
Intent intent = installer.getUninstallScreen();
if (intent != null) {
// uninstall screen required
Utils.debugLog(TAG, "screen screen required");
startActivityForResult(intent, REQUEST_UNINSTALL_DIALOG);
return;
}
startUninstall();
}
use of org.fdroid.fdroid.installer.Installer in project fdroidclient by f-droid.
the class AppListItemController method onActionButtonPressed.
protected void onActionButtonPressed(App app) {
if (app == null) {
return;
}
// When the button says "Open", then launch the app.
if (currentStatus != null && currentStatus.status == AppUpdateStatusManager.Status.Installed) {
Intent intent = activity.getPackageManager().getLaunchIntentForPackage(app.packageName);
if (intent != null) {
activity.startActivity(intent);
// Once it is explicitly launched by the user, then we can pretty much forget about
// any sort of notification that the app was successfully installed. It should be
// apparent to the user because they just launched it.
AppUpdateStatusManager.getInstance(activity).removeApk(currentStatus.getCanonicalUrl());
}
return;
}
if (currentStatus != null && currentStatus.status == AppUpdateStatusManager.Status.ReadyToInstall) {
String canonicalUrl = currentStatus.apk.getCanonicalUrl();
File apkFilePath = ApkCache.getApkDownloadPath(activity, canonicalUrl);
Utils.debugLog(TAG, "skip download, we have already downloaded " + currentStatus.apk.getCanonicalUrl() + " to " + apkFilePath);
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(activity);
final BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
broadcastManager.unregisterReceiver(this);
if (Installer.ACTION_INSTALL_USER_INTERACTION.equals(intent.getAction())) {
PendingIntent pendingIntent = intent.getParcelableExtra(Installer.EXTRA_USER_INTERACTION_PI);
try {
pendingIntent.send();
} catch (PendingIntent.CanceledException ignored) {
}
}
}
};
Uri canonicalUri = Uri.parse(canonicalUrl);
broadcastManager.registerReceiver(receiver, Installer.getInstallIntentFilter(canonicalUri));
Installer installer = InstallerFactory.create(activity, currentStatus.apk);
installer.installPackage(Uri.parse(apkFilePath.toURI().toString()), canonicalUri);
} else {
final Apk suggestedApk = ApkProvider.Helper.findSuggestedApk(activity, app);
InstallManagerService.queue(activity, app, suggestedApk);
}
}
Aggregations