Merge "Docs: Updates guidance about using permissions when accessing OBB expansion files, Bug: 34273998 Test: Ran "make" to verify error-free building." into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e4d0557334
@@ -127,8 +127,8 @@ public abstract class Context {
|
|||||||
* File creation mode: allow all other applications to have read access to
|
* File creation mode: allow all other applications to have read access to
|
||||||
* the created file.
|
* the created file.
|
||||||
* <p>
|
* <p>
|
||||||
* As of {@link android.os.Build.VERSION_CODES#N} attempting to use this
|
* Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this
|
||||||
* mode will throw a {@link SecurityException}.
|
* mode throws a {@link SecurityException}.
|
||||||
*
|
*
|
||||||
* @deprecated Creating world-readable files is very dangerous, and likely
|
* @deprecated Creating world-readable files is very dangerous, and likely
|
||||||
* to cause security holes in applications. It is strongly
|
* to cause security holes in applications. It is strongly
|
||||||
@@ -147,7 +147,7 @@ public abstract class Context {
|
|||||||
* File creation mode: allow all other applications to have write access to
|
* File creation mode: allow all other applications to have write access to
|
||||||
* the created file.
|
* the created file.
|
||||||
* <p>
|
* <p>
|
||||||
* As of {@link android.os.Build.VERSION_CODES#N} attempting to use this
|
* Starting from {@link android.os.Build.VERSION_CODES#N}, attempting to use this
|
||||||
* mode will throw a {@link SecurityException}.
|
* mode will throw a {@link SecurityException}.
|
||||||
*
|
*
|
||||||
* @deprecated Creating world-writable files is very dangerous, and likely
|
* @deprecated Creating world-writable files is very dangerous, and likely
|
||||||
@@ -1127,13 +1127,47 @@ public abstract class Context {
|
|||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions
|
* Starting in {@link android.os.Build.VERSION_CODES#KITKAT}, no permissions
|
||||||
* are required to read or write to the returned path; it's always
|
* are required to read or write to the path that this method returns.
|
||||||
* accessible to the calling app. This only applies to paths generated for
|
* However, starting from {@link android.os.Build.VERSION_CODES#M},
|
||||||
* package name of the calling application. To access paths belonging to
|
* to read the OBB expansion files, you must declare the
|
||||||
* other packages,
|
* {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission in the app manifest and ask for
|
||||||
* {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} and/or
|
* permission at runtime as follows:
|
||||||
* {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} are required.
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
|
* {@code <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
|
||||||
|
* android:maxSdkVersion="23" />}
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* Starting from {@link android.os.Build.VERSION_CODES#N},
|
||||||
|
* {@link android.Manifest.permission#READ_EXTERNAL_STORAGE}
|
||||||
|
* permission is not required, so don’t ask for this
|
||||||
|
* permission at runtime. To handle both cases, your app must first try to read the OBB file,
|
||||||
|
* and if it fails, you must request
|
||||||
|
* {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} permission at runtime.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* The following code snippet shows how to do this:
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* File obb = new File(obb_filename);
|
||||||
|
* boolean open_failed = false;
|
||||||
|
*
|
||||||
|
* try {
|
||||||
|
* BufferedReader br = new BufferedReader(new FileReader(obb));
|
||||||
|
* open_failed = false;
|
||||||
|
* ReadObbFile(br);
|
||||||
|
* } catch (IOException e) {
|
||||||
|
* open_failed = true;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* if (open_failed) {
|
||||||
|
* // request READ_EXTERNAL_STORAGE permission before reading OBB file
|
||||||
|
* ReadObbFileWithPermission();
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* On devices with multiple users (as described by {@link UserManager}),
|
* On devices with multiple users (as described by {@link UserManager}),
|
||||||
* multiple users may share the same OBB storage location. Applications
|
* multiple users may share the same OBB storage location. Applications
|
||||||
* should ensure that multiple instances running under different users don't
|
* should ensure that multiple instances running under different users don't
|
||||||
|
|||||||
Reference in New Issue
Block a user