Commit 3c12eaaf authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

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

This reverts commit 04d9ccbc.

Reason for revert: https://crbug.com/1063165

Original change's description:
> [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/+/2098804
> Reviewed-by: Richard Coles <torne@chromium.org>
> Reviewed-by: Nate 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}

TBR=torne@chromium.org,ntfschr@chromium.org,hazems@chromium.org

Change-Id: I7fea8cf56a9396d30ac272de4a870e0b4bcb9c99
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2111950Reviewed-by: default avatarBrian Sheedy <bsheedy@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751873}
parent 270f0083
......@@ -114,34 +114,16 @@ android_resources("devui_resources") {
custom_package = "org.chromium.android_webview.devui"
}
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 = []
custom_package = "org.chromium.android_webview.devui.icon"
android_manifest = _manifest_file
android_manifest_dep = ":${target_name}__manifest"
}
}
webview_devui_launcher("system_webview_devui_launcher_icon_resources") {
default_enabled_state = standalone_or_trichrome_icon_default_enabled_state
android_resources("devui_launcher_icon_resources") {
resource_dirs = []
custom_package = "org.chromium.android_webview.devui.icon"
android_manifest = "java/DeveloperUiLauncherManifest.xml"
}
webview_devui_launcher("monochrome_devui_launcher_icon_resources") {
default_enabled_state = monochrome_launcher_icon_default_enabled_state
android_resources("monochrome_devui_launcher_icon_resources") {
resource_dirs = []
android_manifest = "java/MonochromeDeveloperUiLauncherManifest.xml"
custom_package = "org.chromium.android_webview.devui.icon"
}
jinja_template("system_webview_manifest") {
......
......@@ -8,7 +8,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
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" />
<!--suppress HardcodedText -->
......@@ -16,8 +15,7 @@
<activity-alias android:name="org.chromium.android_webview.devui.LauncherActivity"
android:targetActivity="org.chromium.android_webview.devui.MainActivity"
android:label="WebView DevTools"
android:exported="true"
android:enabled="{{ icon_enabled }}">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<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,18 +99,23 @@ public class WebViewApkApplication extends Application {
public static void postDeveloperUiLauncherIconTask() {
PostTask.postTask(TaskTraits.BEST_EFFORT, () -> {
Context context = ContextUtils.getApplicationContext();
ComponentName devToolsLauncherActivity = new ComponentName(
context, "org.chromium.android_webview.devui.LauncherActivity");
if (WebViewPackageHelper.isCurrentSystemWebViewImplementation(context)) {
// Enable the component to show the launcher icon.
context.getPackageManager().setComponentEnabledSetting(devToolsLauncherActivity,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
} else {
// Disable the component to hide the launcher icon.
context.getPackageManager().setComponentEnabledSetting(devToolsLauncherActivity,
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
PackageManager.DONT_KILL_APP);
try {
ComponentName devToolsLauncherActivity = new ComponentName(
context, "org.chromium.android_webview.devui.MonochromeLauncherActivity");
if (WebViewPackageHelper.isCurrentSystemWebViewImplementation(context)) {
// Enable the component to show the launcher icon.
context.getPackageManager().setComponentEnabledSetting(devToolsLauncherActivity,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
} else {
// Disable the component to hide the launcher icon.
context.getPackageManager().setComponentEnabledSetting(devToolsLauncherActivity,
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
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,7 +44,6 @@ template("system_webview_apk_or_module_tmpl") {
deps += [
"//android_webview:locale_pak_assets",
"//android_webview:pak_file_assets",
"//android_webview/nonembedded:system_webview_devui_launcher_icon_resources",
]
if (_exclude_weblayer_java) {
......@@ -69,6 +68,10 @@ template("system_webview_apk_or_module_tmpl") {
alternative_android_sdk_dep = webview_framework_dep
}
if (webview_devui_show_icon) {
deps += [ "//android_webview/nonembedded:devui_launcher_icon_resources" ]
}
_use_trichrome_library =
defined(use_trichrome_library) && use_trichrome_library
assert(
......
......@@ -6,19 +6,13 @@ import("//build/config/android/channel.gni")
import("//weblayer/variables.gni")
declare_args() {
# Always show a launcher icon to open WebView developer UI for all build variants and channels.
# When this is off, all prestable build variants will still show launcher icons except for
# Monochrome which will only show its launcher icon when it's the selected WebView provider.
webview_devui_always_show_icon = false
# Show a launcher icon to open WebView developer UI. This is enabled by
# default for all prestable builds. The icon for Monochrome is shown
# dynamically at runtime if Monochrome is the current selected system WebView
# implementation or hidden otherwise.
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 =
"$root_gen_dir/android_webview/system_webview_apk/AndroidManifest.xml"
trichrome_webview_android_manifest =
......
......@@ -1058,7 +1058,7 @@
android:exported="true"
android:label="WebView
DevTools"
android:name="org.chromium.android_webview.devui.LauncherActivity"
android:name="org.chromium.android_webview.devui.MonochromeLauncherActivity"
android:targetActivity="org.chromium.android_webview.devui.MainActivity">
<intent-filter>
<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