Commit e0650426 authored by Nate Fischer's avatar Nate Fischer Committed by Commit Bot

AW: add a GN arg for shell package name

No change to production logic, only test shell.

This adds 'system_webview_shell_package_name' to configure WebView
shell's package name. This is handy for Android emulators, because the
default package name will cause signature mismatches.

I kept the original documentation (for removing the shell from the
system image) because it may be relevant for some use cases. But I hope
the GN arg is a simpler solution for most developers.

Fixed: 1061211
Test: $OUT/bin/system_webview_shell_apk package-info (verify name)
Test: $OUT/bin/system_webview_shell_apk install (succeeds on emulator)
Test: Upload to gerrit > open file > click "gitiles" > verify markdown
Change-Id: I24a35524bc5042da33b8203637ec67a0f610f363
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2101859Reviewed-by: default avatarHazem Ashmawy <hazems@chromium.org>
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750249}
parent 91211712
...@@ -20,6 +20,38 @@ at the top. This can be helpful for checking which WebView version is installed ...@@ -20,6 +20,38 @@ at the top. This can be helpful for checking which WebView version is installed
& selected on the device. & selected on the device.
*** ***
## Setting up the build
The bare minimum GN args is just `target_os = "android"`. It's simplest to just
reuse the same out/ folder you use for WebView or Chrome for Android.
If you're building for an emulator, be aware WebView shell is preinstalled with
a different signing key. If you just need a WebView app, the preinstalled
WebView shell may be sufficient (and you don't need to build your own).
If you want a more up-to-date WebView shell or you want to use the convenience
scripts in this guide (ex. `.../system_webview_shell_apk launch <url>`), then
you can workaround the signature mismatch by changing your local WebView shell's
package name. Simply add the following to your GN args (run `gn args
out/Default`):
```gn
# Change the package name to anything that won't conflict. If you're not sure
# what to use, here's a safe choice:
system_webview_shell_package_name = "org.chromium.my_webview_shell"
```
This will let your local build install alongside the preinstalled WebView shell.
If you'd like, you can disable the preinstalled shell to avoid confusing the two
apps. In a terminal:
```sh
$ adb root
# Make sure to specify the default package name ("org.chromium.webview_shell"),
# not the one you used in the GN args above!
$ adb shell pm disable org.chromium.webview_shell
```
## Building the shell ## Building the shell
```sh ```sh
...@@ -33,18 +65,31 @@ $ autoninja -C out/Default system_webview_shell_apk ...@@ -33,18 +65,31 @@ $ autoninja -C out/Default system_webview_shell_apk
$ out/Default/bin/system_webview_shell_apk install $ out/Default/bin/system_webview_shell_apk install
``` ```
The WebView shell may be preinstalled on a device or emulator. If the signature ## Running the shell
of the locally built shell does not match the preinstalled shell then the
install will fail &ndash; usually with this error:
```sh
# Launch a URL from the commandline, or open the app from the app launcher
$ out/Default/bin/system_webview_shell_apk launch "https://www.google.com/"
# For more commands:
$ out/Default/bin/system_webview_shell_apk --help
``` ```
...
path/to/SystemWebViewShell.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE:
Package org.chromium.webview_shell signatures do not match previously installed
version; ignoring!]
```
If this occurs then delete the preinstalled WebView shell as so: *** note
**Note:** `system_webview_shell_apk` does not support modifying CLI flags. See
https://crbug.com/959425. Instead, you should modify WebView's flags by
following [commandline-flags.md](./commandline-flags.md).
***
## Troubleshooting
### INSTALL\_FAILED\_UPDATE\_INCOMPATIBLE: Package ... signatures do not match previously installed version
The easiest way to workaround this is to [change the shell's package name in a
local build](#building-for-the-emulator).
If you **need** to use the same package name (ex. you're installing an official
build of WebView shell), then you can modify the system image.
*** note *** note
**Note:** If using the emulator ensure it is being started with the **Note:** If using the emulator ensure it is being started with the
...@@ -66,19 +111,3 @@ $ adb shell rm /system/app/Browser2/Browser2.apk ...@@ -66,19 +111,3 @@ $ adb shell rm /system/app/Browser2/Browser2.apk
$ adb shell stop $ adb shell stop
$ adb shell start $ adb shell start
``` ```
## Running the shell
```sh
# Launch a URL from the commandline, or open the app from the app launcher
$ out/Default/bin/system_webview_shell_apk launch "https://www.google.com/"
# For more commands:
$ out/Default/bin/system_webview_shell_apk --help
```
*** note
**Note:** `system_webview_shell_apk` does not support modifying CLI flags. See
https://crbug.com/959425. Instead, you should modify WebView's flags by
following [commandline-flags.md](./commandline-flags.md).
***
...@@ -16,6 +16,17 @@ group("system_webview_shell") { ...@@ -16,6 +16,17 @@ group("system_webview_shell") {
] ]
} }
declare_args() {
# Android package name to use for system_webview_shell_apk (the WebView shell
# browser). You can change this package name to work around signing key
# conflicts (INSTALL_FAILED_UPDATE_INCOMPATIBLE) on devices/emulators which
# have the shell browser preinstalled under the default package name.
system_webview_shell_package_name = "org.chromium.webview_shell"
}
system_webview_shell_android_manifest =
"$root_gen_dir/android_webview/system_webview_shell_apk/AndroidManifest.xml"
android_apk("system_webview_shell_apk") { android_apk("system_webview_shell_apk") {
apk_name = "SystemWebViewShell" apk_name = "SystemWebViewShell"
sources = [ sources = [
...@@ -35,7 +46,8 @@ android_apk("system_webview_shell_apk") { ...@@ -35,7 +46,8 @@ android_apk("system_webview_shell_apk") {
"apk/src/org/chromium/webview_shell/WebViewTracingActivity.java", "apk/src/org/chromium/webview_shell/WebViewTracingActivity.java",
"apk/src/org/chromium/webview_shell/WebViewWithClipPath.java", "apk/src/org/chromium/webview_shell/WebViewWithClipPath.java",
] ]
android_manifest = "apk/AndroidManifest.xml" android_manifest = system_webview_shell_android_manifest
android_manifest_dep = ":system_webview_shell_manifest"
target_sdk_version = 29 target_sdk_version = 29
deps = [ deps = [
":system_webview_shell_apk_resources", ":system_webview_shell_apk_resources",
...@@ -45,6 +57,12 @@ android_apk("system_webview_shell_apk") { ...@@ -45,6 +57,12 @@ android_apk("system_webview_shell_apk") {
] ]
} }
jinja_template("system_webview_shell_manifest") {
input = "apk/AndroidManifest.xml"
output = system_webview_shell_android_manifest
variables = [ "manifest_package=$system_webview_shell_package_name" ]
}
android_resources("system_webview_shell_apk_resources") { android_resources("system_webview_shell_apk_resources") {
resource_dirs = [ "apk/res" ] resource_dirs = [ "apk/res" ]
custom_package = "org.chromium.webview_shell" custom_package = "org.chromium.webview_shell"
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<manifest <manifest
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
package="org.chromium.webview_shell" package="{{manifest_package|default('org.chromium.webview_shell')}}"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0" > android:versionName="1.0" >
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment