android.content.pm.IPackageDeleteObserver Java Examples

The following examples show how to use android.content.pm.IPackageDeleteObserver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppUtils.java    From product-emm with Apache License 2.0 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 #2
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer, int flags,
        int userId) {
    try {
        mPM.deletePackageAsUser(packageName, observer, userId, flags);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #3
Source File: ApplicationManager.java    From Demo_Public with MIT License 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 #4
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer,
        int flags, int userId) {
    try {
        mPM.deletePackageAsUser(packageName, PackageManager.VERSION_CODE_HIGHEST,
                observer, userId, flags);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #5
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer, int flags,
        int userId) {
    try {
        mPM.deletePackageAsUser(packageName, observer, userId, flags);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #6
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer,
        int flags, int userId) {
    try {
        mPM.deletePackageAsUser(packageName, PackageManager.VERSION_CODE_HIGHEST,
                observer, userId, flags);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #7
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer,
        int flags, int userId) {
    try {
        mPM.deletePackageAsUser(packageName, PackageManager.VERSION_CODE_HIGHEST,
                observer, userId, flags);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #8
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    try {
        mPM.deletePackageAsUser(packageName, observer, UserHandle.myUserId(), flags);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #9
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    try {
        mPM.deletePackage(packageName, observer, flags);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #10
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer,
        int flags, int userId) {
    try {
        mPM.deletePackageAsUser(packageName, PackageManager.VERSION_CODE_HIGHEST,
                observer, userId, flags);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #11
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer,
        int flags, int userId) {
    try {
        mPM.deletePackageAsUser(packageName, PackageManager.VERSION_CODE_HIGHEST,
                observer, userId, flags);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #12
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    try {
        mPM.deletePackageAsUser(packageName, observer, UserHandle.myUserId(), flags);
    } catch (RemoteException e) {
        // Should never happen!
    }
}
 
Example #13
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public void deletePackageAsUser(String packageName, IPackageDeleteObserver observer,
        int flags, int userId) {
    try {
        mPM.deletePackageAsUser(packageName, PackageManager.VERSION_CODE_HIGHEST,
                observer, userId, flags);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example #14
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    deletePackageAsUser(packageName, observer, flags, mContext.getUserId());
}
 
Example #15
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    deletePackageAsUser(packageName, observer, flags, mContext.getUserId());
}
 
Example #16
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
@UnsupportedAppUsage
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    deletePackageAsUser(packageName, observer, flags, getUserId());
}
 
Example #17
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    deletePackageAsUser(packageName, observer, flags, mContext.getUserId());
}
 
Example #18
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    deletePackageAsUser(packageName, observer, flags, mContext.getUserId());
}
 
Example #19
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    deletePackageAsUser(packageName, observer, flags, mContext.getUserId());
}
 
Example #20
Source File: PackageManagerWrapper.java    From MiPushFramework with GNU General Public License v3.0 4 votes vote down vote up
/** @hide */
@Override public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
	mBase.deletePackage(packageName, observer, flags);
}
 
Example #21
Source File: PackageManagerWrapper.java    From MiPushFramework with GNU General Public License v3.0 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 #22
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    deletePackageAsUser(packageName, observer, flags, mContext.getUserId());
}
 
Example #23
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@Override
public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
    deletePackageAsUser(packageName, observer, flags, mContext.getUserId());
}