summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author shafik <shafik@google.com> 2020-02-06 18:21:07 +0000
committer shafik <shafik@google.com> 2020-02-13 20:13:46 +0000
commit0f2c4d12eb97440eead1d4e4f17f44add5286c65 (patch)
tree8d7f66cb71256b3e21b568ffd6ada7a11b6d6fa9
parentb9d84550d5232ee4788f29c5834b4728c5ba5dd0 (diff)
Add intent to clear app cache
Adds a new public API intent action that should be used to launch a dialog that prompts the user to clear app caches. The intent can be used by apps holding MANAGE_EXTERNAL_STORAGE permission or with OP_MANAGE_EXTERNAL_STORAGE allowed Bug: 144341120 Test: build Change-Id: Icc6de16da4f892f1ed46ffc89e51071647a17400
-rw-r--r--api/current.txt1
-rw-r--r--core/java/android/os/storage/StorageManager.java14
2 files changed, 15 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index ac52e589cbb2..2e623155b7a7 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -37314,6 +37314,7 @@ package android.os.storage {
method public void setCacheBehaviorTombstone(java.io.File, boolean) throws java.io.IOException;
method public boolean unmountObb(String, boolean, android.os.storage.OnObbStateChangeListener);
method public void unregisterStorageVolumeCallback(@NonNull android.os.storage.StorageManager.StorageVolumeCallback);
+ field @RequiresPermission(android.Manifest.permission.MANAGE_EXTERNAL_STORAGE) public static final String ACTION_CLEAR_APP_CACHE = "android.os.storage.action.CLEAR_APP_CACHE";
field public static final String ACTION_MANAGE_STORAGE = "android.os.storage.action.MANAGE_STORAGE";
field public static final String EXTRA_REQUESTED_BYTES = "android.os.storage.extra.REQUESTED_BYTES";
field public static final String EXTRA_UUID = "android.os.storage.extra.UUID";
diff --git a/core/java/android/os/storage/StorageManager.java b/core/java/android/os/storage/StorageManager.java
index bb1dafc50484..8d04df0560f5 100644
--- a/core/java/android/os/storage/StorageManager.java
+++ b/core/java/android/os/storage/StorageManager.java
@@ -215,6 +215,20 @@ public class StorageManager {
public static final String ACTION_MANAGE_STORAGE = "android.os.storage.action.MANAGE_STORAGE";
/**
+ * Activity Action: Allows the user to free up space by clearing app external cache directories.
+ * The intent doesn't automatically clear cache, but shows a dialog and lets the user decide.
+ * <p>
+ * This intent should be launched using
+ * {@link Activity#startActivityForResult(Intent, int)} so that the user
+ * knows which app is requesting to clear cache. The returned result will
+ * be {@link Activity#RESULT_OK} if the activity was launched and the user accepted to clear
+ * cache, or {@link Activity#RESULT_CANCELED} otherwise.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_EXTERNAL_STORAGE)
+ @SdkConstant(SdkConstant.SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_CLEAR_APP_CACHE = "android.os.storage.action.CLEAR_APP_CACHE";
+
+ /**
* Extra {@link UUID} used to indicate the storage volume where an
* application is interested in allocating or managing disk space.
*