Android: Add a TraceReferences check that Chrome does not use WebView
This should give use assurance that our statically linked
dependencies do try and use WebView.
Adds a disallowed_library_classes GN variable for android_apk and
android_app_bundle. tracereferences.py enforces it by removing the
listed classes from the library jars (using singlejar), so that
TraceReferences reports every reference to them as a missing definition.
On failure, it prints the diagnostics along with -whyareyoukeeping rules
that show why the referencing code is kept.
Chrome's APKs and bundles set it to android.webkit.WebView.
Check runtime: 3.11s -> 3.25s for chrome_apk.
Example error: TraceReferences failed: DEX contains references to
classes listed in disallowed_library_classes: android.webkit.WebView
Missing method void
android.webkit.WebView.setWebContentsDebuggingEnabled(boolean)
(referenced from: void
com.google.android.gms.common.util.WebViewUtils.setWebContentsDebuggingEnabled(boolean))
To see why the referencing code is kept, add these rules to a ProGuard
config (e.g. //base/android/proguard/chromium_apk.flags). If names are
obfuscated, also set enable_proguard_obfuscation=false.
-whyareyoukeeping class com.google.android.gms.common.util.WebViewUtils
{
void setWebContentsDebuggingEnabled(boolean);
}
Agent-Generated: true
Change-Id: I44842335c7c338862980b99470738847abc6dbe8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8544215
Reviewed-by: Sam Maier <smaier@google.com>
Cr-Commit-Position: refs/heads/main@{#1720884}
NOKEYCHECK=True
GitOrigin-RevId: 6bcbefb7cfb334bf29f1b62ab20aae6b8e58b027
2 files changed