/** * Attempts to delete a package. Since this may take a little while, the * result will be posted back to the given observer. A deletion will fail if * the calling context lacks the * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the * named package cannot be found, or if the named package is a system * package. * * @param packageName The name of the package to delete * @param observer An observer callback to get notified when the package * deletion is complete. * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} * will be called when that happens. observer may be null to * indicate that no callback is desired. * @hide */ @SuppressWarnings("HiddenAbstractMethod") @RequiresPermission(Manifest.permission.DELETE_PACKAGES) @UnsupportedAppUsage publicabstractvoiddeletePackage(@NonNull String packageName, @Nullable IPackageDeleteObserver observer, @DeleteFlagsint flags);
@Override publicvoiduninstall(VersionedPackage versionedPackage, String callerPackageName, int flags, IntentSender statusReceiver, int userId) { finalComputersnapshot= mPm.snapshotComputer(); finalintcallingUid= Binder.getCallingUid(); snapshot.enforceCrossUserPermission(callingUid, userId, true, true, "uninstall"); // Create by yeruilai 2025-11-01 20:46:06 Enable silent loading for System users // if ((callingUid != Process.SHELL_UID) && (callingUid != Process.ROOT_UID)) { if ((callingUid != Process.SHELL_UID) && (callingUid != Process.ROOT_UID) && (callingUid != Process.SYSTEM_UID)) { mAppOps.checkPackage(callingUid, callerPackageName); }
// Check whether the caller is device owner or affiliated profile owner, in which case we do // it silently. DevicePolicyManagerInternaldpmi= LocalServices.getService(DevicePolicyManagerInternal.class); finalbooleancanSilentlyInstallPackage= dpmi != null && dpmi.canSilentlyInstallPackage(callerPackageName, callingUid);