Java Code Examples for android.content.pm.IPackageDeleteObserver

The following examples show how to use android.content.pm.IPackageDeleteObserver. These examples are extracted from open source projects.
Example 1
Project: product-emm   File: AppUtils.java    License: 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
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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 4
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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 5
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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 6
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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 8
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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 10
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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 12
Project: android_9.0.0_r45   File: ApplicationPackageManager.java    License: 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 13
Project: Demo_Public   File: ApplicationManager.java    License: 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 14
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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 17
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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 20
Project: AndroidComponentPlugin   File: ApplicationPackageManager.java    License: 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 21
Project: android_9.0.0_r45   File: ApplicationPackageManager.java    License: 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 22
Project: MiPushFramework   File: PackageManagerWrapper.java    License: 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 23
Project: MiPushFramework   File: PackageManagerWrapper.java    License: 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);
}