Merge "Add periodically pulling data from StatsD" into sc-v2-dev
diff --git a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/drawable/hvac_button_off_bg.xml b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/drawable/hvac_button_off_bg.xml
index 2cc9886..d40ad01 100644
--- a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/drawable/hvac_button_off_bg.xml
+++ b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/drawable/hvac_button_off_bg.xml
@@ -16,7 +16,7 @@
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
- <shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <shape>
<solid android:color="@color/hvac_off_background_color"/>
<corners android:radius="@dimen/hvac_panel_off_button_radius"/>
</shape>
diff --git a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/drawable/hvac_panel_bg.xml b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/drawable/hvac_panel_bg.xml
index 1bdac16..f0cd3bd 100644
--- a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/drawable/hvac_panel_bg.xml
+++ b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/drawable/hvac_panel_bg.xml
@@ -17,5 +17,12 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/hvac_background_color"/>
- <corners android:radius="@dimen/hvac_panel_bg_radius"/>
+
+ <!-- android:radius must be defined even with overrides. -->
+ <corners
+ android:radius="1dp"
+ android:topLeftRadius="@dimen/hvac_panel_bg_radius"
+ android:topRightRadius="@dimen/hvac_panel_bg_radius"
+ android:bottomLeftRadius="0dp"
+ android:bottomRightRadius="0dp"/>
</shape>
\ No newline at end of file
diff --git a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/drawable/ic_hvac_close.xml b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/drawable/ic_hvac_close.xml
deleted file mode 100644
index e9ae42e..0000000
--- a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/drawable/ic_hvac_close.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2021 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.
- -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="@dimen/hvac_panel_exit_icon_dimen"
- android:height="@dimen/hvac_panel_exit_icon_dimen"
- android:viewportWidth="26"
- android:viewportHeight="26">
- <path
- android:pathData="M25.8327 2.75199L23.2477 0.166992L12.9994 10.4153L2.75102 0.166992L0.166016 2.75199L10.4144 13.0003L0.166016 23.2487L2.75102 25.8337L12.9994 15.5853L23.2477 25.8337L25.8327 23.2487L15.5844 13.0003L25.8327 2.75199Z"
- android:fillColor="@color/hvac_off_icon_fill_color" />
-</vector>
\ No newline at end of file
diff --git a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/layout/hvac_panel_container.xml b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/layout/hvac_panel_container.xml
index 64577aa..d834e38 100644
--- a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/layout/hvac_panel_container.xml
+++ b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/layout/hvac_panel_container.xml
@@ -30,35 +30,6 @@
android:layout_height="match_parent"
android:background="@drawable/hvac_panel_bg">
- <ImageButton
- android:id="@+id/hvac_panel_close_button"
- android:layout_width="@dimen/hvac_panel_exit_button_dimen"
- android:layout_height="@dimen/hvac_panel_exit_button_dimen"
- android:layout_marginLeft="@dimen/hvac_panel_exit_button_margin"
- android:layout_marginTop="@dimen/hvac_panel_exit_button_margin"
- android:background="@drawable/hvac_default_background"
- android:scaleType="center"
- android:src="@drawable/ic_hvac_close"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintLeft_toLeftOf="parent"/>
- <FrameLayout
- android:id="@+id/hvac_header_title"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/wrap_content"
- android:layout_marginTop="@dimen/hvac_panel_title_margin"
- android:layout_marginLeft="@dimen/hvac_panel_button_dimen"
- android:layout_marginRight="@dimen/hvac_panel_button_dimen"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintLeft_toLeftOf="parent"
- app:layout_constraintRight_toRightOf="parent">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:text="@string/hvac_panel_header"
- android:gravity="center"/>
- </FrameLayout>
-
<androidx.constraintlayout.widget.Guideline
android:id="@+id/top_guideline"
android:layout_width="match_parent"
@@ -77,6 +48,7 @@
android:layout_marginBottom="@dimen/hvac_panel_button_internal_margin"
android:layout_marginLeft="@dimen/hvac_panel_button_external_margin"
android:layout_marginRight="@dimen/hvac_panel_button_internal_margin"
+ android:layout_marginTop="@dimen/hvac_panel_button_external_top_margin"
android:background="@drawable/hvac_default_background"
app:layout_constraintBottom_toTopOf="@+id/steering_wheel_heat_on_off"
app:layout_constraintLeft_toLeftOf="parent"
@@ -136,6 +108,7 @@
android:layout_marginBottom="@dimen/hvac_panel_button_internal_margin"
android:layout_marginLeft="@dimen/hvac_panel_button_internal_margin"
android:layout_marginRight="@dimen/hvac_panel_button_internal_margin"
+ android:layout_marginTop="@dimen/hvac_panel_button_external_top_margin"
android:background="@drawable/hvac_cool_background"
app:layout_constraintBottom_toTopOf="@+id/seat_heater_driver_on_off"
app:layout_constraintLeft_toRightOf="@+id/cooling_on_off"
@@ -173,6 +146,7 @@
android:layout_marginBottom="@dimen/hvac_panel_button_internal_margin"
android:layout_marginLeft="@dimen/hvac_panel_button_internal_margin"
android:layout_marginRight="@dimen/hvac_panel_button_internal_margin"
+ android:layout_marginTop="@dimen/hvac_panel_button_external_top_margin"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@+id/fan_speed_control"
app:layout_constraintLeft_toRightOf="@+id/seat_cooler_driver_on_off"
@@ -211,6 +185,7 @@
android:layout_marginBottom="@dimen/hvac_panel_button_internal_margin"
android:layout_marginLeft="@dimen/hvac_panel_button_internal_margin"
android:layout_marginRight="@dimen/hvac_panel_button_internal_margin"
+ android:layout_marginTop="@dimen/hvac_panel_button_external_top_margin"
android:background="@drawable/hvac_cool_background"
app:layout_constraintBottom_toTopOf="@+id/seat_heater_passenger_on_off"
app:layout_constraintRight_toLeftOf="@+id/recycle_air_on_off"
@@ -246,6 +221,7 @@
android:layout_marginBottom="@dimen/hvac_panel_button_internal_margin"
android:layout_marginLeft="@dimen/hvac_panel_button_internal_margin"
android:layout_marginRight="@dimen/hvac_panel_button_external_margin"
+ android:layout_marginTop="@dimen/hvac_panel_button_external_top_margin"
android:background="@drawable/hvac_default_background"
app:layout_constraintBottom_toTopOf="@+id/hvac_driver_passenger_sync"
app:layout_constraintRight_toRightOf="parent"
@@ -292,7 +268,6 @@
systemui:hvacToggleOffButtonDrawable="@drawable/ic_auto_off"/>
<include
- layout="@layout/hvac_panel_handle_bar"
- app:layout_constraintTop_toTopOf="parent"/>
+ layout="@layout/hvac_panel_handle_bar"/>
</com.android.systemui.car.hvac.HvacPanelView>
</com.android.car.ui.FocusArea>
diff --git a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/layout/hvac_panel_handle_bar.xml b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/layout/hvac_panel_handle_bar.xml
index 0ebd055..62a1e81 100644
--- a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/layout/hvac_panel_handle_bar.xml
+++ b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/layout/hvac_panel_handle_bar.xml
@@ -14,15 +14,24 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<FrameLayout
+
+<merge
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <View
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <FrameLayout
android:id="@+id/handle_bar"
- android:layout_width="@dimen/hvac_panel_handle_bar_width"
- android:layout_height="@dimen/hvac_panel_handle_bar_height"
- android:layout_marginTop="@dimen/hvac_panel_handle_bar_margin_top"
- android:layout_gravity="top|center_horizontal"
- android:background="@drawable/hvac_panel_handle_bar"/>
-</FrameLayout>
\ No newline at end of file
+ android:layout_width="@dimen/hvac_panel_handle_bar_container_width"
+ android:layout_height="@dimen/hvac_panel_handle_bar_container_height"
+ android:layout_gravity="center"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintHorizontal_chainStyle="packed">
+ <View
+ android:layout_width="@dimen/hvac_panel_handle_bar_width"
+ android:layout_height="@dimen/hvac_panel_handle_bar_height"
+ android:layout_marginTop="@dimen/hvac_panel_handle_bar_margin_top"
+ android:layout_gravity="top|center_horizontal"
+ android:background="@drawable/hvac_panel_handle_bar"/>
+ </FrameLayout>
+</merge>
diff --git a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/values/colors.xml b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/values/colors.xml
index 6f685b3..2c5c903 100644
--- a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/values/colors.xml
+++ b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/values/colors.xml
@@ -34,9 +34,11 @@
<color name="hvac_master_switch_color">@color/car_nav_icon_fill_color</color>
<color name="hvac_on_icon_fill_color">@android:color/black</color>
<color name="hvac_off_icon_fill_color">@android:color/white</color>
- <color name="hvac_on_cooling_background_color">#669DF6</color>
+ <color name="hvac_on_cooling_background_color">#6BF0FF</color>
<color name="hvac_on_heating_background_color">#EE675C</color>
- <color name="hvac_on_background_color">#50E3C2</color>
+ <color name="hvac_on_background_color">#6BF0FF</color>
<color name="hvac_off_background_color">#3C4043</color>
+ <color name="dark_mode_icon_color_single_tone">@color/car_nav_icon_fill_color</color>
+ <color name="light_mode_icon_color_single_tone">@color/car_nav_icon_fill_color</color>
</resources>
diff --git a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/values/dimens.xml b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/values/dimens.xml
index 3064fd9..0ec6298 100644
--- a/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/values/dimens.xml
+++ b/car_product/car_ui_portrait/apps/CarUiPortraitSystemUI/res/values/dimens.xml
@@ -42,29 +42,26 @@
<dimen name="system_bar_user_icon_drawing_size">44dp</dimen>
<dimen name="status_bar_system_icon_spacing">32dp</dimen>
+ <dimen name="hvac_panel_handle_bar_container_height">64dp</dimen>
+ <dimen name="hvac_panel_handle_bar_container_width">728dp</dimen>
<dimen name="hvac_panel_handle_bar_height">6dp</dimen>
- <dimen name="hvac_panel_handle_bar_margin_top">8dp</dimen>
- <dimen name="hvac_panel_handle_bar_width">64dp</dimen>
+ <dimen name="hvac_panel_handle_bar_margin_top">17dp</dimen>
+ <dimen name="hvac_panel_handle_bar_width">120dp</dimen>
<dimen name="hvac_panel_bg_radius">24dp</dimen>
<dimen name="hvac_panel_off_button_radius">24dp</dimen>
<dimen name="hvac_panel_on_button_radius">44dp</dimen>
- <dimen name="hvac_panel_full_expanded_height">472dp</dimen>
- <dimen name="hvac_panel_exit_icon_dimen">21dp</dimen>
- <dimen name="hvac_panel_exit_button_dimen">64dp</dimen>
- <dimen name="hvac_panel_exit_button_margin">24dp</dimen>
+ <dimen name="hvac_panel_full_expanded_height">456dp</dimen>
<dimen name="hvac_panel_title_margin">36dp</dimen>
- <dimen name="hvac_panel_buttons_guideline">120dp</dimen>
+ <dimen name="hvac_panel_buttons_guideline">@dimen/hvac_panel_handle_bar_container_height</dimen>
<dimen name="hvac_panel_icon_dimen">48dp</dimen>
<dimen name="hvac_panel_tall_icon_dimen">108dp</dimen>
<dimen name="hvac_panel_wide_icon_dimen">96dp</dimen>
- <dimen name="hvac_panel_icon_inset_dimen">22dp</dimen>
- <dimen name="hvac_panel_icon_inset_wide_dimen">92dp</dimen>
- <dimen name="hvac_panel_icon_inset_extra_wide_dimen">140dp</dimen>
<dimen name="hvac_panel_button_dimen">88dp</dimen>
<dimen name="hvac_panel_tall_button_height">148dp</dimen>
<dimen name="hvac_panel_wide_button_width">374dp</dimen>
<dimen name="hvac_panel_slider_width">696dp</dimen>
<dimen name="hvac_panel_button_external_margin">24dp</dimen>
+ <dimen name="hvac_panel_button_external_top_margin">16dp</dimen>
<dimen name="hvac_panel_button_internal_margin">16dp</dimen>
<item name="hvac_heat_or_cool_off_alpha" format="float" type="dimen">0.3</item>
diff --git a/car_product/car_ui_portrait/bootanimation/bootanimation.zip b/car_product/car_ui_portrait/bootanimation/bootanimation.zip
index cc40a4b..d7b90b3 100644
--- a/car_product/car_ui_portrait/bootanimation/bootanimation.zip
+++ b/car_product/car_ui_portrait/bootanimation/bootanimation.zip
Binary files differ
diff --git a/car_product/car_ui_portrait/bootanimation/parts/desc.txt b/car_product/car_ui_portrait/bootanimation/parts/desc.txt
index 483f8e2..a4ebbac 100644
--- a/car_product/car_ui_portrait/bootanimation/parts/desc.txt
+++ b/car_product/car_ui_portrait/bootanimation/parts/desc.txt
@@ -1,2 +1,2 @@
986 1000 60
-p 0 0 part0
+c 1 0 part0
diff --git a/car_product/car_ui_portrait/rro/android/res/color/btn_device_default_dark.xml b/car_product/car_ui_portrait/rro/android/res/color/btn_device_default_dark.xml
index 4fac96d..037fe3e 100644
--- a/car_product/car_ui_portrait/rro/android/res/color/btn_device_default_dark.xml
+++ b/car_product/car_ui_portrait/rro/android/res/color/btn_device_default_dark.xml
@@ -18,6 +18,6 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:alpha="?android:attr/disabledAlpha"
- android:color="@*android:color/system_neutral1_200"/>
- <item android:color="@*android:color/system_neutral1_200"/>
+ android:color="@*android:color/system_accent1_200"/>
+ <item android:color="@*android:color/system_accent1_200"/>
</selector>
\ No newline at end of file
diff --git a/car_product/car_ui_portrait/rro/android/res/values/styles_device_default.xml b/car_product/car_ui_portrait/rro/android/res/values/styles_device_default.xml
index de80014..f94f3ae 100644
--- a/car_product/car_ui_portrait/rro/android/res/values/styles_device_default.xml
+++ b/car_product/car_ui_portrait/rro/android/res/values/styles_device_default.xml
@@ -119,6 +119,7 @@
<style name="Widget.DeviceDefault.CompoundButton.Switch" parent="android:Widget.Material.CompoundButton.Switch">
<item name="android:thumb">@*android:drawable/car_switch_thumb</item>
<item name="android:track">@*android:drawable/car_switch_track</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
<style name="Widget.DeviceDefault.ProgressBar.Horizontal" parent="android:Widget.Material.ProgressBar.Horizontal">
diff --git a/car_product/car_ui_portrait/rro/android/res/values/themes_device_defaults.xml b/car_product/car_ui_portrait/rro/android/res/values/themes_device_defaults.xml
index 7075424..3fe8dfe 100644
--- a/car_product/car_ui_portrait/rro/android/res/values/themes_device_defaults.xml
+++ b/car_product/car_ui_portrait/rro/android/res/values/themes_device_defaults.xml
@@ -42,19 +42,7 @@
<!-- Color palette -->
<item name="android:statusBarColor">@android:color/black</item>
- <item name="android:textColorHint">@*android:color/car_body2</item>
- <item name="android:textColorPrimary">@*android:color/text_color_primary</item>
- <item name="android:textColorSecondary">@*android:color/car_body2</item>
- <item name="android:colorAccent">@*android:color/accent_device_default_light</item>
- <item name="android:colorBackground">@*android:color/background_device_default_light</item>
- <item name="android:colorBackgroundFloating">@*android:color/background_floating_device_default_light</item>
- <item name="android:colorButtonNormal">@*android:color/car_highlight</item>
- <item name="android:colorControlHighlight">@*android:color/car_card_ripple_background</item>
- <item name="android:colorControlNormal">@*android:color/car_body2</item>
- <item name="android:colorPrimary">@*android:color/primary_device_default_light</item>
- <item name="android:colorPrimaryDark">@*android:color/primary_device_default_dark</item>
- <item name="android:colorForeground">@*android:color/car_card_light</item>
- <item name="android:editTextColor">@*android:color/car_body1</item>
+ <item name="android:colorButtonNormal">@color/btn_device_default_dark</item>
</style>
<style name="Theme.DeviceDefault.Dialog" parent="android:Theme.Material.Dialog">
diff --git a/car_product/car_ui_portrait/rro/car-ui-customizations/res/color/car_ui_text_color_primary.xml b/car_product/car_ui_portrait/rro/car-ui-customizations/res/color/car_ui_text_color_primary.xml
index 860f219..e87a692 100644
--- a/car_product/car_ui_portrait/rro/car-ui-customizations/res/color/car_ui_text_color_primary.xml
+++ b/car_product/car_ui_portrait/rro/car-ui-customizations/res/color/car_ui_text_color_primary.xml
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2021 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.
--->
+ ~ Copyright (C) 2021 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.
+ -->
<!-- Copy of ?android:attr/textColorPrimary (frameworks/base/res/res/color/text_color_primary.xml)
but with a ux restricted state. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:state_enabled="false"
android:alpha="?android:attr/disabledAlpha"
- android:color="?android:attr/colorForeground"/>
+ android:color="?android:attr/textColorPrimary"/>
<item app:state_ux_restricted="true"
android:alpha="?android:attr/disabledAlpha"
- android:color="?android:attr/colorForeground"/>
- <item android:color="?android:attr/colorForeground"/>
+ android:color="?android:attr/textColorPrimary"/>
+ <item android:color="?android:attr/textColorPrimary"/>
</selector>
diff --git a/car_product/car_ui_portrait/rro/car-ui-customizations/res/color/car_ui_text_color_secondary.xml b/car_product/car_ui_portrait/rro/car-ui-customizations/res/color/car_ui_text_color_secondary.xml
index f99fc861..0f1fcb5 100644
--- a/car_product/car_ui_portrait/rro/car-ui-customizations/res/color/car_ui_text_color_secondary.xml
+++ b/car_product/car_ui_portrait/rro/car-ui-customizations/res/color/car_ui_text_color_secondary.xml
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (C) 2021 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.
--->
+ ~ Copyright (C) 2021 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.
+ -->
<!-- Copy of ?android:attr/textColorSecondary (frameworks/base/res/res/color/text_color_secondary.xml)
but with a ux restricted state. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:state_enabled="false"
android:alpha="?android:attr/disabledAlpha"
- android:color="?android:attr/colorForeground"/>
+ android:color="?android:attr/textColorSecondary"/>
<item app:state_ux_restricted="true"
android:alpha="?android:attr/disabledAlpha"
- android:color="?android:attr/colorForeground"/>
- <item android:color="?android:attr/colorForeground"/>
+ android:color="?android:attr/textColorSecondary"/>
+ <item android:color="?android:attr/textColorSecondary"/>
</selector>
diff --git a/car_product/car_ui_portrait/rro/car-ui-customizations/res/drawable/car_ui_activity_background.xml b/car_product/car_ui_portrait/rro/car-ui-customizations/res/drawable/car_ui_activity_background.xml
new file mode 100644
index 0000000..f70ad67
--- /dev/null
+++ b/car_product/car_ui_portrait/rro/car-ui-customizations/res/drawable/car_ui_activity_background.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 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.
+ -->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+ <item android:drawable="?android:attr/colorBackground"/>
+</layer-list>
diff --git a/car_product/car_ui_portrait/rro/car-ui-customizations/res/values/drawables.xml b/car_product/car_ui_portrait/rro/car-ui-customizations/res/values/drawables.xml
deleted file mode 100644
index 7bf9ad7..0000000
--- a/car_product/car_ui_portrait/rro/car-ui-customizations/res/values/drawables.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2021 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.
- -->
-<resources>
- <drawable name="car_ui_activity_background">#FDFDFD</drawable>
-</resources>
diff --git a/car_product/car_ui_portrait/rro/car-ui-customizations/res/values/styles.xml b/car_product/car_ui_portrait/rro/car-ui-customizations/res/values/styles.xml
index cf229bd..6326714 100644
--- a/car_product/car_ui_portrait/rro/car-ui-customizations/res/values/styles.xml
+++ b/car_product/car_ui_portrait/rro/car-ui-customizations/res/values/styles.xml
@@ -22,4 +22,15 @@
<style name="TextAppearance_CarUi_AlertDialog_Subtitle" parent="android:TextAppearance.DeviceDefault">
<item name="android:textSize">@dimen/car_ui_body3_size</item>
</style>
-</resources>
\ No newline at end of file
+
+ <style name="TextAppearance.CarUi.PreferenceCategoryTitle" parent="android:TextAppearance.DeviceDefault">
+ <item name="android:fontFamily">sans-serif-medium</item>
+ <item name="android:textColor">?android:attr/colorAccent</item>
+ <item name="android:textSize">24sp</item>
+ </style>
+
+ <style name="TextAppearance.CarUi.PreferenceSummary" parent="android:TextAppearance.DeviceDefault">
+ <item name="android:textColor">?android:attr/textColorSecondary</item>
+ <item name="android:textSize">24sp</item>
+ </style>
+</resources>
diff --git a/packages/ScriptExecutor/Android.bp b/packages/ScriptExecutor/Android.bp
index 6e35f4e..8e1c535 100644
--- a/packages/ScriptExecutor/Android.bp
+++ b/packages/ScriptExecutor/Android.bp
@@ -45,7 +45,6 @@
],
shared_libs: [
- "libandroid_runtime",
"libbinder",
"libnativehelper",
"libutils",
diff --git a/packages/ScriptExecutor/src/BundleWrapper.cpp b/packages/ScriptExecutor/src/BundleWrapper.cpp
index 28412cc..dbb9f50 100644
--- a/packages/ScriptExecutor/src/BundleWrapper.cpp
+++ b/packages/ScriptExecutor/src/BundleWrapper.cpp
@@ -17,7 +17,6 @@
#include "BundleWrapper.h"
#include <android-base/logging.h>
-#include <android_runtime/AndroidRuntime.h>
namespace com {
namespace android {
diff --git a/service/src/com/android/car/telemetry/systemmonitor/SystemMonitor.java b/service/src/com/android/car/telemetry/systemmonitor/SystemMonitor.java
index e9b1cb4..fec3fef 100644
--- a/service/src/com/android/car/telemetry/systemmonitor/SystemMonitor.java
+++ b/service/src/com/android/car/telemetry/systemmonitor/SystemMonitor.java
@@ -53,6 +53,7 @@
private final Context mContext;
private final ActivityManager mActivityManager;
private final String mLoadavgPath;
+ private final Runnable mSystemLoadRunnable = this::getSystemLoadRepeated;
@GuardedBy("mLock")
@Nullable private SystemMonitorCallback mCallback;
@@ -100,7 +101,7 @@
public void setSystemMonitorCallback(SystemMonitorCallback callback) {
synchronized (mLock) {
mCallback = callback;
- if (!mWorkerHandler.hasCallbacks(this::getSystemLoadRepeated)) {
+ if (!mSystemMonitorRunning) {
startSystemLoadMonitoring();
}
}
@@ -217,7 +218,7 @@
mCallback.onSystemMonitorEvent(event);
} finally {
if (mSystemMonitorRunning) {
- mWorkerHandler.postDelayed(this::getSystemLoadRepeated, POLL_INTERVAL_MILLIS);
+ mWorkerHandler.postDelayed(mSystemLoadRunnable, POLL_INTERVAL_MILLIS);
}
}
}
@@ -228,7 +229,7 @@
*/
private void startSystemLoadMonitoring() {
synchronized (mLock) {
- mWorkerHandler.post(this::getSystemLoadRepeated);
+ mWorkerHandler.post(mSystemLoadRunnable);
mSystemMonitorRunning = true;
}
}
@@ -239,7 +240,7 @@
@GuardedBy("mLock")
private void stopSystemLoadMonitoringLocked() {
synchronized (mLock) {
- mWorkerHandler.removeCallbacks(this::getSystemLoadRepeated);
+ mWorkerHandler.removeCallbacks(mSystemLoadRunnable);
mSystemMonitorRunning = false;
}
}
diff --git a/service/src/com/android/car/watchdog/WatchdogPerfHandler.java b/service/src/com/android/car/watchdog/WatchdogPerfHandler.java
index 19523b6..920de47 100644
--- a/service/src/com/android/car/watchdog/WatchdogPerfHandler.java
+++ b/service/src/com/android/car/watchdog/WatchdogPerfHandler.java
@@ -162,7 +162,6 @@
synchronized (mLock) {
checkAndHandleDateChangeLocked();
}
- mMainHandler.post(this::fetchAndSyncResourceOveruseConfigurations);
if (DEBUG) {
Slogf.d(TAG, "WatchdogPerfHandler is initialized");
}
@@ -185,15 +184,26 @@
/** Retries any pending requests on re-connecting to the daemon */
public void onDaemonConnectionChange(boolean isConnected) {
+ boolean hasPendingRequest;
synchronized (mLock) {
mIsConnectedToDaemon = isConnected;
+ hasPendingRequest = mPendingSetResourceOveruseConfigurationsRequest != null;
}
if (isConnected) {
- /*
- * Retry pending set resource overuse configuration request before processing any new
- * set/get requests. Thus notify the waiting requests only after the retry completes.
- */
- retryPendingSetResourceOveruseConfigurations();
+ if (hasPendingRequest) {
+ /*
+ * Retry pending set resource overuse configuration request before processing any
+ * new set/get requests. Thus notify the waiting requests only after the retry
+ * completes.
+ */
+ retryPendingSetResourceOveruseConfigurations();
+ } else {
+ /* Start fetch/sync configs only when there are no pending set requests because the
+ * above retry starts fetch/sync configs on success. If the retry fails, the daemon
+ * has crashed and shouldn't start fetchAndSyncResourceOveruseConfigurations.
+ */
+ mMainHandler.post(this::fetchAndSyncResourceOveruseConfigurations);
+ }
}
synchronized (mLock) {
mLock.notifyAll();
@@ -667,8 +677,6 @@
boolean hasRecurringOveruse = recurringIoOverusesByUid.valueAt(i);
String genericPackageName = genericPackageNamesByUid.get(uid);
int userId = UserHandle.getUserId(uid);
- String key = getUserPackageUniqueId(userId, genericPackageName);
- PackageResourceUsage usage = mUsageByUserPackage.get(key);
PackageResourceOveruseAction overuseAction = new PackageResourceOveruseAction();
overuseAction.packageIdentifier = new PackageIdentifier();
@@ -677,6 +685,13 @@
overuseAction.resourceTypes = new int[]{ ResourceType.IO };
overuseAction.resourceOveruseActionType = NOT_KILLED;
+ String key = getUserPackageUniqueId(userId, genericPackageName);
+ PackageResourceUsage usage = mUsageByUserPackage.get(key);
+ if (usage == null) {
+ /* This case shouldn't happen but placed here as a fail safe. */
+ mOveruseActionsByUserPackage.add(overuseAction);
+ continue;
+ }
List<String> packages = Collections.singletonList(genericPackageName);
if (usage.isSharedPackage()) {
packages = mPackageInfoHandler.getPackagesForUid(uid, genericPackageName);
diff --git a/tests/ThemePlayground/AndroidManifest.xml b/tests/ThemePlayground/AndroidManifest.xml
index cebff5e..8070a15 100644
--- a/tests/ThemePlayground/AndroidManifest.xml
+++ b/tests/ThemePlayground/AndroidManifest.xml
@@ -48,6 +48,12 @@
android:resizeableActivity="true"
android:allowEmbedded="true">
</activity>
+ <activity android:name=".ColorPalette"
+ android:label="@string/palette_elements"
+ android:windowSoftInputMode="stateUnchanged"
+ android:resizeableActivity="true"
+ android:allowEmbedded="true">
+ </activity>
<activity android:name=".ProgressBarSamples"
android:label="@string/progress_bar_elements"
android:windowSoftInputMode="stateUnchanged"
diff --git a/tests/ThemePlayground/res/layout/color_palette.xml b/tests/ThemePlayground/res/layout/color_palette.xml
new file mode 100644
index 0000000..e335b30
--- /dev/null
+++ b/tests/ThemePlayground/res/layout/color_palette.xml
@@ -0,0 +1,436 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 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
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <ScrollView
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_marginBottom="8dp"
+ android:layout_marginEnd="16dp"
+ android:layout_marginStart="16dp"
+ android:layout_marginTop="8dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_0">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_0"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_10">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_10"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_50">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_50"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_100">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_100"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_200">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_200"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_300">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_300"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_400">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_400"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_500">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_500"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_600">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_600"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_700">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_700"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_800">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_800"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_900">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_900"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent1_1000">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent1_1000"/>
+ </FrameLayout>
+
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_0">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_0"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_10">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_10"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_50">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_50"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_100">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_100"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_200">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_200"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_300">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_300"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_400">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_400"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_500">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_500"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_600">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_600"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_700">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_700"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_800">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_800"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_900">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_900"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent2_1000">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent2_1000"/>
+ </FrameLayout>
+
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_0">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_0"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_10">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_10"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_50">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_50"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_100">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_100"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_200">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_200"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_300">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_300"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_400">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_400"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_500">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_500"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_600">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_600"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_700">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_700"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_800">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_800"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_900">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_900"/>
+ </FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp"
+ android:background="@drawable/system_accent3_1000">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="*android:color/system_accent3_1000"/>
+ </FrameLayout>
+
+ </LinearLayout>
+ </ScrollView>
+ <include layout="@layout/menu_button"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/tests/ThemePlayground/res/menu/menu_main.xml b/tests/ThemePlayground/res/menu/menu_main.xml
index 8e4fd8c..647b02d 100644
--- a/tests/ThemePlayground/res/menu/menu_main.xml
+++ b/tests/ThemePlayground/res/menu/menu_main.xml
@@ -30,6 +30,10 @@
android:orderInCategory="100"
android:title="@string/panel_elements"/>
<item
+ android:id="@+id/palette_elements"
+ android:orderInCategory="100"
+ android:title="@string/palette_elements"/>
+ <item
android:id="@+id/progress_bar_elements"
android:orderInCategory="100"
android:title="@string/progress_bar_elements"/>
diff --git a/tests/ThemePlayground/res/values/drawables.xml b/tests/ThemePlayground/res/values/drawables.xml
new file mode 100644
index 0000000..aeb9c88
--- /dev/null
+++ b/tests/ThemePlayground/res/values/drawables.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 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.
+ -->
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <drawable name="system_accent1_0">@*android:color/system_accent1_0</drawable>
+ <drawable name="system_accent1_10">@*android:color/system_accent1_10</drawable>
+ <drawable name="system_accent1_50">@*android:color/system_accent1_50</drawable>
+ <drawable name="system_accent1_100">@*android:color/system_accent1_100</drawable>
+ <drawable name="system_accent1_200">@*android:color/system_accent1_200</drawable>
+ <drawable name="system_accent1_300">@*android:color/system_accent1_300</drawable>
+ <drawable name="system_accent1_400">@*android:color/system_accent1_400</drawable>
+ <drawable name="system_accent1_500">@*android:color/system_accent1_500</drawable>
+ <drawable name="system_accent1_600">@*android:color/system_accent1_600</drawable>
+ <drawable name="system_accent1_700">@*android:color/system_accent1_700</drawable>
+ <drawable name="system_accent1_800">@*android:color/system_accent1_800</drawable>
+ <drawable name="system_accent1_900">@*android:color/system_accent1_900</drawable>
+ <drawable name="system_accent1_1000">@*android:color/system_accent1_1000</drawable>
+
+ <drawable name="system_accent2_0">@*android:color/system_accent2_0</drawable>
+ <drawable name="system_accent2_10">@*android:color/system_accent2_10</drawable>
+ <drawable name="system_accent2_50">@*android:color/system_accent2_50</drawable>
+ <drawable name="system_accent2_100">@*android:color/system_accent2_100</drawable>
+ <drawable name="system_accent2_200">@*android:color/system_accent2_200</drawable>
+ <drawable name="system_accent2_300">@*android:color/system_accent2_300</drawable>
+ <drawable name="system_accent2_400">@*android:color/system_accent2_400</drawable>
+ <drawable name="system_accent2_500">@*android:color/system_accent2_500</drawable>
+ <drawable name="system_accent2_600">@*android:color/system_accent2_600</drawable>
+ <drawable name="system_accent2_700">@*android:color/system_accent2_700</drawable>
+ <drawable name="system_accent2_800">@*android:color/system_accent2_800</drawable>
+ <drawable name="system_accent2_900">@*android:color/system_accent2_900</drawable>
+ <drawable name="system_accent2_1000">@*android:color/system_accent2_1000</drawable>
+
+ <drawable name="system_accent3_0">@*android:color/system_accent3_0</drawable>
+ <drawable name="system_accent3_10">@*android:color/system_accent3_10</drawable>
+ <drawable name="system_accent3_50">@*android:color/system_accent3_50</drawable>
+ <drawable name="system_accent3_100">@*android:color/system_accent3_100</drawable>
+ <drawable name="system_accent3_200">@*android:color/system_accent3_200</drawable>
+ <drawable name="system_accent3_300">@*android:color/system_accent3_300</drawable>
+ <drawable name="system_accent3_400">@*android:color/system_accent3_400</drawable>
+ <drawable name="system_accent3_500">@*android:color/system_accent3_500</drawable>
+ <drawable name="system_accent3_600">@*android:color/system_accent3_600</drawable>
+ <drawable name="system_accent3_700">@*android:color/system_accent3_700</drawable>
+ <drawable name="system_accent3_800">@*android:color/system_accent3_800</drawable>
+ <drawable name="system_accent3_900">@*android:color/system_accent3_900</drawable>
+ <drawable name="system_accent3_1000">@*android:color/system_accent3_1000</drawable>
+
+</resources>
diff --git a/tests/ThemePlayground/res/values/strings.xml b/tests/ThemePlayground/res/values/strings.xml
index c355777..bd4b79a 100644
--- a/tests/ThemePlayground/res/values/strings.xml
+++ b/tests/ThemePlayground/res/values/strings.xml
@@ -20,6 +20,7 @@
<string name="button_elements" translatable="false">Button Elements</string>
<string name="progress_bar_elements" translatable="false">Progress Bar Elements</string>
<string name="panel_elements" translatable="false">Color Panels</string>
+ <string name="palette_elements" translatable="false">Color Palette</string>
<string name="dialog_elements" translatable="false">Dialogs</string>
<string name="toggle_theme" translatable="false">Change configuration(Day/Night)</string>
<string name="apply" translatable="false">Apply</string>
diff --git a/tests/ThemePlayground/src/com/android/car/themeplayground/AbstractSampleActivity.java b/tests/ThemePlayground/src/com/android/car/themeplayground/AbstractSampleActivity.java
index c197925..0f7cdfa 100644
--- a/tests/ThemePlayground/src/com/android/car/themeplayground/AbstractSampleActivity.java
+++ b/tests/ThemePlayground/src/com/android/car/themeplayground/AbstractSampleActivity.java
@@ -58,6 +58,8 @@
return startSampleActivity(ProgressBarSamples.class);
case R.id.panel_elements:
return startSampleActivity(ColorSamples.class);
+ case R.id.palette_elements:
+ return startSampleActivity(ColorPalette.class);
case R.id.dialog_elements:
return startSampleActivity(DialogSamples.class);
case R.id.toggle_theme:
diff --git a/tests/ThemePlayground/src/com/android/car/themeplayground/ColorPalette.java b/tests/ThemePlayground/src/com/android/car/themeplayground/ColorPalette.java
new file mode 100644
index 0000000..5f9f9ac
--- /dev/null
+++ b/tests/ThemePlayground/src/com/android/car/themeplayground/ColorPalette.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+package com.android.car.themeplayground;
+
+import android.os.Bundle;
+
+/**
+ * Activity that renders a bunch of color values from the theme.
+ */
+public class ColorPalette extends AbstractSampleActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Utils.onActivityCreateSetTheme(this);
+ setContentView(R.layout.color_palette);
+ }
+}
diff --git a/tests/carservice_unit_test/src/com/android/car/telemetry/systemmonitor/SystemMonitorUnitTest.java b/tests/carservice_unit_test/src/com/android/car/telemetry/systemmonitor/SystemMonitorUnitTest.java
index a16ea1e..09591be 100644
--- a/tests/carservice_unit_test/src/com/android/car/telemetry/systemmonitor/SystemMonitorUnitTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/telemetry/systemmonitor/SystemMonitorUnitTest.java
@@ -22,6 +22,7 @@
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -67,9 +68,16 @@
public void setup() {
when(mMockContext.getSystemService(anyString())).thenReturn(mMockActivityManager);
when(mMockHandler.post(any(Runnable.class))).thenAnswer(i -> {
- ((Runnable) i.getArguments()[0]).run();
+ Runnable runnable = i.getArgument(0);
+ runnable.run();
return true;
});
+ doAnswer(i -> {
+ MemoryInfo mi = i.getArgument(0);
+ mi.availMem = TEST_AVAILMEM;
+ mi.totalMem = TEST_TOTALMEM;
+ return null;
+ }).when(mMockActivityManager).getMemoryInfo(any(MemoryInfo.class));
}
@Test
@@ -142,13 +150,6 @@
public void testAfterSetCallback_callbackCalled() throws IOException {
SystemMonitor systemMonitor = new SystemMonitor(
mMockContext, mMockHandler, writeTempFile(TEST_LOADAVG));
- doAnswer(i -> {
- Object[] args = i.getArguments();
- MemoryInfo mi = (MemoryInfo) args[0];
- mi.availMem = TEST_AVAILMEM;
- mi.totalMem = TEST_TOTALMEM;
- return null;
- }).when(mMockActivityManager).getMemoryInfo(any(MemoryInfo.class));
systemMonitor.setSystemMonitorCallback(mMockCallback);
@@ -180,6 +181,21 @@
assertThat(systemMonitor.getCpuLoad()).isNull();
}
+ @Test
+ public void testWhenUnsetCallback_sameCallbackFromSetCallbackIsRemoved() throws IOException {
+ SystemMonitor systemMonitor = new SystemMonitor(
+ mMockContext, mMockHandler, writeTempFile(TEST_LOADAVG));
+
+ systemMonitor.setSystemMonitorCallback(mMockCallback);
+ systemMonitor.unsetSystemMonitorCallback();
+
+ verify(mMockHandler, times(1)).post(mRunnableCaptor.capture());
+ Runnable setRunnable = mRunnableCaptor.getValue();
+ verify(mMockHandler, times(1)).removeCallbacks(mRunnableCaptor.capture());
+ Runnable unsetRunnalbe = mRunnableCaptor.getValue();
+ assertThat(setRunnable).isEqualTo(unsetRunnalbe);
+ }
+
/**
* Creates and writes to the temp file, returns its path.
*/
diff --git a/tests/carservice_unit_test/src/com/android/car/watchdog/CarWatchdogServiceUnitTest.java b/tests/carservice_unit_test/src/com/android/car/watchdog/CarWatchdogServiceUnitTest.java
index 1189784..6ac2def 100644
--- a/tests/carservice_unit_test/src/com/android/car/watchdog/CarWatchdogServiceUnitTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/watchdog/CarWatchdogServiceUnitTest.java
@@ -97,6 +97,7 @@
import com.google.common.truth.Correspondence;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -124,6 +125,7 @@
private static final String CAR_WATCHDOG_DAEMON_INTERFACE = "carwatchdogd_system";
private static final int MAX_WAIT_TIME_MS = 3000;
private static final int INVALID_SESSION_ID = -1;
+ private static final int RESOURCE_OVERUSE_KILLING_DELAY_MILLS = 1000;
@Mock private Context mMockContext;
@Mock private PackageManager mMockPackageManager;
@@ -135,6 +137,7 @@
private ICarWatchdogServiceForSystem mWatchdogServiceForSystemImpl;
private IBinder.DeathRecipient mCarWatchdogDaemonBinderDeathRecipient;
private BroadcastReceiver mBroadcastReceiver;
+ private boolean mIsDaemonCrashed;
private final SparseArray<String> mGenericPackageNameByUid = new SparseArray<>();
private final SparseArray<List<String>> mPackagesBySharedUid = new SparseArray<>();
private final ArrayMap<String, android.content.pm.PackageInfo> mPmPackageInfoByUserPackage =
@@ -157,14 +160,33 @@
when(mMockContext.getPackageName()).thenReturn(
CarWatchdogServiceUnitTest.class.getCanonicalName());
mCarWatchdogService = new CarWatchdogService(mMockContext);
+ mCarWatchdogService.setResourceOveruseKillingDelay(RESOURCE_OVERUSE_KILLING_DELAY_MILLS);
mockWatchdogDaemon();
setupUsers();
mCarWatchdogService.init();
- verifyResourceOveruseConfigurationsSynced(1);
mWatchdogServiceForSystemImpl = registerCarWatchdogService();
captureBroadcastReceiver();
captureDaemonBinderDeathRecipient();
mockPackageManager();
+ verifyResourceOveruseConfigurationsSynced(1);
+ }
+
+ /**
+ * Releases resources.
+ */
+ @After
+ public void tearDown() throws Exception {
+ if (mIsDaemonCrashed) {
+ /* Note: On daemon crash, CarWatchdogService retries daemon connection on the main
+ * thread. This retry outlives the test and impacts other test runs. Thus always call
+ * restartWatchdogDaemonAndAwait after crashing the daemon and before completing
+ * teardown.
+ */
+ restartWatchdogDaemonAndAwait();
+ }
+ mGenericPackageNameByUid.clear();
+ mPackagesBySharedUid.clear();
+ mPmPackageInfoByUserPackage.clear();
}
@Test
@@ -312,7 +334,7 @@
/* remainingWriteBytes= */constructPerStateBytes(450, 120, 340),
/* writtenBytes= */constructPerStateBytes(5000, 6000, 9000),
/* totalOveruses= */2)));
- mWatchdogServiceForSystemImpl.latestIoOveruseStats(packageIoOveruseStats);
+ pushLatestIoOveruseStatsAndWait(packageIoOveruseStats);
List<ResourceOveruseStats> expectedStats = Arrays.asList(
constructResourceOveruseStats(1103456, "third_party_package",
@@ -364,7 +386,7 @@
/* writtenBytes= */constructPerStateBytes(80, 170, 260),
/* totalOveruses= */1)));
- mWatchdogServiceForSystemImpl.latestIoOveruseStats(packageIoOveruseStats);
+ pushLatestIoOveruseStatsAndWait(packageIoOveruseStats);
List<ResourceOveruseStats> expectedStats = Arrays.asList(
constructResourceOveruseStats(1103456, "shared:vendor_shared_package",
@@ -425,7 +447,7 @@
/* remainingWriteBytes= */constructPerStateBytes(450, 120, 340),
/* writtenBytes= */constructPerStateBytes(7000000, 6000, 9000),
/* totalOveruses= */2)));
- mWatchdogServiceForSystemImpl.latestIoOveruseStats(packageIoOveruseStats);
+ pushLatestIoOveruseStatsAndWait(packageIoOveruseStats);
List<ResourceOveruseStats> expectedStats = Collections.singletonList(
constructResourceOveruseStats(1201278, "vendor_package.critical",
@@ -459,7 +481,7 @@
/* remainingWriteBytes= */constructPerStateBytes(450, 120, 340),
/* writtenBytes= */constructPerStateBytes(500, 600, 900),
/* totalOveruses= */2)));
- mWatchdogServiceForSystemImpl.latestIoOveruseStats(packageIoOveruseStats);
+ pushLatestIoOveruseStatsAndWait(packageIoOveruseStats);
ResourceOveruseStats expectedStats =
constructResourceOveruseStats(1201278, "vendor_package.critical",
@@ -676,7 +698,7 @@
/* writtenBytes= */constructPerStateBytes(100, 200, 300),
/* totalOveruses= */2)));
- mWatchdogServiceForSystemImpl.latestIoOveruseStats(packageIoOveruseStats);
+ pushLatestIoOveruseStatsAndWait(packageIoOveruseStats);
verify(mockListener).onOveruse(any());
@@ -685,7 +707,7 @@
verify(mockListener, atLeastOnce()).asBinder();
verify(mockBinder).unlinkToDeath(any(IBinder.DeathRecipient.class), anyInt());
- mWatchdogServiceForSystemImpl.latestIoOveruseStats(packageIoOveruseStats);
+ pushLatestIoOveruseStatsAndWait(packageIoOveruseStats);
verifyNoMoreInteractions(mockListener);
}
@@ -901,38 +923,34 @@
@Test
public void testGetPackageKillableStatesAsUserWithSafeToKillPackages() throws Exception {
- android.automotive.watchdog.internal.ResourceOveruseConfiguration systemConfig =
- new android.automotive.watchdog.internal.ResourceOveruseConfiguration();
- systemConfig.componentType = ComponentType.SYSTEM;
- systemConfig.safeToKillPackages = Collections.singletonList("system_package.non_critical");
- android.automotive.watchdog.internal.ResourceOveruseConfiguration vendorConfig =
- new android.automotive.watchdog.internal.ResourceOveruseConfiguration();
- vendorConfig.componentType = ComponentType.VENDOR;
- vendorConfig.safeToKillPackages = Collections.singletonList("vendor_package.non_critical");
- when(mMockCarWatchdogDaemon.getResourceOveruseConfigurations())
- .thenReturn(Arrays.asList(systemConfig, vendorConfig));
- mCarWatchdogService.init();
mockUmGetAliveUsers(mMockUserManager, 11, 12);
+ List<android.automotive.watchdog.internal.ResourceOveruseConfiguration> configs =
+ sampleInternalResourceOveruseConfigurations();
+ injectResourceOveruseConfigsAndWait(configs);
injectPackageInfos(Arrays.asList(
- constructPackageManagerPackageInfo("system_package.non_critical", 1102459, null),
+ constructPackageManagerPackageInfo("system_package.non_critical.A", 1102459, null),
constructPackageManagerPackageInfo("third_party_package", 1103456, null),
- constructPackageManagerPackageInfo("vendor_package.critical", 1101278, null),
- constructPackageManagerPackageInfo("vendor_package.non_critical", 1105573, null),
+ constructPackageManagerPackageInfo("vendor_package.critical.B", 1101278, null),
+ constructPackageManagerPackageInfo("vendor_package.non_critical.A", 1105573, null),
constructPackageManagerPackageInfo("third_party_package", 1203456, null),
- constructPackageManagerPackageInfo("vendor_package.critical", 1201278, null)));
+ constructPackageManagerPackageInfo("vendor_package.critical.B", 1201278, null)));
PackageKillableStateSubject.assertThat(
- mCarWatchdogService.getPackageKillableStatesAsUser(new UserHandle(11)))
+ mCarWatchdogService.getPackageKillableStatesAsUser(UserHandle.ALL))
.containsExactly(
- new PackageKillableState("system_package.non_critical", 11,
+ new PackageKillableState("system_package.non_critical.A", 11,
PackageKillableState.KILLABLE_STATE_YES),
new PackageKillableState("third_party_package", 11,
PackageKillableState.KILLABLE_STATE_YES),
- new PackageKillableState("vendor_package.critical", 11,
+ new PackageKillableState("vendor_package.critical.B", 11,
PackageKillableState.KILLABLE_STATE_NEVER),
- new PackageKillableState("vendor_package.non_critical", 11,
- PackageKillableState.KILLABLE_STATE_YES));
+ new PackageKillableState("vendor_package.non_critical.A", 11,
+ PackageKillableState.KILLABLE_STATE_YES),
+ new PackageKillableState("third_party_package", 12,
+ PackageKillableState.KILLABLE_STATE_YES),
+ new PackageKillableState("vendor_package.critical.B", 12,
+ PackageKillableState.KILLABLE_STATE_NEVER));
}
@Test
@@ -968,15 +986,13 @@
@Test
public void testGetPackageKillableStatesAsUserWithSharedUidsAndSafeToKillPackages()
throws Exception {
+ mockUmGetAliveUsers(mMockUserManager, 11);
android.automotive.watchdog.internal.ResourceOveruseConfiguration vendorConfig =
new android.automotive.watchdog.internal.ResourceOveruseConfiguration();
vendorConfig.componentType = ComponentType.VENDOR;
vendorConfig.safeToKillPackages = Collections.singletonList(
"vendor_package.non_critical.A");
- when(mMockCarWatchdogDaemon.getResourceOveruseConfigurations())
- .thenReturn(Arrays.asList(vendorConfig));
- mCarWatchdogService.init();
- mockUmGetAliveUsers(mMockUserManager, 11);
+ injectResourceOveruseConfigsAndWait(Collections.singletonList(vendorConfig));
injectPackageInfos(Arrays.asList(
constructPackageManagerPackageInfo(
@@ -1008,15 +1024,13 @@
@Test
public void testGetPackageKillableStatesAsUserWithSharedUidsAndSafeToKillSharedPackage()
throws Exception {
+ mockUmGetAliveUsers(mMockUserManager, 11);
android.automotive.watchdog.internal.ResourceOveruseConfiguration vendorConfig =
new android.automotive.watchdog.internal.ResourceOveruseConfiguration();
vendorConfig.componentType = ComponentType.VENDOR;
vendorConfig.safeToKillPackages = Collections.singletonList(
"shared:vendor_shared_package.B");
- when(mMockCarWatchdogDaemon.getResourceOveruseConfigurations())
- .thenReturn(Arrays.asList(vendorConfig));
- mCarWatchdogService.init();
- mockUmGetAliveUsers(mMockUserManager, 11);
+ injectResourceOveruseConfigsAndWait(Collections.singletonList(vendorConfig));
injectPackageInfos(Arrays.asList(
constructPackageManagerPackageInfo(
@@ -1383,7 +1397,6 @@
int nonCriticalVndrPkgUid = getUid(2564);
int thirdPartyPkgUid = getUid(2044);
- mCarWatchdogService.setResourceOveruseKillingDelay(1000);
injectPackageInfos(Arrays.asList(
constructPackageManagerPackageInfo(
"system_package.critical", criticalSysPkgUid, null),
@@ -1432,14 +1445,7 @@
/* writtenBytes= */constructPerStateBytes(100, 200, 300),
/* totalOveruses= */2)));
- mWatchdogServiceForSystemImpl.latestIoOveruseStats(packageIoOveruseStats);
-
- /*
- * Handling of packages that exceed I/O thresholds is done on the main thread. To ensure
- * the handling completes before verification, wait for the message to be posted on the
- * main thread and execute an empty block on the main thread.
- */
- delayedRunOnMainSync(() -> {}, /* delayMillis= */2000);
+ pushLatestIoOveruseStatsAndWait(packageIoOveruseStats);
List<ResourceOveruseStats> expectedStats = new ArrayList<>();
@@ -1480,7 +1486,6 @@
int nonCriticalVndrSharedUid = getUid(2564);
int thirdPartySharedUid = getUid(2044);
- mCarWatchdogService.setResourceOveruseKillingDelay(1000);
injectPackageInfos(Arrays.asList(
constructPackageManagerPackageInfo(
"system_package.A", criticalSysSharedUid, "system_shared_package"),
@@ -1526,14 +1531,7 @@
/* writtenBytes= */constructPerStateBytes(100, 200, 300),
/* totalOveruses= */2)));
- mWatchdogServiceForSystemImpl.latestIoOveruseStats(packageIoOveruseStats);
-
- /*
- * Handling of packages that exceed I/O thresholds is done on the main thread. To ensure
- * the handling completes before verification, wait for the message to be posted on the
- * main thread and execute an empty block on the main thread.
- */
- delayedRunOnMainSync(() -> {}, /* delayMillis= */2000);
+ pushLatestIoOveruseStatsAndWait(packageIoOveruseStats);
List<ResourceOveruseStats> expectedStats = new ArrayList<>();
@@ -1791,12 +1789,10 @@
when(mMockBinder.queryLocalInterface(anyString())).thenReturn(mMockCarWatchdogDaemon);
when(mMockCarWatchdogDaemon.asBinder()).thenReturn(mMockBinder);
doReturn(mMockBinder).when(() -> ServiceManager.getService(CAR_WATCHDOG_DAEMON_INTERFACE));
+ mIsDaemonCrashed = false;
}
private void mockPackageManager() throws Exception {
- mGenericPackageNameByUid.clear();
- mPackagesBySharedUid.clear();
- mPmPackageInfoByUserPackage.clear();
when(mMockPackageManager.getNamesForUids(any())).thenAnswer(args -> {
int[] uids = args.getArgument(0);
String[] names = new String[uids.length];
@@ -1866,12 +1862,13 @@
mCarWatchdogDaemonBinderDeathRecipient = deathRecipientCaptor.getValue();
}
- public void crashWatchdogDaemon() {
+ private void crashWatchdogDaemon() {
doReturn(null).when(() -> ServiceManager.getService(CAR_WATCHDOG_DAEMON_INTERFACE));
mCarWatchdogDaemonBinderDeathRecipient.binderDied();
+ mIsDaemonCrashed = true;
}
- public void restartWatchdogDaemonAndAwait() throws Exception {
+ private void restartWatchdogDaemonAndAwait() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
doAnswer(args -> {
latch.countDown();
@@ -1879,6 +1876,11 @@
}).when(mMockBinder).linkToDeath(any(), anyInt());
mockWatchdogDaemon();
latch.await(MAX_WAIT_TIME_MS, TimeUnit.MILLISECONDS);
+ /* On daemon connect, CarWatchdogService posts a new message on the main thread to fetch
+ * the resource overuse configs. Post a message on the same thread and wait until the fetch
+ * completes, so the tests are deterministic.
+ */
+ CarServiceUtils.runOnMainSync(() -> {});
}
private void setupUsers() {
@@ -1933,6 +1935,17 @@
return resourceOveruseConfigurationsCaptor.getValue();
}
+ private void injectResourceOveruseConfigsAndWait(
+ List<android.automotive.watchdog.internal.ResourceOveruseConfiguration> configs)
+ throws Exception {
+ when(mMockCarWatchdogDaemon.getResourceOveruseConfigurations()).thenReturn(configs);
+ /* Trigger CarWatchdogService to fetch/sync resource overuse configurations by changing the
+ * daemon connection status from connected -> disconnected -> connected.
+ */
+ crashWatchdogDaemon();
+ restartWatchdogDaemonAndAwait();
+ }
+
private SparseArray<PackageIoOveruseStats> injectIoOveruseStatsForPackages(
SparseArray<String> genericPackageNameByUid, Set<String> killablePackages,
Set<String> shouldNotifyPackages) throws Exception {
@@ -1950,7 +1963,7 @@
packageIoOveruseStatsByUid.put(uid, stats);
packageIoOveruseStats.add(stats);
}
- mWatchdogServiceForSystemImpl.latestIoOveruseStats(packageIoOveruseStats);
+ pushLatestIoOveruseStatsAndWait(packageIoOveruseStats);
return packageIoOveruseStatsByUid;
}
@@ -1990,6 +2003,17 @@
anyInt(), eq(UserHandle.myUserId()), anyString());
}
+ private void pushLatestIoOveruseStatsAndWait(
+ List<PackageIoOveruseStats> packageIoOveruseStats) throws Exception {
+ mWatchdogServiceForSystemImpl.latestIoOveruseStats(packageIoOveruseStats);
+ /* The latestIoOveruseStats call performs resource overuse killing/disabling on the main
+ * thread by posting a new message with RESOURCE_OVERUSE_KILLING_DELAY_MILLS delay. Ensure
+ * this message is processed before returning so the effects of the killing/disabling is
+ * verified.
+ */
+ delayedRunOnMainSync(() -> {}, RESOURCE_OVERUSE_KILLING_DELAY_MILLS * 2);
+ }
+
private void verifyActionsTakenOnResourceOveruse(List<PackageResourceOveruseAction> expected)
throws Exception {
ArgumentCaptor<List<PackageResourceOveruseAction>> resourceOveruseActionsCaptor =
@@ -2057,11 +2081,13 @@
private static ResourceOveruseConfiguration.Builder sampleResourceOveruseConfigurationBuilder(
int componentType, IoOveruseConfiguration ioOveruseConfig) {
- String prefix = WatchdogPerfHandler.toComponentTypeStr(componentType);
- List<String> safeToKill = Arrays.asList(prefix + "_package.A", prefix + "_pkg.B");
+ String prefix = WatchdogPerfHandler.toComponentTypeStr(componentType).toLowerCase();
+ List<String> safeToKill = Arrays.asList(prefix + "_package.non_critical.A",
+ prefix + "_pkg.non_critical.B");
List<String> vendorPrefixes = Arrays.asList(prefix + "_package", prefix + "_pkg");
Map<String, String> pkgToAppCategory = new ArrayMap<>();
- pkgToAppCategory.put(prefix + "_package.A", "android.car.watchdog.app.category.MEDIA");
+ pkgToAppCategory.put(prefix + "_package.non_critical.A",
+ "android.car.watchdog.app.category.MEDIA");
ResourceOveruseConfiguration.Builder configBuilder =
new ResourceOveruseConfiguration.Builder(componentType, safeToKill,
vendorPrefixes, pkgToAppCategory);
@@ -2071,7 +2097,7 @@
private static IoOveruseConfiguration.Builder sampleIoOveruseConfigurationBuilder(
int componentType) {
- String prefix = WatchdogPerfHandler.toComponentTypeStr(componentType);
+ String prefix = WatchdogPerfHandler.toComponentTypeStr(componentType).toLowerCase();
PerStateBytes componentLevelThresholds = new PerStateBytes(
/* foregroundModeBytes= */10, /* backgroundModeBytes= */20,
/* garageModeBytes= */30);
@@ -2101,15 +2127,16 @@
private static android.automotive.watchdog.internal.ResourceOveruseConfiguration
sampleInternalResourceOveruseConfiguration(int componentType,
android.automotive.watchdog.internal.IoOveruseConfiguration ioOveruseConfig) {
- String prefix = WatchdogPerfHandler.toComponentTypeStr(componentType);
+ String prefix = WatchdogPerfHandler.toComponentTypeStr(componentType).toLowerCase();
android.automotive.watchdog.internal.ResourceOveruseConfiguration config =
new android.automotive.watchdog.internal.ResourceOveruseConfiguration();
config.componentType = componentType;
- config.safeToKillPackages = Arrays.asList(prefix + "_package.A", prefix + "_pkg.B");
+ config.safeToKillPackages = Arrays.asList(prefix + "_package.non_critical.A",
+ prefix + "_pkg.non_critical.B");
config.vendorPackagePrefixes = Arrays.asList(prefix + "_package", prefix + "_pkg");
PackageMetadata metadata = new PackageMetadata();
- metadata.packageName = prefix + "_package.A";
+ metadata.packageName = prefix + "_package.non_critical.A";
metadata.appCategoryType = ApplicationCategoryType.MEDIA;
config.packageMetadata = Collections.singletonList(metadata);
@@ -2122,11 +2149,12 @@
private static android.automotive.watchdog.internal.IoOveruseConfiguration
sampleInternalIoOveruseConfiguration(int componentType) {
- String prefix = WatchdogPerfHandler.toComponentTypeStr(componentType);
+ String prefix = WatchdogPerfHandler.toComponentTypeStr(componentType).toLowerCase();
android.automotive.watchdog.internal.IoOveruseConfiguration config =
new android.automotive.watchdog.internal.IoOveruseConfiguration();
- config.componentLevelThresholds = constructPerStateIoOveruseThreshold(prefix,
- /* fgBytes= */10, /* bgBytes= */20, /* gmBytes= */30);
+ config.componentLevelThresholds = constructPerStateIoOveruseThreshold(
+ WatchdogPerfHandler.toComponentTypeStr(componentType), /* fgBytes= */10,
+ /* bgBytes= */20, /* gmBytes= */30);
config.packageSpecificThresholds = Collections.singletonList(
constructPerStateIoOveruseThreshold(prefix + "_package.A", /* fgBytes= */40,
/* bgBytes= */50, /* gmBytes= */60));