mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-01-31 10:11:38 -05:00
Set PackageInstaller as org.fdroid.fdroid whenever possible (closes: #355)
This commit is contained in:
@@ -68,6 +68,8 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
|
||||
import org.fdroid.fdroid.compat.PackageManagerCompat;
|
||||
|
||||
public class AppDetails extends ListActivity {
|
||||
|
||||
private static final int REQUEST_INSTALL = 0;
|
||||
@@ -967,6 +969,8 @@ public class AppDetails extends ListActivity {
|
||||
if (downloadHandler != null) {
|
||||
downloadHandler = null;
|
||||
}
|
||||
|
||||
PackageManagerCompat.setInstaller(mPm, app.id);
|
||||
resetRequired = true;
|
||||
break;
|
||||
case REQUEST_UNINSTALL:
|
||||
|
||||
28
src/org/fdroid/fdroid/compat/PackageManagerCompat.java
Normal file
28
src/org/fdroid/fdroid/compat/PackageManagerCompat.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package org.fdroid.fdroid.compat;
|
||||
|
||||
import java.lang.Exception;
|
||||
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class PackageManagerCompat extends Compatibility {
|
||||
|
||||
public static void setInstaller(PackageManager mPm, String app_id) {
|
||||
if (!hasApi(11)) return;
|
||||
try {
|
||||
mPm.setInstallerPackageName(app_id, "org.fdroid.fdroid");
|
||||
Log.d("FDroid", "Installer package name for " +
|
||||
app_id + " set successfully");
|
||||
} catch (Exception e) {
|
||||
// Many problems can occur:
|
||||
// * App wasn't installed due to incompatibility
|
||||
// * User canceled install
|
||||
// * Another app interfered in the process
|
||||
// * Another app already set the target's installer package
|
||||
// * ...
|
||||
Log.d("FDroid", "Could not set installer package name for " +
|
||||
app_id + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user