From 9f77f7f31b2427d22bf77c0a0c1b8cf9294c65ff Mon Sep 17 00:00:00 2001 From: Nandana Dutt Date: Fri, 18 Jun 2021 11:48:19 +0100 Subject: [PATCH] Undeprecate storage directory APIs Android 10 did not support file path operations for apps in scoped storage. But Android 11 and above do support file path operations for such apps. Undeprecate getExternalStorageDirectory() and getExternalStoragePublicDirectory() to reflect the current level of support. BUG: 153562415 Test: m Change-Id: Ibd93ca07a0c08b11a82b70dca8c2cd7d49600354 (cherry picked from commit 74bf4e682dadfcc5276d36fd2f59f375b6dfd3c2) --- core/api/current.txt | 4 ++-- core/java/android/os/Environment.java | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index cfc567e99a18f..c6d272a244f2d 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -31070,8 +31070,8 @@ package android.os { ctor public Environment(); method public static java.io.File getDataDirectory(); method public static java.io.File getDownloadCacheDirectory(); - method @Deprecated public static java.io.File getExternalStorageDirectory(); - method @Deprecated public static java.io.File getExternalStoragePublicDirectory(String); + method public static java.io.File getExternalStorageDirectory(); + method public static java.io.File getExternalStoragePublicDirectory(String); method public static String getExternalStorageState(); method public static String getExternalStorageState(java.io.File); method @NonNull public static java.io.File getRootDirectory(); diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java index 2ed0bad69460d..308e6d56b96e0 100644 --- a/core/java/android/os/Environment.java +++ b/core/java/android/os/Environment.java @@ -189,13 +189,11 @@ public class Environment { } @UnsupportedAppUsage - @Deprecated public File getExternalStorageDirectory() { return getExternalDirs()[0]; } @UnsupportedAppUsage - @Deprecated public File getExternalStoragePublicDirectory(String type) { return buildExternalStoragePublicDirs(type)[0]; } @@ -698,11 +696,7 @@ public class Environment { * * @see #getExternalStorageState() * @see #isExternalStorageRemovable() - * @deprecated Alternatives such as {@link Context#getExternalFilesDir(String)}, - * {@link MediaStore}, or {@link Intent#ACTION_OPEN_DOCUMENT} offer better - * performance. */ - @Deprecated public static File getExternalStorageDirectory() { throwIfUserRequired(); return sCurrentUser.getExternalDirs()[0]; @@ -1009,11 +1003,7 @@ public class Environment { * @return Returns the File path for the directory. Note that this directory * may not yet exist, so you must make sure it exists before using * it such as with {@link File#mkdirs File.mkdirs()}. - * @deprecated Alternatives such as {@link Context#getExternalFilesDir(String)}, - * {@link MediaStore}, or {@link Intent#ACTION_OPEN_DOCUMENT} offer better - * performance. */ - @Deprecated public static File getExternalStoragePublicDirectory(String type) { throwIfUserRequired(); return sCurrentUser.buildExternalStoragePublicDirs(type)[0];