Skip to content

Commit

Permalink
Update Android SDK and Android System SDK to S.
Browse files Browse the repository at this point in the history
Switch to the S SDK and system SDK, and add the WebView code to support
WebView S APIs.

Bug: 1223110
Change-Id: Ice272cdcc313cfd9f2845fa66a59d7c99e974314
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3032285
Reviewed-by: Ted Choc <[email protected]>
Reviewed-by: Andrew Grieve <[email protected]>
Commit-Queue: Richard Coles <[email protected]>
Cr-Commit-Position: refs/heads/master@{#904462}
  • Loading branch information
tornewuff authored and Chromium LUCI CQ committed Jul 22, 2021
1 parent 0870fef commit 1d71054
Show file tree
Hide file tree
Showing 26 changed files with 129 additions and 104 deletions.
22 changes: 11 additions & 11 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,11 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_build-tools_version
# and whatever else without interference from each other.
'android_sdk_build-tools_version': '8LZujEmLjSh0g3JciDA3cslSptxKs9HOa_iUPXkOeYQC',
'android_sdk_build-tools_version': 'tRoD45SCi7UleQqSV7MrMQO1_e5P8ysphkCcj6z_cCQC',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_emulator_version
# and whatever else without interference from each other.
'android_sdk_emulator_version': 'A4EvXZUIuQho0QRDJopMUpgyp6NA3aiDQjGKPUKbowMC',
'android_sdk_emulator_version': 'gMHhUuoQRKfxr-MBn3fNNXZtkAVXtOwMwT7kfx8jkIgC',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_extras_version
# and whatever else without interference from each other.
Expand All @@ -331,15 +331,15 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_platform-tools_version
# and whatever else without interference from each other.
'android_sdk_platform-tools_version': '8tF0AOj7Dwlv4j7_nfkhxWB0jzrvWWYjEIpirt8FIWYC',
'android_sdk_platform-tools_version': 'qi_k82nm6j9nz4dQosOoqXew4_TFAy8rcGOHDLptx1sC',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_platforms_version
# and whatever else without interference from each other.
'android_sdk_platforms_version': 'YMUu9EHNZ__2Xcxl-KsaSf-dI5TMt_P62IseUVsxktMC',
'android_sdk_platforms_version': 'lL3IGexKjYlwjO_1Ga-xwxgwbE_w-lmi2Zi1uOlWUIAC',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_sources_version
# and whatever else without interference from each other.
'android_sdk_sources_version': '4gxhM8E62bvZpQs7Q3d0DinQaW0RLCIefhXrQBFkNy8C',
'android_sdk_sources_version': 'n7svc8KYah-i4s8zwkVa85SI3_H0WFOniP0mpwNdFO0C',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling feed
# and whatever else without interference from each other.
Expand Down Expand Up @@ -788,8 +788,8 @@ deps = {
'src/third_party/android_system_sdk': {
'packages': [
{
'package': 'chromium/third_party/android_system_sdk',
'version': 'no8ss5nRg6uYDM08HboypuIQuix7bS1kVqRGyWmwP-YC',
'package': 'chromium/third_party/android_system_sdk/public',
'version': 'oSfDIvHlCa6W0gS79Q5OOfB9E4eBg3uAvi3BEDN21U0C',
},
],
'condition': 'checkout_android',
Expand Down Expand Up @@ -837,7 +837,7 @@ deps = {
'src/third_party/android_sdk/public': {
'packages': [
{
'package': 'chromium/third_party/android_sdk/public/build-tools/30.0.1',
'package': 'chromium/third_party/android_sdk/public/build-tools/31.0.0',
'version': Var('android_sdk_build-tools_version'),
},
{
Expand All @@ -857,16 +857,16 @@ deps = {
'version': Var('android_sdk_platform-tools_version'),
},
{
'package': 'chromium/third_party/android_sdk/public/platforms/android-30',
'package': 'chromium/third_party/android_sdk/public/platforms/android-31',
'version': Var('android_sdk_platforms_version'),
},
{
'package': 'chromium/third_party/android_sdk/public/sources/android-29',
'package': 'chromium/third_party/android_sdk/public/sources/android-30',
'version': Var('android_sdk_sources_version'),
},
{
'package': 'chromium/third_party/android_sdk/public/cmdline-tools',
'version': 'V__2Ycej-H2-6AcXX5A3gi7sIk74SuN44PBm2uC_N1sC',
'version': 'ZT3JmI6GMG4YVcZ1OtECRVMOLLJAWAdPbi-OclubJLMC',
},
],
'condition': 'checkout_android_native_support',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.webview"
platformBuildVersionCode="30"
platformBuildVersionName="11"
platformBuildVersionCode="31"
platformBuildVersionName="12"
android:isolatedSplits="true">
<queries> # DIFF-ANCHOR: 0c3a615d
<intent> # DIFF-ANCHOR: 28c960ba
Expand All @@ -15,7 +15,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30"/>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31"/>
<application
android:name="org.chromium.android_webview.nonembedded.WebViewApkApplication"
android:extractNativeLibs="True"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.webview"
platformBuildVersionCode="30"
platformBuildVersionName="11"
platformBuildVersionCode="31"
platformBuildVersionName="12"
android:isolatedSplits="true">
<queries> # DIFF-ANCHOR: 0c3a615d
<intent> # DIFF-ANCHOR: 28c960ba
Expand All @@ -15,7 +15,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="30"/>
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="31"/>
<application
android:name="org.chromium.android_webview.nonembedded.WebViewApkApplication"
android:extractNativeLibs="False"
Expand Down
1 change: 1 addition & 0 deletions android_webview/glue/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ android_library("glue_java") {
"java/src/com/android/webview/chromium/WebViewChromiumFactoryProviderForP.java",
"java/src/com/android/webview/chromium/WebViewChromiumFactoryProviderForQ.java",
"java/src/com/android/webview/chromium/WebViewChromiumFactoryProviderForR.java",
"java/src/com/android/webview/chromium/WebViewChromiumFactoryProviderForS.java",
"java/src/com/android/webview/chromium/WebViewContentsClientAdapter.java",
"java/src/com/android/webview/chromium/WebViewDatabaseAdapter.java",
"java/src/com/android/webview/chromium/WebViewDelegateFactory.java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ private GlueApiHelperForR() {}
public static PacProcessor getPacProcessor() {
return PacProcessorImpl.getInstance();
}

public static PacProcessor createPacProcessor() {
return PacProcessorImpl.createInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,64 @@

package com.android.webview.chromium;

import android.annotation.TargetApi;
import android.net.Network;
import android.webkit.PacProcessor;

import org.chromium.android_webview.AwPacProcessor;
import org.chromium.base.JNIUtils;
import org.chromium.base.library_loader.LibraryLoader;

@TargetApi(28)
final class PacProcessorImpl implements PacProcessor {
private PacProcessorImpl() {
static {
JNIUtils.setClassLoader(WebViewChromiumFactoryProvider.class.getClassLoader());
LibraryLoader.getInstance().ensureInitialized();

// This will set up Chromium environment to run proxy resolver.
AwPacProcessor.initializeEnvironment();
}

private static final PacProcessorImpl sInstance = new PacProcessorImpl();
private static class LazyHolder {
static final PacProcessorImpl sInstance = new PacProcessorImpl();
}

AwPacProcessor mProcessor;

public static PacProcessorImpl getInstance() {
return sInstance;
private PacProcessorImpl() {
mProcessor = new AwPacProcessor();
}

public static PacProcessor getInstance() {
return LazyHolder.sInstance;
}

public static PacProcessor createInstance() {
return new PacProcessorImpl();
}

@Override
public void release() {
mProcessor.destroy();
}

@Override
public boolean setProxyScript(String script) {
return AwPacProcessor.getInstance().setProxyScript(script);
return mProcessor.setProxyScript(script);
}

@Override
public String findProxyForUrl(String url) {
return AwPacProcessor.getInstance().makeProxyRequest(url);
return mProcessor.makeProxyRequest(url);
}

@Override
public void setNetwork(Network network) {
mProcessor.setNetwork(network);
}

@Override
public Network getNetwork() {
return mProcessor.getNetwork();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private void initialize(WebViewDelegate webViewDelegate) {
multiProcess, packageId);

// Enable modern SameSite cookie behavior if the app targets at least S.
if (BuildInfo.targetsAtLeastS()) {
if (ctx.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.S) {
CommandLine cl = CommandLine.getInstance();
cl.appendSwitch(AwSwitches.WEBVIEW_ENABLE_MODERN_COOKIE_SAME_SITE);
}
Expand Down Expand Up @@ -791,4 +791,9 @@ public static void setWebLayerRunningInSameProcess() {
public PacProcessor getPacProcessor() {
return GlueApiHelperForR.getPacProcessor();
}

@Override
public PacProcessor createPacProcessor() {
return GlueApiHelperForR.createPacProcessor();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package com.android.webview.chromium;

class WebViewChromiumFactoryProviderForS extends WebViewChromiumFactoryProvider {
public static WebViewChromiumFactoryProvider create(android.webkit.WebViewDelegate delegate) {
return new WebViewChromiumFactoryProviderForS(delegate);
}

protected WebViewChromiumFactoryProviderForS(android.webkit.WebViewDelegate delegate) {
super(delegate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import androidx.annotation.RequiresApi;

import org.chromium.android_webview.common.services.ServiceNames;
import org.chromium.base.BuildInfo;
import org.chromium.base.ContextUtils;

import java.util.HashMap;
Expand Down Expand Up @@ -67,7 +66,7 @@ private static void startDeveloperUiService(String webViewPackageName) {
try {
context.startForegroundService(intent);
} catch (IllegalStateException e) {
assert BuildInfo.isAtLeastS()
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
: "Unable to start DeveloperUiService, this is only expected on Android S";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.chromium.android_webview.common.FlagOverrideHelper;
import org.chromium.android_webview.common.ProductionSupportedFlagList;
import org.chromium.android_webview.common.services.IDeveloperUiService;
import org.chromium.base.BuildInfo;
import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
import org.chromium.base.IntentUtils;
Expand Down Expand Up @@ -92,7 +91,7 @@ public void setFlagOverrides(Map overriddenFlags) {
try {
enableDeveloperMode();
} catch (IllegalStateException e) {
assert BuildInfo.isAtLeastS()
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
: "Unable enable developer mode, this is only expected on Android S";
String msg = "Unable to create foreground service (client is likely in "
+ "background). Continuing as a background service.";
Expand Down
4 changes: 0 additions & 4 deletions base/android/java/src/org/chromium/base/BuildInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ public class BuildInfo {
private static PackageInfo sBrowserPackageInfo;
private static boolean sInitialized;

// TODO(crbug.com/1192402): Replace this with Build.VERSION_CODES.S in the code once chromium
// import Android S SDK.
public static final int ANDROID_S_API_SDK_INT = 31;

/** Not a member variable to avoid creating the instance early (it is set early in start up). */
private static String sFirebaseAppId = "";

Expand Down
43 changes: 6 additions & 37 deletions base/android/java/src/org/chromium/base/compat/ApiHelperForS.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,23 @@
import android.content.ClipData;
import android.content.ClipDescription;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Process;
import android.view.textclassifier.TextLinks;

import androidx.annotation.NonNull;

import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.BuildInfo;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.annotations.VerifiesOnS;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
* Utility class to use new APIs that were added in S (API level 31). These need to exist in a
* separate class so that Android framework can successfully verify classes without
* encountering the new APIs.
*/
@VerifiesOnS
@TargetApi(BuildInfo.ANDROID_S_API_SDK_INT)
@TargetApi(Build.VERSION_CODES.S)
public final class ApiHelperForS {
private static final String TAG = "ApiHelperForS";

Expand All @@ -39,42 +35,22 @@ private ApiHelperForS() {}
* See {@link ClipDescription#isStyleText()}.
*/
public static boolean isStyleText(ClipDescription clipDescription) {
try {
Method isStyledTextMethod = ClipDescription.class.getDeclaredMethod("isStyledText");
return (boolean) isStyledTextMethod.invoke(clipDescription);
} catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
Log.e(TAG, "Failed to invoke ClipDescription#isStyledText() ", e);
return false;
}
return clipDescription.isStyledText();
}

/**
* See {@link ClipDescription#getConfidenceScore()}.
*/
public static float getConfidenceScore(
ClipDescription clipDescription, @NonNull String entityType) {
try {
Method getConfidenceScoreMethod =
ClipDescription.class.getDeclaredMethod("getConfidenceScore", String.class);
return (float) getConfidenceScoreMethod.invoke(clipDescription, entityType);
} catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException
| IllegalStateException e) {
Log.e(TAG, "Failed to invoke ClipDescription#getConfidenceScore() ", e);
return 0;
}
return clipDescription.getConfidenceScore(entityType);
}

/**
* See {@link ClipData.Item#getTextLinks()}.
*/
public static TextLinks getTextLinks(ClipData.Item item) {
try {
Method getTextLinksMethod = ClipData.Item.class.getDeclaredMethod("getTextLinks");
return (TextLinks) getTextLinksMethod.invoke(item);
} catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
Log.e(TAG, "Failed to invoke ClipData.Item#getTextLinks() ", e);
return null;
}
return item.getTextLinks();
}

public static boolean hasBluetoothConnectPermission() {
Expand All @@ -90,13 +66,6 @@ public static boolean hasBluetoothConnectPermission() {
*/
public static void setAutoEnterEnabled(
PictureInPictureParams.Builder builder, boolean enabled) {
try {
Method setAutoEnterEnabledMethod =
PictureInPictureParams.Builder.class.getDeclaredMethod(
"setAutoEnterEnabled", boolean.class);
setAutoEnterEnabledMethod.invoke(builder, enabled);
} catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
Log.e(TAG, "Failed to invoke PictureInPictureParams.Builder#setAutoEnterEnabled() ", e);
}
builder.setAutoEnterEnabled(enabled);
}
}
4 changes: 2 additions & 2 deletions build/android/gyp/merge_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
'guava-28.1-jre.jar'),
os.path.join('external', 'kotlin-plugin-ij', 'Kotlin', 'kotlinc', 'lib',
'kotlin-stdlib.jar'),
os.path.join('external', 'com', 'google', 'code', 'gson', 'gson', '2.8.5',
'gson-2.8.5.jar'),
os.path.join('external', 'com', 'google', 'code', 'gson', 'gson', '2.8.6',
'gson-2.8.6.jar'),
]


Expand Down
2 changes: 1 addition & 1 deletion build/android/pylib/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@

SCREENSHOTS_DIR = os.path.join(DIR_SOURCE_ROOT, 'out_screenshots')

ANDROID_SDK_BUILD_TOOLS_VERSION = '30.0.1'
ANDROID_SDK_BUILD_TOOLS_VERSION = '31.0.0'
ANDROID_SDK_ROOT = os.path.join(DIR_SOURCE_ROOT, 'third_party', 'android_sdk',
'public')
ANDROID_SDK_TOOLS = os.path.join(ANDROID_SDK_ROOT,
Expand Down
Loading

0 comments on commit 1d71054

Please sign in to comment.