Commit 04d9ccbc authored by Hazem Ashmawy's avatar Hazem Ashmawy Committed by Commit Bot

[AW] DevUI: Always merge dev ui launcher manifest to the final manifest

Always merge dev ui launcher manifest for standalone and trichrome
webview into the final manifest unconditionally similar to monochrome
launcher manifest.

Use jinja_template to:
- Generate the manifests for all variants from one Manifest file.
- Pass a variable to determine the default enabled state for the
  launcher activity-alias.

Standalone, Trichrome and Monochrome WebView, all use one activity-alias
to show the launcher icon.

Change the name and the behaviour of the GN flag to always show the
launcher icon. If the flag is set to true then Monochrome will always
show the icon unconditionally.

Fixed: 1047824
Test: Enable/Disable the flag for stable/prestable WebView variants
Test: check no changes permissions in standalone and trichrome manifest
Change-Id: Ida10e39e294715e69ad19f1253cf302113322cc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2098804Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Reviewed-by: default avatarNate Fischer <ntfschr@chromium.org>
Commit-Queue: Hazem Ashmawy <hazems@chromium.org>
Auto-Submit: Hazem Ashmawy <hazems@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751735}
parent 416fa0f7
...@@ -114,16 +114,34 @@ android_resources("devui_resources") { ...@@ -114,16 +114,34 @@ android_resources("devui_resources") {
custom_package = "org.chromium.android_webview.devui" custom_package = "org.chromium.android_webview.devui"
} }
android_resources("devui_launcher_icon_resources") { template("webview_devui_launcher") {
forward_variables_from(invoker, "*")
_manifest_file = "$root_gen_dir/android_webview/DeveloperUiLauncherManifest__${target_name}.xml"
jinja_template("${target_name}__manifest") {
input = "java/DeveloperUiLauncherManifest.xml"
output = _manifest_file
variables = [ "icon_enabled=$default_enabled_state" ]
}
# Define an android resources target with an AndroidManifest and no actual resources to merge
# the activity alias defined in DeveloperUiLauncherManifest.xml to the final APK mainfest of the
# target that depends on it.
android_resources(target_name) {
resource_dirs = [] resource_dirs = []
custom_package = "org.chromium.android_webview.devui.icon" custom_package = "org.chromium.android_webview.devui.icon"
android_manifest = "java/DeveloperUiLauncherManifest.xml" android_manifest = _manifest_file
android_manifest_dep = ":${target_name}__manifest"
}
} }
android_resources("monochrome_devui_launcher_icon_resources") { webview_devui_launcher("system_webview_devui_launcher_icon_resources") {
resource_dirs = [] default_enabled_state = standalone_or_trichrome_icon_default_enabled_state
android_manifest = "java/MonochromeDeveloperUiLauncherManifest.xml" }
custom_package = "org.chromium.android_webview.devui.icon"
webview_devui_launcher("monochrome_devui_launcher_icon_resources") {
default_enabled_state = monochrome_launcher_icon_default_enabled_state
} }
jinja_template("system_webview_manifest") { jinja_template("system_webview_manifest") {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.chromium.android_webview.devui"> package="org.chromium.android_webview.devui">
<!-- required so Manifest merger doesn't add unused permissions see https://crbug.com/1046380 -->
<uses-sdk android:minSdkVersion="21" /> <uses-sdk android:minSdkVersion="21" />
<!--suppress HardcodedText --> <!--suppress HardcodedText -->
...@@ -15,7 +16,8 @@ ...@@ -15,7 +16,8 @@
<activity-alias android:name="org.chromium.android_webview.devui.LauncherActivity" <activity-alias android:name="org.chromium.android_webview.devui.LauncherActivity"
android:targetActivity="org.chromium.android_webview.devui.MainActivity" android:targetActivity="org.chromium.android_webview.devui.MainActivity"
android:label="WebView DevTools" android:label="WebView DevTools"
android:exported="true"> android:exported="true"
android:enabled="{{ icon_enabled }}">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
......
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.chromium.android_webview.devui">
<uses-sdk android:minSdkVersion="24" />
<!-- This should only be merged to Monochrome manifest -->
<!--suppress HardcodedText -->
<application>
<activity-alias android:name="org.chromium.android_webview.devui.MonochromeLauncherActivity"
android:targetActivity="org.chromium.android_webview.devui.MainActivity"
android:label="WebView DevTools"
android:exported="true"
android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
</application>
</manifest>
...@@ -99,9 +99,8 @@ public class WebViewApkApplication extends Application { ...@@ -99,9 +99,8 @@ public class WebViewApkApplication extends Application {
public static void postDeveloperUiLauncherIconTask() { public static void postDeveloperUiLauncherIconTask() {
PostTask.postTask(TaskTraits.BEST_EFFORT, () -> { PostTask.postTask(TaskTraits.BEST_EFFORT, () -> {
Context context = ContextUtils.getApplicationContext(); Context context = ContextUtils.getApplicationContext();
try {
ComponentName devToolsLauncherActivity = new ComponentName( ComponentName devToolsLauncherActivity = new ComponentName(
context, "org.chromium.android_webview.devui.MonochromeLauncherActivity"); context, "org.chromium.android_webview.devui.LauncherActivity");
if (WebViewPackageHelper.isCurrentSystemWebViewImplementation(context)) { if (WebViewPackageHelper.isCurrentSystemWebViewImplementation(context)) {
// Enable the component to show the launcher icon. // Enable the component to show the launcher icon.
context.getPackageManager().setComponentEnabledSetting(devToolsLauncherActivity, context.getPackageManager().setComponentEnabledSetting(devToolsLauncherActivity,
...@@ -113,10 +112,6 @@ public class WebViewApkApplication extends Application { ...@@ -113,10 +112,6 @@ public class WebViewApkApplication extends Application {
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
PackageManager.DONT_KILL_APP); PackageManager.DONT_KILL_APP);
} }
} catch (IllegalArgumentException e) {
// If MonochromeLauncherActivity doesn't exist, Dynamically showing/hiding DevTools
// launcher icon is not enabled in this package; e.g when it is a stable channel.
}
}); });
} }
......
...@@ -44,6 +44,7 @@ template("system_webview_apk_or_module_tmpl") { ...@@ -44,6 +44,7 @@ template("system_webview_apk_or_module_tmpl") {
deps += [ deps += [
"//android_webview:locale_pak_assets", "//android_webview:locale_pak_assets",
"//android_webview:pak_file_assets", "//android_webview:pak_file_assets",
"//android_webview/nonembedded:system_webview_devui_launcher_icon_resources",
] ]
if (_exclude_weblayer_java) { if (_exclude_weblayer_java) {
...@@ -68,10 +69,6 @@ template("system_webview_apk_or_module_tmpl") { ...@@ -68,10 +69,6 @@ template("system_webview_apk_or_module_tmpl") {
alternative_android_sdk_dep = webview_framework_dep alternative_android_sdk_dep = webview_framework_dep
} }
if (webview_devui_show_icon) {
deps += [ "//android_webview/nonembedded:devui_launcher_icon_resources" ]
}
_use_trichrome_library = _use_trichrome_library =
defined(use_trichrome_library) && use_trichrome_library defined(use_trichrome_library) && use_trichrome_library
assert( assert(
......
...@@ -6,13 +6,19 @@ import("//build/config/android/channel.gni") ...@@ -6,13 +6,19 @@ import("//build/config/android/channel.gni")
import("//weblayer/variables.gni") import("//weblayer/variables.gni")
declare_args() { declare_args() {
# Show a launcher icon to open WebView developer UI. This is enabled by # Always show a launcher icon to open WebView developer UI for all build variants and channels.
# default for all prestable builds. The icon for Monochrome is shown # When this is off, all prestable build variants will still show launcher icons except for
# dynamically at runtime if Monochrome is the current selected system WebView # Monochrome which will only show its launcher icon when it's the selected WebView provider.
# implementation or hidden otherwise. webview_devui_always_show_icon = false
webview_devui_show_icon = android_channel != "stable"
} }
# Used in standalone and trichrome, configures whether the launcher icon is on or off all the time
standalone_or_trichrome_icon_default_enabled_state =
android_channel != "stable" || webview_devui_always_show_icon
# Used only in monochrome, configures whether the launcher icon is on all the time vs. on conditionally
monochrome_launcher_icon_default_enabled_state = webview_devui_always_show_icon
system_webview_android_manifest = system_webview_android_manifest =
"$root_gen_dir/android_webview/system_webview_apk/AndroidManifest.xml" "$root_gen_dir/android_webview/system_webview_apk/AndroidManifest.xml"
trichrome_webview_android_manifest = trichrome_webview_android_manifest =
......
...@@ -1058,7 +1058,7 @@ ...@@ -1058,7 +1058,7 @@
android:exported="true" android:exported="true"
android:label="WebView android:label="WebView
DevTools" DevTools"
android:name="org.chromium.android_webview.devui.MonochromeLauncherActivity" android:name="org.chromium.android_webview.devui.LauncherActivity"
android:targetActivity="org.chromium.android_webview.devui.MainActivity"> android:targetActivity="org.chromium.android_webview.devui.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
......
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