Skip to content

Commit 1c8135a

Browse files
jsharkeyAndroid (Google) Code Review
authored andcommitted
Merge "Update docs for multi-user storage behavior." into jb-mr1-dev
2 parents 0058f4e + 8c16579 commit 1c8135a

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

core/java/android/content/Context.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import android.os.Handler;
3434
import android.os.Looper;
3535
import android.os.UserHandle;
36+
import android.os.UserManager;
3637
import android.util.AttributeSet;
3738
import android.view.CompatibilityInfoHolder;
3839
import android.view.Display;
@@ -587,6 +588,10 @@ public abstract FileOutputStream openFileOutput(String name, int mode)
587588
* can read and write files placed here.
588589
* </ul>
589590
*
591+
* <p>On devices with multiple users (as described by {@link UserManager}),
592+
* each user has their own isolated external storage. Applications only
593+
* have access to the external storage for the user they're running as.</p>
594+
*
590595
* <p>Here is an example of typical code to manipulate a file in
591596
* an application's private storage:</p>
592597
*
@@ -616,6 +621,9 @@ public abstract FileOutputStream openFileOutput(String name, int mode)
616621
* {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
617622
* private_picture}
618623
*
624+
* <p>Writing to this path requires the
625+
* {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission.</p>
626+
*
619627
* @param type The type of files directory to return. May be null for
620628
* the root of the files directory or one of
621629
* the following Environment constants for a subdirectory:
@@ -641,6 +649,11 @@ public abstract FileOutputStream openFileOutput(String name, int mode)
641649
* Return the directory where this application's OBB files (if there
642650
* are any) can be found. Note if the application does not have any OBB
643651
* files, this directory may not exist.
652+
*
653+
* <p>On devices with multiple users (as described by {@link UserManager}),
654+
* multiple users may share the same OBB storage location. Applications
655+
* should ensure that multiple instances running under different users
656+
* don't interfere with each other.</p>
644657
*/
645658
public abstract File getObbDir();
646659

@@ -689,6 +702,13 @@ public abstract FileOutputStream openFileOutput(String name, int mode)
689702
* can read and write files placed here.
690703
* </ul>
691704
*
705+
* <p>On devices with multiple users (as described by {@link UserManager}),
706+
* each user has their own isolated external storage. Applications only
707+
* have access to the external storage for the user they're running as.</p>
708+
*
709+
* <p>Writing to this path requires the
710+
* {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission.</p>
711+
*
692712
* @return Returns the path of the directory holding application cache files
693713
* on external storage. Returns null if external storage is not currently
694714
* mounted so it could not ensure the path exists; you will need to call

core/java/android/os/Environment.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ public static File getDataDirectory() {
274274
* built-in storage in a device that is distinct from the protected
275275
* internal storage and can be mounted as a filesystem on a computer.</em></p>
276276
*
277+
* <p>On devices with multiple users (as described by {@link UserManager}),
278+
* each user has their own isolated external storage. Applications only
279+
* have access to the external storage for the user they're running as.</p>
280+
*
277281
* <p>In devices with multiple "external" storage directories (such as
278282
* both secure app storage and mountable shared storage), this directory
279283
* represents the "primary" external storage that the user will interact
@@ -286,7 +290,16 @@ public static File getDataDirectory() {
286290
* Context.getExternalFilesDir}, which the system will take care of deleting
287291
* if the application is uninstalled. Other shared files should be placed
288292
* in one of the directories returned by
289-
* {@link #getExternalStoragePublicDirectory}.
293+
* {@link #getExternalStoragePublicDirectory}.</p>
294+
*
295+
* <p>Writing to this path requires the
296+
* {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission. In
297+
* a future platform release, access to this path will require the
298+
* {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission,
299+
* which is automatically granted if you hold the write permission.</p>
300+
*
301+
* <p>This path may change between platform versions, so applications
302+
* should only persist relative paths.</p>
290303
*
291304
* <p>Here is an example of typical code to monitor the state of
292305
* external storage:</p>
@@ -423,6 +436,10 @@ public static File getEmulatedStorageObbSource() {
423436
* to ensure you don't erase their files or get in the way of their own
424437
* organization.
425438
*
439+
* <p>On devices with multiple users (as described by {@link UserManager}),
440+
* each user has their own isolated external storage. Applications only
441+
* have access to the external storage for the user they're running as.</p>
442+
*
426443
* <p>Here is an example of typical code to manipulate a picture on
427444
* the public external storage:</p>
428445
*
@@ -500,7 +517,10 @@ public static File getExternalStorageAppCacheDirectory(String packageName) {
500517
}
501518

502519
/**
503-
* Gets the Android Download/Cache content directory.
520+
* Gets the Android download/cache content directory.
521+
* <p>
522+
* Access to this path requires the
523+
* {@link android.Manifest.permission#ACCESS_CACHE_FILESYSTEM} permission.
504524
*/
505525
public static File getDownloadCacheDirectory() {
506526
return DOWNLOAD_CACHE_DIRECTORY;
@@ -563,7 +583,7 @@ public static File getDownloadCacheDirectory() {
563583
/**
564584
* Gets the current state of the primary "external" storage device.
565585
*
566-
* <p>See {@link #getExternalStorageDirectory()} for more information.
586+
* @see #getExternalStorageDirectory()
567587
*/
568588
public static String getExternalStorageState() {
569589
try {

0 commit comments

Comments
 (0)