Set PackageInstaller as org.fdroid.fdroid whenever possible (closes: #355)
This commit is contained in:
parent
8f334fefeb
commit
85cd9abd4c
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user