diff options
| author | 2020-08-04 00:38:57 +0100 | |
|---|---|---|
| committer | 2020-08-06 14:44:32 +0100 | |
| commit | 1d0dede72da719832247d06969e5abe5428fdab2 (patch) | |
| tree | a719053bb8ebd53e84a6ea28dc172bb169a6aad6 | |
| parent | cb631bcf154cd2811c20234c1d3a48afba123866 (diff) | |
Add new methods to PacProcessor to
- allow multiple PacProcessors
- allow network-aware DNS lookups in PAC scripts
Bug: 162785263
Test: n/a
Change-Id: I39432d8f6358e386527b00b58d92e74ef32763d1
| -rwxr-xr-x | api/system-current.txt | 4 | ||||
| -rw-r--r-- | core/java/android/webkit/PacProcessor.java | 35 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewFactoryProvider.java | 17 | ||||
| -rw-r--r-- | non-updatable-api/system-current.txt | 4 |
4 files changed, 58 insertions, 2 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index fb0d924673b8..98bf612cd8de 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -12725,6 +12725,9 @@ package android.webkit { public interface PacProcessor { method @Nullable public String findProxyForUrl(@NonNull String); method @NonNull public static android.webkit.PacProcessor getInstance(); + method @NonNull public static android.webkit.PacProcessor getInstanceForNetwork(long); + method public default long getNetworkHandle(); + method public default void releasePacProcessor(); method public boolean setProxyScript(@NonNull String); } @@ -12864,6 +12867,7 @@ package android.webkit { method public android.webkit.CookieManager getCookieManager(); method public android.webkit.GeolocationPermissions getGeolocationPermissions(); method @NonNull public default android.webkit.PacProcessor getPacProcessor(); + method @NonNull public default android.webkit.PacProcessor getPacProcessorForNetwork(long); method public android.webkit.ServiceWorkerController getServiceWorkerController(); method public android.webkit.WebViewFactoryProvider.Statics getStatics(); method @Deprecated public android.webkit.TokenBindingService getTokenBindingService(); diff --git a/core/java/android/webkit/PacProcessor.java b/core/java/android/webkit/PacProcessor.java index 5ef450fa65dd..7e7b987f72f3 100644 --- a/core/java/android/webkit/PacProcessor.java +++ b/core/java/android/webkit/PacProcessor.java @@ -19,7 +19,7 @@ package android.webkit; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; - +import android.net.Network; /** * Class to evaluate PAC scripts. @@ -40,6 +40,20 @@ public interface PacProcessor { } /** + * Returns PacProcessor instance associated with the {@link Network}. + * The host resolution is done on this {@link Network}. + * + * @param networkHandle a handle representing {@link Network} handle. + * @return PacProcessor instance for the specified network. + * @see Network#getNetworkHandle + * @see Network#fromNetworkHandle + */ + @NonNull + static PacProcessor getInstanceForNetwork(long networkHandle) { + return WebViewFactory.getProvider().getPacProcessorForNetwork(networkHandle); + } + + /** * Set PAC script to use. * * @param script PAC script. @@ -55,4 +69,23 @@ public interface PacProcessor { */ @Nullable String findProxyForUrl(@NonNull String url); + + /** + * Stops support for this {@link PacProcessor} and release its resources. + * No methods of this class must be called after calling this method. + */ + default void releasePacProcessor() { + throw new UnsupportedOperationException("Not implemented"); + } + + /** + * Returns a network handle associated with this {@link PacProcessor}. + * + * @return a network handle or 0 if a network is unspecified. + * @see Network#getNetworkHandle + * @see Network#fromNetworkHandle + */ + default long getNetworkHandle() { + throw new UnsupportedOperationException("Not implemented"); + } } diff --git a/core/java/android/webkit/WebViewFactoryProvider.java b/core/java/android/webkit/WebViewFactoryProvider.java index f7c3ec09dd67..f1863e319689 100644 --- a/core/java/android/webkit/WebViewFactoryProvider.java +++ b/core/java/android/webkit/WebViewFactoryProvider.java @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.SystemApi; import android.content.Context; import android.content.Intent; +import android.net.Network; import android.net.Uri; import java.util.List; @@ -175,7 +176,7 @@ public interface WebViewFactoryProvider { WebViewDatabase getWebViewDatabase(Context context); /** - * Gets the singleton PacProcessor instance. + * Gets the default PacProcessor instance. * @return the PacProcessor instance */ @NonNull @@ -184,6 +185,20 @@ public interface WebViewFactoryProvider { } /** + * Returns PacProcessor instance associated with the {@link Network}. + * The host resolution is done on this {@link Network}. + * + * @param networkHandle a network handle representing the {@link Network}. + * @return the {@link PacProcessor} instance associated with {@link Network}. + * @see Network#getNetworkHandle + * @see Network#fromNetworkHandle + */ + @NonNull + default PacProcessor getPacProcessorForNetwork(long networkHandle) { + throw new UnsupportedOperationException("Not implemented"); + } + + /** * Gets the classloader used to load internal WebView implementation classes. This interface * should only be used by the WebView Support Library. */ diff --git a/non-updatable-api/system-current.txt b/non-updatable-api/system-current.txt index 385ae278975c..52823548c007 100644 --- a/non-updatable-api/system-current.txt +++ b/non-updatable-api/system-current.txt @@ -11568,6 +11568,9 @@ package android.webkit { public interface PacProcessor { method @Nullable public String findProxyForUrl(@NonNull String); method @NonNull public static android.webkit.PacProcessor getInstance(); + method @NonNull public static android.webkit.PacProcessor getInstanceForNetwork(long); + method public default long getNetworkHandle(); + method public default void releasePacProcessor(); method public boolean setProxyScript(@NonNull String); } @@ -11707,6 +11710,7 @@ package android.webkit { method public android.webkit.CookieManager getCookieManager(); method public android.webkit.GeolocationPermissions getGeolocationPermissions(); method @NonNull public default android.webkit.PacProcessor getPacProcessor(); + method @NonNull public default android.webkit.PacProcessor getPacProcessorForNetwork(long); method public android.webkit.ServiceWorkerController getServiceWorkerController(); method public android.webkit.WebViewFactoryProvider.Statics getStatics(); method @Deprecated public android.webkit.TokenBindingService getTokenBindingService(); |