Skip to content

Commit

Permalink
Reland "Move getPacProcessor() to GlueApiHelperForR"
Browse files Browse the repository at this point in the history
This is a reland of 02b24a7

Forgot to add the line in proguard.py to make VerifiesOnR work
correctly.

Original change's description:
> Move getPacProcessor() to GlueApiHelperForR
>
> Follow up after feedback on http://crrev.com/c/2328302.
>
> Bug: 1111909
> Change-Id: If3107a6bc513d2aad898e8bc87c8436392ee057d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2335385
> Commit-Queue: Clark DuVall <[email protected]>
> Reviewed-by: Nate Fischer <[email protected]>
> Reviewed-by: Richard Coles <[email protected]>
> Cr-Commit-Position: refs/heads/master@{#794655}

[email protected]

Bug: 1111909
Change-Id: I64eafe0fb9093907a5510142d73455aee3af2c67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2337385
Commit-Queue: Clark DuVall <[email protected]>
Reviewed-by: Sam Maier <[email protected]>
Reviewed-by: Nate Fischer <[email protected]>
Cr-Commit-Position: refs/heads/master@{#794814}
  • Loading branch information
clarkduvall authored and Commit Bot committed Aug 5, 2020
1 parent a15d6d3 commit 528e18d
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 8 deletions.
1 change: 1 addition & 0 deletions android_webview/glue/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ android_library("glue_java") {
"java/src/com/android/webview/chromium/GlueApiHelperForOMR1.java",
"java/src/com/android/webview/chromium/GlueApiHelperForP.java",
"java/src/com/android/webview/chromium/GlueApiHelperForQ.java",
"java/src/com/android/webview/chromium/GlueApiHelperForR.java",
"java/src/com/android/webview/chromium/GraphicsUtils.java",
"java/src/com/android/webview/chromium/MonochromeLibraryPreloader.java",
"java/src/com/android/webview/chromium/PacProcessorImpl.java",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2020 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;

import android.annotation.TargetApi;
import android.os.Build;
import android.webkit.PacProcessor;

import org.chromium.base.annotations.VerifiesOnR;

/**
* Utility class to use new APIs that were added in R (API level 30). These need to exist in a
* separate class so that Android framework can successfully verify glue layer classes without
* encountering the new APIs. Note that GlueApiHelper is only for APIs that cannot go to ApiHelper
* in base/, for reasons such as using system APIs or instantiating an adapter class that is
* specific to glue layer.
*/
@VerifiesOnR
@TargetApi(Build.VERSION_CODES.R)
public final class GlueApiHelperForR {
private GlueApiHelperForR() {}

public static PacProcessor getPacProcessor() {
return PacProcessorImpl.getInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.view.ViewGroup;
import android.webkit.CookieManager;
import android.webkit.GeolocationPermissions;
import android.webkit.PacProcessor;
import android.webkit.ServiceWorkerController;
import android.webkit.TokenBindingService;
import android.webkit.TracingController;
Expand Down Expand Up @@ -715,4 +716,9 @@ public static void setWebLayerRunningInSameProcess() {
getSingleton().getBrowserContextOnUiThread().setWebLayerRunningInSameProcess();
});
}

@Override
public PacProcessor getPacProcessor() {
return GlueApiHelperForR.getPacProcessor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

package com.android.webview.chromium;

import android.webkit.PacProcessor;

class WebViewChromiumFactoryProviderForR extends WebViewChromiumFactoryProvider {
public static WebViewChromiumFactoryProvider create(android.webkit.WebViewDelegate delegate) {
return new WebViewChromiumFactoryProviderForR(delegate);
Expand All @@ -14,9 +12,4 @@ public static WebViewChromiumFactoryProvider create(android.webkit.WebViewDelega
protected WebViewChromiumFactoryProviderForR(android.webkit.WebViewDelegate delegate) {
super(delegate);
}

@Override
public PacProcessor getPacProcessor() {
return PacProcessorImpl.getInstance();
}
}
1 change: 1 addition & 0 deletions base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3556,6 +3556,7 @@ if (is_android) {
"android/java/src/org/chromium/base/annotations/VerifiesOnOMR1.java",
"android/java/src/org/chromium/base/annotations/VerifiesOnP.java",
"android/java/src/org/chromium/base/annotations/VerifiesOnQ.java",
"android/java/src/org/chromium/base/annotations/VerifiesOnR.java",
"android/java/src/org/chromium/base/compat/ApiHelperForM.java",
"android/java/src/org/chromium/base/compat/ApiHelperForN.java",
"android/java/src/org/chromium/base/compat/ApiHelperForO.java",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2020 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 org.chromium.base.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* The annotated method or class verifies on R, but not below.
*
* The annotated method (or methods on the annotated class) are guaranteed to not be inlined by R8
* on builds targeted below R. This prevents class verification errors (which results in a very slow
* retry-verification-at-runtime) from spreading into other classes on these lower versions.
*/
@Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.CLASS)
public @interface VerifiesOnR {}
1 change: 1 addition & 0 deletions build/android/gyp/proguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
(27, 'OMR1'),
(28, 'P'),
(29, 'Q'),
(30, 'R'),
]
_CHECKDISCARD_RE = re.compile(r'^\s*-checkdiscard[\s\S]*?}', re.MULTILINE)
_DIRECTIVE_RE = re.compile(r'^\s*-', re.MULTILINE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,3 +784,13 @@
-keepclassmembers,allowobfuscation class ** {
@org.chromium.base.annotations.VerifiesOnQ <methods>;
}
-keep @interface org.chromium.base.annotations.VerifiesOnR
-if @org.chromium.base.annotations.VerifiesOnR class * {
*** *(...);
}
-keep,allowobfuscation class <1> {
*** <2>(...);
}
-keepclassmembers,allowobfuscation class ** {
@org.chromium.base.annotations.VerifiesOnR <methods>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,9 @@ private static void deleteDirectoryContents(File directory) {
}

private static void notifyWebViewRunningInProcess(ClassLoader webViewClassLoader) {
try {
// TODO(crbug.com/1112001): Investigate why loading classes causes strict mode
// violations in some situations.
try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) {
Class<?> webViewChromiumFactoryProviderClass =
Class.forName("com.android.webview.chromium.WebViewChromiumFactoryProvider",
true, webViewClassLoader);
Expand Down

0 comments on commit 528e18d

Please sign in to comment.