Java Code Examples for android.content.pm.IPackageDeleteObserver

The following are top voted examples for showing how to use android.content.pm.IPackageDeleteObserver. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: fdroid   File: PrivilegedService.java   View source code 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    // get internal methods via reflection
    try {
        Class<?>[] installTypes = {
            Uri.class, IPackageInstallObserver.class, int.class,
            String.class,
        };
        Class<?>[] deleteTypes = {
            String.class, IPackageDeleteObserver.class,
            int.class,
        };

        PackageManager pm = getPackageManager();
        mInstallMethod = pm.getClass().getMethod("installPackage", installTypes);
        mDeleteMethod = pm.getClass().getMethod("deletePackage", deleteTypes);
    } catch (NoSuchMethodException e) {
        Log.e(TAG, "Android not compatible!", e);
        stopSelf();
    }
}
 
Example 2
Project: AppHub   File: PrivilegedService.java   View source code 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    // get internal methods via reflection
    try {
        Class<?>[] installTypes = {
            Uri.class, IPackageInstallObserver.class, int.class,
            String.class,
        };
        Class<?>[] deleteTypes = {
            String.class, IPackageDeleteObserver.class,
            int.class,
        };

        PackageManager pm = getPackageManager();
        mInstallMethod = pm.getClass().getMethod("installPackage", installTypes);
        mDeleteMethod = pm.getClass().getMethod("deletePackage", deleteTypes);
    } catch (NoSuchMethodException e) {
        Log.e(TAG, "Android not compatible!", e);
        stopSelf();
    }
}
 
Example 3
Project: product-emm   File: AppUtils.java   View source code 6 votes vote down vote up
/**
 * Silently uninstalls the app resides in the provided URI.
 * @param context - Application context.
 * @param  packageName - App package name.
 */
public static void silentUninstallApp(Context context, String packageName) {
    if (packageName != null && packageName.contains(PACKAGE_PREFIX)) {
        packageName = packageName.replace(PACKAGE_PREFIX, "");
    }
    final String _packageName = packageName;
    PackageManager pm = context.getPackageManager();
    IPackageDeleteObserver observer = new IPackageDeleteObserver() {
        @Override
        public void packageDeleted(String s, int i) throws RemoteException {
            Log.d(TAG, _packageName + " deleted successfully.");
        }

        @Override
        public IBinder asBinder() {
            return null;
        }
    };
    pm.deletePackage(packageName, observer, DELETE_ALL_USERS);
}
 
Example 4
Project: f-droid   File: SystemInstaller.java   View source code 6 votes vote down vote up
public SystemInstaller(Context context, PackageManager pm,
        InstallerCallback callback) throws AndroidNotCompatibleException {
    super(context, pm, callback);

    // create internal callbacks
    mInstallObserver = new PackageInstallObserver();
    mDeleteObserver = new PackageDeleteObserver();

    try {
        Class<?>[] installTypes = new Class[] {
                Uri.class, IPackageInstallObserver.class, int.class,
                String.class
        };
        Class<?>[] deleteTypes = new Class[] {
                String.class, IPackageDeleteObserver.class,
                int.class
        };

        mInstallMethod = mPm.getClass().getMethod("installPackage", installTypes);
        mDeleteMethod = mPm.getClass().getMethod("deletePackage", deleteTypes);
    } catch (NoSuchMethodException e) {
        throw new AndroidNotCompatibleException(e);
    }
}
 
Example 5
Project: Demo_Public   File: ApplicationManager.java   View source code 5 votes vote down vote up
public ApplicationManager(Context context) throws SecurityException, NoSuchMethodException {
	
       observer = new PackageInstallObserver();
       observerdelete = new PackageDeleteObserver(); 
       pm = context.getPackageManager();
       
       Class<?>[] types = new Class[] {Uri.class, IPackageInstallObserver.class, int.class, String.class};
       Class<?>[] uninstalltypes = new Class[] {String.class, IPackageDeleteObserver.class, int.class};
       
	method = pm.getClass().getMethod("installPackage", types);
	uninstallmethod = pm.getClass().getMethod("deletePackage", uninstalltypes);
}
 
Example 6
Project: DeviceControl   File: AppHelper.java   View source code 5 votes vote down vote up
public static void uninstallPackage(PackageManager pm, String pkg) {
    try {
        Method m = pm.getClass().getDeclaredMethod("deletePackage", String.class, IPackageDeleteObserver.class, int.class);
        m.invoke(pm, pkg, null, /* DELETE_ALL_USERS */ 2);
    } catch (Exception e) {
        Timber.e(e, "could not call deletePackage via reflection");
    }
}
 
Example 7
Project: MiPushFramework   File: PackageManagerWrapper.java   View source code 4 votes vote down vote up
/** @hide */
@Override public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
	mBase.deletePackage(packageName, observer, flags);
}
 
Example 8
Project: MiPushFramework   File: PackageManagerWrapper.java   View source code 4 votes vote down vote up
/** @hide */
@RequiresPermission(Manifest.permission.DELETE_PACKAGES)
@Override public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer, int flags, int userId) {
	mBase.deletePackageAsUser(packageName, observer, flags, userId);
}
 
Example 9
Project: condom   File: PackageManagerWrapper.java   View source code 4 votes vote down vote up
/** @hide */
@Override public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
	mBase.deletePackage(packageName, observer, flags);
}
 
Example 10
Project: condom   File: PackageManagerWrapper.java   View source code 4 votes vote down vote up
/** @hide */
@RequiresPermission(Manifest.permission.DELETE_PACKAGES)
@Override public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer, int flags, int userId) {
	mBase.deletePackageAsUser(packageName, observer, flags, userId);
}
 
Example 11
Project: FullRobolectricTestSample   File: StubPackageManager.java   View source code 2 votes vote down vote up
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {

}