Initial implementation of OPEN_EXTERNAL_DIRECTORY.
It opens a an alert dialog that tells user application X is requesting
access to folder Y on volume Z; if user accepts, it returns the proper
URI, otherwise it returns RESULT_CANCELED.
The requested path must satisfy the following requirements:
1.It's directory (getName()) must be one of the pre-definied folders on
Environment.
2.It's root (getParent()) must be a valid external storage root.
In order to satisfy #2, DocumentsUI calls the ExternalStorageProvider,
through a custom call() implementation.
BUG: 23011462
Change-Id: I8e491e82ae320df88f7b8923286c4c1ad050ae80
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index ba215bb..c776ef8 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -402,7 +402,7 @@
* type.
*/
public static String DIRECTORY_PODCASTS = "Podcasts";
-
+
/**
* Standard directory in which to place any audio files that should be
* in the list of ringtones that the user can select (not as regular
@@ -414,7 +414,7 @@
* type.
*/
public static String DIRECTORY_RINGTONES = "Ringtones";
-
+
/**
* Standard directory in which to place any audio files that should be
* in the list of alarms that the user can select (not as regular
@@ -426,7 +426,7 @@
* type.
*/
public static String DIRECTORY_ALARMS = "Alarms";
-
+
/**
* Standard directory in which to place any audio files that should be
* in the list of notifications that the user can select (not as regular
@@ -438,7 +438,7 @@
* type.
*/
public static String DIRECTORY_NOTIFICATIONS = "Notifications";
-
+
/**
* Standard directory in which to place pictures that are available to
* the user. Note that this is primarily a convention for the top-level
@@ -446,7 +446,7 @@
* in any directory.
*/
public static String DIRECTORY_PICTURES = "Pictures";
-
+
/**
* Standard directory in which to place movies that are available to
* the user. Note that this is primarily a convention for the top-level
@@ -454,7 +454,7 @@
* in any directory.
*/
public static String DIRECTORY_MOVIES = "Movies";
-
+
/**
* Standard directory in which to place files that have been downloaded by
* the user. Note that this is primarily a convention for the top-level
@@ -464,7 +464,7 @@
* backwards compatibility reasons.
*/
public static String DIRECTORY_DOWNLOADS = "Download";
-
+
/**
* The traditional location for pictures and videos when mounting the
* device as a camera. Note that this is primarily a convention for the
@@ -496,7 +496,7 @@
* </ul>
* @hide
*/
- public static final String[] STANDARD_DIRECTORIES = {
+ private static final String[] STANDARD_DIRECTORIES = {
DIRECTORY_MUSIC,
DIRECTORY_PODCASTS,
DIRECTORY_RINGTONES,
@@ -510,6 +510,18 @@
};
/**
+ * @hide
+ */
+ public static boolean isStandardDirectory(String dir) {
+ for (String valid : STANDARD_DIRECTORIES) {
+ if (valid.equals(dir)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Get a top-level shared/external storage directory for placing files of a
* particular type. This is where the user will typically place and manage
* their own files, so you should be careful about what you put here to
@@ -559,7 +571,7 @@
throwIfUserRequired();
return sCurrentUser.buildExternalStorageAppDataDirs(packageName);
}
-
+
/**
* Generates the raw path to an application's media
* @hide
@@ -568,7 +580,7 @@
throwIfUserRequired();
return sCurrentUser.buildExternalStorageAppMediaDirs(packageName);
}
-
+
/**
* Generates the raw path to an application's OBB files
* @hide
@@ -577,7 +589,7 @@
throwIfUserRequired();
return sCurrentUser.buildExternalStorageAppObbDirs(packageName);
}
-
+
/**
* Generates the path to an application's files.
* @hide
@@ -595,7 +607,7 @@
throwIfUserRequired();
return sCurrentUser.buildExternalStorageAppCacheDirs(packageName);
}
-
+
/**
* Return the download/cache content directory.
*/