diff options
author | Ang Li <ihcinihsdk@google.com> | 2024-03-19 21:37:31 +0000 |
---|---|---|
committer | Ang Li <ihcinihsdk@google.com> | 2024-03-19 23:02:47 +0000 |
commit | 2a60462b5e06f4ae13673a74d19082f285070698 (patch) | |
tree | dd900bc32668aa484af76605ca35340a93447d70 /nativeruntime | |
parent | c8931685ae688029f9137528055073fadeed8f1b (diff) | |
download | robolectric-2a60462b5e06f4ae13673a74d19082f285070698.tar.gz |
Check in the resources for Google font usage in Robolectric.
Bug: 314945503
Test: atest -c SystemUIGoogleRoboRNGTests:com/android/screenshot/ResourceLoadingRNGTest
(Tested in git-main against ag/26594475)
Change-Id: Ib5d1630341383afeec597ed49b6bd138af5f6284
Diffstat (limited to 'nativeruntime')
8 files changed, 260 insertions, 0 deletions
diff --git a/nativeruntime/src/main/resources/arsc/Android.bp b/nativeruntime/src/main/resources/arsc/Android.bp new file mode 100644 index 000000000..50a46abae --- /dev/null +++ b/nativeruntime/src/main/resources/arsc/Android.bp @@ -0,0 +1,69 @@ +// +// Copyright (C) 2024 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +genrule { + name: "color-and-font-res-compile-public", + tools: ["aapt2"], + srcs: [ + "color_and_font_res/values/public.xml", + ], + out: ["values_public.arsc.flat"], + cmd: "$(location aapt2) compile $(in) -o $(genDir)", +} + +genrule { + name: "color-and-font-res-compile-colors", + tools: ["aapt2"], + srcs: [ + "color_and_font_res/values/colors.xml", + ], + out: ["values_colors.arsc.flat"], + cmd: "$(location aapt2) compile $(in) -o $(genDir)", +} + +genrule { + name: "color-and-font-res-compile-config", + tools: ["aapt2"], + srcs: [ + "color_and_font_res/values/config.xml", + ], + out: ["values_config.arsc.flat"], + cmd: "$(location aapt2) compile $(in) -o $(genDir)", +} + +genrule { + name: "color-and-font-res-apk", + tools: ["aapt2"], + // The first input file in the list must be the manifest + srcs: [ + "ColorAndFontAndroidManifest.xml", + ":color-and-font-res-compile-public", + ":color-and-font-res-compile-colors", + ":color-and-font-res-compile-config", + ], + out: ["color-and-font-res.apk"], + cmd: "$(location aapt2) link -o $(out) --manifest $(in)", +} + +genrule { + name: "color-and-font-res-arsc", + srcs: [":color-and-font-res-apk"], + out: ["color_and_font_res.arsc"], + cmd: "mkdir -p $(genDir)/color-and-font-res-arsc && " + + "unzip -x $(in) resources.arsc -d $(genDir)/color-and-font-res-arsc && " + + "mkdir -p $$(dirname $(out)) && " + + "mv $(genDir)/color-and-font-res-arsc/resources.arsc $(out) && " + + "echo 'Created $(out)'", +} diff --git a/nativeruntime/src/main/resources/arsc/ColorAndFontAndroidManifest.xml b/nativeruntime/src/main/resources/arsc/ColorAndFontAndroidManifest.xml new file mode 100644 index 000000000..11970fd18 --- /dev/null +++ b/nativeruntime/src/main/resources/arsc/ColorAndFontAndroidManifest.xml @@ -0,0 +1,5 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="android"> +<application/> +</manifest> + diff --git a/nativeruntime/src/main/resources/arsc/README b/nativeruntime/src/main/resources/arsc/README new file mode 100644 index 000000000..83f3677a9 --- /dev/null +++ b/nativeruntime/src/main/resources/arsc/README @@ -0,0 +1,11 @@ +The `color_and_font_res` comes from +`frameworks/base/core/res/remote_color_resources_res`, with a config XML file +added. This enables the possibility of both Material You Colors and the usage of +Google fonts. + +To build and update `color_and_font_res.arsc`, please follow the steps below: + +1. m color-and-font-res-arsc +2. cp +${ANDROID_BUILD_TOP}/out/soong/.intermediates/external/robolectric/nativeruntime/src/main/resources/arsc/color-and-font-res-arsc/gen/color_and_font_res.arsc \ +${ANDROID_BUILD_TOP}/external/robolectric/nativeruntime/src/main/resources/arsc/. diff --git a/nativeruntime/src/main/resources/arsc/color_and_font_res.arsc b/nativeruntime/src/main/resources/arsc/color_and_font_res.arsc Binary files differnew file mode 100644 index 000000000..42c52899c --- /dev/null +++ b/nativeruntime/src/main/resources/arsc/color_and_font_res.arsc diff --git a/nativeruntime/src/main/resources/arsc/color_and_font_res/symbols.xml b/nativeruntime/src/main/resources/arsc/color_and_font_res/symbols.xml new file mode 100644 index 000000000..b3b4a1282 --- /dev/null +++ b/nativeruntime/src/main/resources/arsc/color_and_font_res/symbols.xml @@ -0,0 +1,4 @@ +<resources> + <!-- ARSC file used to overlay local colors when rendering a RemoteViews --> + <java-symbol type="raw" name="color_and_font_res" /> +</resources> diff --git a/nativeruntime/src/main/resources/arsc/color_and_font_res/values/colors.xml b/nativeruntime/src/main/resources/arsc/color_and_font_res/values/colors.xml new file mode 100644 index 000000000..5a194b721 --- /dev/null +++ b/nativeruntime/src/main/resources/arsc/color_and_font_res/values/colors.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="system_accent1_0">#ffffff</color> + <color name="system_accent1_10">#91fff4</color> + <color name="system_accent1_50">#91fff4</color> + <color name="system_accent1_100">#83f6e5</color> + <color name="system_accent1_200">#65d9c9</color> + <color name="system_accent1_300">#45bdae</color> + <color name="system_accent1_400">#1fa293</color> + <color name="system_accent1_500">#008377</color> + <color name="system_accent1_600">#006d61</color> + <color name="system_accent1_700">#005449</color> + <color name="system_accent1_800">#003c33</color> + <color name="system_accent1_900">#00271e</color> + <color name="system_accent1_1000">#000000</color> + <color name="system_accent2_0">#ffffff</color> + <color name="system_accent2_10">#ffffff</color> + <color name="system_accent2_50">#91fff4</color> + <color name="system_accent2_100">#83f6e5</color> + <color name="system_accent2_200">#65d9c9</color> + <color name="system_accent2_300">#45bdae</color> + <color name="system_accent2_400">#1fa293</color> + <color name="system_accent2_500">#008377</color> + <color name="system_accent2_600">#006d61</color> + <color name="system_accent2_700">#005449</color> + <color name="system_accent2_800">#003c33</color> + <color name="system_accent2_900">#00271e</color> + <color name="system_accent2_1000">#000000</color> + <color name="system_accent3_0">#ffffff</color> + <color name="system_accent3_10">#91fff4</color> + <color name="system_accent3_50">#91fff4</color> + <color name="system_accent3_100">#83f6e5</color> + <color name="system_accent3_200">#65d9c9</color> + <color name="system_accent3_300">#45bdae</color> + <color name="system_accent3_400">#1fa293</color> + <color name="system_accent3_500">#008377</color> + <color name="system_accent3_600">#006d61</color> + <color name="system_accent3_700">#005449</color> + <color name="system_accent3_800">#003c33</color> + <color name="system_accent3_900">#00271e</color> + <color name="system_accent3_1000">#000000</color> + <color name="system_neutral1_0">#ffffff</color> + <color name="system_neutral1_10">#f0f0f0</color> + <color name="system_neutral1_50">#f0f0f0</color> + <color name="system_neutral1_100">#e2e2e2</color> + <color name="system_neutral1_200">#c6c6c6</color> + <color name="system_neutral1_300">#ababab</color> + <color name="system_neutral1_400">#909090</color> + <color name="system_neutral1_500">#757575</color> + <color name="system_neutral1_600">#5e5e5e</color> + <color name="system_neutral1_700">#464646</color> + <color name="system_neutral1_800">#303030</color> + <color name="system_neutral1_900">#1b1b1b</color> + <color name="system_neutral1_1000">#000000</color> + <color name="system_neutral2_0">#ffffff</color> + <color name="system_neutral2_10">#f0f0f0</color> + <color name="system_neutral2_50">#f0f0f0</color> + <color name="system_neutral2_100">#e2e2e2</color> + <color name="system_neutral2_200">#c6c6c6</color> + <color name="system_neutral2_300">#ababab</color> + <color name="system_neutral2_400">#909090</color> + <color name="system_neutral2_500">#757575</color> + <color name="system_neutral2_600">#5e5e5e</color> + <color name="system_neutral2_700">#464646</color> + <color name="system_neutral2_800">#303030</color> + <color name="system_neutral2_900">#1b1b1b</color> + <color name="system_neutral2_1000">#000000</color> +</resources> diff --git a/nativeruntime/src/main/resources/arsc/color_and_font_res/values/config.xml b/nativeruntime/src/main/resources/arsc/color_and_font_res/values/config.xml new file mode 100644 index 000000000..ca427b8cb --- /dev/null +++ b/nativeruntime/src/main/resources/arsc/color_and_font_res/values/config.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2024, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> + +<!-- These resources are around just to allow their values to be customized + for different hardware and product builds. Do not translate. + + NOTE: The naming convention is "config_camelCaseValue". Some legacy + entries do not follow the convention, but all new entries should. --> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Name of a font family to use for headlines. If empty, falls back to platform default --> + <string name="config_headlineFontFamily" translatable="false">plh-go-sans</string> + <!-- Name of a font family to use for body text. --> + <string name="config_bodyFontFamily" translatable="false">plh-go-sans-text</string> +</resources> diff --git a/nativeruntime/src/main/resources/arsc/color_and_font_res/values/public.xml b/nativeruntime/src/main/resources/arsc/color_and_font_res/values/public.xml new file mode 100644 index 000000000..57a46996b --- /dev/null +++ b/nativeruntime/src/main/resources/arsc/color_and_font_res/values/public.xml @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <public type="string" name="config_bodyFontFamily" id="0x010401f1" /> + <public type="string" name="config_headlineFontFamily" id="0x01040262" /> + <public-group type="color" first-id="0x0106001d"> + <public name="system_accent1_0" /> + <public name="system_accent1_10" /> + <public name="system_accent1_50" /> + <public name="system_accent1_100" /> + <public name="system_accent1_200" /> + <public name="system_accent1_300" /> + <public name="system_accent1_400" /> + <public name="system_accent1_500" /> + <public name="system_accent1_600" /> + <public name="system_accent1_700" /> + <public name="system_accent1_800" /> + <public name="system_accent1_900" /> + <public name="system_accent1_1000" /> + <public name="system_accent2_0" /> + <public name="system_accent2_10" /> + <public name="system_accent2_50" /> + <public name="system_accent2_100" /> + <public name="system_accent2_200" /> + <public name="system_accent2_300" /> + <public name="system_accent2_400" /> + <public name="system_accent2_500" /> + <public name="system_accent2_600" /> + <public name="system_accent2_700" /> + <public name="system_accent2_800" /> + <public name="system_accent2_900" /> + <public name="system_accent2_1000" /> + <public name="system_accent3_0" /> + <public name="system_accent3_10" /> + <public name="system_accent3_50" /> + <public name="system_accent3_100" /> + <public name="system_accent3_200" /> + <public name="system_accent3_300" /> + <public name="system_accent3_400" /> + <public name="system_accent3_500" /> + <public name="system_accent3_600" /> + <public name="system_accent3_700" /> + <public name="system_accent3_800" /> + <public name="system_accent3_900" /> + <public name="system_accent3_1000" /> + <public name="system_neutral1_0" /> + <public name="system_neutral1_10" /> + <public name="system_neutral1_50" /> + <public name="system_neutral1_100" /> + <public name="system_neutral1_200" /> + <public name="system_neutral1_300" /> + <public name="system_neutral1_400" /> + <public name="system_neutral1_500" /> + <public name="system_neutral1_600" /> + <public name="system_neutral1_700" /> + <public name="system_neutral1_800" /> + <public name="system_neutral1_900" /> + <public name="system_neutral1_1000" /> + <public name="system_neutral2_0" /> + <public name="system_neutral2_10" /> + <public name="system_neutral2_50" /> + <public name="system_neutral2_100" /> + <public name="system_neutral2_200" /> + <public name="system_neutral2_300" /> + <public name="system_neutral2_400" /> + <public name="system_neutral2_500" /> + <public name="system_neutral2_600" /> + <public name="system_neutral2_700" /> + <public name="system_neutral2_800" /> + <public name="system_neutral2_900" /> + <public name="system_neutral2_1000" /> + </public-group> +</resources> |