Commit 76391555 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Remove app_single_page_icon.webp from chrome_modern_apk and above

It's used only for chrome_apk.

Also simplifies resource_blacklist_regex in compile_resources.py so that
it is able to remove a resource from all densities.

Bug: 988047
Change-Id: Ic47140f9f597dcee7abd0762131a5dbffd08780b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1721452Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Reviewed-by: default avatarMohamed Heikal <mheikal@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682102}
parent 4e6169d7
......@@ -101,7 +101,8 @@ template("system_webview_apk_tmpl") {
aapt_locale_whitelist = locales
resource_blacklist_regex = "[/-]xxxhdpi[/-]"
# Match drawables, but not mipmaps.
resource_blacklist_regex = "drawable[^/]*-xxxhdpi"
# Exception rationale in https://crbug.com/691733.
resource_blacklist_exceptions = [
......
......@@ -516,16 +516,11 @@ https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/android/java/README
sys.exit(1)
def _ResourceNameFromPath(path):
return os.path.splitext(os.path.basename(path))[0]
def _CreateKeepPredicate(resource_dirs, resource_blacklist_regex,
def _CreateKeepPredicate(resource_blacklist_regex,
resource_blacklist_exceptions):
"""Return a predicate lambda to determine which resource files to keep.
Args:
resource_dirs: list of top-level resource directories.
resource_blacklist_regex: A regular expression describing all resources
to exclude, except if they are mip-maps, or if they are listed
in |resource_blacklist_exceptions|.
......@@ -535,35 +530,16 @@ def _CreateKeepPredicate(resource_dirs, resource_blacklist_regex,
A lambda that takes a path, and returns true if the corresponding file
must be kept.
"""
naive_predicate = lambda path: os.path.basename(path)[0] != '.'
predicate = lambda path: os.path.basename(path)[0] != '.'
if resource_blacklist_regex == '':
# Do not extract dotfiles (e.g. ".gitkeep"). aapt ignores them anyways.
return naive_predicate
if resource_blacklist_regex != '':
# A simple predicate that only removes (returns False for) paths covered by
# the blacklist regex, except if they are mipmaps, or listed as exceptions.
naive_predicate = lambda path: (
not re.search(resource_blacklist_regex, path) or
re.search(r'[/-]mipmap[/-]', path) or
build_utils.MatchesGlob(path, resource_blacklist_exceptions))
# Build a set of all names from drawables kept by naive_predicate().
# Used later to ensure that we never exclude drawables from densities
# that are filtered-out by naive_predicate().
non_filtered_drawables = set()
for resource_dir in resource_dirs:
for path in _IterFiles(resource_dir):
if re.search(r'[/-]drawable[/-]', path) and naive_predicate(path):
non_filtered_drawables.add(_ResourceNameFromPath(path))
# NOTE: Defined as a function, instead of a lambda to avoid the
# auto-formatter to put this on a very long line that overflows.
def drawable_predicate(path):
return (naive_predicate(path)
or _ResourceNameFromPath(path) not in non_filtered_drawables)
return predicate
return drawable_predicate
# A simple predicate that only removes (returns False for) paths covered by
# the blacklist regex or listed as exceptions.
return lambda path: (
not re.search(resource_blacklist_regex, path) or
build_utils.MatchesGlob(path, resource_blacklist_exceptions))
def _ConvertToWebP(webp_binary, png_files):
......@@ -720,8 +696,7 @@ def _PackageApk(options, build):
# Create a function that selects which resource files should be packaged
# into the final output. Any file that does not pass the predicate will
# be removed below.
keep_predicate = _CreateKeepPredicate(dep_subdirs,
options.resource_blacklist_regex,
keep_predicate = _CreateKeepPredicate(options.resource_blacklist_regex,
options.resource_blacklist_exceptions)
png_paths = []
for directory in dep_subdirs:
......
......@@ -148,7 +148,12 @@ template("chrome_public_common_apk_or_module_tmpl") {
}
target_sdk_version = android_sdk_version
resource_blacklist_regex = "[/-]xxxhdpi[/-]"
# Match drawables, but not mipmaps.
resource_blacklist_regex = "drawable[^/]*-xxxhdpi"
if (min_sdk_version >= 21) {
# Resources used by AndroidManifest.xml only for pre-21.
resource_blacklist_regex += "|app_single_page_icon"
}
# Exception rationale in https://crbug.com/691733.
resource_blacklist_exceptions = [
......@@ -156,6 +161,7 @@ template("chrome_public_common_apk_or_module_tmpl") {
"*.9.*", # Most nine-patches contain shadows.
"*ic_file_download_white*", # Bottom edge seems misaligned.
"*ic_lock.*", # Bottom edge seems misaligned.
"*ic_group_*", # Appear only in xxxhdpi.
]
if (!_is_monochrome) {
......
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