Loading core/java/android/app/ApplicationPackageManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -1920,6 +1920,16 @@ public class ApplicationPackageManager extends PackageManager { } } @Override public void deleteApplicationCacheFilesAsUser(String packageName, int userId, IPackageDataObserver observer) { try { mPM.deleteApplicationCacheFilesAsUser(packageName, userId, observer); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } @Override public void freeStorageAndNotify(String volumeUuid, long idealStorageSize, IPackageDataObserver observer) { Loading core/java/android/content/pm/IPackageManager.aidl +9 −0 Original line number Diff line number Diff line Loading @@ -387,6 +387,15 @@ interface IPackageManager { */ void deleteApplicationCacheFiles(in String packageName, IPackageDataObserver observer); /** * Delete all the cache files in an applications cache directory * @param packageName The package name of the application whose cache * files need to be deleted * @param userId the user to delete application cache for * @param observer a callback used to notify when the deletion is finished. */ void deleteApplicationCacheFilesAsUser(in String packageName, int userId, IPackageDataObserver observer); /** * Clear the user data directory of an application. * @param packageName The package name of the application whose cache Loading core/java/android/content/pm/PackageManager.java +21 −0 Original line number Diff line number Diff line Loading @@ -4971,6 +4971,27 @@ public abstract class PackageManager { public abstract void deleteApplicationCacheFiles(String packageName, IPackageDataObserver observer); /** * Attempts to delete the cache files associated with an application for a given user. 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_CACHE_FILES} permission, if the named package * cannot be found, or if the named package is a "system package". If {@code userId} does not * belong to the calling user, the caller must have * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission. * * @param packageName The name of the package to delete * @param userId the user for which the cache files needs to be deleted * @param observer An observer callback to get notified when the cache file deletion is * complete. * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} * will be called when that happens. observer may be null to indicate that no * callback is desired. * @hide */ public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId, IPackageDataObserver observer); /** * Free storage by deleting LRU sorted list of cache files across * all applications. If the currently available free storage Loading services/core/java/com/android/server/pm/PackageManagerService.java +11 −2 Original line number Diff line number Diff line Loading @@ -16033,16 +16033,25 @@ public class PackageManagerService extends IPackageManager.Stub { @Override public void deleteApplicationCacheFiles(final String packageName, final IPackageDataObserver observer) { final int userId = UserHandle.getCallingUserId(); deleteApplicationCacheFilesAsUser(packageName, userId, observer); } @Override public void deleteApplicationCacheFilesAsUser(final String packageName, final int userId, final IPackageDataObserver observer) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.DELETE_CACHE_FILES, null); // Queue up an async operation since the package deletion may take a little while. final int userId = UserHandle.getCallingUserId(); enforceCrossUserPermission(Binder.getCallingUid(), userId, /* requireFullPermission= */ true, /* checkShell= */ false, "delete application cache files"); final PackageParser.Package pkg; synchronized (mPackages) { pkg = mPackages.get(packageName); } // Queue up an async operation since the package deletion may take a little while. mHandler.post(new Runnable() { public void run() { try (PackageFreezer freezer = freezePackage(packageName, test-runner/src/android/test/mock/MockPackageManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -691,6 +691,15 @@ public class MockPackageManager extends PackageManager { throw new UnsupportedOperationException(); } /** * @hide - to match hiding in superclass */ @Override public void deleteApplicationCacheFilesAsUser(String packageName, int userId, IPackageDataObserver observer) { throw new UnsupportedOperationException(); } /** {@hide} */ @Override public void freeStorageAndNotify(String volumeUuid, long idealStorageSize, Loading Loading
core/java/android/app/ApplicationPackageManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -1920,6 +1920,16 @@ public class ApplicationPackageManager extends PackageManager { } } @Override public void deleteApplicationCacheFilesAsUser(String packageName, int userId, IPackageDataObserver observer) { try { mPM.deleteApplicationCacheFilesAsUser(packageName, userId, observer); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } @Override public void freeStorageAndNotify(String volumeUuid, long idealStorageSize, IPackageDataObserver observer) { Loading
core/java/android/content/pm/IPackageManager.aidl +9 −0 Original line number Diff line number Diff line Loading @@ -387,6 +387,15 @@ interface IPackageManager { */ void deleteApplicationCacheFiles(in String packageName, IPackageDataObserver observer); /** * Delete all the cache files in an applications cache directory * @param packageName The package name of the application whose cache * files need to be deleted * @param userId the user to delete application cache for * @param observer a callback used to notify when the deletion is finished. */ void deleteApplicationCacheFilesAsUser(in String packageName, int userId, IPackageDataObserver observer); /** * Clear the user data directory of an application. * @param packageName The package name of the application whose cache Loading
core/java/android/content/pm/PackageManager.java +21 −0 Original line number Diff line number Diff line Loading @@ -4971,6 +4971,27 @@ public abstract class PackageManager { public abstract void deleteApplicationCacheFiles(String packageName, IPackageDataObserver observer); /** * Attempts to delete the cache files associated with an application for a given user. 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_CACHE_FILES} permission, if the named package * cannot be found, or if the named package is a "system package". If {@code userId} does not * belong to the calling user, the caller must have * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission. * * @param packageName The name of the package to delete * @param userId the user for which the cache files needs to be deleted * @param observer An observer callback to get notified when the cache file deletion is * complete. * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} * will be called when that happens. observer may be null to indicate that no * callback is desired. * @hide */ public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId, IPackageDataObserver observer); /** * Free storage by deleting LRU sorted list of cache files across * all applications. If the currently available free storage Loading
services/core/java/com/android/server/pm/PackageManagerService.java +11 −2 Original line number Diff line number Diff line Loading @@ -16033,16 +16033,25 @@ public class PackageManagerService extends IPackageManager.Stub { @Override public void deleteApplicationCacheFiles(final String packageName, final IPackageDataObserver observer) { final int userId = UserHandle.getCallingUserId(); deleteApplicationCacheFilesAsUser(packageName, userId, observer); } @Override public void deleteApplicationCacheFilesAsUser(final String packageName, final int userId, final IPackageDataObserver observer) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.DELETE_CACHE_FILES, null); // Queue up an async operation since the package deletion may take a little while. final int userId = UserHandle.getCallingUserId(); enforceCrossUserPermission(Binder.getCallingUid(), userId, /* requireFullPermission= */ true, /* checkShell= */ false, "delete application cache files"); final PackageParser.Package pkg; synchronized (mPackages) { pkg = mPackages.get(packageName); } // Queue up an async operation since the package deletion may take a little while. mHandler.post(new Runnable() { public void run() { try (PackageFreezer freezer = freezePackage(packageName,
test-runner/src/android/test/mock/MockPackageManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -691,6 +691,15 @@ public class MockPackageManager extends PackageManager { throw new UnsupportedOperationException(); } /** * @hide - to match hiding in superclass */ @Override public void deleteApplicationCacheFilesAsUser(String packageName, int userId, IPackageDataObserver observer) { throw new UnsupportedOperationException(); } /** {@hide} */ @Override public void freeStorageAndNotify(String volumeUuid, long idealStorageSize, Loading