Merge "Update restriciton page to support legacy string" into sc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 323ce38..61c0c4e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2887,6 +2887,7 @@
<!-- Confirmation dialog for enabling notification access from CompanionDeviceManager -->
<activity android:name=".notification.NotificationAccessConfirmationActivity"
+ android:taskAffinity=".notification.NotificationAccessConfirmationActivity"
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert" />
<receiver android:name="com.android.settingslib.bluetooth.BluetoothDiscoverableTimeoutReceiver"
diff --git a/res/drawable/ic_face_enroll_introduction_glasses.xml b/res/drawable/ic_face_enroll_introduction_glasses.xml
new file mode 100644
index 0000000..5b259d6
--- /dev/null
+++ b/res/drawable/ic_face_enroll_introduction_glasses.xml
@@ -0,0 +1,28 @@
+<!--
+ ~ 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="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
+
+ <path
+ android:fillColor="#000000"
+ android:pathData="M18.75,7C16.26,7 14.19,8.74 13.65,11.065C12.39,10.525 11.22,10.675 10.35,11.05C9.795,8.725 7.725,7 5.25,7C2.355,7 0,9.355 0,12.25C0,15.145 2.355,17.5 5.25,17.5C8.01,17.5 10.245,15.37 10.455,12.67C10.905,12.355 12.09,11.77 13.545,12.7C13.785,15.385 16.005,17.5 18.75,17.5C21.645,17.5 24,15.145 24,12.25C24,9.355 21.645,7 18.75,7ZM5.25,16C3.18,16 1.5,14.32 1.5,12.25C1.5,10.18 3.18,8.5 5.25,8.5C7.32,8.5 9,10.18 9,12.25C9,14.32 7.32,16 5.25,16ZM18.75,16C16.68,16 15,14.32 15,12.25C15,10.18 16.68,8.5 18.75,8.5C20.82,8.5 22.5,10.18 22.5,12.25C22.5,14.32 20.82,16 18.75,16Z" />
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_homepage_about_v2.xml b/res/drawable/ic_homepage_about_v2.xml
deleted file mode 100644
index c069bfc..0000000
--- a/res/drawable/ic_homepage_about_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_about_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_phone_info" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_accessibility_v2.xml b/res/drawable/ic_homepage_accessibility_v2.xml
deleted file mode 100644
index 24ca8cf..0000000
--- a/res/drawable/ic_homepage_accessibility_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_accessibility_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_settings_accessibility" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_accounts_v2.xml b/res/drawable/ic_homepage_accounts_v2.xml
deleted file mode 100644
index 6ea981f..0000000
--- a/res/drawable/ic_homepage_accounts_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_accounts_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_settings_accounts" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_apps_v2.xml b/res/drawable/ic_homepage_apps_v2.xml
deleted file mode 100644
index c6ac0c4..0000000
--- a/res/drawable/ic_homepage_apps_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_app_and_notification_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_apps" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_battery_v2.xml b/res/drawable/ic_homepage_battery_v2.xml
deleted file mode 100644
index 680031f..0000000
--- a/res/drawable/ic_homepage_battery_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_battery_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_settings_battery_white" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_connected_device_v2.xml b/res/drawable/ic_homepage_connected_device_v2.xml
deleted file mode 100644
index f3e95d2..0000000
--- a/res/drawable/ic_homepage_connected_device_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_connected_device_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_devices_other" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_display_v2.xml b/res/drawable/ic_homepage_display_v2.xml
deleted file mode 100644
index e4014ee..0000000
--- a/res/drawable/ic_homepage_display_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_display_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_settings_display_white" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_emergency_v2.xml b/res/drawable/ic_homepage_emergency_v2.xml
deleted file mode 100644
index 86d1470..0000000
--- a/res/drawable/ic_homepage_emergency_v2.xml
+++ /dev/null
@@ -1,33 +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.
- -->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_emergency_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_settings_emergency" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_location_v2.xml b/res/drawable/ic_homepage_location_v2.xml
deleted file mode 100644
index 5dc72eb..0000000
--- a/res/drawable/ic_homepage_location_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_location_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_settings_location"/>
-</layer-list>
diff --git a/res/drawable/ic_homepage_network_v2.xml b/res/drawable/ic_homepage_network_v2.xml
deleted file mode 100644
index d3b33e9..0000000
--- a/res/drawable/ic_homepage_network_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_network_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_settings_wireless_white" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_notification_v2.xml b/res/drawable/ic_homepage_notification_v2.xml
deleted file mode 100644
index 3883cfb..0000000
--- a/res/drawable/ic_homepage_notification_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2020 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_notification_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_notifications_white" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_privacy_v2.xml b/res/drawable/ic_homepage_privacy_v2.xml
deleted file mode 100644
index 56e6da8..0000000
--- a/res/drawable/ic_homepage_privacy_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_privacy_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_settings_privacy"/>
-</layer-list>
diff --git a/res/drawable/ic_homepage_security_v2.xml b/res/drawable/ic_homepage_security_v2.xml
deleted file mode 100644
index 5e33add..0000000
--- a/res/drawable/ic_homepage_security_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_security_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_settings_security_white" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_sound_v2.xml b/res/drawable/ic_homepage_sound_v2.xml
deleted file mode 100644
index 8561820..0000000
--- a/res/drawable/ic_homepage_sound_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_sound_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_volume_up_24dp" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_storage_v2.xml b/res/drawable/ic_homepage_storage_v2.xml
deleted file mode 100644
index 1a8b7d2..0000000
--- a/res/drawable/ic_homepage_storage_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_storage_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_storage_white" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_support_v2.xml b/res/drawable/ic_homepage_support_v2.xml
deleted file mode 100644
index 8139973..0000000
--- a/res/drawable/ic_homepage_support_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_support_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_help" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_system_dashboard_v2.xml b/res/drawable/ic_homepage_system_dashboard_v2.xml
deleted file mode 100644
index 7c016a2..0000000
--- a/res/drawable/ic_homepage_system_dashboard_v2.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_system_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_settings_system_dashboard_white" />
-</layer-list>
diff --git a/res/drawable/ic_homepage_wallpaper_v2.xml b/res/drawable/ic_homepage_wallpaper_v2.xml
deleted file mode 100644
index ee16339..0000000
--- a/res/drawable/ic_homepage_wallpaper_v2.xml
+++ /dev/null
@@ -1,33 +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.
- -->
-
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item>
- <com.android.settingslib.widget.AdaptiveIconShapeDrawable
- android:width="@dimen/homepage_image_size"
- android:height="@dimen/homepage_image_size"
- android:color="@color/homepage_wallpaper_background" />
- </item>
-
- <item
- android:width="@dimen/dashboard_tile_foreground_image_size"
- android:height="@dimen/dashboard_tile_foreground_image_size"
- android:start="@dimen/homepage_foreground_image_inset"
- android:top="@dimen/homepage_foreground_image_inset"
- android:drawable="@drawable/ic_settings_wallpaper_white" />
-</layer-list>
diff --git a/res/layout/battery_chart_graph.xml b/res/layout/battery_chart_graph.xml
index 21973a4..65d41cf 100644
--- a/res/layout/battery_chart_graph.xml
+++ b/res/layout/battery_chart_graph.xml
@@ -28,7 +28,7 @@
android:layout_height="wrap_content"
android:layout_marginVertical="16dp"
android:textAppearance="?android:attr/textAppearanceSmall"
- settings:textColor="?android:attr/textColorSecondary"
+ android:textColor="?android:attr/textColorSecondary"
android:text="@string/battery_usage_chart_graph_hint" />
<com.android.settings.fuelgauge.BatteryChartView
@@ -37,6 +37,7 @@
android:layout_height="165dp"
android:layout_marginBottom="16dp"
android:visibility="invisible"
+ android:contentDescription="@string/battery_usage_chart"
android:textAppearance="?android:attr/textAppearanceSmall"
settings:textColor="?android:attr/textColorSecondary" />
<TextView
diff --git a/res/layout/dialog_single_radio_choice_list_item.xml b/res/layout/dialog_single_radio_choice_list_item.xml
index 5842528..49ef352 100644
--- a/res/layout/dialog_single_radio_choice_list_item.xml
+++ b/res/layout/dialog_single_radio_choice_list_item.xml
@@ -50,7 +50,7 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:layout_marginTop="8dp"
- android:layout_alignLeft="@id/title"
+ android:layout_alignStart="@id/title"
android:layout_below="@id/title" />
<ImageView
@@ -59,6 +59,6 @@
android:layout_height="@dimen/accessibility_imageview_size"
android:layout_marginTop="16dp"
android:scaleType="fitStart"
- android:layout_alignLeft="@id/title"
+ android:layout_alignStart="@id/title"
android:layout_below="@id/summary"/>
</com.android.settings.widget.CheckableRelativeLayout>
\ No newline at end of file
diff --git a/res/layout/face_enroll_introduction.xml b/res/layout/face_enroll_introduction.xml
index 826f5fe..22dba83 100644
--- a/res/layout/face_enroll_introduction.xml
+++ b/res/layout/face_enroll_introduction.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- ~ Copyright (C) 2019 The Android Open Source Project
+ ~ 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.
@@ -12,7 +12,7 @@
~ 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
+ ~ limitations under the License.
-->
<com.google.android.setupdesign.GlifLayout
@@ -32,13 +32,6 @@
android:orientation="vertical">
<com.google.android.setupdesign.view.RichTextView
- android:id="@+id/sud_layout_description"
- style="@style/SudDescription.Glif"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/security_settings_face_enroll_introduction_message"/>
-
- <com.google.android.setupdesign.view.RichTextView
android:id="@+id/error_text"
style="@style/SudDescription.Glif"
android:layout_width="match_parent"
@@ -48,7 +41,7 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginVertical="12dp">
+ android:layout_marginBottom="12dp">
<com.google.android.setupdesign.view.IllustrationVideoView
android:id="@+id/illustration_normal"
@@ -67,23 +60,35 @@
android:layout_gravity="center_horizontal|bottom"
android:paddingTop="12dp">
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_face_enroll_introduction_info_title"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="20sp"/>
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal">
+ android:orientation="horizontal"
+ android:paddingTop="24dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:background="@drawable/ic_info_outline_24dp">
- </ImageView>
+ android:background="@drawable/ic_face_enroll_introduction_glasses"/>
+
<Space
- android:layout_width="24dp"
+ android:layout_width="16dp"
android:layout_height="wrap_content"/>
+
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/security_settings_face_enroll_introduction_footer_part_0"/>
+ android:text="@string/security_settings_face_enroll_introduction_info_glasses"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="16sp"
+ android:lineSpacingExtra="4sp"/>
</LinearLayout>
@@ -96,15 +101,19 @@
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:background="@drawable/ic_face_enroll_introduction_shield">
- </ImageView>
+ android:background="@drawable/ic_face_enroll_introduction_visibility"/>
+
<Space
- android:layout_width="24dp"
+ android:layout_width="16dp"
android:layout_height="wrap_content"/>
+
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:text="@string/security_settings_face_enroll_introduction_footer_part_1"/>
+ android:text="@string/security_settings_face_enroll_introduction_info_looking"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="16sp"
+ android:lineSpacingExtra="4sp"/>
</LinearLayout>
@@ -117,40 +126,70 @@
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:background="@drawable/ic_face_enroll_introduction_visibility">
- </ImageView>
+ android:background="@drawable/ic_face_enroll_introduction_shield"/>
+
<Space
- android:layout_width="24dp"
+ android:layout_width="16dp"
android:layout_height="wrap_content"/>
+
<TextView
- android:id="@+id/face_enroll_introduction_footer_part_2"
android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_face_enroll_introduction_info_security"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="16sp"
+ android:lineSpacingExtra="4sp"/>
</LinearLayout>
- <LinearLayout
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="40dp"/>
+
+ <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:paddingTop="24dp">
+ android:text="@string/security_settings_face_enroll_introduction_how_title"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="20sp"/>
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/ic_face_enroll_introduction_people">
- </ImageView>
- <Space
- android:layout_width="24dp"
- android:layout_height="wrap_content"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/security_settings_face_enroll_introduction_footer_part_3"/>
- </LinearLayout>
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="24dp"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_face_enroll_introduction_how_message"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="14sp"
+ android:lineSpacingExtra="2sp"/>
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="24dp"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_face_enroll_introduction_control_title"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="20sp"/>
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="24dp"/>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_face_enroll_introduction_control_message"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="14sp"
+ android:lineSpacingExtra="2sp"/>
</LinearLayout>
</LinearLayout>
-</com.google.android.setupdesign.GlifLayout>
+</com.google.android.setupdesign.GlifLayout>
\ No newline at end of file
diff --git a/res/layout/fingerprint_enroll_introduction.xml b/res/layout/fingerprint_enroll_introduction.xml
index acf516f..03a8e7f 100644
--- a/res/layout/fingerprint_enroll_introduction.xml
+++ b/res/layout/fingerprint_enroll_introduction.xml
@@ -155,6 +155,55 @@
</LinearLayout>
+ <!-- Keep in mind -->
+ <com.google.android.setupdesign.view.RichTextView
+ style="@style/SudDescription.Glif"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAlignment="viewStart"
+ android:paddingTop="12dp"
+ android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_2" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingTop="12dp">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:contentDescription="@null"
+ android:src="@drawable/ic_info_outline_24dp"/>
+ <Space
+ android:layout_width="24dp"
+ android:layout_height="wrap_content"/>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_5" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingTop="12dp">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:contentDescription="@null"
+ android:src="@drawable/ic_link_24dp"/>
+ <Space
+ android:layout_width="24dp"
+ android:layout_height="wrap_content"/>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_fingerprint_v2_enroll_introduction_message_learn_more" />
+ </LinearLayout>
+
</LinearLayout>
</com.google.android.setupdesign.GlifLayout>
diff --git a/res/layout/homepage_preference.xml b/res/layout/homepage_preference.xml
deleted file mode 100644
index 480340a..0000000
--- a/res/layout/homepage_preference.xml
+++ /dev/null
@@ -1,75 +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.
- -->
-
-<LinearLayout
- 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="wrap_content"
- android:minHeight="72dp"
- android:gravity="center_vertical"
- android:paddingStart="24dp"
- android:paddingEnd="24dp"
- android:background="?android:attr/selectableItemBackground"
- android:clipToPadding="false"
- android:baselineAligned="false">
-
- <LinearLayout
- android:id="@+id/icon_frame"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="start|center_vertical"
- android:orientation="horizontal"
- android:paddingTop="4dp"
- android:paddingBottom="4dp"
- android:layout_marginEnd="16dp">
-
- <androidx.preference.internal.PreferenceImageView
- android:id="@android:id/icon"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:maxWidth="48dp"
- app:maxHeight="48dp"/>
-
- </LinearLayout>
-
- <RelativeLayout
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:paddingTop="16dp"
- android:paddingBottom="16dp">
-
- <TextView
- android:id="@android:id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:textAppearance="@style/TextAppearance.HomepagePreferenceTitle"
- android:ellipsize="marquee"/>
-
- <TextView android:id="@android:id/summary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@android:id/title"
- android:layout_alignStart="@android:id/title"
- android:layout_alignLeft="@android:id/title"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/textColorSecondary"
- android:maxLines="4"/>
- </RelativeLayout>
-</LinearLayout>
\ No newline at end of file
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 6661410..f8caff3 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1523,7 +1523,6 @@
[CHAR LIMIT=NONE] -->
<string-array name="allowlist_hide_entry_in_battery_usage" translatable="false">
<item>"com.google.android.gms.persistent"</item>
- <item>"dex2oat64"</item>
</string-array>
<!-- Array of titles palette list for accessibility. -->
diff --git a/res/values/config.xml b/res/values/config.xml
index b2323c2..d37db44 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -269,11 +269,6 @@
<!-- ComponentName to launch a vendor-specific enrollment activity if available -->
<string name="config_face_enroll" translatable="false"></string>
- <!-- Fully qualified name of the introductory activity for face enrollment. -->
- <string name="config_face_enroll_introduction" translatable="false">
- com.android.settings.biometrics.face.FaceEnrollIntroduction
- </string>
-
<!-- App intent -->
<string name="config_account_intent_uri" translatable="false"></string>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 076ab04..6197282 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -118,12 +118,6 @@
<!-- Dashboard foreground image inset (from background edge to foreground edge) -->
<dimen name="dashboard_tile_foreground_image_inset">6dp</dimen>
- <!-- Homepage image tile size -->
- <dimen name="homepage_image_size">48dp</dimen>
-
- <!-- Homepage foreground image inset (from background edge to foreground edge) -->
- <dimen name="homepage_foreground_image_inset">12dp</dimen>
-
<!-- Preference icon foreground image inset (from background edge to foreground edge) -->
<dimen name="preference_icon_foreground_image_inset">12dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a2119fb1..b49127a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -731,13 +731,7 @@
<!-- In the security screen, the header title for security statuses -->
<string name="security_status_title">Security status</string>
<!-- Summary for Security settings, explaining a few important settings under it [CHAR LIMIT=NONE] -->
- <string name="security_dashboard_summary_face">Screen lock, face unlock</string>
- <!-- Summary for Security settings, explaining a few important settings under it [CHAR LIMIT=NONE] -->
- <string name="security_dashboard_summary">Screen lock, fingerprint</string>
- <!-- Summary for Security settings when fingerprint is not supported [CHAR LIMIT=NONE]-->
- <string name="security_dashboard_summary_no_fingerprint">Screen lock</string>
- <!-- Summary for Security settings when biometric unlock is supported [CHAR LIMIT=NONE] -->
- <string name="security_dashboard_summary_biometric">Screen lock, biometric unlock, app security</string>
+ <string name="security_dashboard_summary">Screen lock, Find My Device, app security</string>
<!-- Face enrollment and settings --><skip />
<!-- Message shown in summary field when face unlock is set up. [CHAR LIMIT=40] -->
@@ -777,7 +771,7 @@
<!-- Button text to cancel enrollment [CHAR LIMIT=30] -->
<string name="security_settings_face_enroll_introduction_no_thanks">No thanks</string>
<!-- Button text to start enrollment [CHAR LIMIT=30] -->
- <string name="security_settings_face_enroll_introduction_agree">Agree</string>
+ <string name="security_settings_face_enroll_introduction_agree">I agree</string>
<!-- Button text to scroll to the end of a scrollview. [CHAR LIMIT=30] -->
<string name="security_settings_face_enroll_introduction_more">More</string>
<!-- Introduction title shown in face enrollment to introduce the face unlock feature [CHAR LIMIT=40] -->
@@ -790,14 +784,22 @@
<string name="security_settings_face_enroll_introduction_message_unlock_disabled">Use your face to unlock your phone or approve purchases.\n\nNote: You can\u2019t use your face to unlock this device. For more information, contact your organization\u2019s admin.</string>
<!-- Introduction detail message shown in face enrollment screen in setup wizard. [CHAR LIMIT=NONE] -->
<string name="security_settings_face_enroll_introduction_message_setup">Use your face to unlock your phone, authorize purchases, or sign in to apps</string>
- <!-- Introduction message shown in face enrollment that provides extra detail. [CHAR LIMIT=NONE] -->
- <string name="security_settings_face_enroll_introduction_footer_part_0"></string>
- <!-- Introduction message shown in face enrollment that provides extra detail. [CHAR LIMIT=NONE] -->
- <string name="security_settings_face_enroll_introduction_footer_part_1"></string>
- <!-- Introduction message shown in face enrollment that provides extra detail. [CHAR LIMIT=NONE] -->
- <string name="security_settings_face_enroll_introduction_footer_part_2"></string>
- <!-- Introduction message shown in face enrollment that provides extra detail. [CHAR LIMIT=NONE] -->
- <string name="security_settings_face_enroll_introduction_footer_part_3"></string>
+ <!-- Title of a section on the face enrollment introduction page that provides additional information. [CHAR LIMIT=40] -->
+ <string name="security_settings_face_enroll_introduction_info_title"></string>
+ <!-- Message on the face enrollment introduction page that provides information about glasses. [CHAR LIMIT=NONE] -->
+ <string name="security_settings_face_enroll_introduction_info_glasses"></string>
+ <!-- Message on the face enrollment introduction page that provides information about what could cause the phone to unlock. [CHAR LIMIT=NONE] -->
+ <string name="security_settings_face_enroll_introduction_info_looking"></string>
+ <!-- Message on the face enrollment introduction page that provides information about the security of face unlock. [CHAR LIMIT=NONE] -->
+ <string name="security_settings_face_enroll_introduction_info_security"></string>
+ <!-- Title of a section on the face enrollment introduction page that explains how face unlock works. [CHAR LIMIT=40] -->
+ <string name="security_settings_face_enroll_introduction_how_title"></string>
+ <!-- Message on the face enrollment introduction page that explains how face unlock works. [CHAR LIMIT=NONE] -->
+ <string name="security_settings_face_enroll_introduction_how_message"></string>
+ <!-- Title of a section on the face enrollment introduction page that explains privacy controls for face unlock. [CHAR LIMIT=NONE] -->
+ <string name="security_settings_face_enroll_introduction_control_title"></string>
+ <!-- Message on the face enrollment introduction page that explains privacy controls for face unlock [CHAR LIMIT=NONE] -->
+ <string name="security_settings_face_enroll_introduction_control_message"></string>
<!-- Title shown in face enrollment dialog [CHAR LIMIT=40] -->
<string name="security_settings_face_enroll_repeat_title">Center your face in the circle</string>
<!-- Button text to skip enrollment of face [CHAR LIMIT=40] -->
@@ -943,6 +945,8 @@
<string name="security_settings_fingerprint_v2_enroll_introduction_footer_message_3">The phone will also use images from your interactions with Fingerprint Unlock to update your fingerprint model. Images used to create your fingerprint model are never stored, but the fingerprint model is stored securely on your phone and never leaves the phone. All processing occurs securely on your phone.</string>
<!-- Introduction description message shown in fingerprint enrollment introduction screen in setup wizard. [CHAR LIMIT=NONE]-->
<string name="security_settings_fingerprint_v2_enroll_introduction_footer_message_4">You can delete your fingerprint model, or turn off Fingerprint Unlock at any time in Settings. Fingerprint models are stored on the phone until you delete them.</string>
+ <!-- Introduction description message shown in fingerprint enrollment introduction screen in setup wizard. [CHAR LIMIT=NONE] -->
+ <string name="security_settings_fingerprint_v2_enroll_introduction_footer_message_5">Your phone can be unlocked when you don\u2019t intend to, like if someone holds it up to your finger.</string>
<!-- Introduction detail message shown in fingerprint enrollment introduction to learn more about fingerprint [CHAR LIMIT=NONE]-->
<string name="security_settings_fingerprint_v2_enroll_introduction_message_learn_more"></string>
@@ -6485,6 +6489,8 @@
<string name="battery_usage_for_background_time">Background: <xliff:g id="time">%s</xliff:g></string>
<!-- [CHAR_LIMIT=NONE] Battery usage main screen footer contentt -->
<string name="battery_usage_screen_footer">Battery usage data is approximate and doesn\'t measure usage when phone is charging</string>
+ <!-- [CHAR_LIMIT=NONE] Accessibility content description for battery chart view. -->
+ <string name="battery_usage_chart">Battery usage chart</string>
<!-- Process Stats strings -->
<skip />
@@ -10793,16 +10799,7 @@
<!-- Summary of display with screen sleep timeout [CHAR LIMIT=NONE] -->
<string name="display_summary">Sleep after <xliff:g id="timeout_description" example="10 minutes">%1$s</xliff:g> of inactivity</string>
<!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
- <string name="display_dashboard_summary">Wallpaper, sleep, font size</string>
-
- <!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
- <string name="display_dashboard_summary_with_style">Styles, wallpapers, screen timeout, font size</string>
-
- <!-- Summary for the top level Display Settings [CHAR LIMIT=NONE]-->
- <string name="display_dashboard_summary_2">Screen timeout, font size</string>
-
- <!-- Summary for Display settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
- <string name="display_dashboard_nowallpaper_summary">Sleep, font size</string>
+ <string name="display_dashboard_summary">Screen timeout, font size</string>
<!-- Example summary of display used in Setup Wizard preview screen [CHAR LIMIT=NONE] -->
<string name="display_summary_example">Sleep after 10 minutes of inactivity</string>
@@ -11374,6 +11371,9 @@
<!-- [CHAR LIMIT=60] Summary string on dark theme explaining why the toggle is disabled while the setting is still on-->
<string name="dark_ui_mode_disabled_summary_dark_theme_on">Temporarily disabled due to Battery Saver</string>
+ <!-- [CHAR LIMIT=60] Summary string for screen attention explaining why the toggle is disabled by battery saver-->
+ <string name="ambient_camera_summary_battery_saver_on">Temporarily disabled due to Battery Saver</string>
+
<!-- [CHAR LIMIT=60] Summary string on dark theme explaining why the toggle is disabled while the setting is off-->
<string name="dark_ui_mode_disabled_summary_dark_theme_off">Temporarily turned on due to Battery Saver</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index b7a6dab..e8670f9 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -315,12 +315,6 @@
<item name="android:singleLine">true</item>
</style>
- <style name="TextAppearance.HomepagePreferenceTitle"
- parent="@*android:style/TextAppearance.DeviceDefault">
- <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
- <item name="android:textSize">20sp</item>
- </style>
-
<style name="TextAppearance.HomepageCardTitle"
parent="@*android:style/TextAppearance.DeviceDefault.Subhead">
<item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
diff --git a/res/xml/auto_rotate_settings.xml b/res/xml/auto_rotate_settings.xml
index bc47b81..f11c0ba 100644
--- a/res/xml/auto_rotate_settings.xml
+++ b/res/xml/auto_rotate_settings.xml
@@ -32,6 +32,11 @@
android:summary="@string/auto_rotate_camera_lock_summary"
settings:controller="com.android.settings.display.SmartAutoRotateCameraStateController" />
+ <com.android.settingslib.widget.BannerMessagePreference
+ android:key="camera_battery_saver_state"
+ android:title="@string/ambient_camera_summary_battery_saver_on"
+ settings:controller="com.android.settings.display.SmartAutoRotateBatterySaverController" />
+
<SwitchPreference
android:key="face_based_rotate"
android:title="@string/auto_rotate_switch_face_based"
diff --git a/res/xml/top_level_settings_grouped.xml b/res/xml/top_level_settings_grouped.xml
index 2b29940..7b4f8a1 100644
--- a/res/xml/top_level_settings_grouped.xml
+++ b/res/xml/top_level_settings_grouped.xml
@@ -20,154 +20,154 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="top_level_settings_grouped">
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.network.NetworkDashboardFragment"
- android:icon="@drawable/ic_homepage_network_v2"
+ android:icon="@drawable/ic_settings_wireless"
android:key="top_level_network"
android:order="-150"
android:title="@string/network_dashboard_title"
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.network.TopLevelNetworkEntryPreferenceController"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
- android:icon="@drawable/ic_homepage_connected_device_v2"
+ android:icon="@drawable/ic_devices_other"
android:key="top_level_connected_devices"
android:order="-140"
android:title="@string/connected_devices_dashboard_title"
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.connecteddevice.TopLevelConnectedDevicesPreferenceController"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.applications.AppDashboardFragment"
- android:icon="@drawable/ic_homepage_apps_v2"
+ android:icon="@drawable/ic_apps"
android:key="top_level_apps"
android:order="-130"
android:title="@string/apps_dashboard_title"
android:summary="@string/app_and_notification_dashboard_summary"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.notification.ConfigureNotificationSettings"
- android:icon="@drawable/ic_homepage_notification_v2"
+ android:icon="@drawable/ic_notifications"
android:key="top_level_notification"
android:order="-120"
android:title="@string/configure_notification_settings"
android:summary="@string/notification_dashboard_summary"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
- android:icon="@drawable/ic_homepage_battery_v2"
+ android:icon="@drawable/ic_settings_battery_white"
android:key="top_level_battery"
android:order="-110"
android:title="@string/power_usage_summary_title"
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.fuelgauge.TopLevelBatteryPreferenceController"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.deviceinfo.StorageDashboardFragment"
- android:icon="@drawable/ic_homepage_storage_v2"
+ android:icon="@drawable/ic_storage_white"
android:key="top_level_storage"
android:order="-100"
android:title="@string/storage_settings"
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.notification.SoundSettings"
- android:icon="@drawable/ic_homepage_sound_v2"
+ android:icon="@drawable/ic_volume_up_24dp"
android:key="top_level_sound"
android:order="-90"
android:title="@string/sound_settings"
android:summary="@string/sound_dashboard_summary"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.DisplaySettings"
- android:icon="@drawable/ic_homepage_display_v2"
+ android:icon="@drawable/ic_settings_display_white"
android:key="top_level_display"
android:order="-80"
android:title="@string/display_settings"
- android:summary="@string/summary_placeholder"
+ android:summary="@string/display_dashboard_summary"
settings:controller="com.android.settings.display.TopLevelDisplayPreferenceController"/>
- <com.android.settings.homepage.RestrictedHomepagePreference
- android:icon="@drawable/ic_homepage_wallpaper_v2"
+ <com.android.settingslib.RestrictedTopLevelPreference
+ android:icon="@drawable/ic_settings_wallpaper_white"
android:key="top_level_wallpaper"
android:order="-70"
android:title="@string/wallpaper_settings_title"
android:summary="@string/wallpaper_dashboard_summary"
settings:controller="com.android.settings.display.TopLevelWallpaperPreferenceController"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.accessibility.AccessibilitySettings"
- android:icon="@drawable/ic_homepage_accessibility_v2"
+ android:icon="@drawable/ic_settings_accessibility"
android:key="top_level_accessibility"
android:order="-60"
android:title="@string/accessibility_settings"
android:summary="@string/accessibility_settings_summary"
settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.security.SecuritySettings"
- android:icon="@drawable/ic_homepage_security_v2"
+ android:icon="@drawable/ic_settings_security_white"
android:key="top_level_security"
android:order="-50"
android:title="@string/security_settings_title"
- android:summary="@string/security_dashboard_summary_biometric"
+ android:summary="@string/security_dashboard_summary"
settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.privacy.PrivacyDashboardFragment"
- android:icon="@drawable/ic_homepage_privacy_v2"
+ android:icon="@drawable/ic_settings_privacy"
android:key="top_level_privacy"
android:order="-40"
android:title="@string/privacy_dashboard_title"
android:summary="@string/privacy_dashboard_summary"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.location.LocationSettings"
- android:icon="@drawable/ic_homepage_location_v2"
+ android:icon="@drawable/ic_settings_location"
android:key="top_level_location"
android:order="-30"
android:title="@string/location_settings_title"
android:summary="@string/location_settings_loading_app_permission_stats"
settings:controller="com.android.settings.location.TopLevelLocationPreferenceController"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:key="top_level_emergency"
android:title="@string/emergency_settings_preference_title"
android:summary="@string/emergency_dashboard_summary"
- android:icon="@drawable/ic_homepage_emergency_v2"
+ android:icon="@drawable/ic_settings_emergency"
android:order="-20"
android:fragment="com.android.settings.emergency.EmergencyDashboardFragment"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.accounts.AccountDashboardFragment"
- android:icon="@drawable/ic_homepage_accounts_v2"
+ android:icon="@drawable/ic_settings_accounts"
android:key="top_level_accounts"
android:order="-10"
android:title="@string/account_dashboard_title"
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.system.SystemDashboardFragment"
- android:icon="@drawable/ic_homepage_system_dashboard_v2"
+ android:icon="@drawable/ic_settings_system_dashboard_white"
android:key="top_level_system"
android:order="10"
android:title="@string/header_category_system"
android:summary="@string/system_dashboard_summary"/>
- <com.android.settings.homepage.HomepagePreference
+ <Preference
android:fragment="com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment"
- android:icon="@drawable/ic_homepage_about_v2"
+ android:icon="@drawable/ic_phone_info"
android:key="top_level_about_device"
android:order="20"
android:title="@string/about_settings"
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.deviceinfo.aboutphone.TopLevelAboutDevicePreferenceController"/>
- <com.android.settings.homepage.HomepagePreference
- android:icon="@drawable/ic_homepage_support_v2"
+ <Preference
+ android:icon="@drawable/ic_help"
android:key="top_level_support"
android:order="100"
android:title="@string/page_tab_title_support"
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 7614070..4287810 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -1211,6 +1211,14 @@
return roundedBitmap;
}
+ /**
+ * Returns the color of homepage preference icons.
+ */
+ @ColorInt
+ public static int getHomepageIconColor(Context context) {
+ return getColorAttrDefaultColor(context, android.R.attr.textColorPrimary);
+ }
+
public static boolean isProviderModelEnabled(Context context) {
return FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL);
}
diff --git a/src/com/android/settings/accessibility/ItemInfoArrayAdapter.java b/src/com/android/settings/accessibility/ItemInfoArrayAdapter.java
index edb16a2..a7c4177 100644
--- a/src/com/android/settings/accessibility/ItemInfoArrayAdapter.java
+++ b/src/com/android/settings/accessibility/ItemInfoArrayAdapter.java
@@ -61,6 +61,12 @@
}
final ImageView image = root.findViewById(R.id.image);
image.setImageResource(item.mDrawableId);
+ if (getContext().getResources().getConfiguration().getLayoutDirection()
+ == View.LAYOUT_DIRECTION_LTR) {
+ image.setScaleType(ImageView.ScaleType.FIT_START);
+ } else {
+ image.setScaleType(ImageView.ScaleType.FIT_END);
+ }
return root;
}
diff --git a/src/com/android/settings/biometrics/BiometricUtils.java b/src/com/android/settings/biometrics/BiometricUtils.java
index 9de8105..03cdb0d 100644
--- a/src/com/android/settings/biometrics/BiometricUtils.java
+++ b/src/com/android/settings/biometrics/BiometricUtils.java
@@ -16,8 +16,6 @@
package com.android.settings.biometrics;
-import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
-
import android.app.Activity;
import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
@@ -34,8 +32,8 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.VerifyCredentialResponse;
-import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
+import com.android.settings.biometrics.face.FaceEnrollIntroduction;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollFindSensor;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
import com.android.settings.biometrics.fingerprint.SetupFingerprintEnrollIntroduction;
@@ -173,9 +171,7 @@
*/
public static Intent getFaceIntroIntent(@NonNull Context context,
@NonNull Intent activityIntent) {
- final String className = context.getString(R.string.config_face_enroll_introduction);
- Intent intent = new Intent();
- intent.setClassName(SETTINGS_PACKAGE_NAME, className);
+ final Intent intent = new Intent(context, FaceEnrollIntroduction.class);
WizardManagerHelper.copyWizardManagerExtras(activityIntent, intent);
return intent;
}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index c81c275..d93eef7 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 The Android Open Source Project
+ * 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.
@@ -11,7 +11,7 @@
* 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
+ * limitations under the License.
*/
package com.android.settings.biometrics.face;
@@ -41,8 +41,11 @@
import java.util.List;
+/**
+ * Provides introductory info about face unlock and prompts the user to agree before starting face
+ * enrollment.
+ */
public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
-
private static final String TAG = "FaceEnrollIntroduction";
private FaceManager mFaceManager;
@@ -66,6 +69,9 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ getLayout().setDescriptionText(getString(
+ R.string.security_settings_face_enroll_introduction_message));
+
mFaceManager = Utils.getFaceManagerOrNull(this);
mFaceFeatureProvider = FeatureFactory.getFactory(getApplicationContext())
.getFaceFeatureProvider();
@@ -82,7 +88,7 @@
FooterButton.Builder nextButtonBuilder = new FooterButton.Builder(this)
.setText(R.string.security_settings_face_enroll_introduction_agree)
- .setButtonType(FooterButton.ButtonType.NEXT)
+ .setButtonType(FooterButton.ButtonType.OPT_IN)
.setTheme(R.style.SudGlifButton_Primary);
if (maxFacesEnrolled()) {
nextButtonBuilder.setListener(this::onNextButtonClick);
@@ -97,13 +103,6 @@
this::onNextButtonClick);
}
- final TextView footer2 = findViewById(R.id.face_enroll_introduction_footer_part_2);
- final int footer2TextResource =
- mFaceFeatureProvider.isAttentionSupported(getApplicationContext())
- ? R.string.security_settings_face_enroll_introduction_footer_part_2
- : R.string.security_settings_face_settings_footer_attention_not_supported;
- footer2.setText(footer2TextResource);
-
// This path is an entry point for SetNewPasswordController, e.g.
// adb shell am start -a android.app.action.SET_NEW_PASSWORD
if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
diff --git a/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java b/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java
index c2143c0..2ceaa0d 100644
--- a/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceStatusPreferenceController.java
@@ -68,7 +68,7 @@
@Override
protected String getEnrollClassName() {
- return mContext.getResources().getString(R.string.config_face_enroll_introduction);
+ return FaceEnrollIntroduction.class.getName();
}
}
diff --git a/src/com/android/settings/bluetooth/DevicePickerActivity.java b/src/com/android/settings/bluetooth/DevicePickerActivity.java
index 77e8ba4..a4f025b 100644
--- a/src/com/android/settings/bluetooth/DevicePickerActivity.java
+++ b/src/com/android/settings/bluetooth/DevicePickerActivity.java
@@ -16,6 +16,8 @@
package com.android.settings.bluetooth;
+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
import android.os.Bundle;
import androidx.fragment.app.FragmentActivity;
@@ -31,6 +33,7 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
setContentView(R.layout.bluetooth_device_picker);
}
}
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 254a6a7..b404ecc 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -59,6 +59,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.profileselector.ProfileSelectDialog;
import com.android.settings.overlay.FeatureFactory;
@@ -401,12 +402,12 @@
private void setPreferenceIcon(Preference preference, Tile tile, boolean forceRoundedIcon,
String iconPackage, Icon icon) {
Drawable iconDrawable = icon.loadDrawable(preference.getContext());
- if (forceRoundedIcon && !TextUtils.equals(mContext.getPackageName(), iconPackage)) {
+ if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)
+ && TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) {
+ iconDrawable.setTint(Utils.getHomepageIconColor(preference.getContext()));
+ } else if (forceRoundedIcon && !TextUtils.equals(mContext.getPackageName(), iconPackage)) {
iconDrawable = new AdaptiveIcon(mContext, iconDrawable,
- FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)
- && TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)
- ? R.dimen.homepage_foreground_image_inset
- : R.dimen.dashboard_tile_foreground_image_inset);
+ R.dimen.dashboard_tile_foreground_image_inset);
((AdaptiveIcon) iconDrawable).setBackgroundColor(mContext, tile);
}
preference.setIcon(iconDrawable);
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index 1b2be80..e0c9820 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -39,13 +39,11 @@
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.PreferenceControllerListHelper;
import com.android.settings.core.SettingsBaseActivity;
-import com.android.settings.homepage.HomepagePreference;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.PrimarySwitchPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.ProviderTile;
import com.android.settingslib.drawer.Tile;
@@ -538,10 +536,6 @@
@VisibleForTesting
Preference createPreference(Tile tile) {
- if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)
- && TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) {
- return new HomepagePreference(getPrefContext());
- }
return tile instanceof ProviderTile
? new SwitchPreference(getPrefContext())
: tile.hasSwitch()
diff --git a/src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceController.java
index 6b06daf..cfee6a4 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageUsageProgressBarPreferenceController.java
@@ -47,6 +47,7 @@
long mTotalBytes;
private UsageProgressBarPreference mUsageProgressBarPreference;
private StorageEntry mStorageEntry;
+ boolean mIsUpdateStateFromSelectedStorageEntry;
public StorageUsageProgressBarPreferenceController(Context context, String key) {
super(context, key);
@@ -68,7 +69,6 @@
@Override
public void displayPreference(PreferenceScreen screen) {
mUsageProgressBarPreference = screen.findPreference(getPreferenceKey());
- getStorageStatsAndUpdateUi();
}
private void getStorageStatsAndUpdateUi() {
@@ -101,12 +101,18 @@
if (mUsageProgressBarPreference == null) {
return;
}
+ mIsUpdateStateFromSelectedStorageEntry = true;
ThreadUtils.postOnMainThread(() -> updateState(mUsageProgressBarPreference));
});
}
@Override
public void updateState(Preference preference) {
+ if (!mIsUpdateStateFromSelectedStorageEntry) {
+ // Returns here to avoid jank by unnecessary UI update.
+ return;
+ }
+ mIsUpdateStateFromSelectedStorageEntry = false;
mUsageProgressBarPreference.setUsageSummary(
getStorageSummary(R.string.storage_usage_summary, mUsedBytes));
mUsageProgressBarPreference.setTotalSummary(
diff --git a/src/com/android/settings/display/AdaptiveSleepBatterySaverPreferenceController.java b/src/com/android/settings/display/AdaptiveSleepBatterySaverPreferenceController.java
new file mode 100644
index 0000000..855c507
--- /dev/null
+++ b/src/com/android/settings/display/AdaptiveSleepBatterySaverPreferenceController.java
@@ -0,0 +1,71 @@
+/*
+ * 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.settings.display;
+
+import android.content.Context;
+import android.os.PowerManager;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settingslib.widget.BannerMessagePreference;
+
+/**
+ * The controller of Screen attention's battery saver warning preference.
+ * The preference appears when Screen Attention feature is disabled by battery saver mode.
+ */
+public class AdaptiveSleepBatterySaverPreferenceController {
+
+ @VisibleForTesting
+ final BannerMessagePreference mPreference;
+ private final PowerManager mPowerManager;
+
+ public AdaptiveSleepBatterySaverPreferenceController(Context context) {
+ mPreference = new BannerMessagePreference(context);
+ mPreference.setTitle(R.string.ambient_camera_summary_battery_saver_on);
+ mPreference.setPositiveButtonText(R.string.disable_text);
+ mPowerManager = context.getSystemService(PowerManager.class);
+ mPreference.setPositiveButtonOnClickListener(p -> {
+ mPowerManager.setPowerSaveModeEnabled(false);
+ });
+ }
+
+ /**
+ * Adds the controlled preference to the provided preference screen.
+ */
+ public void addToScreen(PreferenceScreen screen) {
+ screen.addPreference(mPreference);
+ updateVisibility();
+ }
+
+ /**
+ * Need this because all controller tests use RoboElectric. No easy way to mock this service,
+ * so we mock the call we need
+ */
+ @VisibleForTesting
+ boolean isPowerSaveMode() {
+ return mPowerManager.isPowerSaveMode();
+ }
+
+ /**
+ * Refreshes the visibility of the preference.
+ */
+ public void updateVisibility() {
+ mPreference.setVisible(isPowerSaveMode());
+ }
+}
diff --git a/src/com/android/settings/display/AdaptiveSleepPreferenceController.java b/src/com/android/settings/display/AdaptiveSleepPreferenceController.java
index 8f61683..c57904e 100644
--- a/src/com/android/settings/display/AdaptiveSleepPreferenceController.java
+++ b/src/com/android/settings/display/AdaptiveSleepPreferenceController.java
@@ -28,6 +28,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.hardware.SensorPrivacyManager;
+import android.os.PowerManager;
import android.os.UserManager;
import android.provider.Settings;
import android.service.attention.AttentionService;
@@ -53,6 +54,7 @@
private final PackageManager mPackageManager;
private final Context mContext;
private final MetricsFeatureProvider mMetricsFeatureProvider;
+ private final PowerManager mPowerManager;
@VisibleForTesting
RestrictedSwitchPreference mPreference;
@@ -62,6 +64,20 @@
mRestrictionUtils = restrictionUtils;
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
mPrivacyManager = SensorPrivacyManager.getInstance(context);
+ mPowerManager = context.getSystemService(PowerManager.class);
+ mPreference = new RestrictedSwitchPreference(context);
+ mPreference.setTitle(R.string.adaptive_sleep_title);
+ mPreference.setSummary(R.string.adaptive_sleep_description);
+ mPreference.setChecked(isChecked());
+ mPreference.setKey(PREFERENCE_KEY);
+ mPreference.setOnPreferenceClickListener(preference -> {
+ final boolean isChecked = ((RestrictedSwitchPreference) preference).isChecked();
+ mMetricsFeatureProvider.action(context, SettingsEnums.ACTION_SCREEN_ATTENTION_CHANGED,
+ isChecked);
+ Settings.Secure.putInt(context.getContentResolver(),
+ Settings.Secure.ADAPTIVE_SLEEP, isChecked ? 1 : DEFAULT_VALUE);
+ return true;
+ });
mPackageManager = context.getPackageManager();
}
@@ -87,7 +103,8 @@
if (enforcedAdmin != null) {
mPreference.setDisabledByAdmin(enforcedAdmin);
} else {
- mPreference.setEnabled(hasSufficientPermission(mPackageManager) && !isCameraLocked());
+ mPreference.setEnabled(hasSufficientPermission(mPackageManager) && !isCameraLocked()
+ && !isPowerSaveMode());
}
}
@@ -114,7 +131,7 @@
@VisibleForTesting
boolean isChecked() {
return hasSufficientPermission(mContext.getPackageManager()) && !isCameraLocked()
- && Settings.Secure.getInt(mContext.getContentResolver(),
+ && !isPowerSaveMode() && Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ADAPTIVE_SLEEP, DEFAULT_VALUE)
!= DEFAULT_VALUE;
}
@@ -128,6 +145,11 @@
return mPrivacyManager.isSensorPrivacyEnabled(CAMERA);
}
+ @VisibleForTesting
+ boolean isPowerSaveMode() {
+ return mPowerManager.isPowerSaveMode();
+ }
+
public static int isControllerAvailable(Context context) {
return context.getResources().getBoolean(
com.android.internal.R.bool.config_adaptive_sleep_available)
diff --git a/src/com/android/settings/display/ScreenTimeoutSettings.java b/src/com/android/settings/display/ScreenTimeoutSettings.java
index 6dfb225..b4d120e 100644
--- a/src/com/android/settings/display/ScreenTimeoutSettings.java
+++ b/src/com/android/settings/display/ScreenTimeoutSettings.java
@@ -21,10 +21,14 @@
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.hardware.SensorPrivacyManager;
+import android.os.PowerManager;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.SpannableString;
@@ -73,6 +77,12 @@
private FooterPreference mPrivacyPreference;
private final MetricsFeatureProvider mMetricsFeatureProvider;
private SensorPrivacyManager mPrivacyManager;
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mAdaptiveSleepBatterySaverPreferenceController.updateVisibility();
+ }
+ };
@VisibleForTesting
Context mContext;
@@ -92,6 +102,9 @@
@VisibleForTesting
AdaptiveSleepPreferenceController mAdaptiveSleepController;
+ @VisibleForTesting
+ AdaptiveSleepBatterySaverPreferenceController mAdaptiveSleepBatterySaverPreferenceController;
+
public ScreenTimeoutSettings() {
super();
mMetricsFeatureProvider = FeatureFactory.getFactory(getContext())
@@ -109,6 +122,13 @@
context);
mAdaptiveSleepCameraStatePreferenceController =
new AdaptiveSleepCameraStatePreferenceController(context);
+ mAdaptiveSleepBatterySaverPreferenceController =
+ new AdaptiveSleepBatterySaverPreferenceController(context);
+ mPrivacyPreference = new FooterPreference(context);
+ mPrivacyPreference.setIcon(R.drawable.ic_privacy_shield_24dp);
+ mPrivacyPreference.setTitle(R.string.adaptive_sleep_privacy);
+ mPrivacyPreference.setSelectable(false);
+ mPrivacyPreference.setLayoutResource(R.layout.preference_footer);
mPrivacyManager = SensorPrivacyManager.getInstance(context);
mPrivacyManager.addSensorPrivacyListener(CAMERA,
(sensor, enabled) -> mAdaptiveSleepController.updatePreference());
@@ -136,7 +156,16 @@
super.onStart();
mAdaptiveSleepPermissionController.updateVisibility();
mAdaptiveSleepCameraStatePreferenceController.updateVisibility();
+ mAdaptiveSleepBatterySaverPreferenceController.updateVisibility();
mAdaptiveSleepController.updatePreference();
+ mContext.registerReceiver(mReceiver,
+ new IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED));
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
+ mContext.unregisterReceiver(mReceiver);
}
@Override
@@ -176,6 +205,7 @@
if (isScreenAttentionAvailable(getContext())) {
mAdaptiveSleepPermissionController.addToScreen(screen);
mAdaptiveSleepCameraStatePreferenceController.addToScreen(screen);
+ mAdaptiveSleepBatterySaverPreferenceController.addToScreen(screen);
mAdaptiveSleepController.addToScreen(screen);
screen.addPreference(mPrivacyPreference);
}
diff --git a/src/com/android/settings/display/SmartAutoRotateBatterySaverController.java b/src/com/android/settings/display/SmartAutoRotateBatterySaverController.java
new file mode 100644
index 0000000..9bb2196
--- /dev/null
+++ b/src/com/android/settings/display/SmartAutoRotateBatterySaverController.java
@@ -0,0 +1,96 @@
+/*
+ * 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.settings.display;
+
+import static com.android.settings.display.SmartAutoRotateController.isRotationResolverServiceAvailable;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.PowerManager;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+import com.android.settingslib.widget.BannerMessagePreference;
+
+/**
+ * The controller of camera based rotate battery saver warning preference. The preference appears
+ * when battery saver mode is enabled.
+ */
+public class SmartAutoRotateBatterySaverController extends BasePreferenceController implements
+ LifecycleObserver, OnStart, OnStop {
+
+ private Preference mPreference;
+ private final PowerManager mPowerManager;
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (mPreference == null) {
+ return;
+ }
+ mPreference.setVisible(isPowerSaveMode());
+ updateState(mPreference);
+ }
+ };
+
+ public SmartAutoRotateBatterySaverController(Context context, String key) {
+ super(context, key);
+ mPowerManager = context.getSystemService(PowerManager.class);
+ }
+
+ @VisibleForTesting
+ boolean isPowerSaveMode() {
+ return mPowerManager.isPowerSaveMode();
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ ((BannerMessagePreference) mPreference)
+ .setPositiveButtonText(R.string.disable_text)
+ .setPositiveButtonOnClickListener(v -> {
+ mPowerManager.setPowerSaveModeEnabled(false);
+ });
+ }
+
+ @Override
+ public void onStart() {
+ mContext.registerReceiver(mReceiver,
+ new IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED));
+ }
+
+ @Override
+ public void onStop() {
+ mContext.unregisterReceiver(mReceiver);
+ }
+
+ @Override
+ @AvailabilityStatus
+ public int getAvailabilityStatus() {
+ return isRotationResolverServiceAvailable(mContext)
+ && isPowerSaveMode() ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
+ }
+}
diff --git a/src/com/android/settings/display/SmartAutoRotateController.java b/src/com/android/settings/display/SmartAutoRotateController.java
index cf2a9a6..90b0d55 100644
--- a/src/com/android/settings/display/SmartAutoRotateController.java
+++ b/src/com/android/settings/display/SmartAutoRotateController.java
@@ -20,15 +20,19 @@
import android.Manifest;
import android.app.settings.SettingsEnums;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.hardware.SensorPrivacyManager;
+import android.os.PowerManager;
import android.provider.Settings;
import android.service.rotationresolver.RotationResolverService;
import android.text.TextUtils;
+import androidx.lifecycle.LifecycleObserver;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -37,15 +41,24 @@
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
/**
* SmartAutoRotateController controls whether auto rotation is enabled
*/
public class SmartAutoRotateController extends TogglePreferenceController implements
- Preference.OnPreferenceChangeListener {
+ Preference.OnPreferenceChangeListener, LifecycleObserver, OnStart, OnStop {
private final MetricsFeatureProvider mMetricsFeatureProvider;
private final SensorPrivacyManager mPrivacyManager;
+ private final PowerManager mPowerManager;
+ private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ updateState(mPreference);
+ }
+ };
private Preference mPreference;
public SmartAutoRotateController(Context context, String preferenceKey) {
@@ -54,6 +67,7 @@
mPrivacyManager = SensorPrivacyManager.getInstance(context);
mPrivacyManager
.addSensorPrivacyListener(CAMERA, (sensor, enabled) -> updateState(mPreference));
+ mPowerManager = context.getSystemService(PowerManager.class);
}
@Override
@@ -62,7 +76,7 @@
return UNSUPPORTED_ON_DEVICE;
}
return !RotationPolicy.isRotationLocked(mContext) && hasSufficientPermission(mContext)
- && !isCameraLocked() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
+ && !isCameraLocked() && !isPowerSaveMode() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
}
@Override
@@ -82,11 +96,27 @@
return mPrivacyManager.isSensorPrivacyEnabled(SensorPrivacyManager.Sensors.CAMERA);
}
+ @VisibleForTesting
+ boolean isPowerSaveMode() {
+ return mPowerManager.isPowerSaveMode();
+ }
+
+ @Override
+ public void onStart() {
+ mContext.registerReceiver(mReceiver,
+ new IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED));
+ }
+
+ @Override
+ public void onStop() {
+ mContext.unregisterReceiver(mReceiver);
+ }
+
@Override
public boolean isChecked() {
- return hasSufficientPermission(mContext) && !isCameraLocked() && Settings.Secure.getInt(
- mContext.getContentResolver(),
- CAMERA_AUTOROTATE, 0) == 1;
+ return hasSufficientPermission(mContext) && !isCameraLocked() && !isPowerSaveMode()
+ && Settings.Secure.getInt(mContext.getContentResolver(),
+ CAMERA_AUTOROTATE, 0) == 1;
}
@Override
diff --git a/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java b/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java
index 1a91775..f697a8c 100644
--- a/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java
+++ b/src/com/android/settings/display/SmartAutoRotatePreferenceFragment.java
@@ -21,6 +21,7 @@
import android.app.settings.SettingsEnums;
import android.hardware.SensorPrivacyManager;
import android.os.Bundle;
+import android.os.PowerManager;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
@@ -50,6 +51,7 @@
private RotationPolicy.RotationPolicyListener mRotationPolicyListener;
private SensorPrivacyManager mPrivacyManager;
private AutoRotateSwitchBarController mSwitchBarController;
+ private PowerManager mPowerManager;
private static final String FACE_SWITCH_PREFERENCE_ID = "face_based_rotate";
@Override
@@ -69,6 +71,7 @@
mSwitchBarController = new AutoRotateSwitchBarController(activity, switchBar,
getSettingsLifecycle());
mPrivacyManager = SensorPrivacyManager.getInstance(activity);
+ mPowerManager = getSystemService(PowerManager.class);
final Preference footerPreference = findPreference(FooterPreference.KEY_FOOTER);
if (footerPreference != null) {
footerPreference.setTitle(Html.fromHtml(getString(R.string.smart_rotate_text_headline),
@@ -89,9 +92,10 @@
final boolean isLocked = RotationPolicy.isRotationLocked(getContext());
final boolean isCameraLocked = mPrivacyManager.isSensorPrivacyEnabled(
SensorPrivacyManager.Sensors.CAMERA);
+ final boolean isBatterySaver = mPowerManager.isPowerSaveMode();
final Preference preference = findPreference(FACE_SWITCH_PREFERENCE_ID);
if (preference != null && hasSufficientPermission(getContext())) {
- preference.setEnabled(!isLocked && !isCameraLocked);
+ preference.setEnabled(!isLocked && !isCameraLocked && !isBatterySaver);
}
}
};
diff --git a/src/com/android/settings/display/TopLevelDisplayPreferenceController.java b/src/com/android/settings/display/TopLevelDisplayPreferenceController.java
index 73aafe5..5fda13e 100644
--- a/src/com/android/settings/display/TopLevelDisplayPreferenceController.java
+++ b/src/com/android/settings/display/TopLevelDisplayPreferenceController.java
@@ -33,18 +33,4 @@
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
-
- @Override
- public CharSequence getSummary() {
- final WallpaperPreferenceController controller =
- new WallpaperPreferenceController(mContext, "unused_key");
- if (controller.isAvailable()) {
- return mContext.getText(
- controller.areStylesAvailable()
- ? R.string.display_dashboard_summary_with_style
- : R.string.display_dashboard_summary);
- } else {
- return mContext.getText(R.string.display_dashboard_nowallpaper_summary);
- }
- }
}
diff --git a/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java b/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java
index 7b3d788..c84a15e 100644
--- a/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java
+++ b/src/com/android/settings/display/TopLevelWallpaperPreferenceController.java
@@ -25,7 +25,6 @@
import android.content.pm.ResolveInfo;
import android.os.UserHandle;
import android.text.TextUtils;
-import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.preference.Preference;
@@ -33,8 +32,6 @@
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.core.FeatureFlags;
-import com.android.settings.homepage.RestrictedHomepagePreference;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.RestrictedTopLevelPreference;
@@ -92,11 +89,7 @@
@Override
public void updateState(Preference preference) {
- if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)) {
- disablePreferenceIfManaged((RestrictedHomepagePreference) preference);
- } else {
- disablePreferenceIfManaged((RestrictedTopLevelPreference) preference);
- }
+ disablePreferenceIfManaged((RestrictedTopLevelPreference) preference);
}
@Override
@@ -140,18 +133,4 @@
}
}
}
-
- private void disablePreferenceIfManaged(RestrictedHomepagePreference pref) {
- final String restriction = DISALLOW_SET_WALLPAPER;
- if (pref != null) {
- pref.setDisabledByAdmin(null);
- if (RestrictedLockUtilsInternal.hasBaseUserRestriction(mContext,
- restriction, UserHandle.myUserId())) {
- // Do not show the admin dialog for system restriction.
- pref.setEnabled(false);
- } else {
- pref.checkRestrictionAndSetDisabled(restriction);
- }
- }
- }
}
diff --git a/src/com/android/settings/fuelgauge/BatteryChartView.java b/src/com/android/settings/fuelgauge/BatteryChartView.java
index cd76d0e..1048017 100644
--- a/src/com/android/settings/fuelgauge/BatteryChartView.java
+++ b/src/com/android/settings/fuelgauge/BatteryChartView.java
@@ -15,6 +15,7 @@
import static java.lang.Math.round;
+import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
@@ -28,23 +29,30 @@
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.View;
+import android.view.accessibility.AccessibilityManager;
import android.widget.TextView;
import androidx.appcompat.widget.AppCompatImageView;
+import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.Utils;
+import java.util.Arrays;
+import java.util.List;
import java.util.Locale;
/** A widget component to draw chart graph. */
public class BatteryChartView extends AppCompatImageView implements View.OnClickListener {
private static final String TAG = "BatteryChartView";
+ private static final List<String> ACCESSIBILITY_SERVICE_NAMES =
+ Arrays.asList("SwitchAccessService", "TalkBackService", "JustSpeakService");
// For drawing the percentage information.
private static final String[] PERCENTAGES = new String[] {"100%", "50%", "0%"};
private static final int DEFAULT_TRAPEZOID_COUNT = 12;
private static final int DEFAULT_TIMESTAMP_COUNT = 4;
+
/** Selects all trapezoid shapes. */
public static final int SELECTED_INDEX_ALL = -1;
public static final int SELECTED_INDEX_INVALID = -2;
@@ -57,10 +65,11 @@
private int mDividerWidth;
private int mDividerHeight;
private int mTrapezoidCount;
- private int mSelectedIndex;
private float mTrapezoidVOffset;
private float mTrapezoidHOffset;
- private boolean mIsSlotsClickable;
+ private boolean mIsSlotsClickabled;
+
+ @VisibleForTesting int mSelectedIndex;
// Colors for drawing the trapezoid shape and dividers.
private int mTrapezoidColor;
@@ -247,26 +256,37 @@
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
+ updateClickableState();
+ }
+
+ private void updateClickableState() {
final Context context = mContext;
- mIsSlotsClickable =
+ mIsSlotsClickabled =
FeatureFactory.getFactory(context)
- .getPowerUsageFeatureProvider(context)
- .isChartGraphSlotsEnabled(context);
- Log.d(TAG, "isChartGraphSlotsEnabled:" + mIsSlotsClickable);
+ .getPowerUsageFeatureProvider(context)
+ .isChartGraphSlotsEnabled(context)
+ && !isAccessibilityEnabled(context);
+ Log.d(TAG, "isChartGraphSlotsEnabled:" + mIsSlotsClickabled);
setClickable(isClickable());
// Initializes the trapezoid curve paint for non-clickable case.
- if (!mIsSlotsClickable && mTrapezoidCurvePaint == null) {
+ if (!mIsSlotsClickabled && mTrapezoidCurvePaint == null) {
mTrapezoidCurvePaint = new Paint();
mTrapezoidCurvePaint.setAntiAlias(true);
mTrapezoidCurvePaint.setColor(mTrapezoidSolidColor);
mTrapezoidCurvePaint.setStyle(Paint.Style.STROKE);
mTrapezoidCurvePaint.setStrokeWidth(mDividerWidth * 2);
}
+ invalidate();
}
@Override
public void setClickable(boolean clickable) {
- super.setClickable(mIsSlotsClickable && clickable);
+ super.setClickable(mIsSlotsClickabled && clickable);
+ }
+
+ @VisibleForTesting
+ void setClickableForce(boolean clickable) {
+ super.setClickable(clickable);
}
private void initializeColors(Context context) {
@@ -412,7 +432,7 @@
}
// Configures the trapezoid paint color.
final int trapezoidColor =
- !mIsSlotsClickable
+ !mIsSlotsClickabled
? mTrapezoidColor
: mSelectedIndex == index || mSelectedIndex == SELECTED_INDEX_ALL
? mTrapezoidSolidColor : mTrapezoidColor;
@@ -469,6 +489,29 @@
&& mLevels[trapezoidIndex + 1] != 0;
}
+ @VisibleForTesting
+ static boolean isAccessibilityEnabled(Context context) {
+ final AccessibilityManager accessibilityManager =
+ context.getSystemService(AccessibilityManager.class);
+ if (!accessibilityManager.isEnabled()) {
+ return false;
+ }
+ final List<AccessibilityServiceInfo> serviceInfoList =
+ accessibilityManager.getEnabledAccessibilityServiceList(
+ AccessibilityServiceInfo.FEEDBACK_SPOKEN
+ | AccessibilityServiceInfo.FEEDBACK_GENERIC);
+ for (AccessibilityServiceInfo info : serviceInfoList) {
+ for (String serviceName : ACCESSIBILITY_SERVICE_NAMES) {
+ final String serviceId = info.getId();
+ if (serviceId != null && serviceId.contains(serviceName)) {
+ Log.d(TAG, "acccessibilityEnabled:" + serviceId);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
// A container class for each trapezoid left and right location.
private static final class TrapezoidSlot {
public float mLeft;
diff --git a/src/com/android/settings/homepage/HomepagePreference.java b/src/com/android/settings/homepage/HomepagePreference.java
deleted file mode 100644
index 6086b9f..0000000
--- a/src/com/android/settings/homepage/HomepagePreference.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.settings.homepage;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import androidx.preference.Preference;
-
-import com.android.settings.R;
-
-/** A customized layout for homepage preference. */
-public class HomepagePreference extends Preference {
-
- public HomepagePreference(Context context) {
- super(context);
- setLayoutResource(R.layout.homepage_preference);
- }
-
- public HomepagePreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- setLayoutResource(R.layout.homepage_preference);
- }
-
- public HomepagePreference(Context context, AttributeSet attrs, int defStyleAttr) {
- this(context, attrs, defStyleAttr, /* defStyleRes= */ 0);
- setLayoutResource(R.layout.homepage_preference);
- }
-
- public HomepagePreference(Context context, AttributeSet attrs,
- int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- setLayoutResource(R.layout.homepage_preference);
- }
-}
diff --git a/src/com/android/settings/homepage/RestrictedHomepagePreference.java b/src/com/android/settings/homepage/RestrictedHomepagePreference.java
deleted file mode 100644
index 476642d..0000000
--- a/src/com/android/settings/homepage/RestrictedHomepagePreference.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.settings.homepage;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import androidx.core.content.res.TypedArrayUtils;
-
-import com.android.settings.R;
-import com.android.settingslib.RestrictedTopLevelPreference;
-
-/** Homepage preference that can be disabled by a device admin using a user restriction. */
-public class RestrictedHomepagePreference extends RestrictedTopLevelPreference {
-
- public RestrictedHomepagePreference(Context context, AttributeSet attrs,
- int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- setLayoutResource(R.layout.homepage_preference);
- }
-
- public RestrictedHomepagePreference(Context context, AttributeSet attrs, int defStyleAttr) {
- this(context, attrs, defStyleAttr, /* defStyleRes= */ 0);
- }
-
- public RestrictedHomepagePreference(Context context, AttributeSet attrs) {
- this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.preferenceStyle,
- android.R.attr.preferenceStyle));
- }
-
- public RestrictedHomepagePreference(Context context) {
- this(context, /* attrs= */ null);
- }
-}
diff --git a/src/com/android/settings/homepage/TopLevelSettings.java b/src/com/android/settings/homepage/TopLevelSettings.java
index 47a46f2..f4f7f61 100644
--- a/src/com/android/settings/homepage/TopLevelSettings.java
+++ b/src/com/android/settings/homepage/TopLevelSettings.java
@@ -21,6 +21,7 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import android.util.FeatureFlagUtils;
@@ -28,8 +29,10 @@
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
@@ -103,6 +106,31 @@
}
@Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ super.onCreatePreferences(savedInstanceState, rootKey);
+ if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
+ return;
+ }
+ final PreferenceScreen screen = getPreferenceScreen();
+ if (screen == null) {
+ return;
+ }
+ // Tint the homepage icons
+ final int tintColor = Utils.getHomepageIconColor(getContext());
+ final int count = screen.getPreferenceCount();
+ for (int i = 0; i < count; i++) {
+ final Preference preference = screen.getPreference(i);
+ if (preference == null) {
+ break;
+ }
+ final Drawable icon = preference.getIcon();
+ if (icon != null) {
+ icon.setTint(tintColor);
+ }
+ }
+ }
+
+ @Override
protected boolean shouldForceRoundedIcon() {
return getContext().getResources()
.getBoolean(R.bool.config_force_rounded_icon_TopLevelSettings);
diff --git a/src/com/android/settings/network/ProviderModelSlice.java b/src/com/android/settings/network/ProviderModelSlice.java
index 3d4c4de..84581d7 100644
--- a/src/com/android/settings/network/ProviderModelSlice.java
+++ b/src/com/android/settings/network/ProviderModelSlice.java
@@ -43,6 +43,7 @@
import com.android.settings.slices.CustomSliceable;
import com.android.settings.slices.SliceBackgroundWorker;
import com.android.settings.slices.SliceBuilderUtils;
+import com.android.settings.wifi.WifiUtils;
import com.android.settings.wifi.slice.WifiSlice;
import com.android.settings.wifi.slice.WifiSliceItem;
import com.android.wifitrackerlib.WifiEntry;
@@ -255,7 +256,8 @@
final @ColorInt int tint = Utils.getColorAttrDefaultColor(mContext,
android.R.attr.colorControlNormal);
final Drawable drawable = mContext.getDrawable(
- Utils.getWifiIconResource(wifiSliceItem.getLevel()));
+ WifiUtils.getInternetIconResource(
+ wifiSliceItem.getLevel(), wifiSliceItem.shouldShowXLevelIcon()));
drawable.setTint(tint);
return Utils.createIconWithDrawable(drawable);
}
diff --git a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
index 1da32dc..54b78be 100644
--- a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
@@ -26,6 +26,7 @@
import androidx.preference.Preference;
import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.password.ChooseLockGeneric;
@@ -36,7 +37,7 @@
private static final String KEY_UNLOCK_SET_OR_CHANGE_PROFILE = "unlock_set_or_change_profile";
public ChangeProfileScreenLockPreferenceController(Context context,
- SecuritySettings host) {
+ SettingsPreferenceFragment host) {
super(context, host);
}
diff --git a/src/com/android/settings/security/EncryptionStatusPreferenceController.java b/src/com/android/settings/security/EncryptionStatusPreferenceController.java
index ea38068..322be10 100644
--- a/src/com/android/settings/security/EncryptionStatusPreferenceController.java
+++ b/src/com/android/settings/security/EncryptionStatusPreferenceController.java
@@ -29,9 +29,9 @@
public class EncryptionStatusPreferenceController extends BasePreferenceController {
- static final String PREF_KEY_ENCRYPTION_DETAIL_PAGE =
+ public static final String PREF_KEY_ENCRYPTION_DETAIL_PAGE =
"encryption_and_credentials_encryption_status";
- static final String PREF_KEY_ENCRYPTION_SECURITY_PAGE = "encryption_and_credential";
+ public static final String PREF_KEY_ENCRYPTION_SECURITY_PAGE = "encryption_and_credential";
private final UserManager mUserManager;
diff --git a/src/com/android/settings/security/LockUnificationPreferenceController.java b/src/com/android/settings/security/LockUnificationPreferenceController.java
index e8a23b7..98a3c6f 100644
--- a/src/com/android/settings/security/LockUnificationPreferenceController.java
+++ b/src/com/android/settings/security/LockUnificationPreferenceController.java
@@ -33,6 +33,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockscreenCredential;
import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SubSettingLauncher;
@@ -67,7 +68,7 @@
private final DevicePolicyManager mDpm;
private final LockPatternUtils mLockPatternUtils;
private final int mProfileUserId;
- private final SecuritySettings mHost;
+ private final SettingsPreferenceFragment mHost;
private RestrictedSwitchPreference mUnifyProfile;
@@ -82,7 +83,7 @@
mUnifyProfile = screen.findPreference(KEY_UNIFICATION);
}
- public LockUnificationPreferenceController(Context context, SecuritySettings host) {
+ public LockUnificationPreferenceController(Context context, SettingsPreferenceFragment host) {
super(context);
mHost = host;
mUm = context.getSystemService(UserManager.class);
@@ -175,7 +176,10 @@
.launch();
}
- void startUnification() {
+ /**
+ * Unify primary and profile locks.
+ */
+ public void startUnification() {
// Confirm profile lock
final String title = mContext.getString(
R.string.unlock_set_unlock_launch_picker_title_profile);
diff --git a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
index 5e624cc..dd1d63a 100644
--- a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
@@ -31,11 +31,11 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
+import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.security.SecurityFeatureProvider;
-import com.android.settings.security.SecuritySettings;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -61,7 +61,7 @@
private final LockPatternUtils mLockPatternUtils;
private final TrustAgentManager mTrustAgentManager;
- private final SecuritySettings mHost;
+ private final SettingsPreferenceFragment mHost;
private Intent mTrustAgentClickIntent;
private PreferenceCategory mSecurityCategory;
@@ -69,7 +69,7 @@
@VisibleForTesting
final List<String> mTrustAgentsKeyList;
- public TrustAgentListPreferenceController(Context context, SecuritySettings host,
+ public TrustAgentListPreferenceController(Context context, SettingsPreferenceFragment host,
Lifecycle lifecycle) {
super(context);
final SecurityFeatureProvider provider = FeatureFactory.getFactory(context)
diff --git a/src/com/android/settings/wifi/WifiUtils.java b/src/com/android/settings/wifi/WifiUtils.java
index d05260a..6f955b2 100644
--- a/src/com/android/settings/wifi/WifiUtils.java
+++ b/src/com/android/settings/wifi/WifiUtils.java
@@ -35,7 +35,8 @@
import java.nio.charset.StandardCharsets;
-public class WifiUtils {
+/** A utility class for Wi-Fi functions. */
+public class WifiUtils extends com.android.settingslib.wifi.WifiUtils {
private static final int SSID_ASCII_MIN_LENGTH = 1;
private static final int SSID_ASCII_MAX_LENGTH = 32;
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index e4a571d..1374e76 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -49,6 +49,7 @@
import com.android.settings.slices.SliceBuilderUtils;
import com.android.settings.wifi.WifiDialogActivity;
import com.android.settings.wifi.WifiSettings;
+import com.android.settings.wifi.WifiUtils;
import com.android.settings.wifi.details2.WifiNetworkDetailsFragment2;
import com.android.wifitrackerlib.WifiEntry;
@@ -176,7 +177,8 @@
}
final Drawable drawable = mContext.getDrawable(
- com.android.settingslib.Utils.getWifiIconResource(wifiSliceItem.getLevel()));
+ WifiUtils.getInternetIconResource(wifiSliceItem.getLevel(),
+ wifiSliceItem.shouldShowXLevelIcon()));
drawable.setTint(tint);
return Utils.createIconWithDrawable(drawable);
}
diff --git a/src/com/android/settings/wifi/slice/WifiSliceItem.java b/src/com/android/settings/wifi/slice/WifiSliceItem.java
index 7a0f0d7..9fe54d3 100644
--- a/src/com/android/settings/wifi/slice/WifiSliceItem.java
+++ b/src/com/android/settings/wifi/slice/WifiSliceItem.java
@@ -34,6 +34,7 @@
private final int mSecurity;
private final int mConnectedState;
private final int mLevel;
+ private final boolean mShouldShowXLevelIcon;
private final boolean mShouldEditBeforeConnect;
private final String mSummary;
@@ -53,6 +54,7 @@
mSecurity = wifiEntry.getSecurity();
mConnectedState = wifiEntry.getConnectedState();
mLevel = wifiEntry.getLevel();
+ mShouldShowXLevelIcon = wifiEntry.shouldShowXLevelIcon();
mShouldEditBeforeConnect = wifiEntry.shouldEditBeforeConnect();
mSummary = wifiEntry.getSummary(false /* concise */);
}
@@ -73,6 +75,9 @@
if (getLevel() != otherItem.getLevel()) {
return false;
}
+ if (shouldShowXLevelIcon() != otherItem.shouldShowXLevelIcon()) {
+ return false;
+ }
if (!TextUtils.equals(getSummary(), otherItem.getSummary())) {
return false;
}
@@ -100,6 +105,13 @@
}
/**
+ * Returns whether the level icon for this network should show an X or not.
+ */
+ public boolean shouldShowXLevelIcon() {
+ return mShouldShowXLevelIcon;
+ }
+
+ /**
* In Wi-Fi picker, when users click a saved network, it will connect to the Wi-Fi network.
* However, for some special cases, Wi-Fi picker should show Wi-Fi editor UI for users to edit
* security or password before connecting. Or users will always get connection fail results.
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
index 9d7d746..b83e487 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFragmentTest.java
@@ -48,7 +48,6 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.core.FeatureFlags;
import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.homepage.HomepagePreference;
import com.android.settings.slices.BlockingSlicePrefController;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.widget.PrimarySwitchPreference;
@@ -56,7 +55,6 @@
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
import com.android.settingslib.drawer.ActivityTile;
-import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.ProviderTile;
@@ -338,16 +336,6 @@
}
@Test
- public void createPreference_isHomepageTile_returnHomepagePreference() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, true);
- mActivityTile.setCategory(CategoryKey.CATEGORY_HOMEPAGE);
-
- final Preference pref = mTestFragment.createPreference(mActivityTile);
-
- assertThat(pref).isInstanceOf(HomepagePreference.class);
- }
-
- @Test
public void isFeatureFlagAndIsParalleled_runParalleledUpdatePreferenceStates() {
FeatureFlagUtils.setEnabled(mContext, FeatureFlags.CONTROLLER_ENHANCEMENT, true);
final TestFragment testFragment = spy(new TestFragment(RuntimeEnvironment.application));
@@ -472,7 +460,7 @@
return mIsParalleled;
}
- public void setUsingControllerEnhancement(boolean isParalleled) {
+ void setUsingControllerEnhancement(boolean isParalleled) {
mIsParalleled = isParalleled;
}
}
diff --git a/tests/robotests/src/com/android/settings/display/AdaptiveSleepBatterySaverPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AdaptiveSleepBatterySaverPreferenceControllerTest.java
new file mode 100644
index 0000000..1e30742
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/AdaptiveSleepBatterySaverPreferenceControllerTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.settings.display;
+
+import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+
+import androidx.preference.PreferenceScreen;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class AdaptiveSleepBatterySaverPreferenceControllerTest {
+ private Context mContext;
+ private AdaptiveSleepBatterySaverPreferenceController mController;
+
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private PreferenceScreen mScreen;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(getApplicationContext());
+
+ doReturn(mPackageManager).when(mContext).getPackageManager();
+ when(mPackageManager.getAttentionServicePackageName()).thenReturn("some.package");
+ when(mPackageManager.checkPermission(any(), any())).thenReturn(
+ PackageManager.PERMISSION_GRANTED);
+
+ mController = spy(new AdaptiveSleepBatterySaverPreferenceController(mContext));
+ when(mController.isPowerSaveMode()).thenReturn(false);
+ }
+
+ @Test
+ public void addToScreen_normalCase_hidePreference() {
+ mController.addToScreen(mScreen);
+
+ assertThat(mController.mPreference.isVisible()).isFalse();
+ }
+
+ @Test
+ public void addToScreen_powerSaveEnabled_showPreference() {
+ when(mController.isPowerSaveMode()).thenReturn(true);
+
+ mController.addToScreen(mScreen);
+
+ assertThat(mController.mPreference.isVisible()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
index 880f9cc..1813bd6 100644
--- a/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
@@ -83,9 +83,10 @@
when(mRestrictionUtils.checkIfRestrictionEnforced(any(),
eq(UserManager.DISALLOW_CONFIG_SCREEN_TIMEOUT))).thenReturn(null);
- mController = new AdaptiveSleepPreferenceController(mContext, mRestrictionUtils);
+ mController = spy(new AdaptiveSleepPreferenceController(mContext, mRestrictionUtils));
mController.initializePreference();
when(mController.isCameraLocked()).thenReturn(false);
+ when(mController.isPowerSaveMode()).thenReturn(false);
}
@Test
@@ -174,4 +175,14 @@
assertThat(mController.mPreference.isEnabled()).isFalse();
}
+
+ @Test
+ public void addToScreen_powerSaveEnabled_disablePreference() {
+ when(mController.isPowerSaveMode()).thenReturn(true);
+
+ mController.addToScreen(mScreen);
+
+ assertThat(mController.mPreference.isEnabled()).isFalse();
+ }
+
}
diff --git a/tests/robotests/src/com/android/settings/display/SmartAutoRotateBatterySaverControllerTest.java b/tests/robotests/src/com/android/settings/display/SmartAutoRotateBatterySaverControllerTest.java
new file mode 100644
index 0000000..86f1d88
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/SmartAutoRotateBatterySaverControllerTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.settings.display;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.when;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
+
+import com.android.settings.testutils.ResolveInfoBuilder;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class SmartAutoRotateBatterySaverControllerTest {
+
+ private static final String PACKAGE_NAME = "package_name";
+
+ private SmartAutoRotateBatterySaverController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final Context context = Mockito.spy(RuntimeEnvironment.application);
+ final ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
+ when(context.getContentResolver()).thenReturn(contentResolver);
+ final PackageManager packageManager = Mockito.mock(PackageManager.class);
+ when(context.getPackageManager()).thenReturn(packageManager);
+ doReturn(PACKAGE_NAME).when(packageManager).getRotationResolverPackageName();
+ mController = Mockito.spy(
+ new SmartAutoRotateBatterySaverController(context, "smart_auto_rotate"));
+ when(mController.isPowerSaveMode()).thenReturn(false);
+
+ final ResolveInfo resolveInfo = new ResolveInfoBuilder(PACKAGE_NAME).build();
+ resolveInfo.serviceInfo = new ServiceInfo();
+ when(packageManager.resolveService(any(), anyInt())).thenReturn(resolveInfo);
+ }
+
+ @Test
+ public void getAvailabilityStatus_returnUnsupportedOnDevice() {
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_powerSaveModeEnabled_returnAvailableUnSearchAble() {
+ when(mController.isPowerSaveMode()).thenReturn(true);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/display/SmartAutoRotateControllerTest.java b/tests/robotests/src/com/android/settings/display/SmartAutoRotateControllerTest.java
index a65d880..778721a 100644
--- a/tests/robotests/src/com/android/settings/display/SmartAutoRotateControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/SmartAutoRotateControllerTest.java
@@ -74,8 +74,9 @@
doReturn(PACKAGE_NAME).when(mPackageManager).getRotationResolverPackageName();
doReturn(PackageManager.PERMISSION_GRANTED).when(mPackageManager).checkPermission(
Manifest.permission.CAMERA, PACKAGE_NAME);
- mController = new SmartAutoRotateController(context, "test_key");
+ mController = Mockito.spy(new SmartAutoRotateController(context, "test_key"));
when(mController.isCameraLocked()).thenReturn(false);
+ when(mController.isPowerSaveMode()).thenReturn(false);
doReturn(mController.getPreferenceKey()).when(mPreference).getKey();
final ResolveInfo resolveInfo = new ResolveInfoBuilder(PACKAGE_NAME).build();
@@ -115,6 +116,12 @@
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
}
+ @Test
+ public void getAvailabilityStatus_powerSaveEnabled_returnDisableDependentSetting() {
+ when(mController.isPowerSaveMode()).thenReturn(true);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
+ }
+
private void enableAutoRotation() {
Settings.System.putIntForUser(mContentResolver,
Settings.System.ACCELEROMETER_ROTATION, 1, UserHandle.USER_CURRENT);
diff --git a/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java
index d16a6d2..a5149b9 100644
--- a/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java
@@ -21,47 +21,27 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-
-import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import java.util.ArrayList;
-import java.util.List;
-
@RunWith(RobolectricTestRunner.class)
public class TopLevelDisplayPreferenceControllerTest {
private Context mContext;
- @Mock
- private PackageManager mPackageManager;
-
private TopLevelDisplayPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- when(mContext.getPackageManager()).thenReturn(mPackageManager);
- when(mContext.getString(R.string.config_wallpaper_picker_package)).thenReturn("pkg");
- when(mContext.getString(R.string.config_wallpaper_picker_class)).thenReturn("cls");
-
mController = new TopLevelDisplayPreferenceController(mContext, "test_key");
}
@@ -75,38 +55,4 @@
public void getAvailabilityStatus_unsupportedWhenSet() {
assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
}
-
- @Test
- public void getSummary_hasWallpaper_shouldReturnWallpaperSummary() {
- final List<ResolveInfo> resolveInfos = new ArrayList<>();
- resolveInfos.add(mock(ResolveInfo.class));
- when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
- .thenReturn(resolveInfos);
-
- assertThat(mController.getSummary())
- .isEqualTo(mContext.getText(R.string.display_dashboard_summary));
- }
-
- @Test
- public void getSummary_hasWallpaperWithStyles_shouldReturnWallpaperSummary() {
- when(mContext.getString(R.string.config_styles_and_wallpaper_picker_class))
- .thenReturn("any.nonempty.class");
- final List<ResolveInfo> resolveInfos = new ArrayList<>();
- resolveInfos.add(mock(ResolveInfo.class));
- when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
- .thenReturn(resolveInfos);
-
- assertThat(mController.getSummary())
- .isEqualTo(mContext.getText(R.string.display_dashboard_summary_with_style));
- }
-
- @Test
- public void getSummary_hasWallpaper_shouldReturnNoWallpaperSummary() {
- final List<ResolveInfo> resolveInfos = new ArrayList<>();
- when(mPackageManager.queryIntentActivities(any(Intent.class), anyInt()))
- .thenReturn(resolveInfos);
-
- assertThat(mController.getSummary())
- .isEqualTo(mContext.getText(R.string.display_dashboard_nowallpaper_summary));
- }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java
index a0a1417..3c371a0 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java
@@ -634,9 +634,6 @@
assertThat(mBatteryChartPreferenceController
.isValidToShowEntry("com.google.android.gms.persistent"))
.isFalse();
- assertThat(mBatteryChartPreferenceController
- .isValidToShowEntry("dex2oat64"))
- .isFalse();
}
private static Map<Long, Map<String, BatteryHistEntry>> createBatteryHistoryMap() {
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartViewTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartViewTest.java
new file mode 100644
index 0000000..877ebc2
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryChartViewTest.java
@@ -0,0 +1,170 @@
+/*
+ * 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.settings.fuelgauge;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.content.Context;
+import android.view.accessibility.AccessibilityManager;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.Arrays;
+import java.util.ArrayList;
+
+@RunWith(RobolectricTestRunner.class)
+public final class BatteryChartViewTest {
+
+ private Context mContext;
+ private BatteryChartView mBatteryChartView;
+ private FakeFeatureFactory mFeatureFactory;
+ private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
+
+ @Mock private AccessibilityServiceInfo mockAccessibilityServiceInfo;
+ @Mock private AccessibilityManager mockAccessibilityManager;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ mPowerUsageFeatureProvider = mFeatureFactory.powerUsageFeatureProvider;
+ mContext = spy(RuntimeEnvironment.application);
+ mBatteryChartView = new BatteryChartView(mContext);
+ doReturn(mockAccessibilityManager).when(mContext)
+ .getSystemService(AccessibilityManager.class);
+ doReturn("TalkBackService").when(mockAccessibilityServiceInfo).getId();
+ doReturn(Arrays.asList(mockAccessibilityServiceInfo))
+ .when(mockAccessibilityManager)
+ .getEnabledAccessibilityServiceList(anyInt());
+ }
+
+ @Test
+ public void testIsAccessibilityEnabled_disable_returnFalse() {
+ doReturn(false).when(mockAccessibilityManager).isEnabled();
+ assertThat(BatteryChartView.isAccessibilityEnabled(mContext)).isFalse();
+ }
+
+ @Test
+ public void testIsAccessibilityEnabled_emptyInfo_returnFalse() {
+ doReturn(true).when(mockAccessibilityManager).isEnabled();
+ doReturn(new ArrayList<AccessibilityServiceInfo>())
+ .when(mockAccessibilityManager)
+ .getEnabledAccessibilityServiceList(anyInt());
+
+ assertThat(BatteryChartView.isAccessibilityEnabled(mContext)).isFalse();
+ }
+
+ @Test
+ public void testIsAccessibilityEnabled_validServiceId_returnTrue() {
+ doReturn(true).when(mockAccessibilityManager).isEnabled();
+ assertThat(BatteryChartView.isAccessibilityEnabled(mContext)).isTrue();
+ }
+
+ @Test
+ public void testSetSelectedIndex_invokesCallback() {
+ final int selectedIndex[] = new int[1];
+ final int expectedIndex = 2;
+ mBatteryChartView.mSelectedIndex = 1;
+ mBatteryChartView.setOnSelectListener(
+ trapezoidIndex -> {
+ selectedIndex[0] = trapezoidIndex;
+ });
+
+ mBatteryChartView.setSelectedIndex(expectedIndex);
+
+ assertThat(mBatteryChartView.mSelectedIndex)
+ .isEqualTo(expectedIndex);
+ assertThat(selectedIndex[0]).isEqualTo(expectedIndex);
+ }
+
+ @Test
+ public void testSetSelectedIndex_sameIndex_notInvokesCallback() {
+ final int selectedIndex[] = new int[1];
+ final int expectedIndex = 1;
+ mBatteryChartView.mSelectedIndex = expectedIndex;
+ mBatteryChartView.setOnSelectListener(
+ trapezoidIndex -> {
+ selectedIndex[0] = trapezoidIndex;
+ });
+
+ mBatteryChartView.setSelectedIndex(expectedIndex);
+
+ assertThat(selectedIndex[0]).isNotEqualTo(expectedIndex);
+ }
+
+ @Test
+ public void testClickable_isChartGraphSlotsEnabledIsFalse_notClickable() {
+ mBatteryChartView.setClickableForce(true);
+ when(mPowerUsageFeatureProvider.isChartGraphSlotsEnabled(mContext))
+ .thenReturn(false);
+
+ mBatteryChartView.onAttachedToWindow();
+ assertThat(mBatteryChartView.isClickable()).isFalse();
+ }
+
+ @Test
+ public void testClickable_accessibilityIsDisabled_clickable() {
+ mBatteryChartView.setClickableForce(true);
+ when(mPowerUsageFeatureProvider.isChartGraphSlotsEnabled(mContext))
+ .thenReturn(true);
+ doReturn(false).when(mockAccessibilityManager).isEnabled();
+
+ mBatteryChartView.onAttachedToWindow();
+ assertThat(mBatteryChartView.isClickable()).isTrue();
+ }
+
+ @Test
+ public void testClickable_accessibilityIsEnabledWithoutValidId_clickable() {
+ mBatteryChartView.setClickableForce(true);
+ when(mPowerUsageFeatureProvider.isChartGraphSlotsEnabled(mContext))
+ .thenReturn(true);
+ doReturn(true).when(mockAccessibilityManager).isEnabled();
+ doReturn(new ArrayList<AccessibilityServiceInfo>())
+ .when(mockAccessibilityManager)
+ .getEnabledAccessibilityServiceList(anyInt());
+
+ mBatteryChartView.onAttachedToWindow();
+ assertThat(mBatteryChartView.isClickable()).isTrue();
+ }
+
+ @Test
+ public void testClickable_accessibilityIsEnabledWithValidId_notClickable() {
+ mBatteryChartView.setClickableForce(true);
+ when(mPowerUsageFeatureProvider.isChartGraphSlotsEnabled(mContext))
+ .thenReturn(true);
+ doReturn(true).when(mockAccessibilityManager).isEnabled();
+
+ mBatteryChartView.onAttachedToWindow();
+ assertThat(mBatteryChartView.isClickable()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java b/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java
index 0cc6b43..663d7f7 100644
--- a/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/TopLevelSettingsTest.java
@@ -18,14 +18,24 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
import android.util.FeatureFlagUtils;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
+import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Test;
@@ -43,6 +53,11 @@
mContext = RuntimeEnvironment.application;
mSettings = spy(new TopLevelSettings());
when(mSettings.getContext()).thenReturn(mContext);
+ final FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
+ when(featureFactory.dashboardFeatureProvider
+ .getTilesForCategory(nullable(String.class)))
+ .thenReturn(null);
+ mSettings.onAttach(mContext);
}
@Test
@@ -62,4 +77,21 @@
assertThat(mSettings.getPreferenceScreenResId()).isEqualTo(
R.xml.top_level_settings_grouped);
}
+
+ @Test
+ public void onCreatePreferences_shouldTintPreferenceIcon() {
+ final Preference preference = new Preference(mContext);
+ preference.setTitle(R.string.network_dashboard_title);
+ final Drawable icon = spy(mContext.getDrawable(R.drawable.ic_settings_wireless));
+ preference.setIcon(icon);
+ final PreferenceScreen screen = spy(new PreferenceScreen(mContext, null /* attrs */));
+ doReturn(1).when(screen).getPreferenceCount();
+ doReturn(preference).when(screen).getPreference(anyInt());
+ doReturn(screen).when(mSettings).getPreferenceScreen();
+ doReturn(0).when(mSettings).getPreferenceScreenResId();
+
+ mSettings.onCreatePreferences(new Bundle(), "rootKey");
+
+ verify(icon).setTint(anyInt());
+ }
}
diff --git a/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java
index a34e634..39c966d 100644
--- a/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/HibernatedAppsPreferenceControllerTest.java
@@ -24,17 +24,24 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.usage.IUsageStatsManager;
+import android.app.usage.UsageStats;
+import android.app.usage.UsageStatsManager;
import android.apphibernation.AppHibernationManager;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
+import android.content.pm.ParceledListSlice;
import android.content.res.Resources;
+import android.os.RemoteException;
import android.provider.DeviceConfig;
import androidx.test.core.app.ApplicationProvider;
@@ -58,11 +65,11 @@
PackageManager mPackageManager;
@Mock
AppHibernationManager mAppHibernationManager;
+ @Mock
+ IUsageStatsManager mIUsageStatsManager;
private static final String KEY = "key";
private Context mContext;
private HibernatedAppsPreferenceController mController;
- private PackageInfo mHibernatedPackage;
- private PackageInfo mAutoRevokedPackage;
@Before
public void setUp() {
@@ -73,10 +80,9 @@
when(mContext.getPackageManager()).thenReturn(mPackageManager);
when(mContext.getSystemService(AppHibernationManager.class))
.thenReturn(mAppHibernationManager);
+ when(mContext.getSystemService(UsageStatsManager.class)).thenReturn(
+ new UsageStatsManager(mContext, mIUsageStatsManager));
mController = new HibernatedAppsPreferenceController(mContext, KEY);
- mHibernatedPackage =
- getHibernatedPackage(mAppHibernationManager, mPackageManager, mContext);
- mAutoRevokedPackage = getAutoRevokedPackage(mPackageManager, mContext);
}
@Test
@@ -88,36 +94,71 @@
}
@Test
- public void getSummary_shouldReturnCorrectly() {
+ public void getSummary_getsRightCountForHibernatedPackage() {
+ final PackageInfo hibernatedPkg = getHibernatedPackage();
when(mPackageManager.getInstalledPackages(anyInt())).thenReturn(
- Arrays.asList(mHibernatedPackage, mAutoRevokedPackage, new PackageInfo()));
+ Arrays.asList(hibernatedPkg, new PackageInfo()));
when(mContext.getResources()).thenReturn(mock(Resources.class));
- final int totalHibernated = 2;
mController.getSummary();
- verify(mContext.getResources()).getQuantityString(
- anyInt(), eq(totalHibernated), eq(totalHibernated));
+ verify(mContext.getResources()).getQuantityString(anyInt(), eq(1), eq(1));
}
- private static PackageInfo getHibernatedPackage(
- AppHibernationManager apm, PackageManager pm, Context context) {
+ @Test
+ public void getSummary_getsRightCountForUnusedAutoRevokedPackage() {
+ final PackageInfo autoRevokedPkg = getAutoRevokedPackage();
+ when(mPackageManager.getInstalledPackages(anyInt())).thenReturn(
+ Arrays.asList(autoRevokedPkg, new PackageInfo()));
+ when(mContext.getResources()).thenReturn(mock(Resources.class));
+
+ mController.getSummary();
+ verify(mContext.getResources()).getQuantityString(anyInt(), eq(1), eq(1));
+ }
+
+ @Test
+ public void getSummary_getsRightCountForUsedAutoRevokedPackage() {
+ final PackageInfo usedAutoRevokedPkg = getAutoRevokedPackage();
+ setAutoRevokedPackageUsageStats();
+ when(mPackageManager.getInstalledPackages(anyInt())).thenReturn(
+ Arrays.asList(usedAutoRevokedPkg, new PackageInfo()));
+ when(mContext.getResources()).thenReturn(mock(Resources.class));
+
+ mController.getSummary();
+ verify(mContext.getResources()).getQuantityString(anyInt(), eq(0), eq(0));
+ }
+
+ private PackageInfo getHibernatedPackage() {
final PackageInfo pi = new PackageInfo();
pi.packageName = HIBERNATED_PACKAGE_NAME;
pi.requestedPermissions = new String[] {PERMISSION};
- when(apm.getHibernatingPackagesForUser()).thenReturn(Arrays.asList(pi.packageName));
- when(pm.getPermissionFlags(
- pi.requestedPermissions[0], pi.packageName, context.getUser()))
+ when(mAppHibernationManager.getHibernatingPackagesForUser())
+ .thenReturn(Arrays.asList(pi.packageName));
+ when(mPackageManager.getPermissionFlags(
+ pi.requestedPermissions[0], pi.packageName, mContext.getUser()))
.thenReturn(PackageManager.FLAG_PERMISSION_AUTO_REVOKED);
return pi;
}
- private static PackageInfo getAutoRevokedPackage(PackageManager pm, Context context) {
+ private PackageInfo getAutoRevokedPackage() {
final PackageInfo pi = new PackageInfo();
pi.packageName = AUTO_REVOKED_PACKAGE_NAME;
pi.requestedPermissions = new String[] {PERMISSION};
- when(pm.getPermissionFlags(
- pi.requestedPermissions[0], pi.packageName, context.getUser()))
+ when(mPackageManager.getPermissionFlags(
+ pi.requestedPermissions[0], pi.packageName, mContext.getUser()))
.thenReturn(PackageManager.FLAG_PERMISSION_AUTO_REVOKED);
return pi;
}
+
+ private void setAutoRevokedPackageUsageStats() {
+ final UsageStats us = new UsageStats();
+ us.mPackageName = AUTO_REVOKED_PACKAGE_NAME;
+ us.mLastTimeVisible = System.currentTimeMillis();
+ try {
+ when(mIUsageStatsManager.queryUsageStats(
+ anyInt(), anyLong(), anyLong(), anyString(), anyInt()))
+ .thenReturn(new ParceledListSlice(Arrays.asList(us)));
+ } catch (RemoteException e) {
+ // no-op
+ }
+ }
}