diff options
| -rw-r--r-- | core/api/current.txt | 4 | ||||
| -rw-r--r-- | core/java/android/webkit/WebChromeClient.java | 41 | ||||
| -rw-r--r-- | core/java/android/webkit/flags.aconfig | 8 |
3 files changed, 49 insertions, 4 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index a131ea7d29a7..4781d3b217a4 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -58112,12 +58112,16 @@ package android.webkit { method public abstract String[] getAcceptTypes(); method @Nullable public abstract String getFilenameHint(); method public abstract int getMode(); + method @FlaggedApi("android.webkit.file_system_access") public int getPermissionMode(); method @Nullable public abstract CharSequence getTitle(); method public abstract boolean isCaptureEnabled(); method @Nullable public static android.net.Uri[] parseResult(int, android.content.Intent); field public static final int MODE_OPEN = 0; // 0x0 + field @FlaggedApi("android.webkit.file_system_access") public static final int MODE_OPEN_FOLDER = 2; // 0x2 field public static final int MODE_OPEN_MULTIPLE = 1; // 0x1 field public static final int MODE_SAVE = 3; // 0x3 + field @FlaggedApi("android.webkit.file_system_access") public static final int PERMISSION_MODE_READ = 0; // 0x0 + field @FlaggedApi("android.webkit.file_system_access") public static final int PERMISSION_MODE_READ_WRITE = 1; // 0x1 } public abstract class WebHistoryItem implements java.lang.Cloneable { diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java index b7ee0b8a238a..01579f701954 100644 --- a/core/java/android/webkit/WebChromeClient.java +++ b/core/java/android/webkit/WebChromeClient.java @@ -16,6 +16,8 @@ package android.webkit; +import android.annotation.FlaggedApi; +import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.SystemApi; import android.content.Intent; @@ -25,6 +27,9 @@ import android.net.Uri; import android.os.Message; import android.view.View; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + public class WebChromeClient { /** @@ -551,14 +556,27 @@ public class WebChromeClient { public static final int MODE_OPEN = 0; /** Like Open but allows multiple files to be selected. */ public static final int MODE_OPEN_MULTIPLE = 1; - /** Like Open but allows a folder to be selected. The implementation should enumerate - all files selected by this operation. - This feature is not supported at the moment. - @hide */ + /** Like Open but allows a folder to be selected. */ + @FlaggedApi(android.webkit.Flags.FLAG_FILE_SYSTEM_ACCESS) public static final int MODE_OPEN_FOLDER = 2; /** Allows picking a nonexistent file and saving it. */ public static final int MODE_SAVE = 3; + /** @hide */ + @IntDef(prefix = { "PERMISSION_MODE_" }, value = { + PERMISSION_MODE_READ, + PERMISSION_MODE_READ_WRITE, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface PermissionMode {} + + /** File or directory should be opened for reading only. */ + @FlaggedApi(android.webkit.Flags.FLAG_FILE_SYSTEM_ACCESS) + public static final int PERMISSION_MODE_READ = 0; + /** File or directory should be opened for read and write. */ + @FlaggedApi(android.webkit.Flags.FLAG_FILE_SYSTEM_ACCESS) + public static final int PERMISSION_MODE_READ_WRITE = 1; + /** * Parse the result returned by the file picker activity. This method should be used with * {@link #createIntent}. Refer to {@link #createIntent} for how to use it. @@ -616,6 +634,21 @@ public class WebChromeClient { public abstract String getFilenameHint(); /** + * Returns permission mode {@link #PERMISSION_MODE_READ} or + * {@link #PERMISSION_MODE_READ_WRITE} which indicates the intended mode for opening a file + * or directory. + * + * This can be used to determine whether an Intent such as + * {@link android.content.Intent#ACTION_OPEN_DOCUMENT} should be used rather than + * {@link android.content.Intent#ACTION_GET_CONTENT} to choose files. + */ + @FlaggedApi(Flags.FLAG_FILE_SYSTEM_ACCESS) + @PermissionMode + public int getPermissionMode() { + return PERMISSION_MODE_READ; + } + + /** * Creates an intent that would start a file picker for file selection. * The Intent supports choosing files from simple file sources available * on the device. Some advanced sources (for example, live media capture) diff --git a/core/java/android/webkit/flags.aconfig b/core/java/android/webkit/flags.aconfig index d1013a92476f..b2f1c9af251d 100644 --- a/core/java/android/webkit/flags.aconfig +++ b/core/java/android/webkit/flags.aconfig @@ -26,3 +26,11 @@ flag { description: "New feature reduce user-agent for webview" bug: "371034303" } + +flag { + name: "file_system_access" + is_exported: true + namespace: "webview" + description: "New APIs required by File System Access" + bug: "40101963" +} |