Java 类android.content.pm.IPackageDeleteObserver 实例源码

项目:fdroid    文件:PrivilegedService.java   
@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();
    }
}
项目:AppHub    文件:PrivilegedService.java   
@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();
    }
}
项目:product-emm    文件:AppUtils.java   
/**
 * 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);
}
项目:f-droid    文件:SystemInstaller.java   
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);
    }
}
项目:Demo_Public    文件:ApplicationManager.java   
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);
}
项目:DeviceControl    文件:AppHelper.java   
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");
    }
}
项目:MiPushFramework    文件:PackageManagerWrapper.java   
/** @hide */
@Override public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    mBase.deletePackage(packageName, observer, flags);
}
项目:MiPushFramework    文件:PackageManagerWrapper.java   
/** @hide */
@RequiresPermission(Manifest.permission.DELETE_PACKAGES)
@Override public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer, int flags, int userId) {
    mBase.deletePackageAsUser(packageName, observer, flags, userId);
}
项目:condom    文件:PackageManagerWrapper.java   
/** @hide */
@Override public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    mBase.deletePackage(packageName, observer, flags);
}
项目:condom    文件:PackageManagerWrapper.java   
/** @hide */
@RequiresPermission(Manifest.permission.DELETE_PACKAGES)
@Override public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer, int flags, int userId) {
    mBase.deletePackageAsUser(packageName, observer, flags, userId);
}
项目:FullRobolectricTestSample    文件:StubPackageManager.java   
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {

}