From 179d6b3f0ccc506b20ae432c84fe5c3d09c10bbf Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Sun, 12 Mar 2017 17:27:47 -0600 Subject: [PATCH] Deprecate storage "low" and "ok" broadcasts. These broadcasts resulted in a terrible user experience where dozens of apps would wake up and try deleting everything they possibly can, meaning that we'd thrash between showing/hiding the low space notification to users. Instead, if apps have data that they're okay being purged when the system is chronically low on space, we want to strongly encourage them to rely on the much-improved getCacheDir() behaviors in OC. Test: builds, boots Bug: 35406598 Change-Id: I74abfba1b8d3948363b79f8b66ca0ad60faac756 --- api/current.txt | 4 +-- api/system-current.txt | 4 +-- api/test-current.txt | 4 +-- core/java/android/content/Intent.java | 68 ++++++++++++++++++++++++----------- 4 files changed, 54 insertions(+), 26 deletions(-) diff --git a/api/current.txt b/api/current.txt index 4c900b7cdc18..5d9d9f18adee 100644 --- a/api/current.txt +++ b/api/current.txt @@ -9269,8 +9269,8 @@ package android.content { field public static final java.lang.String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; field public static final java.lang.String ACTION_DEFAULT = "android.intent.action.VIEW"; field public static final java.lang.String ACTION_DELETE = "android.intent.action.DELETE"; - field public static final java.lang.String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; - field public static final java.lang.String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; + field public static final deprecated java.lang.String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; + field public static final deprecated java.lang.String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; field public static final java.lang.String ACTION_DIAL = "android.intent.action.DIAL"; field public static final java.lang.String ACTION_DOCK_EVENT = "android.intent.action.DOCK_EVENT"; field public static final java.lang.String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; diff --git a/api/system-current.txt b/api/system-current.txt index 959adf580c63..f8715d56557d 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9791,8 +9791,8 @@ package android.content { field public static final java.lang.String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; field public static final java.lang.String ACTION_DEFAULT = "android.intent.action.VIEW"; field public static final java.lang.String ACTION_DELETE = "android.intent.action.DELETE"; - field public static final java.lang.String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; - field public static final java.lang.String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; + field public static final deprecated java.lang.String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; + field public static final deprecated java.lang.String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; field public static final java.lang.String ACTION_DIAL = "android.intent.action.DIAL"; field public static final java.lang.String ACTION_DOCK_EVENT = "android.intent.action.DOCK_EVENT"; field public static final java.lang.String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; diff --git a/api/test-current.txt b/api/test-current.txt index 80b63794136c..f03fd15b6b14 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -9299,8 +9299,8 @@ package android.content { field public static final java.lang.String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; field public static final java.lang.String ACTION_DEFAULT = "android.intent.action.VIEW"; field public static final java.lang.String ACTION_DELETE = "android.intent.action.DELETE"; - field public static final java.lang.String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; - field public static final java.lang.String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; + field public static final deprecated java.lang.String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; + field public static final deprecated java.lang.String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; field public static final java.lang.String ACTION_DIAL = "android.intent.action.DIAL"; field public static final java.lang.String ACTION_DOCK_EVENT = "android.intent.action.DOCK_EVENT"; field public static final java.lang.String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index d6306e001516..f62621b42d99 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -40,6 +40,7 @@ import android.os.ResultReceiver; import android.os.ShellCommand; import android.os.StrictMode; import android.os.UserHandle; +import android.os.storage.StorageManager; import android.provider.DocumentsContract; import android.provider.DocumentsProvider; import android.provider.MediaStore; @@ -2443,45 +2444,72 @@ public class Intent implements Parcelable, Cloneable { */ public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN"; /** - * Broadcast Action: A sticky broadcast that indicates low memory + * Broadcast Action: A sticky broadcast that indicates low storage space * condition on the device + *

+ * This is a protected intent that can only be sent by the system. * - *

This is a protected intent that can only be sent - * by the system. + * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} + * or above, this broadcast will no longer be delivered to any + * {@link BroadcastReceiver} defined in your manifest. Instead, + * apps are strongly encouraged to use the improved + * {@link Context#getCacheDir()} behavior so the system can + * automatically free up storage when needed. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + @Deprecated public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; /** - * Broadcast Action: Indicates low memory condition on the device no longer exists + * Broadcast Action: Indicates low storage space condition on the device no + * longer exists + *

+ * This is a protected intent that can only be sent by the system. * - *

This is a protected intent that can only be sent - * by the system. + * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} + * or above, this broadcast will no longer be delivered to any + * {@link BroadcastReceiver} defined in your manifest. Instead, + * apps are strongly encouraged to use the improved + * {@link Context#getCacheDir()} behavior so the system can + * automatically free up storage when needed. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + @Deprecated public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; /** - * Broadcast Action: A sticky broadcast that indicates a memory full - * condition on the device. This is intended for activities that want - * to be able to fill the data partition completely, leaving only - * enough free space to prevent system-wide SQLite failures. - * - *

This is a protected intent that can only be sent - * by the system. + * Broadcast Action: A sticky broadcast that indicates a storage space full + * condition on the device. This is intended for activities that want to be + * able to fill the data partition completely, leaving only enough free + * space to prevent system-wide SQLite failures. + *

+ * This is a protected intent that can only be sent by the system. * - * {@hide} + * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} + * or above, this broadcast will no longer be delivered to any + * {@link BroadcastReceiver} defined in your manifest. Instead, + * apps are strongly encouraged to use the improved + * {@link Context#getCacheDir()} behavior so the system can + * automatically free up storage when needed. + * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + @Deprecated public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL"; /** - * Broadcast Action: Indicates memory full condition on the device - * no longer exists. - * - *

This is a protected intent that can only be sent - * by the system. + * Broadcast Action: Indicates storage space full condition on the device no + * longer exists. + *

+ * This is a protected intent that can only be sent by the system. * - * {@hide} + * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} + * or above, this broadcast will no longer be delivered to any + * {@link BroadcastReceiver} defined in your manifest. Instead, + * apps are strongly encouraged to use the improved + * {@link Context#getCacheDir()} behavior so the system can + * automatically free up storage when needed. + * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + @Deprecated public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL"; /** * Broadcast Action: Indicates low memory condition notification acknowledged by user -- 2.11.0