Follow config overlay's order of aspect ratio options am: a0f573a35e
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/26456385
Change-Id: I30ff221caba3be36834acb44958cf2aed30c17d1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 5a0e98e..ecc795e 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -653,7 +653,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/layout/battery_tips_card.xml"
- line="57"
+ line="58"
column="13"/>
</issue>
@@ -669,7 +669,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/layout/battery_tips_card.xml"
- line="57"
+ line="58"
column="13"/>
</issue>
@@ -1577,11 +1577,11 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <color name="screen_flash_color_button_outer_circle_stroke_color">#FFFFFF</color>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" <color name="battery_good_color_light">#43a047</color> <!-- Material Green 600 -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
- file="res/values-night/colors.xml"
- line="74"
+ file="res/values/colors.xml"
+ line="75"
column="5"/>
</issue>
@@ -1593,11 +1593,11 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <color name="battery_good_color_light">#43a047</color> <!-- Material Green 600 -->"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ errorLine1=" <color name="screen_flash_color_button_outer_circle_stroke_color">#FFFFFF</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
- file="res/values/colors.xml"
- line="75"
+ file="res/values-night/colors.xml"
+ line="76"
column="5"/>
</issue>
@@ -1629,7 +1629,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-night/colors.xml"
- line="77"
+ line="79"
column="5"/>
</issue>
@@ -2269,7 +2269,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="141"
+ line="143"
column="5"/>
</issue>
@@ -2285,7 +2285,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="142"
+ line="144"
column="5"/>
</issue>
@@ -2301,7 +2301,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="143"
+ line="145"
column="5"/>
</issue>
@@ -2317,7 +2317,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="144"
+ line="146"
column="5"/>
</issue>
@@ -2333,7 +2333,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="146"
+ line="148"
column="5"/>
</issue>
@@ -2349,7 +2349,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="148"
+ line="150"
column="5"/>
</issue>
@@ -2365,7 +2365,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="151"
+ line="153"
column="5"/>
</issue>
@@ -2381,7 +2381,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="154"
+ line="156"
column="5"/>
</issue>
@@ -2397,7 +2397,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="155"
+ line="157"
column="5"/>
</issue>
@@ -2413,7 +2413,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="156"
+ line="158"
column="5"/>
</issue>
@@ -2429,7 +2429,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="157"
+ line="159"
column="5"/>
</issue>
@@ -2445,7 +2445,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="158"
+ line="160"
column="5"/>
</issue>
@@ -2461,7 +2461,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="173"
+ line="175"
column="5"/>
</issue>
@@ -2477,7 +2477,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="174"
+ line="176"
column="5"/>
</issue>
@@ -2493,7 +2493,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="177"
+ line="179"
column="5"/>
</issue>
@@ -2509,7 +2509,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="178"
+ line="180"
column="5"/>
</issue>
@@ -2525,7 +2525,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="180"
+ line="182"
column="5"/>
</issue>
@@ -2541,7 +2541,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="181"
+ line="183"
column="5"/>
</issue>
@@ -2557,7 +2557,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="182"
+ line="184"
column="5"/>
</issue>
@@ -2573,7 +2573,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="183"
+ line="185"
column="5"/>
</issue>
@@ -2589,7 +2589,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="187"
+ line="189"
column="5"/>
</issue>
@@ -2605,7 +2605,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="188"
+ line="190"
column="5"/>
</issue>
@@ -2621,7 +2621,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="191"
+ line="193"
column="5"/>
</issue>
@@ -2637,7 +2637,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="192"
+ line="194"
column="5"/>
</issue>
@@ -2653,7 +2653,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="193"
+ line="195"
column="5"/>
</issue>
@@ -2669,7 +2669,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="194"
+ line="196"
column="5"/>
</issue>
@@ -2685,7 +2685,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="195"
+ line="197"
column="5"/>
</issue>
@@ -2701,7 +2701,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="196"
+ line="198"
column="5"/>
</issue>
@@ -2717,7 +2717,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="197"
+ line="199"
column="5"/>
</issue>
@@ -2733,7 +2733,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="198"
+ line="200"
column="5"/>
</issue>
@@ -2749,7 +2749,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="199"
+ line="201"
column="5"/>
</issue>
@@ -2765,7 +2765,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="200"
+ line="202"
column="5"/>
</issue>
@@ -2781,7 +2781,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="201"
+ line="203"
column="5"/>
</issue>
@@ -2797,7 +2797,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="202"
+ line="204"
column="5"/>
</issue>
@@ -2813,7 +2813,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="205"
+ line="207"
column="5"/>
</issue>
@@ -2829,7 +2829,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="206"
+ line="208"
column="5"/>
</issue>
@@ -2845,7 +2845,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="207"
+ line="209"
column="5"/>
</issue>
@@ -2861,7 +2861,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="208"
+ line="210"
column="5"/>
</issue>
@@ -2877,7 +2877,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="209"
+ line="211"
column="5"/>
</issue>
@@ -2893,7 +2893,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="210"
+ line="212"
column="5"/>
</issue>
@@ -2909,7 +2909,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="211"
+ line="213"
column="5"/>
</issue>
@@ -2925,7 +2925,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="212"
+ line="214"
column="5"/>
</issue>
@@ -2941,7 +2941,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="213"
+ line="215"
column="5"/>
</issue>
@@ -2957,7 +2957,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="214"
+ line="216"
column="5"/>
</issue>
@@ -2973,7 +2973,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="215"
+ line="217"
column="5"/>
</issue>
@@ -2989,7 +2989,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="216"
+ line="218"
column="5"/>
</issue>
@@ -3005,7 +3005,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="219"
+ line="221"
column="5"/>
</issue>
@@ -3945,6 +3945,22 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" android:color="@color/accessibility_feature_background"/>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/drawable/ic_color_contrast.xml"
+ line="22"
+ column="13"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" android:color="@color/accessibility_color_inversion_background"/>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -6125,7 +6141,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="944"
+ line="943"
column="43"/>
</issue>
@@ -6141,7 +6157,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="944"
+ line="943"
column="43"/>
</issue>
@@ -6157,7 +6173,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="945"
+ line="944"
column="49"/>
</issue>
@@ -6173,7 +6189,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="945"
+ line="944"
column="49"/>
</issue>
@@ -6189,7 +6205,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="946"
+ line="945"
column="54"/>
</issue>
@@ -6205,7 +6221,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="946"
+ line="945"
column="54"/>
</issue>
@@ -6221,7 +6237,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="947"
+ line="946"
column="47"/>
</issue>
@@ -6237,7 +6253,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="947"
+ line="946"
column="47"/>
</issue>
@@ -6253,7 +6269,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="948"
+ line="947"
column="51"/>
</issue>
@@ -6269,7 +6285,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="948"
+ line="947"
column="51"/>
</issue>
@@ -6285,7 +6301,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="949"
+ line="948"
column="63"/>
</issue>
@@ -6301,7 +6317,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="949"
+ line="948"
column="63"/>
</issue>
diff --git a/res/drawable/ic_trackpad_bottom_right_click.xml b/res/drawable/ic_trackpad_bottom_right_click.xml
deleted file mode 100644
index ec85830..0000000
--- a/res/drawable/ic_trackpad_bottom_right_click.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- Copyright (C) 2023 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="960"
- android:viewportHeight="960"
- android:tint="?android:attr/colorControlNormal">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M120,840L120,780L780,780Q780,780 780,780Q780,780 780,780L780,120L840,120L840,780Q840,804.75 822.38,822.38Q804.75,840 780,840L120,840ZM599.91,670Q571,670 550.5,649.41Q530,628.82 530,599.91Q530,571 550.59,550.5Q571.18,530 600.09,530Q629,530 649.5,550.59Q670,571.18 670,600.09Q670,629 649.41,649.5Q628.82,670 599.91,670ZM220,480L220,420L378,420L119,161L161,119L420,378L420,220L480,220L480,480L220,480Z"/>
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_trackpad_pointer_speed.xml b/res/drawable/ic_trackpad_pointer_speed.xml
deleted file mode 100644
index 128282f..0000000
--- a/res/drawable/ic_trackpad_pointer_speed.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- Copyright (C) 2022 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="960"
- android:viewportHeight="960"
- android:tint="?android:attr/colorControlNormal">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M407,635Q430,658 473.5,656.5Q517,655 537,624L753,285L418,504Q388,524 386,568Q384,612 407,635ZM478,161Q535,161 597,179.5Q659,198 716,243L664,280Q619,250 567.5,235.5Q516,221 477.98,221Q337.51,221 238.75,321.21Q140,421.43 140,563.98Q140,609 152.5,655Q165,701 188,740L767,740Q789,704 802,656Q815,608 815,562Q815,520 802.5,471.5Q790,423 758,382L797,330Q835,386 854,442.5Q873,499 875,556Q877,616 863,669Q849,722 822,767Q810,790 796.5,795Q783,800 763,800L192,800Q175,800 158.5,791.5Q142,783 134,767Q108,719 94,669.5Q80,620 80,564Q80,481 111.5,407.5Q143,334 197,279.5Q251,225 323.68,193Q396.36,161 478,161ZM469,492L469,492Q469,492 469,492Q469,492 469,492Q469,492 469,492Q469,492 469,492Q469,492 469,492Q469,492 469,492L469,492L469,492L469,492Q469,492 469,492Q469,492 469,492Q469,492 469,492Q469,492 469,492Z"/>
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_trackpad_reverse_scrolling.xml b/res/drawable/ic_trackpad_reverse_scrolling.xml
deleted file mode 100644
index a62f904..0000000
--- a/res/drawable/ic_trackpad_reverse_scrolling.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- Copyright (C) 2022 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="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0"
- android:tint="?android:attr/colorControlNormal">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M16.1,25.5V9.7L10.1,15.7L8,13.6L17.65,3.95L27.3,13.6L25.2,15.7L19.1,9.65V25.5ZM30.35,43.95 L20.7,34.25 22.8,32.2 28.8,38.2V22.4H31.8V38.25L37.9,32.2L40,34.3Z"/>
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_trackpad_tap_to_click.xml b/res/drawable/ic_trackpad_tap_to_click.xml
deleted file mode 100644
index 7db0454..0000000
--- a/res/drawable/ic_trackpad_tap_to_click.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
- Copyright (C) 2022 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="24.0dp"
- android:height="24.0dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0"
- android:tint="?android:attr/colorControlNormal">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M23.25,2Q27.8,2 31.025,5.175Q34.25,8.35 34.25,12.9Q34.25,15.5 33.125,17.8Q32,20.1 29.95,21.7H28.25V19.2Q29.7,18.05 30.475,16.4Q31.25,14.75 31.25,12.9Q31.25,9.6 28.9,7.3Q26.55,5 23.25,5Q19.95,5 17.6,7.3Q15.25,9.6 15.25,12.9Q15.25,14.75 16.025,16.4Q16.8,18.05 18.25,19.2V22.8Q15.45,21.35 13.85,18.7Q12.25,16.05 12.25,12.9Q12.25,8.35 15.475,5.175Q18.7,2 23.25,2ZM21.35,44Q20.5,44 19.75,43.675Q19,43.35 18.45,42.8L8.15,32.5L10.95,29.6Q11.65,28.9 12.525,28.525Q13.4,28.15 14.35,28.4L18.25,29.3V13Q18.25,10.9 19.7,9.45Q21.15,8 23.25,8Q25.35,8 26.8,9.45Q28.25,10.9 28.25,13V21.6H29.55Q29.8,21.6 30,21.7Q30.2,21.8 30.45,21.9L37.85,25.5Q39.05,26.05 39.625,27.275Q40.2,28.5 39.95,29.8L38.15,40.7Q37.9,42.15 36.75,43.075Q35.6,44 34.15,44ZM20.95,41H35L37.15,28.55Q37.15,28.55 37.15,28.55Q37.15,28.55 37.15,28.55L28,24H25.25V13Q25.25,12.1 24.7,11.55Q24.15,11 23.25,11Q22.35,11 21.8,11.55Q21.25,12.1 21.25,13V32.95L13.55,31.3L12.4,32.45ZM35,41H20.95H21.25Q21.25,41 21.8,41Q22.35,41 23.25,41Q24.15,41 24.7,41Q25.25,41 25.25,41H28H35Q35,41 35,41Q35,41 35,41Z"/>
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_trackpad_touch_gestures_normal.xml b/res/drawable/ic_trackpad_touch_gestures_normal.xml
deleted file mode 100644
index 34619c8..0000000
--- a/res/drawable/ic_trackpad_touch_gestures_normal.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-Copyright (C) 2022 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="48"
- android:viewportHeight="48"
- android:tint="?android:attr/colorControlNormal">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M40.15,47 L38.2,43.1 34.3,41.15 38.2,39.3 40.15,35.3 42,39.3 46,41.15 42,43.1ZM28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4Q28.5,31.4 28.5,31.4ZM23.05,48H30.4L29.75,45H23.05Q22,45 20.975,44.8Q19.95,44.6 19.25,43.9L6.5,30.65L7.85,29.4L19.75,35.85V9.15Q19.75,8.6 20.1,8.25Q20.45,7.9 21,7.9Q21.55,7.9 21.9,8.25Q22.25,8.6 22.25,9.15V24H26V4.25Q26,3.7 26.35,3.35Q26.7,3 27.25,3Q27.8,3 28.15,3.35Q28.5,3.7 28.5,4.25V24H32.25V6.1Q32.25,5.55 32.6,5.2Q32.95,4.85 33.5,4.85Q34.05,4.85 34.4,5.2Q34.75,5.55 34.75,6.1V24H38.5V12.45Q38.5,11.9 38.85,11.55Q39.2,11.2 39.75,11.2Q40.3,11.2 40.65,11.55Q41,11.9 41,12.45V31.4H44V12.45Q44,10.7 42.75,9.45Q41.5,8.2 39.75,8.2Q39.2,8.2 38.675,8.3Q38.15,8.4 37.75,8.75V6.45Q37.75,4.55 36.525,3.2Q35.3,1.85 33.5,1.85Q32.85,1.85 32.25,2.025Q31.65,2.2 31.1,2.6Q30.65,1.4 29.625,0.7Q28.6,0 27.3,0Q25.55,0 24.275,1.25Q23,2.5 23,4.25V5.55Q22.6,5.2 22.075,5.05Q21.55,4.9 21,4.9Q19.25,4.9 18,6.15Q16.75,7.4 16.75,9.15V30.95L8.85,26.5Q8,26.05 7.1,26.325Q6.2,26.6 5.5,27.25L2,30.3L16.85,45.7Q18.05,46.95 19.675,47.475Q21.3,48 23.05,48ZM6.85,14.8 L5.15,11.15 1.5,9.45 5.15,7.75 6.85,4.1 8.55,7.7 12.2,9.6 8.6,11.15Z"/>
-</vector>
\ No newline at end of file
diff --git a/res/layout/search_bar.xml b/res/layout/search_bar.xml
index 1e83e22..5f6f9c5 100644
--- a/res/layout/search_bar.xml
+++ b/res/layout/search_bar.xml
@@ -34,8 +34,7 @@
android:paddingStart="@dimen/search_bar_padding_start"
android:paddingEnd="@dimen/search_bar_padding_end"
android:background="@drawable/search_bar_selected_background"
- android:focusable="true"
- android:focusableInTouchMode="true"
+ android:touchscreenBlocksFocus="false"
android:nextFocusForward="@+id/homepage_container"
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
android:navigationIcon="@drawable/ic_homepage_search">
diff --git a/res/layout/search_bar_two_pane_version.xml b/res/layout/search_bar_two_pane_version.xml
index 337294e..dec1c45 100644
--- a/res/layout/search_bar_two_pane_version.xml
+++ b/res/layout/search_bar_two_pane_version.xml
@@ -29,8 +29,7 @@
android:paddingStart="@dimen/search_bar_padding_start_two_pane"
android:paddingEnd="@dimen/search_bar_padding_end_two_pane"
android:background="@drawable/search_bar_selected_background"
- android:focusable="true"
- android:focusableInTouchMode="true"
+ android:touchscreenBlocksFocus="false"
android:nextFocusForward="@+id/homepage_container"
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
android:navigationIcon="@drawable/ic_homepage_search">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 55c48af..f26939e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3562,6 +3562,8 @@
<!-- [CHAR LIMIT=30] Title for managed profile location switch -->
<string name="managed_profile_location_switch_title">Location for work profile</string>
+ <!-- [CHAR LIMIT=60] Title for private profile location switch -->
+ <string name="private_profile_location_switch_title">Location for private space</string>
<!-- [CHAR LIMIT=30] Location settings screen. It's a link that directs the user to a page that
shows the location permission setting for each installed app -->
<string name="location_app_level_permissions">App location permissions</string>
@@ -4375,6 +4377,8 @@
<!-- Title text for 'Tap to click'. [CHAR LIMIT=35] -->
<string name="trackpad_tap_to_click">Tap to click</string>
+ <!-- TODO(b/321978150): mark as translatable once we have finalized text from UX. -->
+ <string name="trackpad_tap_dragging" translatable="false">Tap dragging</string>
<!-- Title text for 'Touchpad gestures' [CHAR LIMIT=35] -->
<string name="trackpad_touchpad_gesture_title">Touchpad gestures</string>
<!-- Summary text for 'Touchpad gestures' [CHAR LIMIT=60] -->
@@ -4478,8 +4482,14 @@
<!-- Summary for the modifier key picker dialog page [CHAR LIMIT=35] -->
<string name="modifier_keys_picker_summary">Choose a new key for <xliff:g id="modifier_key_default_name">%1$s</xliff:g>:</string>
+ <!-- Title text for per IME subtype keyboard layout. [CHAR LIMIT=35] -->
+ <string name="ime_label_title"><xliff:g id="ime_label" example="Gboard">%s</xliff:g> layout</string>
<!-- Summary text for keyboards when no layout has been selected. [CHAR LIMIT=35] -->
<string name="default_keyboard_layout">Default</string>
+ <!-- Summary text for keyboards when a layout is automatically selected. [CHAR LIMIT=35] -->
+ <string name="automatic_keyboard_layout_label">Automatic: <xliff:g id="layout_label" example="English(US)">%s</xliff:g></string>
+ <!-- Summary text for keyboards when a layout is user selected. [CHAR LIMIT=35] -->
+ <string name="user_selected_keyboard_layout_label">User selected: <xliff:g id="layout_label" example="English(US)">%s</xliff:g></string>
<!-- Title for the 'Speech' preference category. [CHAR LIMIT=45] -->
<string name="speech_category_title">Speech</string>
@@ -4750,6 +4760,14 @@
<string name="accessibility_magnification_triple_tap_warning_negative_button">Cancel</string>
<!-- Title for the accessibility preference screen to enable screen magnification settings. [CHAR LIMIT=35] -->
<string name="accessibility_magnification_service_settings_title">Magnification settings</string>
+ <!-- Title for accessibility magnification preference where user can move the magnification area by dragging one finger instead of two. [CHAR LIMIT=60] -->
+ <string name="accessibility_magnification_one_finger_panning_title">One-finger panning</string>
+ <!-- Summary for accessibility magnification preference when one finger panning feature is turned on.
+ The feature when enabled allows user to move the magnification area by dragging one finger instead of two. [CHAR LIMIT=60] -->
+ <string name="accessibility_magnification_one_finger_panning_summary_on">Move the magnification area by dragging one finger.</string>
+ <!-- Summary for accessibility magnification preference when one finger panning feature is turned off.
+ The feature when disabled, allows user to move the magnification area by dragging two fingers instead of one. [CHAR LIMIT=60] -->
+ <string name="accessibility_magnification_one_finger_panning_summary_off">Move the magnification area by dragging two fingers.</string>
<!-- Title for the accessibility preference screen to enable navigation bar screen magnification. [CHAR LIMIT=35] -->
<string name="accessibility_screen_magnification_navbar_title">Magnify with shortcut</string>
<!-- Summary for the accessibility magnification setting indicating both "Magnify with button" and "Magnify with triple-tap" are enabled [CHAR LIMIT=50] -->
@@ -11667,6 +11685,13 @@
<!-- Body text of automatic data switching at dual sim onboarding's primary sim page or SIMs page. [CHAR LIMIT=NONE] -->
<string name="primary_sim_automatic_data_msg">Use data from either SIM depending on coverage and availability</string>
+ <!-- Title of asking the user whether to restart device after enabling DSDS. [CHAR LIMIT=NONE] -->
+ <string name="sim_action_restart_dialog_title">Restart to use 2 SIMs</string>
+ <!-- Body text of asking the user whether to restart device after enabling DSDS. [CHAR LIMIT=NONE] -->
+ <string name="sim_action_restart_dialog_msg">To use 2 SIMs at once, restart your device, then turn on both SIMs</string>
+ <!-- Button text to cancel dialog and then enable the sim -->
+ <string name="sim_action_restart_dialog_cancel">Use <xliff:g id="carrier_name" example="Google Fi">%1$s</xliff:g> only</string>
+
<!-- Text of phone number item when the sim is data only. [CHAR LIMIT=NONE] -->
<string name="sim_onboarding_phoneNumber_data_only">Data only</string>
diff --git a/res/xml/accessibility_edit_shortcuts.xml b/res/xml/accessibility_edit_shortcuts.xml
index 8be0ee5..fdb5b99 100644
--- a/res/xml/accessibility_edit_shortcuts.xml
+++ b/res/xml/accessibility_edit_shortcuts.xml
@@ -18,66 +18,68 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto">
- <PreferenceCategory
- android:key="@string/accessibility_shortcut_description_pref">
+ <Preference
+ android:key="@string/accessibility_shortcut_description_pref"
+ android:persistent="false"
+ android:selectable="false"
+ settings:allowDividerAbove="false"
+ settings:allowDividerBelow="false"/>
- <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
- android:key="@string/accessibility_shortcut_fab_pref"
- android:persistent="false"
- android:selectable="true"
- settings:allowDividerAbove="false"
- settings:allowDividerBelow="false"
- settings:controller="com.android.settings.accessibility.shortcuts.FloatingButtonShortcutOptionController" />
+ <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
+ android:key="@string/accessibility_shortcut_fab_pref"
+ android:persistent="false"
+ android:selectable="true"
+ settings:allowDividerAbove="false"
+ settings:allowDividerBelow="false"
+ settings:controller="com.android.settings.accessibility.shortcuts.FloatingButtonShortcutOptionController" />
- <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
- android:key="@string/accessibility_shortcut_gesture_pref"
- android:persistent="false"
- android:selectable="true"
- settings:allowDividerAbove="false"
- settings:allowDividerBelow="false"
- settings:controller="com.android.settings.accessibility.shortcuts.GestureShortcutOptionController" />
+ <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
+ android:key="@string/accessibility_shortcut_gesture_pref"
+ android:persistent="false"
+ android:selectable="true"
+ settings:allowDividerAbove="false"
+ settings:allowDividerBelow="false"
+ settings:controller="com.android.settings.accessibility.shortcuts.GestureShortcutOptionController" />
- <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
- android:key="@string/accessibility_shortcut_nav_button_pref"
- android:persistent="false"
- android:selectable="true"
- settings:allowDividerAbove="false"
- settings:allowDividerBelow="false"
- settings:controller="com.android.settings.accessibility.shortcuts.NavButtonShortcutOptionController" />
+ <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
+ android:key="@string/accessibility_shortcut_nav_button_pref"
+ android:persistent="false"
+ android:selectable="true"
+ settings:allowDividerAbove="false"
+ settings:allowDividerBelow="false"
+ settings:controller="com.android.settings.accessibility.shortcuts.NavButtonShortcutOptionController" />
- <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
- android:key="@string/accessibility_shortcut_volume_keys_pref"
- android:persistent="false"
- android:selectable="true"
- settings:allowDividerAbove="false"
- settings:allowDividerBelow="false"
- settings:controller="com.android.settings.accessibility.shortcuts.VolumeKeysShortcutOptionController" />
+ <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
+ android:key="@string/accessibility_shortcut_volume_keys_pref"
+ android:persistent="false"
+ android:selectable="true"
+ settings:allowDividerAbove="false"
+ settings:allowDividerBelow="false"
+ settings:controller="com.android.settings.accessibility.shortcuts.VolumeKeysShortcutOptionController" />
- <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
- android:key="@string/accessibility_shortcut_two_fingers_double_tap_pref"
- android:persistent="false"
- android:selectable="true"
- settings:allowDividerAbove="false"
- settings:allowDividerBelow="false"
- settings:controller="com.android.settings.accessibility.shortcuts.TwoFingersDoubleTapShortcutOptionController" />
+ <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
+ android:key="@string/accessibility_shortcut_two_fingers_double_tap_pref"
+ android:persistent="false"
+ android:selectable="true"
+ settings:allowDividerAbove="false"
+ settings:allowDividerBelow="false"
+ settings:controller="com.android.settings.accessibility.shortcuts.TwoFingersDoubleTapShortcutOptionController" />
- <Preference
- android:icon="@drawable/ic_keyboard_arrow_down"
- android:key="@string/accessibility_shortcuts_advanced_collapsed"
- android:persistent="false"
- android:selectable="true"
- android:title="@string/accessibility_shortcut_edit_dialog_title_advance"
- settings:allowDividerAbove="false"
- settings:allowDividerBelow="false"
- settings:controller="com.android.settings.accessibility.shortcuts.AdvancedShortcutsPreferenceController" />
+ <Preference
+ android:icon="@drawable/ic_keyboard_arrow_down"
+ android:key="@string/accessibility_shortcuts_advanced_collapsed"
+ android:persistent="false"
+ android:selectable="true"
+ android:title="@string/accessibility_shortcut_edit_dialog_title_advance"
+ settings:allowDividerAbove="false"
+ settings:allowDividerBelow="false"
+ settings:controller="com.android.settings.accessibility.shortcuts.AdvancedShortcutsPreferenceController" />
- <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
- android:key="@string/accessibility_shortcut_triple_tap_pref"
- android:persistent="false"
- android:selectable="true"
- settings:allowDividerAbove="false"
- settings:allowDividerBelow="false"
- settings:controller="com.android.settings.accessibility.shortcuts.TripleTapShortcutOptionController" />
- </PreferenceCategory>
-
+ <com.android.settings.accessibility.shortcuts.ShortcutOptionPreference
+ android:key="@string/accessibility_shortcut_triple_tap_pref"
+ android:persistent="false"
+ android:selectable="true"
+ settings:allowDividerAbove="false"
+ settings:allowDividerBelow="false"
+ settings:controller="com.android.settings.accessibility.shortcuts.TripleTapShortcutOptionController" />
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index fe87efd..206cc46 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -49,6 +49,14 @@
settings:forWork="true"
settings:useAdminDisabledSummary="true"/>
+ <!-- This preference gets removed if there is no private profile -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:enabled="false"
+ android:key="private_profile_location_switch"
+ android:selectable="true"
+ android:title="@string/private_profile_location_switch_title"
+ settings:controller="com.android.settings.location.LocationForPrivateProfilePreferenceController"/>
+
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
<Preference
android:key="app_level_permissions"
diff --git a/res/xml/trackpad_settings.xml b/res/xml/trackpad_settings.xml
index cca92a3..6601036 100644
--- a/res/xml/trackpad_settings.xml
+++ b/res/xml/trackpad_settings.xml
@@ -23,7 +23,6 @@
android:key="trackpad_gesture_settings"
android:title="@string/trackpad_touchpad_gesture_title"
android:summary="@string/trackpad_touchpad_gesture_summary"
- android:icon="@drawable/ic_trackpad_touch_gestures_normal"
android:order="-10"
android:fragment="com.android.settings.inputmethod.TrackpadTouchGestureSettings"
settings:controller="com.android.settings.inputmethod.TrackpadTouchGestureSettingsController"/>
@@ -31,7 +30,6 @@
<SwitchPreferenceCompat
android:key="trackpad_tap_to_click"
android:title="@string/trackpad_tap_to_click"
- android:icon="@drawable/ic_trackpad_tap_to_click"
settings:controller="com.android.settings.inputmethod.TrackpadTapToClickPreferenceController"
android:order="10"/>
@@ -39,7 +37,6 @@
android:key="trackpad_reverse_scrolling"
android:title="@string/trackpad_reverse_scrolling_title"
android:summary="@string/trackpad_reverse_scrolling_summary"
- android:icon="@drawable/ic_trackpad_reverse_scrolling"
settings:controller="com.android.settings.inputmethod.TrackpadReverseScrollingPreferenceController"
android:order="20"/>
@@ -47,15 +44,20 @@
android:key="trackpad_bottom_right_tap"
android:title="@string/trackpad_bottom_right_tap_title"
android:summary="@string/trackpad_bottom_right_tap_summary"
- android:icon="@drawable/ic_trackpad_bottom_right_click"
settings:controller="com.android.settings.inputmethod.TrackpadBottomPreferenceController"
android:order="30"
settings:keywords="@string/keywords_trackpad_bottom_right_tap"/>
+ <!-- TODO(b/321978150): add a summary line once we have finalized text from UX. -->
+ <SwitchPreferenceCompat
+ android:key="trackpad_tap_dragging"
+ android:title="@string/trackpad_tap_dragging"
+ settings:controller="com.android.settings.inputmethod.TrackpadTapDraggingPreferenceController"
+ android:order="35"/>
+
<com.android.settings.widget.SeekBarPreference
android:key="trackpad_pointer_speed"
android:title="@string/trackpad_pointer_speed"
- android:icon="@drawable/ic_trackpad_pointer_speed"
android:order="40"
android:selectable="false"
settings:controller="com.android.settings.inputmethod.TrackpadPointerSpeedPreferenceController"/>
@@ -63,6 +65,5 @@
<com.android.settingslib.widget.ButtonPreference
android:key="trackpad_touch_gesture"
android:title="@string/trackpad_touch_gesture"
- android:icon="@drawable/ic_trackpad_touch_gestures_inverse"
settings:controller="com.android.settings.inputmethod.TouchGesturesButtonPreferenceController"/>
</PreferenceScreen>
diff --git a/src/com/android/settings/SettingsInitialize.java b/src/com/android/settings/SettingsInitialize.java
index c0c0777..297bad7 100644
--- a/src/com/android/settings/SettingsInitialize.java
+++ b/src/com/android/settings/SettingsInitialize.java
@@ -118,7 +118,8 @@
}
private void privateProfileSetup(Context context, PackageManager pm, UserInfo userInfo) {
- if (Flags.allowPrivateProfile()) {
+ if (Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
if (userInfo == null || !userInfo.isPrivateProfile()) {
return;
}
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 108e331..6e36ee3 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -1228,6 +1228,7 @@
UserProperties userProperties = userManager.getUserProperties(userHandle);
if (userProperties.getShowInSettings() == UserProperties.SHOW_IN_SETTINGS_SEPARATE) {
if (Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
&& userProperties.getShowInQuietMode()
== UserProperties.SHOW_IN_QUIET_MODE_HIDDEN) {
if (!userManager.isQuietModeEnabled(userHandle)) {
diff --git a/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceController.java b/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceController.java
index 869443c..58aa0cc 100644
--- a/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceController.java
+++ b/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceController.java
@@ -47,7 +47,7 @@
/**
- * A preference controller to turn on/off keyboard vibration state with a single toggle.
+ * A preference controller to turn on/off keyboard vibration state with a single toggle.
*/
public class KeyboardVibrationTogglePreferenceController extends TogglePreferenceController
implements DefaultLifecycleObserver {
@@ -110,7 +110,9 @@
@Override
public int getAvailabilityStatus() {
if (Flags.keyboardCategoryEnabled()
- && mContext.getResources().getBoolean(R.bool.config_keyboard_vibration_supported)) {
+ && mContext.getResources().getBoolean(R.bool.config_keyboard_vibration_supported)
+ && mContext.getResources().getFloat(
+ com.android.internal.R.dimen.config_keyboardHapticFeedbackFixedAmplitude) > 0) {
return AVAILABLE;
}
return UNSUPPORTED_ON_DEVICE;
diff --git a/src/com/android/settings/accessibility/MagnificationAlwaysOnPreferenceController.java b/src/com/android/settings/accessibility/MagnificationAlwaysOnPreferenceController.java
index e455aa8..f3d8575 100644
--- a/src/com/android/settings/accessibility/MagnificationAlwaysOnPreferenceController.java
+++ b/src/com/android/settings/accessibility/MagnificationAlwaysOnPreferenceController.java
@@ -22,12 +22,6 @@
import android.content.Context;
import android.provider.Settings;
-import androidx.lifecycle.Lifecycle;
-import androidx.lifecycle.LifecycleObserver;
-import androidx.lifecycle.OnLifecycleEvent;
-import androidx.preference.PreferenceScreen;
-import androidx.preference.TwoStatePreference;
-
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
@@ -36,15 +30,12 @@
* feature, where the magnifier will not deactivate on Activity transitions; it will only zoom out
* to 100%.
*/
-public class MagnificationAlwaysOnPreferenceController extends TogglePreferenceController
- implements LifecycleObserver {
+public class MagnificationAlwaysOnPreferenceController extends TogglePreferenceController {
private static final String TAG =
MagnificationAlwaysOnPreferenceController.class.getSimpleName();
static final String PREF_KEY = Settings.Secure.ACCESSIBILITY_MAGNIFICATION_ALWAYS_ON_ENABLED;
- private TwoStatePreference mSwitchPreference;
-
public MagnificationAlwaysOnPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@@ -71,24 +62,4 @@
public int getSliceHighlightMenuRes() {
return R.string.menu_key_accessibility;
}
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mSwitchPreference = screen.findPreference(getPreferenceKey());
- }
-
- // TODO(b/186731461): Remove it when this controller is used in DashBoardFragment only.
- @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
- void onResume() {
- updateState();
- }
-
- /**
- * Updates the state of preference components which has been displayed by
- * {@link MagnificationAlwaysOnPreferenceController#displayPreference}.
- */
- void updateState() {
- updateState(mSwitchPreference);
- }
}
diff --git a/src/com/android/settings/accessibility/MagnificationFollowTypingPreferenceController.java b/src/com/android/settings/accessibility/MagnificationFollowTypingPreferenceController.java
index 86983e3..b269a99 100644
--- a/src/com/android/settings/accessibility/MagnificationFollowTypingPreferenceController.java
+++ b/src/com/android/settings/accessibility/MagnificationFollowTypingPreferenceController.java
@@ -22,25 +22,16 @@
import android.content.Context;
import android.provider.Settings;
-import androidx.lifecycle.Lifecycle;
-import androidx.lifecycle.LifecycleObserver;
-import androidx.lifecycle.OnLifecycleEvent;
-import androidx.preference.PreferenceScreen;
-import androidx.preference.TwoStatePreference;
-
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
/** Controller that accesses and switches the preference status of following typing feature */
-public class MagnificationFollowTypingPreferenceController extends TogglePreferenceController
- implements LifecycleObserver {
+public class MagnificationFollowTypingPreferenceController extends TogglePreferenceController {
private static final String TAG =
MagnificationFollowTypingPreferenceController.class.getSimpleName();
static final String PREF_KEY = "magnification_follow_typing";
- private TwoStatePreference mFollowTypingPreference;
-
public MagnificationFollowTypingPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@@ -67,24 +58,4 @@
public int getSliceHighlightMenuRes() {
return R.string.menu_key_accessibility;
}
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mFollowTypingPreference = screen.findPreference(getPreferenceKey());
- }
-
- // TODO(b/186731461): Remove it when this controller is used in DashBoardFragment only.
- @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
- void onResume() {
- updateState();
- }
-
- /**
- * Updates the state of preference components which has been displayed by
- * {@link MagnificationFollowTypingPreferenceController#displayPreference}.
- */
- void updateState() {
- updateState(mFollowTypingPreference);
- }
}
diff --git a/src/com/android/settings/accessibility/MagnificationJoystickPreferenceController.java b/src/com/android/settings/accessibility/MagnificationJoystickPreferenceController.java
index 0a24e96..b480a0a 100644
--- a/src/com/android/settings/accessibility/MagnificationJoystickPreferenceController.java
+++ b/src/com/android/settings/accessibility/MagnificationJoystickPreferenceController.java
@@ -22,27 +22,18 @@
import android.content.Context;
import android.provider.Settings;
-import androidx.lifecycle.Lifecycle;
-import androidx.lifecycle.LifecycleObserver;
-import androidx.lifecycle.OnLifecycleEvent;
-import androidx.preference.PreferenceScreen;
-import androidx.preference.TwoStatePreference;
-
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
/**
* Controller that accesses and switches the preference status of the magnification joystick feature
*/
-public class MagnificationJoystickPreferenceController extends TogglePreferenceController
- implements LifecycleObserver {
+public class MagnificationJoystickPreferenceController extends TogglePreferenceController {
private static final String TAG =
MagnificationJoystickPreferenceController.class.getSimpleName();
static final String PREF_KEY = Settings.Secure.ACCESSIBILITY_MAGNIFICATION_JOYSTICK_ENABLED;
- private TwoStatePreference mSwitchPreference;
-
public MagnificationJoystickPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@@ -69,24 +60,4 @@
public int getSliceHighlightMenuRes() {
return R.string.menu_key_accessibility;
}
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- mSwitchPreference = screen.findPreference(getPreferenceKey());
- }
-
- // TODO(b/186731461): Remove it when this controller is used in DashBoardFragment only.
- @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
- void onResume() {
- updateState();
- }
-
- /**
- * Updates the state of preference components which has been displayed by
- * {@link MagnificationJoystickPreferenceController#displayPreference}.
- */
- void updateState() {
- updateState(mSwitchPreference);
- }
}
diff --git a/src/com/android/settings/accessibility/MagnificationModePreferenceController.java b/src/com/android/settings/accessibility/MagnificationModePreferenceController.java
index 4acf230..a8814ac 100644
--- a/src/com/android/settings/accessibility/MagnificationModePreferenceController.java
+++ b/src/com/android/settings/accessibility/MagnificationModePreferenceController.java
@@ -47,7 +47,6 @@
import com.android.settings.utils.AnnotationSpan;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnCreate;
-import com.android.settingslib.core.lifecycle.events.OnResume;
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
import java.util.ArrayList;
@@ -55,7 +54,7 @@
/** Controller that shows the magnification area mode summary and the preference click behavior. */
public class MagnificationModePreferenceController extends BasePreferenceController implements
- DialogCreatable, LifecycleObserver, OnCreate, OnResume, OnSaveInstanceState {
+ DialogCreatable, LifecycleObserver, OnCreate, OnSaveInstanceState {
static final String PREF_KEY = "screen_magnification_mode";
private static final int DIALOG_ID_BASE = 10;
@@ -297,12 +296,6 @@
updateCapabilitiesAndSummary(mModeCache);
}
- // TODO(b/186731461): Remove it when this controller is used in DashBoardFragment only.
- @Override
- public void onResume() {
- updateState(mModePreference);
- }
-
/**
* An interface to help the delegate to show the dialog. It will be injected to the delegate.
*/
diff --git a/src/com/android/settings/accessibility/MagnificationOneFingerPanningPreferenceController.java b/src/com/android/settings/accessibility/MagnificationOneFingerPanningPreferenceController.java
new file mode 100644
index 0000000..a2ce948
--- /dev/null
+++ b/src/com/android/settings/accessibility/MagnificationOneFingerPanningPreferenceController.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.provider.Settings;
+
+import androidx.annotation.Nullable;
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.TwoStatePreference;
+
+import com.android.server.accessibility.Flags;
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+
+public class MagnificationOneFingerPanningPreferenceController
+ extends TogglePreferenceController {
+ static final String PREF_KEY = Settings.Secure.ACCESSIBILITY_SINGLE_FINGER_PANNING_ENABLED;
+
+ @Nullable
+ private TwoStatePreference mSwitchPreference;
+
+ @VisibleForTesting
+ final boolean mDefaultValue;
+
+ public MagnificationOneFingerPanningPreferenceController(Context context) {
+ super(context, PREF_KEY);
+ boolean defaultValue;
+ try {
+ defaultValue = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_enable_a11y_magnification_single_panning);
+ } catch (Resources.NotFoundException e) {
+ defaultValue = false;
+ }
+ mDefaultValue = defaultValue;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return (Flags.enableMagnificationOneFingerPanningGesture())
+ ? AVAILABLE : DISABLED_FOR_USER;
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Secure.getInt(
+ mContext.getContentResolver(),
+ PREF_KEY,
+ (mDefaultValue) ? ON : OFF) == ON;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ var toReturn = Settings.Secure.putInt(mContext.getContentResolver(),
+ PREF_KEY,
+ (isChecked ? ON : OFF));
+ if (mSwitchPreference != null) {
+ refreshSummary(mSwitchPreference);
+ }
+ return toReturn;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ return (isChecked())
+ ? mContext.getString(
+ R.string.accessibility_magnification_one_finger_panning_summary_on)
+ : mContext.getString(
+ R.string.accessibility_magnification_one_finger_panning_summary_off);
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_accessibility;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mSwitchPreference = screen.findPreference(getPreferenceKey());
+ refreshSummary(mSwitchPreference);
+ }
+}
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 023556c..985d45d 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -200,28 +200,16 @@
final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY);
generalCategory.addPreference(mSettingsPreference);
+ addOneFingerPanningSetting(generalCategory);
final MagnificationModePreferenceController magnificationModePreferenceController =
new MagnificationModePreferenceController(getContext(),
MagnificationModePreferenceController.PREF_KEY);
magnificationModePreferenceController.setDialogHelper(this);
getSettingsLifecycle().addObserver(magnificationModePreferenceController);
magnificationModePreferenceController.displayPreference(getPreferenceScreen());
+ addPreferenceController(magnificationModePreferenceController);
- mFollowingTypingSwitchPreference = new SwitchPreferenceCompat(getPrefContext());
- mFollowingTypingSwitchPreference.setTitle(
- R.string.accessibility_screen_magnification_follow_typing_title);
- mFollowingTypingSwitchPreference.setSummary(
- R.string.accessibility_screen_magnification_follow_typing_summary);
- mFollowingTypingSwitchPreference.setKey(
- MagnificationFollowTypingPreferenceController.PREF_KEY);
- generalCategory.addPreference(mFollowingTypingSwitchPreference);
-
- mFollowTypingPreferenceController = new MagnificationFollowTypingPreferenceController(
- getContext(), MagnificationFollowTypingPreferenceController.PREF_KEY);
- getSettingsLifecycle().addObserver(mFollowTypingPreferenceController);
- mFollowTypingPreferenceController.displayPreference(getPreferenceScreen());
- addPreferenceController(mFollowTypingPreferenceController);
-
+ addFollowTypingSetting(generalCategory);
addAlwaysOnSetting(generalCategory);
addJoystickSetting(generalCategory);
}
@@ -250,6 +238,22 @@
super.onProcessArguments(arguments);
}
+ private void addFollowTypingSetting(PreferenceCategory generalCategory) {
+ var followTypingSwitchPreference = new SwitchPreferenceCompat(getPrefContext());
+ followTypingSwitchPreference.setTitle(
+ R.string.accessibility_screen_magnification_follow_typing_title);
+ followTypingSwitchPreference.setSummary(
+ R.string.accessibility_screen_magnification_follow_typing_summary);
+ followTypingSwitchPreference.setKey(
+ MagnificationFollowTypingPreferenceController.PREF_KEY);
+ generalCategory.addPreference(followTypingSwitchPreference);
+
+ var followTypingPreferenceController = new MagnificationFollowTypingPreferenceController(
+ getContext(), MagnificationFollowTypingPreferenceController.PREF_KEY);
+ followTypingPreferenceController.displayPreference(getPreferenceScreen());
+ addPreferenceController(followTypingPreferenceController);
+ }
+
private boolean isAlwaysOnSettingEnabled() {
final boolean defaultValue = getContext().getResources().getBoolean(
com.android.internal.R.bool.config_magnification_always_on_enabled);
@@ -276,11 +280,28 @@
var alwaysOnPreferenceController = new MagnificationAlwaysOnPreferenceController(
getContext(), MagnificationAlwaysOnPreferenceController.PREF_KEY);
- getSettingsLifecycle().addObserver(alwaysOnPreferenceController);
alwaysOnPreferenceController.displayPreference(getPreferenceScreen());
addPreferenceController(alwaysOnPreferenceController);
}
+ private void addOneFingerPanningSetting(PreferenceCategory generalCategory) {
+ if (!Flags.enableMagnificationOneFingerPanningGesture()) {
+ return;
+ }
+
+ var oneFingerPanningPreference = new SwitchPreferenceCompat(getPrefContext());
+ oneFingerPanningPreference.setTitle(
+ R.string.accessibility_magnification_one_finger_panning_title);
+ oneFingerPanningPreference.setKey(
+ MagnificationOneFingerPanningPreferenceController.PREF_KEY);
+ generalCategory.addPreference(oneFingerPanningPreference);
+
+ var oneFingerPanningPreferenceController =
+ new MagnificationOneFingerPanningPreferenceController(getContext());
+ oneFingerPanningPreferenceController.displayPreference(getPreferenceScreen());
+ addPreferenceController(oneFingerPanningPreferenceController);
+ }
+
private void addJoystickSetting(PreferenceCategory generalCategory) {
if (!DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_WINDOW_MANAGER,
@@ -304,7 +325,6 @@
getContext(),
MagnificationJoystickPreferenceController.PREF_KEY
);
- getSettingsLifecycle().addObserver(joystickPreferenceController);
joystickPreferenceController.displayPreference(getPreferenceScreen());
addPreferenceController(joystickPreferenceController);
}
diff --git a/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragment.java b/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragment.java
index 5a3b13a..aba342a 100644
--- a/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragment.java
@@ -207,9 +207,9 @@
activity.setTitle(titles.first);
- String categoryKey = activity.getResources().getString(
+ String screenDescriptionPrefKey = getString(
R.string.accessibility_shortcut_description_pref);
- findPreference(categoryKey).setTitle(titles.second);
+ findPreference(screenDescriptionPrefKey).setSummary(titles.second);
}
@NonNull
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index 2d862d6..4f03303 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -311,11 +311,10 @@
// should be shown or not.
if (((profile.isManagedProfile()
&& (mType & ProfileSelectFragment.ProfileType.WORK) != 0)
- || (Flags.allowPrivateProfile()
- && profile.isPrivateProfile()
+ || (isPrivateProfile(profile)
&& (mType & ProfileSelectFragment.ProfileType.PRIVATE) != 0)
|| (!profile.isManagedProfile()
- && !(Flags.allowPrivateProfile() && profile.isPrivateProfile())
+ && !isPrivateProfile(profile)
&& (mType & ProfileSelectFragment.ProfileType.PERSONAL) != 0))
&& !(mUm.getUserProperties(profile.getUserHandle())
.getShowInQuietMode() == UserProperties.SHOW_IN_QUIET_MODE_HIDDEN
@@ -338,6 +337,12 @@
mFragment.forceUpdatePreferences();
}
+ private static boolean isPrivateProfile(UserInfo profile) {
+ return Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
+ && profile.isPrivateProfile();
+ }
+
private void updateProfileUi(final UserInfo userInfo) {
if (mFragment.getPreferenceManager() == null) {
return;
diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
index 4e39070..b2ec589 100644
--- a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
+++ b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
@@ -39,7 +39,6 @@
import com.android.settings.SettingsActivity;
import com.android.settings.SubSettings;
import com.android.settings.biometrics.face.FaceEnrollIntroduction;
-import com.android.settings.biometrics.face.FaceEnrollIntroductionInternal;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroductionInternal;
@@ -260,7 +259,6 @@
addActivityFilter(activityFilters, FingerprintEnrollIntroduction.class);
addActivityFilter(activityFilters, FingerprintEnrollIntroductionInternal.class);
addActivityFilter(activityFilters, FingerprintEnrollEnrolling.class);
- addActivityFilter(activityFilters, FaceEnrollIntroductionInternal.class);
addActivityFilter(activityFilters, FaceEnrollIntroduction.class);
addActivityFilter(activityFilters, RemoteAuthActivity.class);
addActivityFilter(activityFilters, RemoteAuthActivityInternal.class);
diff --git a/src/com/android/settings/applications/credentials/DefaultCombinedPickerPrivate.java b/src/com/android/settings/applications/credentials/DefaultCombinedPickerPrivate.java
index 8d8af0e..52adc4d 100644
--- a/src/com/android/settings/applications/credentials/DefaultCombinedPickerPrivate.java
+++ b/src/com/android/settings/applications/credentials/DefaultCombinedPickerPrivate.java
@@ -17,7 +17,6 @@
package com.android.settings.applications.credentials;
import android.os.UserManager;
-import android.util.Slog;
import com.android.settings.Utils;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment.ProfileType;
@@ -33,13 +32,6 @@
/** Returns whether the user is handled by this fragment. */
public static boolean isUserHandledByFragment(UserManager userManager) {
- try {
- // If there is no private profile then this will throw an exception.
- Utils.getCurrentUserIdOfType(userManager, ProfileType.PRIVATE);
- return true;
- } catch (IllegalStateException e) {
- Slog.e(TAG, "Failed to get private profile user id", e);
- return false;
- }
+ return android.os.Flags.allowPrivateProfile() && userManager.isPrivateProfile();
}
}
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
index 640f21d..86c11c2 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
@@ -167,8 +167,9 @@
}
private boolean shouldSkipProfile(UserHandle profile) {
- return android.os.Flags.allowPrivateProfile()
+ return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.handleInterleavedSettingsForPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
&& mUm.isQuietModeEnabled(profile)
&& mUm.getUserProperties(profile).getShowInQuietMode()
== UserProperties.SHOW_IN_QUIET_MODE_HIDDEN;
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
index f92cfbf..26965fa 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
@@ -340,6 +340,9 @@
final List<FingerprintSensorPropertiesInternal> props =
mFingerprintManager.getSensorPropertiesInternal();
// This will need to be updated for devices with multiple fingerprint sensors
+ if (props == null || props.isEmpty()) {
+ return R.string.fingerprint_intro_error_unknown;
+ }
final int max = props.get(0).maxEnrollmentsPerUser;
final int numEnrolledFingerprints =
mFingerprintManager.getEnrolledFingerprints(mUserId).size();
diff --git a/src/com/android/settings/connecteddevice/threadnetwork/ThreadNetworkPreferenceController.kt b/src/com/android/settings/connecteddevice/threadnetwork/ThreadNetworkPreferenceController.kt
index 10e3f84..f5c0a87 100644
--- a/src/com/android/settings/connecteddevice/threadnetwork/ThreadNetworkPreferenceController.kt
+++ b/src/com/android/settings/connecteddevice/threadnetwork/ThreadNetworkPreferenceController.kt
@@ -156,7 +156,7 @@
return true
}
- override fun onStateChanged(lifecycleOwner: LifecycleOwner, event: Lifecycle.Event) {
+ override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
if (threadController == null) {
return
}
diff --git a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
index 8279588..e8f407b 100644
--- a/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
+++ b/src/com/android/settings/dashboard/profileselector/ProfileSelectFragment.java
@@ -230,7 +230,8 @@
if (bundle != null) {
final int extraTab = bundle.getInt(SettingsActivity.EXTRA_SHOW_FRAGMENT_TAB, -1);
if (extraTab != -1) {
- return ((ViewPagerAdapter) mViewPager.getAdapter()).getTabForPosition(extraTab);
+ return ((ViewPagerAdapter) mViewPager.getAdapter())
+ .getPositionForProfileTab(extraTab);
}
final int userId = bundle.getInt(EXTRA_USER_ID, UserHandle.SYSTEM.getIdentifier());
final boolean isWorkProfile = UserManager.get(activity).isManagedProfile(userId);
@@ -238,7 +239,9 @@
return WORK_TAB;
}
UserInfo userInfo = UserManager.get(activity).getUserInfo(userId);
- if (Flags.allowPrivateProfile() && userInfo != null && userInfo.isPrivateProfile()) {
+ if (Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
+ && userInfo != null && userInfo.isPrivateProfile()) {
return PRIVATE_TAB;
}
}
@@ -248,7 +251,9 @@
return WORK_TAB;
}
UserInfo userInfo = UserManager.get(activity).getUserInfo(intentUser);
- if (Flags.allowPrivateProfile() && userInfo != null && userInfo.isPrivateProfile()) {
+ if (Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
+ && userInfo != null && userInfo.isPrivateProfile()) {
return PRIVATE_TAB;
}
@@ -259,7 +264,7 @@
final DevicePolicyManager devicePolicyManager =
getContext().getSystemService(DevicePolicyManager.class);
- if (Flags.allowPrivateProfile()) {
+ if (Flags.allowPrivateProfile() && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
int tabForPosition =
((ViewPagerAdapter) mViewPager.getAdapter()).getTabForPosition(position);
@@ -330,7 +335,9 @@
ProfileType.WORK,
bundle != null ? bundle.deepCopy() : new Bundle(),
workFragmentConstructor));
- } else if (Flags.allowPrivateProfile() && userInfo.isPrivateProfile()) {
+ } else if (Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
+ && userInfo.isPrivateProfile()) {
if (!privateSpaceInfoProvider.isPrivateSpaceLocked(context)) {
fragments.add(createAndGetFragment(
ProfileType.PRIVATE,
@@ -410,7 +417,22 @@
}
@ProfileType
int profileType = mChildFragments[position].getArguments().getInt(EXTRA_PROFILE);
+ return profileTypeToTab(profileType);
+ }
+ private int getPositionForProfileTab(int profileTab) {
+ for (int i = 0; i < mChildFragments.length; ++i) {
+ Bundle arguments = mChildFragments[i].getArguments();
+ if (arguments != null
+ && profileTypeToTab(arguments.getInt(EXTRA_PROFILE)) == profileTab) {
+ return i;
+ }
+ }
+ Log.e(TAG, "position requested for an unknown profile tab " + profileTab);
+ return 0;
+ }
+
+ private int profileTypeToTab(@ProfileType int profileType) {
if (profileType == ProfileType.WORK) {
return WORK_TAB;
}
diff --git a/src/com/android/settings/dashboard/profileselector/UserAdapter.java b/src/com/android/settings/dashboard/profileselector/UserAdapter.java
index c9e49f1..40d1a93 100644
--- a/src/com/android/settings/dashboard/profileselector/UserAdapter.java
+++ b/src/com/android/settings/dashboard/profileselector/UserAdapter.java
@@ -87,6 +87,7 @@
return resources.getString(WORK_CATEGORY_HEADER,
() -> context.getString(com.android.settingslib.R.string.category_work));
} else if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
&& mUserManager.getUserInfo(userId).isPrivateProfile()) {
return resources.getString(PRIVATE_CATEGORY_HEADER,
() -> context.getString(com.android.settingslib.R.string.category_private));
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
index 887fc32..ef542a3 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
@@ -257,6 +257,7 @@
private boolean shouldSkipProfile(UserInfo userInfo) {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.handleInterleavedSettingsForPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
&& userInfo.isQuietModeEnabled()
&& mUm.getUserProperties(userInfo.getUserHandle()).getShowInQuietMode()
== UserProperties.SHOW_IN_QUIET_MODE_HIDDEN;
diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
index 05dc5be..2bbb567 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
@@ -21,6 +21,7 @@
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
import android.hardware.input.KeyboardLayout;
+import android.hardware.input.KeyboardLayoutSelectionResult;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
@@ -180,7 +181,7 @@
mapLanguageWithLayout(info, subtype);
}
}
- updatePreferenceLayout(preferenceScreen, info);
+ updatePreferenceLayout(preferenceScreen, info, infoList.size() > 1);
}
}
@@ -189,14 +190,15 @@
KeyboardLayout[] keyboardLayouts =
NewKeyboardSettingsUtils.getKeyboardLayouts(
mIm, mUserId, mInputDeviceIdentifier, info, subtype);
- String layout = NewKeyboardSettingsUtils.getKeyboardLayout(
+ KeyboardLayoutSelectionResult result = NewKeyboardSettingsUtils.getKeyboardLayout(
mIm, mUserId, mInputDeviceIdentifier, info, subtype);
- if (layout != null) {
+ if (result.getLayoutDescriptor() != null) {
for (int i = 0; i < keyboardLayouts.length; i++) {
- if (keyboardLayouts[i].getDescriptor().equals(layout)) {
+ if (keyboardLayouts[i].getDescriptor().equals(result.getLayoutDescriptor())) {
KeyboardInfo keyboardInfo = new KeyboardInfo(
subtypeLabel,
keyboardLayouts[i].getLabel(),
+ result.getSelectionCriteria(),
info,
subtype);
mKeyboardInfoList.add(keyboardInfo);
@@ -208,18 +210,22 @@
KeyboardInfo keyboardInfo = new KeyboardInfo(
subtypeLabel,
mContext.getString(R.string.keyboard_default_layout),
+ KeyboardLayoutSelectionResult.LAYOUT_SELECTION_CRITERIA_UNSPECIFIED,
info,
subtype);
mKeyboardInfoList.add(keyboardInfo);
}
}
- private void updatePreferenceLayout(PreferenceScreen preferenceScreen, InputMethodInfo info) {
+ private void updatePreferenceLayout(PreferenceScreen preferenceScreen, InputMethodInfo info,
+ boolean hasMultipleImes) {
if (mKeyboardInfoList.isEmpty()) {
return;
}
PreferenceCategory preferenceCategory = new PreferenceCategory(mContext);
- preferenceCategory.setTitle(info.loadLabel(mContext.getPackageManager()));
+ preferenceCategory.setTitle(hasMultipleImes ? mContext.getString(R.string.ime_label_title,
+ info.loadLabel(mContext.getPackageManager()))
+ : mContext.getString(R.string.enabled_locales_keyboard_layout));
preferenceCategory.setKey(info.getPackageName());
preferenceScreen.addPreference(preferenceCategory);
Collections.sort(mKeyboardInfoList, new Comparator<KeyboardInfo>() {
@@ -234,7 +240,7 @@
final Preference pref = new Preference(mContext);
pref.setKey(keyboardInfo.getPrefId());
pref.setTitle(keyboardInfo.getSubtypeLabel());
- pref.setSummary(keyboardInfo.getLayout());
+ pref.setSummary(keyboardInfo.getLayoutSummaryText(mContext));
pref.setOnPreferenceClickListener(
preference -> {
showKeyboardLayoutPicker(
diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java
index ac8037f..ec727e8 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerController.java
@@ -21,6 +21,7 @@
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
import android.hardware.input.KeyboardLayout;
+import android.hardware.input.KeyboardLayoutSelectionResult;
import android.os.Bundle;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
@@ -201,13 +202,13 @@
private String getSelectedLayoutLabel() {
String label = mContext.getString(R.string.keyboard_default_layout);
- String layout = NewKeyboardSettingsUtils.getKeyboardLayout(
+ KeyboardLayoutSelectionResult result = NewKeyboardSettingsUtils.getKeyboardLayout(
mIm, mUserId, mInputDeviceIdentifier, mInputMethodInfo, mInputMethodSubtype);
KeyboardLayout[] keyboardLayouts = NewKeyboardSettingsUtils.getKeyboardLayouts(
mIm, mUserId, mInputDeviceIdentifier, mInputMethodInfo, mInputMethodSubtype);
- if (layout != null) {
+ if (result.getLayoutDescriptor() != null) {
for (KeyboardLayout keyboardLayout : keyboardLayouts) {
- if (keyboardLayout.getDescriptor().equals(layout)) {
+ if (keyboardLayout.getDescriptor().equals(result.getLayoutDescriptor())) {
label = keyboardLayout.getLabel();
break;
}
diff --git a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
index a927165..8f1e5c8 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
@@ -16,20 +16,30 @@
package com.android.settings.inputmethod;
+import static android.hardware.input.KeyboardLayoutSelectionResult.LAYOUT_SELECTION_CRITERIA_USER;
+import static android.hardware.input.KeyboardLayoutSelectionResult.LAYOUT_SELECTION_CRITERIA_DEVICE;
+import static android.hardware.input.KeyboardLayoutSelectionResult.LAYOUT_SELECTION_CRITERIA_VIRTUAL_KEYBOARD;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SuppressLint;
+import android.annotation.UserIdInt;
import android.content.Context;
import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
import android.hardware.input.KeyboardLayout;
+import android.hardware.input.KeyboardLayoutSelectionResult;
+import android.hardware.input.KeyboardLayoutSelectionResult.LayoutSelectionCriteria;
import android.os.UserHandle;
import android.view.InputDevice;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
-import java.util.ArrayList;
+import com.android.settings.R;
+
import java.util.Arrays;
import java.util.Comparator;
-import java.util.List;
/**
* Utilities of keyboard settings
@@ -56,36 +66,47 @@
return false;
}
- static List<String> getSuitableImeLabels(Context context, InputMethodManager imm, int userId) {
- List<String> suitableInputMethodInfoLabels = new ArrayList<>();
- List<InputMethodInfo> infoList = imm.getEnabledInputMethodListAsUser(UserHandle.of(userId));
- for (InputMethodInfo info : infoList) {
- List<InputMethodSubtype> subtypes =
- imm.getEnabledInputMethodSubtypeList(info, true);
- for (InputMethodSubtype subtype : subtypes) {
- if (subtype.isSuitableForPhysicalKeyboardLayoutMapping()) {
- suitableInputMethodInfoLabels.add(
- info.loadLabel(context.getPackageManager()).toString());
- break;
+ @SuppressLint("MissingPermission")
+ @Nullable
+ static String getSelectedKeyboardLayoutLabelForUser(Context context, @UserIdInt int userId,
+ InputDeviceIdentifier inputDeviceIdentifier) {
+ InputMethodManager imm = context.getSystemService(InputMethodManager.class);
+ InputManager im = context.getSystemService(InputManager.class);
+ if (imm == null || im == null) {
+ return null;
+ }
+ InputMethodInfo imeInfo = imm.getCurrentInputMethodInfoAsUser(UserHandle.of(userId));
+ InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype();
+ KeyboardLayout[] keyboardLayouts = getKeyboardLayouts(im, userId, inputDeviceIdentifier,
+ imeInfo, subtype);
+ KeyboardLayoutSelectionResult result = getKeyboardLayout(im, userId, inputDeviceIdentifier,
+ imeInfo, subtype);
+ if (result != null) {
+ for (KeyboardLayout keyboardLayout : keyboardLayouts) {
+ if (keyboardLayout.getDescriptor().equals(result.getLayoutDescriptor())) {
+ return keyboardLayout.getLabel();
}
}
}
- return suitableInputMethodInfoLabels;
+ return null;
}
static class KeyboardInfo {
CharSequence mSubtypeLabel;
String mLayout;
+ @LayoutSelectionCriteria int mSelectionCriteria;
InputMethodInfo mInputMethodInfo;
InputMethodSubtype mInputMethodSubtype;
KeyboardInfo(
CharSequence subtypeLabel,
String layout,
+ @LayoutSelectionCriteria int selectionCriteria,
InputMethodInfo inputMethodInfo,
InputMethodSubtype inputMethodSubtype) {
mSubtypeLabel = subtypeLabel;
mLayout = layout;
+ mSelectionCriteria = selectionCriteria;
mInputMethodInfo = inputMethodInfo;
mInputMethodSubtype = inputMethodSubtype;
}
@@ -102,6 +123,17 @@
return mLayout;
}
+ String getLayoutSummaryText(Context context) {
+ if (isAutomaticSelection(mSelectionCriteria)) {
+ return context.getResources().getString(R.string.automatic_keyboard_layout_label,
+ mLayout);
+ } else if (isUserSelection(mSelectionCriteria)) {
+ return context.getResources().getString(
+ R.string.user_selected_keyboard_layout_label, mLayout);
+ }
+ return mLayout;
+ }
+
InputMethodInfo getInputMethodInfo() {
return mInputMethodInfo;
}
@@ -121,11 +153,21 @@
return inputManager.getKeyboardLayoutListForInputDevice(identifier, userId, info, subtype);
}
- static String getKeyboardLayout(InputManager inputManager, int userId,
+ @NonNull
+ static KeyboardLayoutSelectionResult getKeyboardLayout(InputManager inputManager, int userId,
InputDeviceIdentifier identifier, InputMethodInfo info, InputMethodSubtype subtype) {
return inputManager.getKeyboardLayoutForInputDevice(identifier, userId, info, subtype);
}
+ static boolean isAutomaticSelection(@LayoutSelectionCriteria int criteria) {
+ return criteria == LAYOUT_SELECTION_CRITERIA_DEVICE
+ || criteria == LAYOUT_SELECTION_CRITERIA_VIRTUAL_KEYBOARD;
+ }
+
+ static boolean isUserSelection(@LayoutSelectionCriteria int criteria) {
+ return criteria == LAYOUT_SELECTION_CRITERIA_USER;
+ }
+
static void sortKeyboardLayoutsByLabel(KeyboardLayout[] keyboardLayouts) {
Arrays.sort(
keyboardLayouts,
diff --git a/src/com/android/settings/inputmethod/OWNERS b/src/com/android/settings/inputmethod/OWNERS
index 7c7d792..8dc4870 100644
--- a/src/com/android/settings/inputmethod/OWNERS
+++ b/src/com/android/settings/inputmethod/OWNERS
@@ -3,6 +3,7 @@
include /OWNERS
# Settings for physical keyboard and game pad are better to be reviewed by the input team
-per-file GameControllerPreferenceController.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS
-per-file KeyboardLayoutPicker*.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS
-per-file PhysicalKeyboard*.java = file: platform/frameworks/base:/services/core/java/com/android/server/input/OWNERS
+per-file GameControllerPreferenceController.java = file:platform/frameworks/base:/INPUT_OWNERS
+per-file KeyboardLayoutPicker*.java = file:platform/frameworks/base:/INPUT_OWNERS
+per-file PhysicalKeyboard*.java = file:platform/frameworks/base:/INPUT_OWNERS
+per-file Trackpad*.java = file:platform/frameworks/base:/INPUT_OWNERS
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
index f2ac550..e102241 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
@@ -288,19 +288,11 @@
final Preference pref = new Preference(getPrefContext());
pref.setTitle(hardKeyboardDeviceInfo.mDeviceName);
if (mIsNewKeyboardSettings) {
- List<String> suitableImes = new ArrayList<>();
- suitableImes.addAll(
- NewKeyboardSettingsUtils.getSuitableImeLabels(
- getContext(), mImm, UserHandle.myUserId()));
- if (!suitableImes.isEmpty()) {
- String summary = suitableImes.get(0);
- StringBuilder result = new StringBuilder(summary);
- for (int i = 1; i < suitableImes.size(); i++) {
- result.append(", ").append(suitableImes.get(i));
- }
- pref.setSummary(result.toString());
- } else {
- pref.setSummary(hardKeyboardDeviceInfo.mLayoutLabel);
+ String currentLayout =
+ NewKeyboardSettingsUtils.getSelectedKeyboardLayoutLabelForUser(getContext(),
+ UserHandle.myUserId(), hardKeyboardDeviceInfo.mDeviceIdentifier);
+ if (currentLayout != null) {
+ pref.setSummary(currentLayout);
}
pref.setOnPreferenceClickListener(
preference -> {
diff --git a/src/com/android/settings/inputmethod/TrackpadTapDraggingPreferenceController.java b/src/com/android/settings/inputmethod/TrackpadTapDraggingPreferenceController.java
new file mode 100644
index 0000000..28c2915
--- /dev/null
+++ b/src/com/android/settings/inputmethod/TrackpadTapDraggingPreferenceController.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.inputmethod;
+
+import android.content.Context;
+import android.hardware.input.InputSettings;
+
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+
+public class TrackpadTapDraggingPreferenceController extends TogglePreferenceController {
+
+ public TrackpadTapDraggingPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return InputSettings.useTouchpadTapDragging(mContext);
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ InputSettings.setTouchpadTapDragging(mContext, isChecked);
+ // TODO(b/321978150): add a metric for tap dragging settings changes.
+ return true;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return InputSettings.isTouchpadTapDraggingFeatureFlagEnabled()
+ ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_system;
+ }
+}
diff --git a/src/com/android/settings/location/LocationForPrivateProfilePreferenceController.java b/src/com/android/settings/location/LocationForPrivateProfilePreferenceController.java
new file mode 100644
index 0000000..a7be7a5
--- /dev/null
+++ b/src/com/android/settings/location/LocationForPrivateProfilePreferenceController.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.location;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.text.TextUtils;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment.ProfileType;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+public class LocationForPrivateProfilePreferenceController
+ extends LocationBasePreferenceController {
+ @Nullable private RestrictedSwitchPreference mPreference;
+ @Nullable private final UserHandle mPrivateProfileHandle;
+ public LocationForPrivateProfilePreferenceController(
+ @NonNull Context context, @NonNull String key) {
+ super(context, key);
+ mPrivateProfileHandle = Utils.getProfileOfType(mUserManager, ProfileType.PRIVATE);
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(@NonNull Preference preference) {
+ if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
+ final boolean switchState = mPreference.isChecked();
+ mUserManager.setUserRestriction(
+ UserManager.DISALLOW_SHARE_LOCATION,
+ !switchState,
+ mPrivateProfileHandle);
+ mPreference.setSummary(switchState
+ ? R.string.switch_on_text : R.string.switch_off_text);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void displayPreference(@NonNull PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ if (mPreference != null) {
+ mPreference.setEnabled(isPrivateProfileAvailable());
+ }
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (!android.os.Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.handleInterleavedSettingsForPrivateSpace()
+ || !isPrivateProfileAvailable()) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ return AVAILABLE;
+ }
+
+ @Override
+ public void onLocationModeChanged(int mode, boolean restricted) {
+ if ((mPreference != null && !mPreference.isVisible())
+ || !isAvailable()
+ || !isPrivateProfileAvailable()) {
+ return;
+ }
+
+ // The profile owner (which is the admin for the child profile) might have added a location
+ // sharing restriction.
+ final RestrictedLockUtils.EnforcedAdmin admin =
+ mLocationEnabler.getShareLocationEnforcedAdmin(
+ mPrivateProfileHandle.getIdentifier());
+ if (admin != null) {
+ mPreference.setDisabledByAdmin(admin);
+ } else {
+ final boolean enabled = mLocationEnabler.isEnabled(mode);
+ mPreference.setEnabled(enabled);
+ int summaryResId;
+
+ final boolean isRestrictedByBase =
+ mLocationEnabler
+ .hasShareLocationRestriction(mPrivateProfileHandle.getIdentifier());
+ if (isRestrictedByBase || !enabled) {
+ mPreference.setChecked(false);
+ summaryResId = enabled ? R.string.switch_off_text
+ : R.string.location_app_permission_summary_location_off;
+ } else {
+ mPreference.setChecked(true);
+ summaryResId = R.string.switch_on_text;
+ }
+ mPreference.setSummary(summaryResId);
+ }
+ }
+
+ private boolean isPrivateProfileAvailable() {
+ return mPrivateProfileHandle != null
+ && !mUserManager.isQuietModeEnabled(mPrivateProfileHandle);
+ }
+}
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 7bb0228..87e8817 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -119,6 +119,7 @@
use(RecentLocationAccessSeeAllButtonPreferenceController.class).init(this);
use(LocationForWorkPreferenceController.class).init(this);
use(LocationSettingsFooterPreferenceController.class).init(this);
+ use(LocationForPrivateProfilePreferenceController.class).init(this);
}
@Override
diff --git a/src/com/android/settings/network/SimOnboardingActivity.kt b/src/com/android/settings/network/SimOnboardingActivity.kt
index 98bb5d7..350f5b8 100644
--- a/src/com/android/settings/network/SimOnboardingActivity.kt
+++ b/src/com/android/settings/network/SimOnboardingActivity.kt
@@ -21,7 +21,6 @@
import android.os.Bundle
import android.telephony.SubscriptionManager
import android.util.Log
-import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
@@ -45,7 +44,6 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
-import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
@@ -67,7 +65,6 @@
import com.android.settingslib.spa.widget.dialog.AlertDialogButton
import com.android.settingslib.spa.widget.dialog.getDialogWidth
import com.android.settingslib.spa.widget.dialog.rememberAlertDialogPresenter
-import com.android.settingslib.spa.widget.editor.SettingsOutlinedTextField
import com.android.settingslib.spa.widget.ui.SettingsTitle
import com.android.settingslib.spaprivileged.framework.common.userManager
import kotlinx.coroutines.CoroutineScope
@@ -83,6 +80,8 @@
lateinit var showBottomSheet: MutableState<Boolean>
lateinit var showError: MutableState<ErrorType>
lateinit var showProgressDialog: MutableState<Boolean>
+ lateinit var showDsdsProgressDialog: MutableState<Boolean>
+ lateinit var showRestartDialog: MutableState<Boolean>
private var switchToEuiccSubscriptionSidecar: SwitchToEuiccSubscriptionSidecar? = null
private var switchToRemovableSlotSidecar: SwitchToRemovableSlotSidecar? = null
@@ -132,6 +131,12 @@
setProgressDialog(false)
}
+ CallbackType.CALLBACK_ENABLE_DSDS-> {
+ scope.launch {
+ onboardingService.startEnableDsds(this@SimOnboardingActivity)
+ }
+ }
+
CallbackType.CALLBACK_ONBOARDING_COMPLETE -> {
showBottomSheet.value = false
setProgressDialog(true)
@@ -179,12 +184,14 @@
showBottomSheet = remember { mutableStateOf(false) }
showError = remember { mutableStateOf(ErrorType.ERROR_NONE) }
showProgressDialog = remember { mutableStateOf(false) }
+ showDsdsProgressDialog = remember { mutableStateOf(false) }
+ showRestartDialog = remember { mutableStateOf(false) }
scope = rememberCoroutineScope()
registerSidecarReceiverFlow()
ErrorDialogImpl()
-
+ RestartDialogImpl()
LaunchedEffect(Unit) {
if (onboardingService.activeSubInfoList.isNotEmpty()) {
showBottomSheet.value = true
@@ -196,29 +203,76 @@
BottomSheetImpl(
sheetState = sheetState,
nextAction = {
- // TODO: if the phone is SS mode and the isDsdsConditionSatisfied is true, then
- // enable the DSDS mode.
- // case#1: the device need the reboot after enabling DSDS. Showing the confirm
- // dialog to user whether reboot device or not.
- // case#2: The device don't need the reboot. Enabling DSDS and then showing
- // the SIM onboarding UI.
-
- // case#2
- val route = getRoute(onboardingService.targetSubId)
- startSpaActivity(route)
+ if (onboardingService.isDsdsConditionSatisfied()) {
+ // TODO: if the phone is SS mode and the isDsdsConditionSatisfied is true,
+ // then enable the DSDS mode.
+ // case#1: the device need the reboot after enabling DSDS. Showing the
+ // confirm dialog to user whether reboot device or not.
+ // case#2: The device don't need the reboot. Enabling DSDS and then showing
+ // the SIM onboarding UI.
+ if (onboardingService.doesSwitchMultiSimConfigTriggerReboot) {
+ // case#1
+ Log.d(TAG, "Device does not support reboot free DSDS.")
+ showRestartDialog.value = true
+ } else {
+ // case#2
+ Log.d(TAG, "Enable DSDS mode")
+ showDsdsProgressDialog.value = true
+ enableMultiSimSidecar?.run(SimOnboardingService.NUM_OF_SIMS_FOR_DSDS)
+ }
+ } else {
+ startSimOnboardingProvider()
+ }
},
cancelAction = { finish() },
)
}
- if(showProgressDialog.value) {
- ProgressDialogImpl()
+ if (showProgressDialog.value) {
+ ProgressDialogImpl(
+ stringResource(
+ R.string.sim_onboarding_progressbar_turning_sim_on,
+ onboardingService.targetSubInfo?.displayName ?: ""
+ )
+ )
+ }
+ if (showDsdsProgressDialog.value) {
+ ProgressDialogImpl(
+ stringResource(R.string.sim_action_enabling_sim_without_carrier_name)
+ )
+ }
+ }
+ @Composable
+ private fun RestartDialogImpl() {
+ val restartDialogPresenter = rememberAlertDialogPresenter(
+ confirmButton = AlertDialogButton(
+ stringResource(R.string.sim_action_reboot)
+ ) {
+ callbackListener(CallbackType.CALLBACK_ENABLE_DSDS)
+ },
+ dismissButton = AlertDialogButton(
+ stringResource(
+ R.string.sim_action_restart_dialog_cancel,
+ onboardingService.targetSubInfo?.displayName ?: "")
+ ) {
+ callbackListener(CallbackType.CALLBACK_ONBOARDING_COMPLETE)
+ },
+ title = stringResource(R.string.sim_action_restart_dialog_title),
+ text = {
+ Text(stringResource(R.string.sim_action_restart_dialog_msg))
+ },
+ )
+
+ if(showRestartDialog.value){
+ LaunchedEffect(Unit) {
+ restartDialogPresenter.open()
+ }
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
- fun ProgressDialogImpl() {
+ fun ProgressDialogImpl(title: String) {
// TODO: Create the SPA's ProgressDialog and using SPA's widget
BasicAlertDialog(
onDismissRequest = {},
@@ -232,19 +286,14 @@
) {
Row(
modifier = Modifier
- .fillMaxWidth()
- .padding(SettingsDimension.itemPaddingStart),
+ .fillMaxWidth()
+ .padding(SettingsDimension.itemPaddingStart),
verticalAlignment = Alignment.CenterVertically
) {
CircularProgressIndicator()
Column(modifier = Modifier
.padding(start = SettingsDimension.itemPaddingStart)) {
- SettingsTitle(
- stringResource(
- R.string.sim_onboarding_progressbar_turning_sim_on,
- onboardingService.targetSubInfo?.displayName ?: ""
- )
- )
+ SettingsTitle(title)
}
}
}
@@ -329,7 +378,7 @@
Log.e(TAG, "Error while sidecarReceiverFlow", e)
}.conflate()
- fun startSimSwitching(){
+ fun startSimSwitching() {
Log.d(TAG, "startSimSwitching:")
var targetSubInfo = onboardingService.targetSubInfo
@@ -376,8 +425,6 @@
switchToEuiccSubscriptionSidecar!!.reset()
showError.value = ErrorType.ERROR_EUICC_SLOT
callbackListener(CallbackType.CALLBACK_ERROR)
- // TODO: showErrorDialog and using privileged_action_disable_fail_title and
- // privileged_action_disable_fail_text
}
}
}
@@ -396,18 +443,19 @@
switchToRemovableSlotSidecar!!.reset()
showError.value = ErrorType.ERROR_REMOVABLE_SLOT
callbackListener(CallbackType.CALLBACK_ERROR)
- // TODO: showErrorDialog and using sim_action_enable_sim_fail_title and
- // sim_action_enable_sim_fail_text
}
}
}
fun handleEnableMultiSimSidecarStateChange() {
+ showDsdsProgressDialog.value = false
when (enableMultiSimSidecar!!.state) {
SidecarFragment.State.SUCCESS -> {
enableMultiSimSidecar!!.reset()
Log.i(TAG, "Successfully switched to DSDS without reboot.")
- handleEnableSubscriptionAfterEnablingDsds()
+ // refresh data
+ initServiceData(this, onboardingService.targetSubId, callbackListener)
+ startSimOnboardingProvider()
}
SidecarFragment.State.ERROR -> {
@@ -415,34 +463,14 @@
Log.i(TAG, "Failed to switch to DSDS without rebooting.")
showError.value = ErrorType.ERROR_ENABLE_DSDS
callbackListener(CallbackType.CALLBACK_ERROR)
- // TODO: showErrorDialog and using dsds_activation_failure_title and
- // dsds_activation_failure_body_msg2
}
}
}
- fun handleEnableSubscriptionAfterEnablingDsds() {
- var targetSubInfo = onboardingService.targetSubInfo
- if (targetSubInfo?.isEmbedded == true) {
- Log.i(TAG,
- "DSDS enabled, start to enable profile: " + targetSubInfo.getSubscriptionId()
- )
- // For eSIM operations, we simply switch to the selected eSIM profile.
- switchToEuiccSubscriptionSidecar!!.run(
- targetSubInfo.subscriptionId,
- UiccSlotUtil.INVALID_PORT_ID,
- null
- )
- return
- }
- Log.i(TAG, "DSDS enabled, start to enable pSIM profile.")
- onboardingService.handleTogglePsimAction()
- callbackListener(CallbackType.CALLBACK_FINISH)
- }
-
@Composable
fun BottomSheetBody(nextAction: () -> Unit) {
- Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.padding(bottom = SettingsDimension.itemPaddingVertical)) {
+ Column(horizontalAlignment = Alignment.CenterHorizontally,
+ modifier = Modifier.padding(bottom = SettingsDimension.itemPaddingVertical)) {
Icon(
imageVector = Icons.Outlined.SignalCellularAlt,
contentDescription = null,
@@ -497,6 +525,11 @@
onboardingService.initData(targetSubId, context,callback)
}
+ private fun startSimOnboardingProvider() {
+ val route = getRoute(onboardingService.targetSubId)
+ startSpaActivity(route)
+ }
+
companion object {
@JvmStatic
fun startSimOnboardingActivity(
@@ -523,9 +556,10 @@
enum class CallbackType(val value:Int){
CALLBACK_ERROR(-1),
CALLBACK_ONBOARDING_COMPLETE(1),
- CALLBACK_SETUP_NAME(2),
- CALLBACK_SETUP_PRIMARY_SIM(3),
- CALLBACK_FINISH(4)
+ CALLBACK_ENABLE_DSDS(2),
+ CALLBACK_SETUP_NAME(3),
+ CALLBACK_SETUP_PRIMARY_SIM(4),
+ CALLBACK_FINISH(5)
}
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/network/SimOnboardingService.kt b/src/com/android/settings/network/SimOnboardingService.kt
index 962741f..2ec1ad3 100644
--- a/src/com/android/settings/network/SimOnboardingService.kt
+++ b/src/com/android/settings/network/SimOnboardingService.kt
@@ -24,6 +24,7 @@
import android.telephony.UiccSlotInfo
import android.util.Log
import com.android.settings.network.SimOnboardingActivity.Companion.CallbackType
+import com.android.settings.sim.SimActivationNotifier
import com.android.settings.spa.network.setAutomaticData
import com.android.settings.spa.network.setDefaultData
import com.android.settings.spa.network.setDefaultSms
@@ -32,9 +33,6 @@
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
-private const val TAG = "SimOnboardingService"
-private const val INVALID = SubscriptionManager.INVALID_SUBSCRIPTION_ID
-
class SimOnboardingService {
var subscriptionManager:SubscriptionManager? = null
var telephonyManager:TelephonyManager? = null
@@ -70,7 +68,7 @@
}
return uiccCardInfoList.any { it.isMultipleEnabledProfilesSupported }
}
- var isRemovableSimEnabled: Boolean = false
+ var isRemovablePsimProfileEnabled: Boolean = false
get() {
if(slotInfoList.isEmpty()) {
Log.w(TAG, "UICC Slot info list is empty.")
@@ -78,7 +76,11 @@
}
return UiccSlotUtil.isRemovableSimEnabled(slotInfoList)
}
-
+ var isEsimProfileEnabled: Boolean = false
+ get() {
+ activeSubInfoList.stream().anyMatch { it.isEmbedded }
+ return false
+ }
var doesTargetSimHaveEsimOperation = false
get() {
return targetSubInfo?.isEmbedded ?: false
@@ -109,6 +111,19 @@
}
return getActiveModemCount != 0 && activeSubInfoList.size == getActiveModemCount
}
+ var isMultiSimEnabled = false
+ get() {
+ return getActiveModemCount > 1
+ }
+ var isMultiSimSupported = false
+ get() {
+ return telephonyManager?.isMultiSimSupported == TelephonyManager.MULTISIM_ALLOWED
+ }
+
+ var doesSwitchMultiSimConfigTriggerReboot = false
+ get() {
+ return telephonyManager?.doesSwitchMultiSimConfigTriggerReboot() ?: false
+ }
fun isValid(): Boolean {
return targetSubId != INVALID
@@ -161,9 +176,10 @@
targetPrimarySimCalls = SubscriptionManager.getDefaultVoiceSubscriptionId()
targetPrimarySimTexts = SubscriptionManager.getDefaultSmsSubscriptionId()
targetPrimarySimMobileData = SubscriptionManager.getDefaultDataSubscriptionId()
+
Log.d(
TAG,"doesTargetSimHaveEsimOperation: $doesTargetSimHaveEsimOperation" +
- ", isRemovableSimEnabled: $isRemovableSimEnabled" +
+ ", isRemovableSimEnabled: $isRemovablePsimProfileEnabled" +
", isMultipleEnabledProfilesSupported: $isMultipleEnabledProfilesSupported" +
", targetPrimarySimCalls: $targetPrimarySimCalls" +
", targetPrimarySimTexts: $targetPrimarySimTexts" +
@@ -261,6 +277,45 @@
}
}
+ fun isDsdsConditionSatisfied(): Boolean {
+ if (isMultiSimEnabled) {
+ Log.d(
+ TAG,
+ "DSDS is already enabled. Condition not satisfied."
+ )
+ return false
+ }
+ if (!isMultiSimSupported) {
+ Log.d(TAG, "Hardware does not support DSDS.")
+ return false
+ }
+ val isActiveSim = activeSubInfoList.isNotEmpty()
+ if (isMultipleEnabledProfilesSupported && isActiveSim) {
+ Log.d(TAG,
+ "Device supports MEP and eSIM operation and eSIM profile is enabled."
+ + " DSDS condition satisfied."
+ )
+ return true
+ }
+
+ if (doesTargetSimHaveEsimOperation && isRemovablePsimProfileEnabled) {
+ Log.d(TAG,
+ "eSIM operation and removable PSIM is enabled. DSDS condition satisfied."
+ )
+ return true
+ }
+
+ if (!doesTargetSimHaveEsimOperation && isEsimProfileEnabled) {
+ Log.d(TAG,
+ "Removable SIM operation and eSIM profile is enabled. DSDS condition"
+ + " satisfied."
+ )
+ return true
+ }
+ Log.d(TAG, "DSDS condition not satisfied.")
+ return false
+ }
+
fun startActivatingSim(){
// TODO: start to activate sim
callback(CallbackType.CALLBACK_FINISH)
@@ -281,30 +336,50 @@
suspend fun startSetupPrimarySim(context: Context) {
withContext(Dispatchers.Default) {
- setDefaultVoice(subscriptionManager,targetPrimarySimCalls)
- setDefaultSms(subscriptionManager,targetPrimarySimTexts)
- setDefaultData(
- context,
- subscriptionManager,
- null,
- targetPrimarySimMobileData
- )
+ if (SubscriptionUtil.getActiveSubscriptions(subscriptionManager).size <= 1) {
+ Log.d(TAG,
+ "startSetupPrimarySim: number of active subscriptionInfo is less than 2"
+ )
+ } else {
+ setDefaultVoice(subscriptionManager, targetPrimarySimCalls)
+ setDefaultSms(subscriptionManager, targetPrimarySimTexts)
+ setDefaultData(
+ context,
+ subscriptionManager,
+ null,
+ targetPrimarySimMobileData
+ )
- var nonDds = targetNonDds
- Log.d(
- TAG,
- "setAutomaticData: targetNonDds: $nonDds," +
- " targetPrimarySimAutoDataSwitch: $targetPrimarySimAutoDataSwitch"
- )
- if (nonDds != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- val telephonyManagerForNonDds: TelephonyManager? =
- context.getSystemService(TelephonyManager::class.java)
- ?.createForSubscriptionId(nonDds)
- setAutomaticData(telephonyManagerForNonDds, targetPrimarySimAutoDataSwitch)
+ var nonDds = targetNonDds
+ Log.d(
+ TAG,
+ "setAutomaticData: targetNonDds: $nonDds," +
+ " targetPrimarySimAutoDataSwitch: $targetPrimarySimAutoDataSwitch"
+ )
+ if (nonDds != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ val telephonyManagerForNonDds: TelephonyManager? =
+ context.getSystemService(TelephonyManager::class.java)
+ ?.createForSubscriptionId(nonDds)
+ setAutomaticData(telephonyManagerForNonDds, targetPrimarySimAutoDataSwitch)
+ }
}
-
// no next action, send finish
callback(CallbackType.CALLBACK_FINISH)
}
}
+
+ suspend fun startEnableDsds(context: Context) {
+ withContext(Dispatchers.Default) {
+ Log.d(TAG, "User confirmed reboot to enable DSDS.")
+ SimActivationNotifier.setShowSimSettingsNotification(context, true)
+ telephonyManager?.switchMultiSimConfig(NUM_OF_SIMS_FOR_DSDS)
+ callback(CallbackType.CALLBACK_FINISH)
+ }
+ }
+
+ companion object{
+ private const val TAG = "SimOnboardingService"
+ private const val INVALID = SubscriptionManager.INVALID_SUBSCRIPTION_ID
+ const val NUM_OF_SIMS_FOR_DSDS = 2
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/network/SubscriptionInfoListViewModel.kt b/src/com/android/settings/network/SubscriptionInfoListViewModel.kt
index f682002..df3b8ba 100644
--- a/src/com/android/settings/network/SubscriptionInfoListViewModel.kt
+++ b/src/com/android/settings/network/SubscriptionInfoListViewModel.kt
@@ -20,6 +20,7 @@
import android.telephony.SubscriptionManager
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope
+import com.android.settings.network.telephony.getSelectableSubscriptionInfoList
import com.android.settings.network.telephony.subscriptionsChangedFlow
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.SharingStarted
@@ -41,10 +42,10 @@
}.stateIn(scope, SharingStarted.Eagerly, initialValue = emptyList())
/**
- * Getting the Selectable SubscriptionInfo List from the SubscriptionManager's
+ * Getting the Selectable SubscriptionInfo List from the SubscriptionRepository's
* getAvailableSubscriptionInfoList
*/
val selectableSubscriptionInfoListFlow = application.subscriptionsChangedFlow().map {
- SubscriptionUtil.getSelectableSubscriptionInfoList(application)
+ application.getSelectableSubscriptionInfoList()
}.stateIn(scope, SharingStarted.Eagerly, initialValue = emptyList())
}
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index 83f6c38..497af25 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -50,12 +50,12 @@
import com.android.settings.network.helper.SubscriptionAnnotation;
import com.android.settings.network.telephony.DeleteEuiccSubscriptionDialogActivity;
import com.android.settings.network.telephony.EuiccRacConnectivityDialogActivity;
+import com.android.settings.network.telephony.SubscriptionRepositoryKt;
import com.android.settings.network.telephony.ToggleSubscriptionDialogActivity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
@@ -499,40 +499,7 @@
* @return list of user selectable subscriptions.
*/
public static List<SubscriptionInfo> getSelectableSubscriptionInfoList(Context context) {
- SubscriptionManager subManager = context.getSystemService(SubscriptionManager.class);
- List<SubscriptionInfo> availableList = subManager.getAvailableSubscriptionInfoList();
- if (availableList == null) {
- return null;
- } else {
- // Multiple subscriptions in a group should only have one representative.
- // It should be the current active primary subscription if any, or any
- // primary subscription.
- List<SubscriptionInfo> selectableList = new ArrayList<>();
- Map<ParcelUuid, SubscriptionInfo> groupMap = new HashMap<>();
-
- for (SubscriptionInfo info : availableList) {
- // Opportunistic subscriptions are considered invisible
- // to users so they should never be returned.
- if (!isSubscriptionVisible(subManager, context, info)) continue;
-
- ParcelUuid groupUuid = info.getGroupUuid();
- if (groupUuid == null) {
- // Doesn't belong to any group. Add in the list.
- selectableList.add(info);
- } else if (!groupMap.containsKey(groupUuid)
- || (groupMap.get(groupUuid).getSimSlotIndex() == INVALID_SIM_SLOT_INDEX
- && info.getSimSlotIndex() != INVALID_SIM_SLOT_INDEX)) {
- // If it belongs to a group that has never been recorded or it's the current
- // active subscription, add it in the list.
- selectableList.remove(groupMap.get(groupUuid));
- selectableList.add(info);
- groupMap.put(groupUuid, info);
- }
-
- }
- Log.d(TAG, "getSelectableSubscriptionInfoList: " + selectableList);
- return selectableList;
- }
+ return SubscriptionRepositoryKt.getSelectableSubscriptionInfoList(context);
}
/**
diff --git a/src/com/android/settings/network/telephony/CellInfoUtil.kt b/src/com/android/settings/network/telephony/CellInfoUtil.kt
index c7b6b24..51f60e7 100644
--- a/src/com/android/settings/network/telephony/CellInfoUtil.kt
+++ b/src/com/android/settings/network/telephony/CellInfoUtil.kt
@@ -82,7 +82,7 @@
*/
@JvmStatic
fun cellInfoListToString(cellInfos: List<CellInfo>): String =
- cellInfos.joinToString { cellInfo -> cellInfo.readableString() }
+ cellInfos.joinToString(System.lineSeparator()) { cellInfo -> cellInfo.readableString() }
/**
* Convert [CellInfo] to a readable string without sensitive info.
diff --git a/src/com/android/settings/network/telephony/NetworkScanHelper.java b/src/com/android/settings/network/telephony/NetworkScanHelper.java
deleted file mode 100644
index 1961329..0000000
--- a/src/com/android/settings/network/telephony/NetworkScanHelper.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.settings.network.telephony;
-
-import android.annotation.IntDef;
-import android.content.Context;
-import android.telephony.AccessNetworkConstants.AccessNetworkType;
-import android.telephony.CellInfo;
-import android.telephony.NetworkScan;
-import android.telephony.NetworkScanRequest;
-import android.telephony.PhoneCapability;
-import android.telephony.RadioAccessSpecifier;
-import android.telephony.TelephonyManager;
-import android.telephony.TelephonyScanManager;
-import android.util.Log;
-
-import androidx.annotation.VisibleForTesting;
-
-import com.android.internal.telephony.CellNetworkScanResult;
-
-import com.android.settings.R;
-
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import com.google.common.util.concurrent.SettableFuture;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.Executor;
-import java.util.stream.Collectors;
-
-/**
- * A helper class that builds the common interface and performs the network scan for two different
- * network scan APIs.
- */
-public class NetworkScanHelper {
- public static final String TAG = "NetworkScanHelper";
-
- /**
- * Callbacks interface to inform the network scan results.
- */
- public interface NetworkScanCallback {
- /**
- * Called when the results is returned from {@link TelephonyManager}. This method will be
- * called at least one time if there is no error occurred during the network scan.
- *
- * <p> This method can be called multiple times in one network scan, until
- * {@link #onComplete()} or {@link #onError(int)} is called.
- *
- * @param results
- */
- void onResults(List<CellInfo> results);
-
- /**
- * Called when the current network scan process is finished. No more
- * {@link #onResults(List)} will be called for the current network scan after this method is
- * called.
- */
- void onComplete();
-
- /**
- * Called when an error occurred during the network scan process.
- *
- * <p> There is no more result returned from {@link TelephonyManager} if an error occurred.
- *
- * <p> {@link #onComplete()} will not be called if an error occurred.
- *
- * @see {@link NetworkScan.ScanErrorCode}
- */
- void onError(int errorCode);
- }
-
- @Retention(RetentionPolicy.SOURCE)
- @IntDef({NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS, NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS})
- public @interface NetworkQueryType {}
-
- /**
- * Performs the network scan using {@link TelephonyManager#getAvailableNetworks()}. The network
- * scan results won't be returned to the caller until the network scan is completed.
- *
- * <p> This is typically used when the modem doesn't support the new network scan api
- * {@link TelephonyManager#requestNetworkScan(
- * NetworkScanRequest, Executor, TelephonyScanManager.NetworkScanCallback)}.
- */
- public static final int NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS = 1;
-
- /**
- * Performs the network scan using {@link TelephonyManager#requestNetworkScan(
- * NetworkScanRequest, Executor, TelephonyScanManager.NetworkScanCallback)} The network scan
- * results will be returned to the caller periodically in a small time window until the network
- * scan is completed. The complete results should be returned in the last called of
- * {@link NetworkScanCallback#onResults(List)}.
- *
- * <p> This is recommended to be used if modem supports the new network scan api
- * {@link TelephonyManager#requestNetworkScan(
- * NetworkScanRequest, Executor, TelephonyScanManager.NetworkScanCallback)}
- */
- public static final int NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS = 2;
-
- /** The constants below are used in the async network scan. */
- @VisibleForTesting
- static final boolean INCREMENTAL_RESULTS = true;
- @VisibleForTesting
- static final int SEARCH_PERIODICITY_SEC = 5;
- @VisibleForTesting
- static final int MAX_SEARCH_TIME_SEC = 300;
- @VisibleForTesting
- static final int INCREMENTAL_RESULTS_PERIODICITY_SEC = 3;
-
- private final NetworkScanCallback mNetworkScanCallback;
- private final TelephonyManager mTelephonyManager;
- private final TelephonyScanManager.NetworkScanCallback mInternalNetworkScanCallback;
- private final Executor mExecutor;
-
- private int mMaxSearchTimeSec = MAX_SEARCH_TIME_SEC;
- private NetworkScan mNetworkScanRequester;
-
- /** Callbacks for sync network scan */
- private ListenableFuture<List<CellInfo>> mNetworkScanFuture;
-
- public NetworkScanHelper(TelephonyManager tm, NetworkScanCallback callback, Executor executor) {
- mTelephonyManager = tm;
- mNetworkScanCallback = callback;
- mInternalNetworkScanCallback = new NetworkScanCallbackImpl();
- mExecutor = executor;
- }
-
- public NetworkScanHelper(Context context, TelephonyManager tm, NetworkScanCallback callback,
- Executor executor) {
- this(tm, callback, executor);
- mMaxSearchTimeSec = context.getResources().getInteger(
- R.integer.config_network_scan_helper_max_search_time_sec);
- }
-
- @VisibleForTesting
- NetworkScanRequest createNetworkScanForPreferredAccessNetworks() {
- long networkTypeBitmap3gpp = mTelephonyManager.getPreferredNetworkTypeBitmask()
- & TelephonyManager.NETWORK_STANDARDS_FAMILY_BITMASK_3GPP;
-
- List<RadioAccessSpecifier> radioAccessSpecifiers = new ArrayList<>();
- // If the allowed network types are unknown or if they are of the right class, scan for
- // them; otherwise, skip them to save scan time and prevent users from being shown networks
- // that they can't connect to.
- if (networkTypeBitmap3gpp == 0
- || (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_2G) != 0) {
- radioAccessSpecifiers.add(
- new RadioAccessSpecifier(AccessNetworkType.GERAN, null, null));
- }
- if (networkTypeBitmap3gpp == 0
- || (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_3G) != 0) {
- radioAccessSpecifiers.add(
- new RadioAccessSpecifier(AccessNetworkType.UTRAN, null, null));
- }
- if (networkTypeBitmap3gpp == 0
- || (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_4G) != 0) {
- radioAccessSpecifiers.add(
- new RadioAccessSpecifier(AccessNetworkType.EUTRAN, null, null));
- }
- // If a device supports 5G stand-alone then the code below should be re-enabled; however
- // a device supporting only non-standalone mode cannot perform PLMN selection and camp on
- // a 5G network, which means that it shouldn't scan for 5G at the expense of battery as
- // part of the manual network selection process.
- //
- if (networkTypeBitmap3gpp == 0
- || (hasNrSaCapability()
- && (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_5G) != 0)) {
- radioAccessSpecifiers.add(
- new RadioAccessSpecifier(AccessNetworkType.NGRAN, null, null));
- Log.d(TAG, "radioAccessSpecifiers add NGRAN.");
- }
-
- return new NetworkScanRequest(
- NetworkScanRequest.SCAN_TYPE_ONE_SHOT,
- radioAccessSpecifiers.toArray(
- new RadioAccessSpecifier[radioAccessSpecifiers.size()]),
- SEARCH_PERIODICITY_SEC,
- mMaxSearchTimeSec,
- INCREMENTAL_RESULTS,
- INCREMENTAL_RESULTS_PERIODICITY_SEC,
- null /* List of PLMN ids (MCC-MNC) */);
- }
-
- /**
- * Performs a network scan for the given type {@code type}.
- * {@link #NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS} is recommended if modem supports
- * {@link TelephonyManager#requestNetworkScan(
- * NetworkScanRequest, Executor, TelephonyScanManager.NetworkScanCallback)}.
- *
- * @param type used to tell which network scan API should be used.
- */
- public void startNetworkScan(@NetworkQueryType int type) {
- if (type == NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS) {
- mNetworkScanFuture = SettableFuture.create();
- Futures.addCallback(mNetworkScanFuture, new FutureCallback<List<CellInfo>>() {
- @Override
- public void onSuccess(List<CellInfo> result) {
- onResults(result);
- onComplete();
- }
-
- @Override
- public void onFailure(Throwable t) {
- if (t instanceof CancellationException) {
- return;
- }
- int errCode = Integer.parseInt(t.getMessage());
- onError(errCode);
- }
- }, MoreExecutors.directExecutor());
- mExecutor.execute(new NetworkScanSyncTask(
- mTelephonyManager, (SettableFuture) mNetworkScanFuture));
- } else if (type == NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS) {
- if (mNetworkScanRequester != null) {
- return;
- }
- mNetworkScanRequester = mTelephonyManager.requestNetworkScan(
- createNetworkScanForPreferredAccessNetworks(),
- mExecutor,
- mInternalNetworkScanCallback);
- if (mNetworkScanRequester == null) {
- onError(NetworkScan.ERROR_RADIO_INTERFACE_ERROR);
- }
- }
- }
-
- /**
- * The network scan of type {@link #NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS} can't be stopped,
- * however, the result of the current network scan won't be returned to the callback after
- * calling this method.
- */
- public void stopNetworkQuery() {
- if (mNetworkScanRequester != null) {
- mNetworkScanRequester.stopScan();
- mNetworkScanRequester = null;
- }
-
- if (mNetworkScanFuture != null) {
- mNetworkScanFuture.cancel(true /* mayInterruptIfRunning */);
- mNetworkScanFuture = null;
- }
- }
-
- private void onResults(List<CellInfo> cellInfos) {
- mNetworkScanCallback.onResults(cellInfos);
- }
-
- private void onComplete() {
- mNetworkScanCallback.onComplete();
- }
-
- private void onError(int errCode) {
- mNetworkScanCallback.onError(errCode);
- }
-
- private boolean hasNrSaCapability() {
- return Arrays.stream(
- mTelephonyManager.getPhoneCapability().getDeviceNrCapabilities())
- .anyMatch(i -> i == PhoneCapability.DEVICE_NR_CAPABILITY_SA);
- }
-
- /**
- * Converts the status code of {@link CellNetworkScanResult} to one of the
- * {@link NetworkScan.ScanErrorCode}.
- * @param errCode status code from {@link CellNetworkScanResult}.
- *
- * @return one of the scan error code from {@link NetworkScan.ScanErrorCode}.
- */
- private static int convertToScanErrorCode(int errCode) {
- switch (errCode) {
- case CellNetworkScanResult.STATUS_RADIO_NOT_AVAILABLE:
- return NetworkScan.ERROR_RADIO_INTERFACE_ERROR;
- case CellNetworkScanResult.STATUS_RADIO_GENERIC_FAILURE:
- default:
- return NetworkScan.ERROR_MODEM_ERROR;
- }
- }
-
- private final class NetworkScanCallbackImpl extends TelephonyScanManager.NetworkScanCallback {
- public void onResults(List<CellInfo> results) {
- Log.d(TAG, "Async scan onResults() results = "
- + CellInfoUtil.cellInfoListToString(results));
- NetworkScanHelper.this.onResults(results);
- }
-
- public void onComplete() {
- Log.d(TAG, "async scan onComplete()");
- NetworkScanHelper.this.onComplete();
- }
-
- public void onError(@NetworkScan.ScanErrorCode int errCode) {
- Log.d(TAG, "async scan onError() errorCode = " + errCode);
- NetworkScanHelper.this.onError(errCode);
- }
- }
-
- private static final class NetworkScanSyncTask implements Runnable {
- private final SettableFuture<List<CellInfo>> mCallback;
- private final TelephonyManager mTelephonyManager;
-
- NetworkScanSyncTask(
- TelephonyManager telephonyManager, SettableFuture<List<CellInfo>> callback) {
- mTelephonyManager = telephonyManager;
- mCallback = callback;
- }
-
- @Override
- public void run() {
- final CellNetworkScanResult result = mTelephonyManager.getAvailableNetworks();
- if (result.getStatus() == CellNetworkScanResult.STATUS_SUCCESS) {
- final List<CellInfo> cellInfos = result.getOperators()
- .stream()
- .map(operatorInfo
- -> CellInfoUtil.convertOperatorInfoToCellInfo(operatorInfo))
- .collect(Collectors.toList());
- Log.d(TAG, "Sync network scan completed, cellInfos = "
- + CellInfoUtil.cellInfoListToString(cellInfos));
- mCallback.set(cellInfos);
- } else {
- final Throwable error = new Throwable(
- Integer.toString(convertToScanErrorCode(result.getStatus())));
- mCallback.setException(error);
- Log.d(TAG, "Sync network scan error, ex = " + error);
- }
- }
- }
-}
diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
index 461930b..eb89d9e 100644
--- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java
+++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
@@ -16,7 +16,6 @@
package com.android.settings.network.telephony;
-import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
@@ -39,6 +38,7 @@
import android.view.View;
import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -48,14 +48,21 @@
import com.android.internal.telephony.OperatorInfo;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.network.telephony.scan.NetworkScanRepository;
+import com.android.settings.network.telephony.scan.NetworkScanRepository.NetworkScanCellInfos;
+import com.android.settings.network.telephony.scan.NetworkScanRepository.NetworkScanComplete;
+import com.android.settings.network.telephony.scan.NetworkScanRepository.NetworkScanError;
+import com.android.settings.network.telephony.scan.NetworkScanRepository.NetworkScanResult;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.utils.ThreadUtils;
+import kotlin.Unit;
+import kotlin.jvm.functions.Function1;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -70,12 +77,8 @@
private static final String TAG = "NetworkSelectSettings";
private static final int EVENT_SET_NETWORK_SELECTION_MANUALLY_DONE = 1;
- private static final int EVENT_NETWORK_SCAN_RESULTS = 2;
- private static final int EVENT_NETWORK_SCAN_ERROR = 3;
- private static final int EVENT_NETWORK_SCAN_COMPLETED = 4;
private static final String PREF_KEY_NETWORK_OPERATORS = "network_operators_preference";
- private static final int MIN_NUMBER_OF_SCAN_REQUIRED = 2;
private PreferenceCategory mPreferenceCategory;
@VisibleForTesting
@@ -90,18 +93,14 @@
private CarrierConfigManager mCarrierConfigManager;
private List<String> mForbiddenPlmns;
private boolean mShow4GForLTE = false;
- private NetworkScanHelper mNetworkScanHelper;
private final ExecutorService mNetworkScanExecutor = Executors.newFixedThreadPool(1);
private MetricsFeatureProvider mMetricsFeatureProvider;
- private boolean mUseNewApi;
- private long mRequestIdManualNetworkSelect;
- private long mRequestIdManualNetworkScan;
- private long mWaitingForNumberOfScanResults;
- @VisibleForTesting
- boolean mIsAggregationEnabled = false;
private CarrierConfigManager.CarrierConfigChangeListener mCarrierConfigChangeListener;
private AtomicBoolean mShouldFilterOutSatellitePlmn = new AtomicBoolean();
+ private NetworkScanRepository mNetworkScanRepository;
+ private boolean mUpdateScanResult = false;
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -113,7 +112,6 @@
@Initializer
protected void onCreateInitialization() {
Context context = getContext();
- mUseNewApi = enableNewAutoSelectNetworkUI(context);
mSubId = getSubId();
mPreferenceCategory = getPreferenceCategory(PREF_KEY_NETWORK_OPERATORS);
@@ -123,8 +121,6 @@
mTelephonyManager = getTelephonyManager(context, mSubId);
mSatelliteManager = getSatelliteManager(context);
mCarrierConfigManager = getCarrierConfigManager(context);
- mNetworkScanHelper = new NetworkScanHelper(
- mTelephonyManager, mCallback, mNetworkScanExecutor);
PersistableBundle bundle = mCarrierConfigManager.getConfigForSubId(mSubId,
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL,
CarrierConfigManager.KEY_REMOVE_SATELLITE_PLMN_IN_MANUAL_NETWORK_SCAN_BOOL);
@@ -135,30 +131,13 @@
true));
mMetricsFeatureProvider = getMetricsFeatureProvider(context);
- mIsAggregationEnabled = enableAggregation(context);
- Log.d(TAG, "init: mUseNewApi:" + mUseNewApi
- + " ,mIsAggregationEnabled:" + mIsAggregationEnabled + " ,mSubId:" + mSubId);
mCarrierConfigChangeListener =
(slotIndex, subId, carrierId, specificCarrierId) -> handleCarrierConfigChanged(
subId);
mCarrierConfigManager.registerCarrierConfigChangeListener(mNetworkScanExecutor,
mCarrierConfigChangeListener);
-
- }
-
- @Keep
- @VisibleForTesting
- protected boolean enableNewAutoSelectNetworkUI(Context context) {
- return context.getResources().getBoolean(
- com.android.internal.R.bool.config_enableNewAutoSelectNetworkUI);
- }
-
- @Keep
- @VisibleForTesting
- protected boolean enableAggregation(Context context) {
- return context.getResources().getBoolean(
- R.bool.config_network_selection_list_aggregation_enabled);
+ mNetworkScanRepository = new NetworkScanRepository(context, mSubId);
}
@Keep
@@ -217,17 +196,42 @@
}
@Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- final Activity activity = getActivity();
- if (activity != null) {
- mProgressHeader = setPinnedHeaderView(
- com.android.settingslib.widget.progressbar.R.layout.progress_header)
- .findViewById(com.android.settingslib.widget.progressbar.R.id.progress_bar_animation);
- setProgressBarVisible(false);
- }
+ mProgressHeader = setPinnedHeaderView(
+ com.android.settingslib.widget.progressbar.R.layout.progress_header
+ ).findViewById(com.android.settingslib.widget.progressbar.R.id.progress_bar_animation);
forceUpdateConnectedPreferenceCategory();
+ launchNetworkScan();
+ }
+
+ private void launchNetworkScan() {
+ mNetworkScanRepository.launchNetworkScan(getViewLifecycleOwner(), new Function1<>() {
+ @Override
+ public Unit invoke(@NonNull NetworkScanResult networkScanResult) {
+ if (!mUpdateScanResult) {
+ // Not update UI if not in scan mode.
+ return Unit.INSTANCE;
+ }
+ if (networkScanResult instanceof NetworkScanCellInfos networkScanCellInfos) {
+ scanResultHandler(networkScanCellInfos.getCellInfos());
+ return Unit.INSTANCE;
+ }
+ if (!isPreferenceScreenEnabled()) {
+ clearPreferenceSummary();
+ enablePreferenceScreen(true);
+ } else if (networkScanResult instanceof NetworkScanComplete
+ && mCellInfoList == null) {
+ // In case the scan timeout before getting any results
+ addMessagePreference(R.string.empty_networks_list);
+ } else if (networkScanResult instanceof NetworkScanError) {
+ addMessagePreference(R.string.network_query_error);
+ }
+
+ return Unit.INSTANCE;
+ }
+ });
}
@Override
@@ -235,12 +239,8 @@
super.onStart();
updateForbiddenPlmns();
- if (isProgressBarVisible()) {
- return;
- }
- if (mWaitingForNumberOfScanResults <= 0) {
- startNetworkQuery();
- }
+ setProgressBarVisible(true);
+ mUpdateScanResult = true;
}
/**
@@ -256,14 +256,6 @@
}
@Override
- public void onStop() {
- if (mWaitingForNumberOfScanResults <= 0) {
- stopNetworkQuery();
- }
- super.onStop();
- }
-
- @Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference == mSelectedPreference) {
Log.d(TAG, "onPreferenceTreeClick: preference is mSelectedPreference. Do nothing.");
@@ -274,7 +266,7 @@
return false;
}
- stopNetworkQuery();
+ mUpdateScanResult = false;
// Refresh the last selected item in case users reselect network.
clearPreferenceSummary();
@@ -293,8 +285,6 @@
// Disable the screen until network is manually set
enablePreferenceScreen(false);
- mRequestIdManualNetworkSelect = getNewRequestId();
- mWaitingForNumberOfScanResults = MIN_NUMBER_OF_SCAN_REQUIRED;
final OperatorInfo operator = mSelectedPreference.getOperatorInfo();
ThreadUtils.postOnBackgroundThread(() -> {
final Message msg = mHandler.obtainMessage(
@@ -328,7 +318,6 @@
switch (msg.what) {
case EVENT_SET_NETWORK_SELECTION_MANUALLY_DONE:
final boolean isSucceed = (boolean) msg.obj;
- stopNetworkQuery();
setProgressBarVisible(false);
enablePreferenceScreen(true);
@@ -340,86 +329,15 @@
Log.e(TAG, "No preference to update!");
}
break;
- case EVENT_NETWORK_SCAN_RESULTS:
- scanResultHandler((List<CellInfo>) msg.obj);
- break;
-
- case EVENT_NETWORK_SCAN_ERROR:
- stopNetworkQuery();
- Log.i(TAG, "Network scan failure " + msg.arg1 + ":"
- + " scan request 0x" + Long.toHexString(mRequestIdManualNetworkScan)
- + ", waiting for scan results = " + mWaitingForNumberOfScanResults
- + ", select request 0x"
- + Long.toHexString(mRequestIdManualNetworkSelect));
- if (mRequestIdManualNetworkScan < mRequestIdManualNetworkSelect) {
- break;
- }
- if (!isPreferenceScreenEnabled()) {
- clearPreferenceSummary();
- enablePreferenceScreen(true);
- } else {
- addMessagePreference(R.string.network_query_error);
- }
- break;
-
- case EVENT_NETWORK_SCAN_COMPLETED:
- stopNetworkQuery();
- Log.d(TAG, "Network scan complete:"
- + " scan request 0x" + Long.toHexString(mRequestIdManualNetworkScan)
- + ", waiting for scan results = " + mWaitingForNumberOfScanResults
- + ", select request 0x"
- + Long.toHexString(mRequestIdManualNetworkSelect));
- if (mRequestIdManualNetworkScan < mRequestIdManualNetworkSelect) {
- break;
- }
- if (!isPreferenceScreenEnabled()) {
- clearPreferenceSummary();
- enablePreferenceScreen(true);
- } else if (mCellInfoList == null) {
- // In case the scan timeout before getting any results
- addMessagePreference(R.string.empty_networks_list);
- }
- break;
}
- return;
}
};
- @VisibleForTesting
- List<CellInfo> doAggregation(List<CellInfo> cellInfoListInput) {
- if (!mIsAggregationEnabled) {
- Log.d(TAG, "no aggregation");
- return new ArrayList<>(cellInfoListInput);
- }
- ArrayList<CellInfo> aggregatedList = new ArrayList<>();
- for (CellInfo cellInfo : cellInfoListInput) {
- String plmn = CellInfoUtil.getNetworkTitle(cellInfo.getCellIdentity());
- Class className = cellInfo.getClass();
-
- Optional<CellInfo> itemInTheList = aggregatedList.stream().filter(
- item -> {
- String itemPlmn = CellInfoUtil.getNetworkTitle(item.getCellIdentity());
- return itemPlmn.equals(plmn) && item.getClass().equals(className);
- })
- .findFirst();
- if (itemInTheList.isPresent()) {
- if (cellInfo.isRegistered() && !itemInTheList.get().isRegistered()) {
- // Adding the registered cellinfo item into list. If there are two registered
- // cellinfo items, then select first one from source list.
- aggregatedList.set(aggregatedList.indexOf(itemInTheList.get()), cellInfo);
- }
- continue;
- }
- aggregatedList.add(cellInfo);
- }
-
- return filterOutSatellitePlmn(aggregatedList);
- }
-
/* We do not want to expose carrier satellite plmns to the user when manually scan the
cellular network. Therefore, it is needed to filter out satellite plmns from current cell
info list */
- private List<CellInfo> filterOutSatellitePlmn(List<CellInfo> cellInfoList) {
+ @VisibleForTesting
+ List<CellInfo> filterOutSatellitePlmn(List<CellInfo> cellInfoList) {
List<String> aggregatedSatellitePlmn = getSatellitePlmnsForCarrierWrapper();
if (!mShouldFilterOutSatellitePlmn.get() || aggregatedSatellitePlmn.isEmpty()) {
return cellInfoList;
@@ -451,39 +369,10 @@
}
}
- private final NetworkScanHelper.NetworkScanCallback mCallback =
- new NetworkScanHelper.NetworkScanCallback() {
- public void onResults(List<CellInfo> results) {
- final Message msg = mHandler.obtainMessage(EVENT_NETWORK_SCAN_RESULTS, results);
- msg.sendToTarget();
- }
-
- public void onComplete() {
- final Message msg = mHandler.obtainMessage(EVENT_NETWORK_SCAN_COMPLETED);
- msg.sendToTarget();
- }
-
- public void onError(int error) {
- final Message msg = mHandler.obtainMessage(EVENT_NETWORK_SCAN_ERROR, error,
- 0 /* arg2 */);
- msg.sendToTarget();
- }
- };
-
@Keep
@VisibleForTesting
protected void scanResultHandler(List<CellInfo> results) {
- if (mRequestIdManualNetworkScan < mRequestIdManualNetworkSelect) {
- Log.d(TAG, "CellInfoList (drop): "
- + CellInfoUtil.cellInfoListToString(new ArrayList<>(results)));
- return;
- }
- mWaitingForNumberOfScanResults--;
- if ((mWaitingForNumberOfScanResults <= 0) && (!isResumed())) {
- stopNetworkQuery();
- }
-
- mCellInfoList = doAggregation(results);
+ mCellInfoList = filterOutSatellitePlmn(results);
Log.d(TAG, "CellInfoList: " + CellInfoUtil.cellInfoListToString(mCellInfoList));
if (mCellInfoList != null && mCellInfoList.size() != 0) {
final NetworkOperatorPreference connectedPref = updateAllPreferenceCategory();
@@ -642,11 +531,6 @@
}
}
- private long getNewRequestId() {
- return Math.max(mRequestIdManualNetworkSelect,
- mRequestIdManualNetworkScan) + 1;
- }
-
private boolean isProgressBarVisible() {
if (mProgressHeader == null) {
return false;
@@ -667,29 +551,8 @@
mPreferenceCategory.addPreference(mStatusMessagePreference);
}
- private void startNetworkQuery() {
- setProgressBarVisible(true);
- if (mNetworkScanHelper != null) {
- mRequestIdManualNetworkScan = getNewRequestId();
- mWaitingForNumberOfScanResults = MIN_NUMBER_OF_SCAN_REQUIRED;
- mNetworkScanHelper.startNetworkScan(
- mUseNewApi
- ? NetworkScanHelper.NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS
- : NetworkScanHelper.NETWORK_SCAN_TYPE_WAIT_FOR_ALL_RESULTS);
- }
- }
-
- private void stopNetworkQuery() {
- setProgressBarVisible(false);
- if (mNetworkScanHelper != null) {
- mWaitingForNumberOfScanResults = 0;
- mNetworkScanHelper.stopNetworkQuery();
- }
- }
-
@Override
public void onDestroy() {
- stopNetworkQuery();
mNetworkScanExecutor.shutdown();
super.onDestroy();
}
diff --git a/src/com/android/settings/network/telephony/SubscriptionRepository.kt b/src/com/android/settings/network/telephony/SubscriptionRepository.kt
index e44b577..1820df9 100644
--- a/src/com/android/settings/network/telephony/SubscriptionRepository.kt
+++ b/src/com/android/settings/network/telephony/SubscriptionRepository.kt
@@ -32,9 +32,12 @@
private const val TAG = "SubscriptionRepository"
-fun Context.isSubscriptionEnabledFlow(subId: Int) = subscriptionsChangedFlow().map {
- val subscriptionManager = getSystemService(SubscriptionManager::class.java)
+val Context.subscriptionManager: SubscriptionManager?
+ get() = getSystemService(SubscriptionManager::class.java)
+fun Context.requireSubscriptionManager(): SubscriptionManager = subscriptionManager!!
+
+fun Context.isSubscriptionEnabledFlow(subId: Int) = subscriptionsChangedFlow().map {
subscriptionManager?.isSubscriptionEnabled(subId) ?: false
}.flowOn(Dispatchers.Default)
@@ -43,7 +46,7 @@
}.flowOn(Dispatchers.Default)
fun Context.subscriptionsChangedFlow() = callbackFlow {
- val subscriptionManager = getSystemService(SubscriptionManager::class.java)!!
+ val subscriptionManager = requireSubscriptionManager()
val listener = object : SubscriptionManager.OnSubscriptionsChangedListener() {
override fun onSubscriptionsChanged() {
@@ -58,3 +61,35 @@
awaitClose { subscriptionManager.removeOnSubscriptionsChangedListener(listener) }
}.conflate().onEach { Log.d(TAG, "subscriptions changed") }.flowOn(Dispatchers.Default)
+
+/**
+ * Return a list of subscriptions that are available and visible to the user.
+ *
+ * @return list of user selectable subscriptions.
+ */
+fun Context.getSelectableSubscriptionInfoList(): List<SubscriptionInfo> {
+ val subscriptionManager = requireSubscriptionManager()
+ val availableList = subscriptionManager.getAvailableSubscriptionInfoList() ?: return emptyList()
+ val visibleList = availableList.filter { subInfo ->
+ // Opportunistic subscriptions are considered invisible
+ // to users so they should never be returned.
+ SubscriptionUtil.isSubscriptionVisible(subscriptionManager, this, subInfo)
+ }
+ // Multiple subscriptions in a group should only have one representative.
+ // It should be the current active primary subscription if any, or any primary subscription.
+ val groupUuidToSelectedIdMap = visibleList
+ .groupBy { it.groupUuid }
+ .mapValues { (_, subInfos) ->
+ subInfos.filter { it.simSlotIndex != SubscriptionManager.INVALID_SIM_SLOT_INDEX }
+ .ifEmpty { subInfos }
+ .minOf { it.subscriptionId }
+ }
+
+ return visibleList
+ .filter { subInfo ->
+ val groupUuid = subInfo.groupUuid ?: return@filter true
+ groupUuidToSelectedIdMap[groupUuid] == subInfo.subscriptionId
+ }
+ .sortedBy { it.subscriptionId }
+ .also { Log.d(TAG, "getSelectableSubscriptionInfoList: $it") }
+}
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.kt b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.kt
index b0ea6a6..0ee1d87 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.kt
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.kt
@@ -22,10 +22,7 @@
import android.telephony.SubscriptionManager
import android.telephony.TelephonyManager
import android.telephony.ims.ImsMmTelManager
-import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
-import androidx.lifecycle.lifecycleScope
-import androidx.lifecycle.repeatOnLifecycle
import androidx.preference.Preference
import androidx.preference.PreferenceScreen
import com.android.settings.R
@@ -33,7 +30,6 @@
import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
/**
@@ -81,17 +77,12 @@
override fun onViewCreated(viewLifecycleOwner: LifecycleOwner) {
wifiCallingRepositoryFactory(mSubId).wifiCallingReadyFlow()
- .collectLatestWithLifecycle(viewLifecycleOwner) {
- preference.isVisible = it
- callingPreferenceCategoryController.updateChildVisible(preferenceKey, it)
+ .collectLatestWithLifecycle(viewLifecycleOwner) { isReady ->
+ preference.isVisible = isReady
+ callingPreferenceCategoryController.updateChildVisible(preferenceKey, isReady)
+ if (isReady) update()
}
- viewLifecycleOwner.lifecycleScope.launch {
- viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
- update()
- }
- }
-
callStateFlowFactory(mSubId).collectLatestWithLifecycle(viewLifecycleOwner) {
preference.isEnabled = (it == TelephonyManager.CALL_STATE_IDLE)
}
diff --git a/src/com/android/settings/network/telephony/scan/NetworkScanRepository.kt b/src/com/android/settings/network/telephony/scan/NetworkScanRepository.kt
new file mode 100644
index 0000000..2067b8c
--- /dev/null
+++ b/src/com/android/settings/network/telephony/scan/NetworkScanRepository.kt
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network.telephony.scan
+
+import android.content.Context
+import android.telephony.AccessNetworkConstants.AccessNetworkType
+import android.telephony.CellInfo
+import android.telephony.NetworkScanRequest
+import android.telephony.PhoneCapability
+import android.telephony.RadioAccessSpecifier
+import android.telephony.TelephonyManager
+import android.telephony.TelephonyScanManager
+import android.util.Log
+import androidx.annotation.VisibleForTesting
+import androidx.lifecycle.LifecycleOwner
+import com.android.settings.network.telephony.CellInfoUtil
+import com.android.settings.network.telephony.CellInfoUtil.getNetworkTitle
+import com.android.settingslib.spa.framework.util.collectLatestWithLifecycle
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.asExecutor
+import kotlinx.coroutines.channels.awaitClose
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.callbackFlow
+import kotlinx.coroutines.flow.flowOn
+
+class NetworkScanRepository(context: Context, subId: Int) {
+ sealed interface NetworkScanResult
+
+ data class NetworkScanCellInfos(val cellInfos: List<CellInfo>) : NetworkScanResult
+ data object NetworkScanComplete : NetworkScanResult
+ data class NetworkScanError(val error: Int) : NetworkScanResult
+
+ private val telephonyManager =
+ context.getSystemService(TelephonyManager::class.java)!!.createForSubscriptionId(subId)
+
+ /** TODO: Move this to UI layer, when UI layer migrated to Kotlin. */
+ fun launchNetworkScan(lifecycleOwner: LifecycleOwner, onResult: (NetworkScanResult) -> Unit) {
+ networkScanFlow().collectLatestWithLifecycle(lifecycleOwner, action = onResult)
+ }
+
+ data class CellInfoScanKey(
+ val title: String?,
+ val className: String,
+ val isRegistered: Boolean,
+ ) {
+ constructor(cellInfo: CellInfo) : this(
+ title = cellInfo.cellIdentity.getNetworkTitle(),
+ className = cellInfo.javaClass.name,
+ isRegistered = cellInfo.isRegistered,
+ )
+ }
+
+ fun networkScanFlow(): Flow<NetworkScanResult> = callbackFlow {
+ val callback = object : TelephonyScanManager.NetworkScanCallback() {
+ override fun onResults(results: List<CellInfo>) {
+ val cellInfos = results.distinctBy { CellInfoScanKey(it) }
+ trySend(NetworkScanCellInfos(cellInfos))
+ Log.d(TAG, "CellInfoList: ${CellInfoUtil.cellInfoListToString(cellInfos)}")
+ }
+
+ override fun onComplete() {
+ trySend(NetworkScanComplete)
+ close()
+ Log.d(TAG, "onComplete")
+ }
+
+ override fun onError(error: Int) {
+ trySend(NetworkScanError(error))
+ close()
+ Log.d(TAG, "onError: $error")
+ }
+ }
+
+ val networkScan = telephonyManager.requestNetworkScan(
+ createNetworkScan(),
+ Dispatchers.Default.asExecutor(),
+ callback,
+ )
+
+ awaitClose { networkScan.stopScan() }
+ }.flowOn(Dispatchers.Default)
+
+ /** Create network scan for allowed network types. */
+ private fun createNetworkScan(): NetworkScanRequest {
+ val allowedNetworkTypes = getAllowedNetworkTypes()
+ Log.d(TAG, "createNetworkScan: allowedNetworkTypes = $allowedNetworkTypes")
+ val radioAccessSpecifiers = allowedNetworkTypes
+ .map { RadioAccessSpecifier(it, null, null) }
+ .toTypedArray()
+ return NetworkScanRequest(
+ NetworkScanRequest.SCAN_TYPE_ONE_SHOT,
+ radioAccessSpecifiers,
+ NetworkScanRequest.MIN_SEARCH_PERIODICITY_SEC, // one shot, not used
+ MAX_SEARCH_TIME_SEC,
+ true,
+ INCREMENTAL_RESULTS_PERIODICITY_SEC,
+ null,
+ )
+ }
+
+ private fun getAllowedNetworkTypes(): List<Int> {
+ val networkTypeBitmap3gpp: Long =
+ telephonyManager.getAllowedNetworkTypesBitmask() and
+ TelephonyManager.NETWORK_STANDARDS_FAMILY_BITMASK_3GPP
+ return buildList {
+ // If the allowed network types are unknown or if they are of the right class, scan for
+ // them; otherwise, skip them to save scan time and prevent users from being shown
+ // networks that they can't connect to.
+ if (networkTypeBitmap3gpp == 0L
+ || networkTypeBitmap3gpp and TelephonyManager.NETWORK_CLASS_BITMASK_2G != 0L
+ ) {
+ add(AccessNetworkType.GERAN)
+ }
+ if (networkTypeBitmap3gpp == 0L
+ || networkTypeBitmap3gpp and TelephonyManager.NETWORK_CLASS_BITMASK_3G != 0L
+ ) {
+ add(AccessNetworkType.UTRAN)
+ }
+ if (networkTypeBitmap3gpp == 0L
+ || networkTypeBitmap3gpp and TelephonyManager.NETWORK_CLASS_BITMASK_4G != 0L
+ ) {
+ add(AccessNetworkType.EUTRAN)
+ }
+ // If a device supports 5G stand-alone then the code below should be re-enabled; however
+ // a device supporting only non-standalone mode cannot perform PLMN selection and camp
+ // on a 5G network, which means that it shouldn't scan for 5G at the expense of battery
+ // as part of the manual network selection process.
+ //
+ if (networkTypeBitmap3gpp == 0L
+ || (networkTypeBitmap3gpp and TelephonyManager.NETWORK_CLASS_BITMASK_5G != 0L &&
+ hasNrSaCapability())
+ ) {
+ add(AccessNetworkType.NGRAN)
+ Log.d(TAG, "radioAccessSpecifiers add NGRAN.")
+ }
+ }
+ }
+
+ private fun hasNrSaCapability(): Boolean {
+ val phoneCapability = telephonyManager.getPhoneCapability()
+ return PhoneCapability.DEVICE_NR_CAPABILITY_SA in phoneCapability.deviceNrCapabilities
+ }
+
+ companion object {
+ private const val TAG = "NetworkScanRepository"
+
+ @VisibleForTesting
+ val MAX_SEARCH_TIME_SEC = 300
+
+ @VisibleForTesting
+ val INCREMENTAL_RESULTS_PERIODICITY_SEC = 3
+ }
+}
diff --git a/src/com/android/settings/notification/zen/ZenModeBackend.java b/src/com/android/settings/notification/zen/ZenModeBackend.java
index c290c83..921a5ee 100644
--- a/src/com/android/settings/notification/zen/ZenModeBackend.java
+++ b/src/com/android/settings/notification/zen/ZenModeBackend.java
@@ -30,6 +30,7 @@
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.Settings;
+import android.service.notification.ZenAdapters;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenPolicy;
import android.util.Log;
@@ -399,14 +400,16 @@
ZenPolicy setDefaultZenPolicy(ZenPolicy zenPolicy) {
int calls;
if (mPolicy.allowCalls()) {
- calls = ZenModeConfig.getZenPolicySenders(mPolicy.allowCallsFrom());
+ calls = ZenAdapters.notificationPolicySendersToZenPolicyPeopleType(
+ mPolicy.allowCallsFrom());
} else {
calls = ZenPolicy.PEOPLE_TYPE_NONE;
}
int messages;
if (mPolicy.allowMessages()) {
- messages = ZenModeConfig.getZenPolicySenders(mPolicy.allowMessagesFrom());
+ messages = ZenAdapters.notificationPolicySendersToZenPolicyPeopleType(
+ mPolicy.allowMessagesFrom());
} else {
messages = ZenPolicy.PEOPLE_TYPE_NONE;
}
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index 631c735..a645300 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -416,6 +416,7 @@
public String getHint(Context context, boolean isAlpha, int type, ProfileType profile) {
if (isAlpha) {
if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
&& profile.equals(ProfileType.Private)) {
return context.getString(alphaHintForPrivateProfile);
} else if (type == TYPE_FINGERPRINT) {
@@ -433,6 +434,7 @@
}
} else {
if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
&& profile.equals(ProfileType.Private)) {
return context.getString(numericHintForPrivateProfile);
} else if (type == TYPE_FINGERPRINT) {
@@ -1147,7 +1149,9 @@
/*flags=*/0).getSystemService(UserManager.class);
if (userManager.isManagedProfile()) {
return ProfileType.Managed;
- } else if (android.os.Flags.allowPrivateProfile() && userManager.isPrivateProfile()) {
+ } else if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
+ && userManager.isPrivateProfile()) {
return ProfileType.Private;
} else if (userManager.isProfile()) {
return ProfileType.Other;
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index 8d0aebe..c331991 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -478,7 +478,9 @@
.getString(SET_WORK_PROFILE_PATTERN_HEADER,
() -> getString(
R.string.lockpassword_choose_your_profile_pattern_header));
- } else if (android.os.Flags.allowPrivateProfile() && isPrivateProfile()) {
+ } else if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
+ && isPrivateProfile()) {
msg = getString(R.string.private_space_choose_your_pattern_header);
} else {
msg = getString(R.string.lockpassword_choose_your_pattern_header);
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index f2ebd1f..cf80513 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -300,6 +300,7 @@
launchedCDC = true;
}
} else if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
&& userProperties != null
&& userProperties.isAuthAlwaysRequiredToDisableQuietMode()
&& isInternalActivity()) {
@@ -413,7 +414,8 @@
private boolean doesUserStateEnforceStrongAuth(int userId) {
if (android.os.Flags.allowPrivateProfile()
- && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()) {
+ && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
// Check if CE storage for user is locked since biometrics can't unlock fbe/keystore of
// the profile user using verifyTiedProfileChallenge. Biometrics can still be used if
// the user is stopped with delayed locking (i.e., with storage unlocked), so the user
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialUtils.java b/src/com/android/settings/password/ConfirmDeviceCredentialUtils.java
index 32e7489..e3182a4 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialUtils.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialUtils.java
@@ -105,7 +105,8 @@
private static boolean isBiometricUnlockEnabledForPrivateSpace() {
return android.os.Flags.allowPrivateProfile()
- && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace();
+ && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures();
}
/**
diff --git a/src/com/android/settings/privatespace/AutoAdvanceSetupFragment.java b/src/com/android/settings/privatespace/AutoAdvanceSetupFragment.java
index 1f0f7bb..7f0118c 100644
--- a/src/com/android/settings/privatespace/AutoAdvanceSetupFragment.java
+++ b/src/com/android/settings/privatespace/AutoAdvanceSetupFragment.java
@@ -104,7 +104,8 @@
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
- if (android.os.Flags.allowPrivateProfile()) {
+ if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
super.onCreate(savedInstanceState);
}
}
diff --git a/src/com/android/settings/privatespace/HidePrivateSpaceController.java b/src/com/android/settings/privatespace/HidePrivateSpaceController.java
index a53055c..903defa 100644
--- a/src/com/android/settings/privatespace/HidePrivateSpaceController.java
+++ b/src/com/android/settings/privatespace/HidePrivateSpaceController.java
@@ -38,7 +38,10 @@
@Override
@AvailabilityStatus
public int getAvailabilityStatus() {
- return android.os.Flags.allowPrivateProfile() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ return android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
+ ? AVAILABLE
+ : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsController.java b/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsController.java
index 1a89d37..6cb54a1 100644
--- a/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsController.java
+++ b/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsController.java
@@ -52,6 +52,7 @@
public int getAvailabilityStatus() {
if (!android.os.Flags.allowPrivateProfile()
|| !android.multiuser.Flags.enablePsSensitiveNotificationsToggle()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()
|| !mPrivateSpaceMaintainer.doesPrivateSpaceExist()) {
return UNSUPPORTED_ON_DEVICE;
}
diff --git a/src/com/android/settings/privatespace/HidePrivateSpaceSettings.java b/src/com/android/settings/privatespace/HidePrivateSpaceSettings.java
index 124978a..c41267f 100644
--- a/src/com/android/settings/privatespace/HidePrivateSpaceSettings.java
+++ b/src/com/android/settings/privatespace/HidePrivateSpaceSettings.java
@@ -27,7 +27,8 @@
@Override
public void onCreate(Bundle icicle) {
- if (android.os.Flags.allowPrivateProfile()) {
+ if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
super.onCreate(icicle);
}
}
diff --git a/src/com/android/settings/privatespace/HidePrivateSpaceSummaryController.java b/src/com/android/settings/privatespace/HidePrivateSpaceSummaryController.java
index 42627af..a366b70 100644
--- a/src/com/android/settings/privatespace/HidePrivateSpaceSummaryController.java
+++ b/src/com/android/settings/privatespace/HidePrivateSpaceSummaryController.java
@@ -36,7 +36,10 @@
@Override
public int getAvailabilityStatus() {
- return android.os.Flags.allowPrivateProfile() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ return android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
+ ? AVAILABLE
+ : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java b/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java
index 12a7440..f2a50dc 100644
--- a/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java
+++ b/src/com/android/settings/privatespace/PrivateProfileContextHelperActivity.java
@@ -59,7 +59,8 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
- if (!android.os.Flags.allowPrivateProfile()) {
+ if (!android.os.Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
return;
}
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
diff --git a/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivity.java b/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivity.java
index 63b1dc9..53d6b22 100644
--- a/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivity.java
+++ b/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivity.java
@@ -77,7 +77,8 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- if (Flags.allowPrivateProfile()) {
+ if (Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
ThemeHelper.trySetDynamicColor(this);
mPrivateSpaceMaintainer =
new Injector().injectPrivateSpaceMaintainer(getApplicationContext());
diff --git a/src/com/android/settings/privatespace/PrivateSpaceDashboardFragment.java b/src/com/android/settings/privatespace/PrivateSpaceDashboardFragment.java
index 726567e..32db8b6 100644
--- a/src/com/android/settings/privatespace/PrivateSpaceDashboardFragment.java
+++ b/src/com/android/settings/privatespace/PrivateSpaceDashboardFragment.java
@@ -32,7 +32,8 @@
@Override
public void onCreate(Bundle icicle) {
- if (android.os.Flags.allowPrivateProfile()) {
+ if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
super.onCreate(icicle);
if (icicle == null
&& getIntent().getBooleanExtra(EXTRA_SHOW_PRIVATE_SPACE_UNLOCKED, false)) {
diff --git a/src/com/android/settings/privatespace/PrivateSpaceEducation.java b/src/com/android/settings/privatespace/PrivateSpaceEducation.java
index 4c99873..cf22895 100644
--- a/src/com/android/settings/privatespace/PrivateSpaceEducation.java
+++ b/src/com/android/settings/privatespace/PrivateSpaceEducation.java
@@ -43,7 +43,8 @@
LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
- if (!android.os.Flags.allowPrivateProfile()) {
+ if (!android.os.Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
return null;
}
GlifLayout rootView =
diff --git a/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java b/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java
index 2d38ae2..3fb9b15 100644
--- a/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java
+++ b/src/com/android/settings/privatespace/PrivateSpaceMaintainer.java
@@ -78,7 +78,8 @@
*/
@VisibleForTesting
public final synchronized boolean createPrivateSpace() {
- if (!Flags.allowPrivateProfile()) {
+ if (!Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
return false;
}
// Check if Private space already exists
@@ -146,7 +147,8 @@
/** Returns true if the Private space exists. */
public synchronized boolean doesPrivateSpaceExist() {
- if (!Flags.allowPrivateProfile()) {
+ if (!Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
return false;
}
if (mUserHandle != null) {
@@ -322,6 +324,7 @@
private boolean isPrivateSpaceAutoLockSupported() {
return android.os.Flags.allowPrivateProfile()
- && android.multiuser.Flags.supportAutolockForPrivateSpace();
+ && android.multiuser.Flags.supportAutolockForPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures();
}
}
diff --git a/src/com/android/settings/privatespace/PrivateSpaceSafetySource.java b/src/com/android/settings/privatespace/PrivateSpaceSafetySource.java
index 6729830..4e1741a 100644
--- a/src/com/android/settings/privatespace/PrivateSpaceSafetySource.java
+++ b/src/com/android/settings/privatespace/PrivateSpaceSafetySource.java
@@ -51,7 +51,8 @@
return;
}
- if (!Flags.allowPrivateProfile()) {
+ if (!Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
// Setting null safetySourceData so that an old entry gets cleared out and this way
// provide a response since SC always expects one on rescan.
SafetyCenterManagerWrapper.get().setSafetySourceData(
diff --git a/src/com/android/settings/privatespace/PrivateSpaceSetLockFragment.java b/src/com/android/settings/privatespace/PrivateSpaceSetLockFragment.java
index 4a1e29b..399c2c8 100644
--- a/src/com/android/settings/privatespace/PrivateSpaceSetLockFragment.java
+++ b/src/com/android/settings/privatespace/PrivateSpaceSetLockFragment.java
@@ -51,7 +51,8 @@
LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
- if (!android.os.Flags.allowPrivateProfile()) {
+ if (!android.os.Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
return null;
}
GlifLayout rootView =
diff --git a/src/com/android/settings/privatespace/PrivateSpaceSetupActivity.java b/src/com/android/settings/privatespace/PrivateSpaceSetupActivity.java
index 78c96dc..ec7132a 100644
--- a/src/com/android/settings/privatespace/PrivateSpaceSetupActivity.java
+++ b/src/com/android/settings/privatespace/PrivateSpaceSetupActivity.java
@@ -42,7 +42,8 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
- if (!android.os.Flags.allowPrivateProfile()) {
+ if (!android.os.Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
return;
}
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
diff --git a/src/com/android/settings/privatespace/SetupSuccessFragment.java b/src/com/android/settings/privatespace/SetupSuccessFragment.java
index 13de1fc..cf63b22 100644
--- a/src/com/android/settings/privatespace/SetupSuccessFragment.java
+++ b/src/com/android/settings/privatespace/SetupSuccessFragment.java
@@ -47,7 +47,8 @@
LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
- if (!android.os.Flags.allowPrivateProfile()) {
+ if (!android.os.Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
return null;
}
GlifLayout rootView =
diff --git a/src/com/android/settings/privatespace/autolock/AutoLockPreferenceController.java b/src/com/android/settings/privatespace/autolock/AutoLockPreferenceController.java
index a7a12a4..3416e14 100644
--- a/src/com/android/settings/privatespace/autolock/AutoLockPreferenceController.java
+++ b/src/com/android/settings/privatespace/autolock/AutoLockPreferenceController.java
@@ -40,7 +40,8 @@
@Override
public int getAvailabilityStatus() {
return android.os.Flags.allowPrivateProfile()
- && android.multiuser.Flags.supportAutolockForPrivateSpace()
+ && android.multiuser.Flags.supportAutolockForPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
diff --git a/src/com/android/settings/privatespace/autolock/AutoLockSettingsFragment.java b/src/com/android/settings/privatespace/autolock/AutoLockSettingsFragment.java
index ef8bf8e..cb332d1 100644
--- a/src/com/android/settings/privatespace/autolock/AutoLockSettingsFragment.java
+++ b/src/com/android/settings/privatespace/autolock/AutoLockSettingsFragment.java
@@ -38,6 +38,8 @@
public class AutoLockSettingsFragment extends RadioButtonPickerFragment {
private static final String TAG = "PSAutoLockSetting";
+
+ private static final String AUTOLOCK_METRIC_KEY = "private_space_autolock_mode";
private PrivateSpaceMaintainer mPrivateSpaceMaintainer;
private CharSequence[] mAutoLockRadioOptions;
private CharSequence[] mAutoLockRadioValues;
@@ -45,7 +47,8 @@
@Override
public void onCreate(@NonNull Bundle icicle) {
if (android.os.Flags.allowPrivateProfile()
- && android.multiuser.Flags.supportAutolockForPrivateSpace()) {
+ && android.multiuser.Flags.supportAutolockForPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
super.onCreate(icicle);
}
}
@@ -111,6 +114,12 @@
try {
@Settings.Secure.PrivateSpaceAutoLockOption final int value = Integer.parseInt(key);
mPrivateSpaceMaintainer.setPrivateSpaceAutoLockSetting(value);
+ mMetricsFeatureProvider.action(
+ mMetricsFeatureProvider.getAttribution(getActivity()),
+ SettingsEnums.ACTION_SET_PRIVATE_SPACE_AUTOLOCK,
+ getMetricsCategory(),
+ AUTOLOCK_METRIC_KEY,
+ value /* value */);
} catch (NumberFormatException e) {
Log.e(TAG, "could not persist screen timeout setting", e);
}
diff --git a/src/com/android/settings/privatespace/delete/DeletePrivateSpaceController.java b/src/com/android/settings/privatespace/delete/DeletePrivateSpaceController.java
index af4535e..a2fc6f8 100644
--- a/src/com/android/settings/privatespace/delete/DeletePrivateSpaceController.java
+++ b/src/com/android/settings/privatespace/delete/DeletePrivateSpaceController.java
@@ -34,7 +34,10 @@
@Override
public int getAvailabilityStatus() {
- return android.os.Flags.allowPrivateProfile() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ return android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
+ ? AVAILABLE
+ : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteActivity.java b/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteActivity.java
index a4109b8..b483aa3 100644
--- a/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteActivity.java
+++ b/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteActivity.java
@@ -35,7 +35,8 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
- if (!android.os.Flags.allowPrivateProfile()) {
+ if (!android.os.Flags.allowPrivateProfile()
+ || !android.multiuser.Flags.enablePrivateSpaceFeatures()) {
return;
}
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
diff --git a/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteFragment.java b/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteFragment.java
index 7dd3a5b..bcc220f 100644
--- a/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteFragment.java
+++ b/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteFragment.java
@@ -56,7 +56,8 @@
@Override
public void onCreate(@Nullable Bundle icicle) {
- if (android.os.Flags.allowPrivateProfile()) {
+ if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
super.onCreate(icicle);
}
}
diff --git a/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragment.java b/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragment.java
index 3a16641..33f0a3e 100644
--- a/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragment.java
+++ b/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragment.java
@@ -62,7 +62,8 @@
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
- if (android.os.Flags.allowPrivateProfile()) {
+ if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
super.onCreate(savedInstanceState);
}
}
diff --git a/src/com/android/settings/privatespace/onelock/FaceFingerprintUnlockController.java b/src/com/android/settings/privatespace/onelock/FaceFingerprintUnlockController.java
index 2e3f284..04f4894 100644
--- a/src/com/android/settings/privatespace/onelock/FaceFingerprintUnlockController.java
+++ b/src/com/android/settings/privatespace/onelock/FaceFingerprintUnlockController.java
@@ -42,6 +42,7 @@
protected boolean isUserSupported() {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
&& mProfileUserId != UserHandle.USER_NULL;
}
diff --git a/src/com/android/settings/privatespace/onelock/PrivateSpaceBiometricSettings.java b/src/com/android/settings/privatespace/onelock/PrivateSpaceBiometricSettings.java
index dc00885..827f0b7 100644
--- a/src/com/android/settings/privatespace/onelock/PrivateSpaceBiometricSettings.java
+++ b/src/com/android/settings/privatespace/onelock/PrivateSpaceBiometricSettings.java
@@ -34,7 +34,8 @@
@Override
public void onAttach(Context context) {
if (android.os.Flags.allowPrivateProfile()
- && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()) {
+ && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
super.onAttach(context);
UserHandle privateProfileHandle =
PrivateSpaceMaintainer.getInstance(context).getPrivateProfileHandle();
diff --git a/src/com/android/settings/privatespace/onelock/PrivateSpaceFacePreferenceController.java b/src/com/android/settings/privatespace/onelock/PrivateSpaceFacePreferenceController.java
index b841d9a..583a093 100644
--- a/src/com/android/settings/privatespace/onelock/PrivateSpaceFacePreferenceController.java
+++ b/src/com/android/settings/privatespace/onelock/PrivateSpaceFacePreferenceController.java
@@ -45,6 +45,7 @@
protected boolean isUserSupported() {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
&& getUserId() != UserHandle.USER_NULL;
}
@@ -63,7 +64,8 @@
@Override
public int getAvailabilityStatus() {
return android.os.Flags.allowPrivateProfile()
- && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
+ && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
diff --git a/src/com/android/settings/privatespace/onelock/PrivateSpaceFingerprintPreferenceController.java b/src/com/android/settings/privatespace/onelock/PrivateSpaceFingerprintPreferenceController.java
index d484904..f88c9fa 100644
--- a/src/com/android/settings/privatespace/onelock/PrivateSpaceFingerprintPreferenceController.java
+++ b/src/com/android/settings/privatespace/onelock/PrivateSpaceFingerprintPreferenceController.java
@@ -47,6 +47,7 @@
protected boolean isUserSupported() {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
&& getUserId() != UserHandle.USER_NULL;
}
@@ -65,7 +66,8 @@
@Override
public int getAvailabilityStatus() {
return android.os.Flags.allowPrivateProfile()
- && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
+ && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
diff --git a/src/com/android/settings/privatespace/onelock/PrivateSpaceLockController.java b/src/com/android/settings/privatespace/onelock/PrivateSpaceLockController.java
index efbe9f9..e0f376e 100644
--- a/src/com/android/settings/privatespace/onelock/PrivateSpaceLockController.java
+++ b/src/com/android/settings/privatespace/onelock/PrivateSpaceLockController.java
@@ -74,7 +74,8 @@
@Override
public boolean isAvailable() {
- return android.os.Flags.allowPrivateProfile();
+ return android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures();
}
@Override
diff --git a/src/com/android/settings/privatespace/onelock/UseOneLockController.java b/src/com/android/settings/privatespace/onelock/UseOneLockController.java
index 31634b9..1af36b3 100644
--- a/src/com/android/settings/privatespace/onelock/UseOneLockController.java
+++ b/src/com/android/settings/privatespace/onelock/UseOneLockController.java
@@ -45,7 +45,10 @@
}
@Override
public int getAvailabilityStatus() {
- return android.os.Flags.allowPrivateProfile() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ return android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
+ ? AVAILABLE
+ : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/privatespace/onelock/UseOneLockControllerSwitch.java b/src/com/android/settings/privatespace/onelock/UseOneLockControllerSwitch.java
index fd7d02b..680f5c7 100644
--- a/src/com/android/settings/privatespace/onelock/UseOneLockControllerSwitch.java
+++ b/src/com/android/settings/privatespace/onelock/UseOneLockControllerSwitch.java
@@ -95,7 +95,8 @@
@Override
public boolean isAvailable() {
- return android.os.Flags.allowPrivateProfile();
+ return android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures();
}
@Override
diff --git a/src/com/android/settings/privatespace/onelock/UseOneLockSettingsFragment.java b/src/com/android/settings/privatespace/onelock/UseOneLockSettingsFragment.java
index 413e02a..ce017e3 100644
--- a/src/com/android/settings/privatespace/onelock/UseOneLockSettingsFragment.java
+++ b/src/com/android/settings/privatespace/onelock/UseOneLockSettingsFragment.java
@@ -39,7 +39,8 @@
@Override
public void onCreate(Bundle icicle) {
- if (android.os.Flags.allowPrivateProfile()) {
+ if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
super.onCreate(icicle);
}
}
diff --git a/src/com/android/settings/safetycenter/BiometricsSafetySource.java b/src/com/android/settings/safetycenter/BiometricsSafetySource.java
index 8e1c786..c93ced1 100644
--- a/src/com/android/settings/safetycenter/BiometricsSafetySource.java
+++ b/src/com/android/settings/safetycenter/BiometricsSafetySource.java
@@ -62,7 +62,9 @@
}
final Context profileParentContext =
context.createContextAsUser(profileParentUserHandle, 0);
- if (android.os.Flags.allowPrivateProfile() && userManager.isPrivateProfile()) {
+ if (android.os.Flags.allowPrivateProfile()
+ && android.multiuser.Flags.enablePrivateSpaceFeatures()
+ && userManager.isPrivateProfile()) {
// SC always expects a response from the source if the broadcast has been sent for this
// source, therefore, we need to send a null SafetySourceData.
SafetyCenterManagerWrapper.get().setSafetySourceData(
diff --git a/src/com/android/settings/search/SearchFeatureProvider.java b/src/com/android/settings/search/SearchFeatureProvider.java
index b1d04d4..5707bc2 100644
--- a/src/com/android/settings/search/SearchFeatureProvider.java
+++ b/src/com/android/settings/search/SearchFeatureProvider.java
@@ -100,6 +100,7 @@
// and goes to the search UI. Also set the background to null so there's no ripple.
final View navView = toolbar.getNavigationView();
navView.setClickable(false);
+ navView.setFocusable(false);
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
navView.setBackground(null);
diff --git a/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java
index cf12e34..2d5905e 100644
--- a/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/KeyboardVibrationTogglePreferenceControllerTest.java
@@ -84,6 +84,9 @@
public void getAvailabilityStatus_featureSupported_available() {
mSetFlagsRule.enableFlags(Flags.FLAG_KEYBOARD_CATEGORY_ENABLED);
when(mResources.getBoolean(R.bool.config_keyboard_vibration_supported)).thenReturn(true);
+ when(mResources.getFloat(
+ com.android.internal.R.dimen.config_keyboardHapticFeedbackFixedAmplitude))
+ .thenReturn(0.8f);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationAlwaysOnPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationAlwaysOnPreferenceControllerTest.java
index e8015c5..417c3d4 100644
--- a/tests/robotests/src/com/android/settings/accessibility/MagnificationAlwaysOnPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/MagnificationAlwaysOnPreferenceControllerTest.java
@@ -17,10 +17,10 @@
package com.android.settings.accessibility;
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
-import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -56,38 +56,13 @@
mSwitchPreference.setKey(MagnificationAlwaysOnPreferenceController.PREF_KEY);
screen.addPreference(mSwitchPreference);
mController.displayPreference(screen);
- }
- @Test
- public void isChecked_defaultStateForAlwaysOn_onResumeShouldReturnTrue() {
- mController.onResume();
-
- assertThat(mController.isChecked()).isTrue();
- assertThat(mSwitchPreference.isChecked()).isTrue();
- }
-
- @Test
- public void isChecked_enableAlwaysOn_onResumeShouldReturnTrue() {
- Settings.Secure.putInt(mContext.getContentResolver(), KEY_ALWAYS_ON, ON);
- mController.onResume();
-
- assertThat(mController.isChecked()).isTrue();
- assertThat(mSwitchPreference.isChecked()).isTrue();
- }
-
- @Test
- public void isChecked_disableAlwaysOn_onResumeShouldReturnFalse() {
- Settings.Secure.putInt(mContext.getContentResolver(), KEY_ALWAYS_ON, OFF);
- mController.onResume();
-
- assertThat(mController.isChecked()).isFalse();
- assertThat(mSwitchPreference.isChecked()).isFalse();
+ mController.updateState(mSwitchPreference);
+ reset(mSwitchPreference);
}
@Test
public void performClick_switchDefaultStateForAlwaysOn_shouldReturnFalse() {
- mController.onResume();
-
mSwitchPreference.performClick();
verify(mSwitchPreference).setChecked(false);
@@ -99,7 +74,7 @@
public void updateState_disableAlwaysOn_shouldReturnFalse() {
Settings.Secure.putInt(mContext.getContentResolver(), KEY_ALWAYS_ON, OFF);
- mController.updateState();
+ mController.updateState(mSwitchPreference);
verify(mSwitchPreference).setChecked(false);
assertThat(mController.isChecked()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationFollowTypingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationFollowTypingPreferenceControllerTest.java
index fd282a0..3aeeca8 100644
--- a/tests/robotests/src/com/android/settings/accessibility/MagnificationFollowTypingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/MagnificationFollowTypingPreferenceControllerTest.java
@@ -17,10 +17,10 @@
package com.android.settings.accessibility;
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
-import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -56,38 +56,13 @@
mSwitchPreference.setKey(MagnificationFollowTypingPreferenceController.PREF_KEY);
screen.addPreference(mSwitchPreference);
mController.displayPreference(screen);
- }
- @Test
- public void isChecked_defaultStateForFollowTyping_onResumeShouldReturnTrue() {
- mController.onResume();
-
- assertThat(mController.isChecked()).isTrue();
- assertThat(mSwitchPreference.isChecked()).isTrue();
- }
-
- @Test
- public void isChecked_enableFollowTyping_onResumeShouldReturnTrue() {
- Settings.Secure.putInt(mContext.getContentResolver(), KEY_FOLLOW_TYPING, ON);
- mController.onResume();
-
- assertThat(mController.isChecked()).isTrue();
- assertThat(mSwitchPreference.isChecked()).isTrue();
- }
-
- @Test
- public void isChecked_disableFollowTyping_onResumeShouldReturnFalse() {
- Settings.Secure.putInt(mContext.getContentResolver(), KEY_FOLLOW_TYPING, OFF);
- mController.onResume();
-
- assertThat(mController.isChecked()).isFalse();
- assertThat(mSwitchPreference.isChecked()).isFalse();
+ mController.updateState(mSwitchPreference);
+ reset(mSwitchPreference);
}
@Test
public void performClick_switchDefaultStateForFollowTyping_shouldReturnFalse() {
- mController.onResume();
-
mSwitchPreference.performClick();
verify(mSwitchPreference).setChecked(false);
@@ -99,7 +74,7 @@
public void updateState_disableFollowTyping_shouldReturnFalse() {
Settings.Secure.putInt(mContext.getContentResolver(), KEY_FOLLOW_TYPING, OFF);
- mController.updateState();
+ mController.updateState(mSwitchPreference);
verify(mSwitchPreference).setChecked(false);
assertThat(mController.isChecked()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationJoystickPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationJoystickPreferenceControllerTest.java
index 236f18c..11258bb 100644
--- a/tests/robotests/src/com/android/settings/accessibility/MagnificationJoystickPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/MagnificationJoystickPreferenceControllerTest.java
@@ -17,10 +17,10 @@
package com.android.settings.accessibility;
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
-import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -56,38 +56,13 @@
mSwitchPreference.setKey(MagnificationJoystickPreferenceController.PREF_KEY);
screen.addPreference(mSwitchPreference);
mController.displayPreference(screen);
- }
- @Test
- public void isChecked_defaultStateForJoystick_onResumeShouldReturnFalse() {
- mController.onResume();
-
- assertThat(mController.isChecked()).isFalse();
- assertThat(mSwitchPreference.isChecked()).isFalse();
- }
-
- @Test
- public void isChecked_enableJoystick_onResumeShouldReturnTrue() {
- Settings.Secure.putInt(mContext.getContentResolver(), KEY_JOYSTICK, ON);
- mController.onResume();
-
- assertThat(mController.isChecked()).isTrue();
- assertThat(mSwitchPreference.isChecked()).isTrue();
- }
-
- @Test
- public void isChecked_disableJoystick_onResumeShouldReturnFalse() {
- Settings.Secure.putInt(mContext.getContentResolver(), KEY_JOYSTICK, OFF);
- mController.onResume();
-
- assertThat(mController.isChecked()).isFalse();
- assertThat(mSwitchPreference.isChecked()).isFalse();
+ mController.updateState(mSwitchPreference);
+ reset(mSwitchPreference);
}
@Test
public void performClick_switchDefaultStateForJoystick_shouldReturnTrue() {
- mController.onResume();
-
mSwitchPreference.performClick();
verify(mSwitchPreference).setChecked(true);
@@ -99,7 +74,7 @@
public void updateState_disableJoystick_shouldReturnFalse() {
Settings.Secure.putInt(mContext.getContentResolver(), KEY_JOYSTICK, OFF);
- mController.updateState();
+ mController.updateState(mSwitchPreference);
verify(mSwitchPreference).setChecked(false);
assertThat(mController.isChecked()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationModePreferenceControllerTest.java
index 62ff39b..0bc3862 100644
--- a/tests/robotests/src/com/android/settings/accessibility/MagnificationModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/MagnificationModePreferenceControllerTest.java
@@ -90,7 +90,6 @@
mModePreference.getOnPreferenceClickListener().onPreferenceClick(mModePreference);
assertThat(getCheckedModeFromDialog()).isEqualTo(MAGNIFICATION_MODE_DEFAULT);
-
}
@Test
diff --git a/tests/robotests/src/com/android/settings/accessibility/MagnificationOneFingerPanningPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/MagnificationOneFingerPanningPreferenceControllerTest.java
new file mode 100644
index 0000000..326a7a0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/MagnificationOneFingerPanningPreferenceControllerTest.java
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.android.server.accessibility.Flags.enableMagnificationOneFingerPanningGesture;
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.platform.test.flag.junit.SetFlagsRule;
+import android.provider.Settings;
+
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.server.accessibility.Flags;
+import com.android.settings.R;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class MagnificationOneFingerPanningPreferenceControllerTest {
+ private static final String ONE_FINGER_PANNING_KEY =
+ Settings.Secure.ACCESSIBILITY_SINGLE_FINGER_PANNING_ENABLED;
+
+ @Rule public final SetFlagsRule mSetFlagsRule =
+ new SetFlagsRule(SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT);
+
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ private final SwitchPreference mSwitchPreference = spy(new SwitchPreference(mContext));
+ private final MagnificationOneFingerPanningPreferenceController mController =
+ new MagnificationOneFingerPanningPreferenceController(mContext);
+
+ private PreferenceScreen mScreen;
+
+ @Before
+ public void setUp() {
+ final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ mScreen = preferenceManager.createPreferenceScreen(mContext);
+ mSwitchPreference.setKey(MagnificationOneFingerPanningPreferenceController.PREF_KEY);
+ mScreen.addPreference(mSwitchPreference);
+ mController.displayPreference(mScreen);
+ }
+
+ @After
+ public void cleanup() {
+ // Can't use resetToDefaults as it NPE with
+ // "Cannot invoke "android.content.IContentProvider.call"
+ Settings.Secure.putInt(
+ mContext.getContentResolver(),
+ MagnificationOneFingerPanningPreferenceController.PREF_KEY,
+ (mController.mDefaultValue) ? ON : OFF);
+ }
+
+ @Test
+ public void displayPreference_defaultState_correctSummarySet() {
+ assertThat(mSwitchPreference.getSummary())
+ .isEqualTo(mContext.getString(
+ R.string.accessibility_magnification_one_finger_panning_summary_off));
+ }
+
+ @Test
+ public void getAvailabilityStatus_defaultState_disabled() {
+ int status = mController.getAvailabilityStatus();
+
+ assertThat(status).isEqualTo(DISABLED_FOR_USER);
+ }
+
+ @Test
+ public void getAvailabilityStatus_featureFlagEnabled_enabled() {
+ enableFlag();
+
+ int status = mController.getAvailabilityStatus();
+
+ assertThat(status).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void isChecked_defaultState_returnFalse() {
+ assertThat(mController.isChecked()).isFalse();
+ assertThat(mSwitchPreference.isChecked()).isFalse();
+ }
+
+ @Test
+ public void isChecked_settingsEnabled_returnTrue() {
+ Settings.Secure.putInt(mContext.getContentResolver(), ONE_FINGER_PANNING_KEY, ON);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void isChecked_settingsDisabled_returnTrue() {
+ Settings.Secure.putInt(mContext.getContentResolver(), ONE_FINGER_PANNING_KEY, OFF);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void setChecked_enabled_enabledSummarySet() {
+ mController.setChecked(true);
+
+ assertThat(mSwitchPreference.getSummary()).isEqualTo(enabledSummary());
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void setChecked_disabled_disabledSummarySet() {
+ mController.setChecked(false);
+
+ assertThat(mController.isChecked()).isFalse();
+ assertThat(mSwitchPreference.getSummary()).isEqualTo(disabledSummary());
+ }
+
+ @Test
+ public void getSummary_disable_disableSummaryTextUsed() {
+ Settings.Secure.putInt(mContext.getContentResolver(), ONE_FINGER_PANNING_KEY, OFF);
+
+ var summary = mController.getSummary();
+
+ assertThat(summary).isEqualTo(disabledSummary());
+ }
+
+ @Test
+ public void getSummary_enable_enabledSummaryTextUsed() {
+ Settings.Secure.putInt(mContext.getContentResolver(), ONE_FINGER_PANNING_KEY, ON);
+
+ var summary = mController.getSummary();
+
+ assertThat(summary).isEqualTo(enabledSummary());
+ }
+
+ @Test
+ public void performClick_switchDefaultState_shouldReturnTrue() {
+ enableFlag();
+
+ mSwitchPreference.performClick();
+
+ verify(mSwitchPreference).setChecked(true);
+ assertThat(mController.isChecked()).isTrue();
+ assertThat(mSwitchPreference.isChecked()).isTrue();
+ }
+
+ private void enableFlag() {
+ mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_ONE_FINGER_PANNING_GESTURE);
+ assertThat(enableMagnificationOneFingerPanningGesture()).isTrue();
+ // This ensures that preference change listeners are added correctly.
+ mController.displayPreference(mScreen);
+ }
+
+ private String enabledSummary() {
+ return mContext.getString(
+ R.string.accessibility_magnification_one_finger_panning_summary_on);
+ }
+
+ private String disabledSummary() {
+ return mContext.getString(
+ R.string.accessibility_magnification_one_finger_panning_summary_off);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
index 4c49395..b459faa 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
@@ -19,6 +19,7 @@
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
+import static com.android.settings.accessibility.MagnificationCapabilities.MagnificationMode;
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_SAVED_USER_SHORTCUT_TYPE;
import static com.google.common.truth.Truth.assertThat;
@@ -43,9 +44,11 @@
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
+import android.provider.DeviceConfig;
import android.provider.Settings;
import androidx.appcompat.app.AlertDialog;
+import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;
import androidx.test.core.app.ApplicationProvider;
@@ -54,12 +57,14 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType;
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import com.android.settings.testutils.shadow.ShadowStorageManager;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.google.common.truth.Correspondence;
+import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -82,6 +87,7 @@
ShadowUserManager.class,
ShadowStorageManager.class,
ShadowSettings.ShadowSecure.class,
+ ShadowDeviceConfig.class,
})
public class ToggleScreenMagnificationPreferenceFragmentTest {
@@ -109,6 +115,11 @@
private static final String KEY_FOLLOW_TYPING =
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_FOLLOW_TYPING_ENABLED;
+ private static final String KEY_ALWAYS_ON =
+ Settings.Secure.ACCESSIBILITY_MAGNIFICATION_ALWAYS_ON_ENABLED;
+ private static final String KEY_JOYSTICK =
+ Settings.Secure.ACCESSIBILITY_MAGNIFICATION_JOYSTICK_ENABLED;
+
private FragmentController<ToggleScreenMagnificationPreferenceFragment> mFragController;
private Context mContext;
private Resources mSpyResources;
@@ -137,15 +148,48 @@
mFragController = FragmentController.of(fragment, SettingsActivity.class);
}
+ @After
+ public void tearDown() {
+ ShadowDeviceConfig.reset();
+ }
+
+ @Test
+ public void onResume_defaultStateForMagnificationMode_preferenceShouldReturnFullScreen() {
+ mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+ // Default is MagnificationMode.FULLSCREEN
+ final String expected =
+ MagnificationCapabilities.getSummary(mContext, MagnificationMode.FULLSCREEN);
+
+ final Preference preference = mFragController.get().findPreference(
+ MagnificationModePreferenceController.PREF_KEY);
+ assertThat(preference).isNotNull();
+ assertThat(preference.getSummary()).isEqualTo(expected);
+ }
+
+ @Test
+ public void onResume_setMagnificationModeToAll_preferenceShouldReturnAll() {
+ setKeyMagnificationMode(MagnificationMode.ALL);
+
+ mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+ final String expected =
+ MagnificationCapabilities.getSummary(mContext, MagnificationMode.ALL);
+
+ final Preference preference = mFragController.get().findPreference(
+ MagnificationModePreferenceController.PREF_KEY);
+ assertThat(preference).isNotNull();
+ assertThat(preference.getSummary()).isEqualTo(expected);
+ }
+
@Test
public void onResume_defaultStateForFollowingTyping_switchPreferenceShouldReturnTrue() {
setKeyFollowTypingEnabled(true);
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
- final TwoStatePreference switchPreference =
- mFragController.get().findPreference(
- MagnificationFollowTypingPreferenceController.PREF_KEY);
+ final TwoStatePreference switchPreference = mFragController.get().findPreference(
+ MagnificationFollowTypingPreferenceController.PREF_KEY);
assertThat(switchPreference).isNotNull();
assertThat(switchPreference.isChecked()).isTrue();
}
@@ -156,9 +200,84 @@
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
- final TwoStatePreference switchPreference =
- mFragController.get().findPreference(
- MagnificationFollowTypingPreferenceController.PREF_KEY);
+ final TwoStatePreference switchPreference = mFragController.get().findPreference(
+ MagnificationFollowTypingPreferenceController.PREF_KEY);
+ assertThat(switchPreference).isNotNull();
+ assertThat(switchPreference.isChecked()).isFalse();
+ }
+
+ @Test
+ public void onResume_defaultStateForAlwaysOn_switchPreferenceShouldReturnTrue() {
+ setAlwaysOnSupported(true);
+
+ mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+ final TwoStatePreference switchPreference = mFragController.get().findPreference(
+ MagnificationAlwaysOnPreferenceController.PREF_KEY);
+ assertThat(switchPreference).isNotNull();
+ assertThat(switchPreference.isChecked()).isTrue();
+ }
+
+ @Test
+ public void onResume_enableAlwaysOn_switchPreferenceShouldReturnTrue() {
+ setAlwaysOnSupported(true);
+ setKeyAlwaysOnEnabled(true);
+
+ mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+ final TwoStatePreference switchPreference = mFragController.get().findPreference(
+ MagnificationAlwaysOnPreferenceController.PREF_KEY);
+ assertThat(switchPreference).isNotNull();
+ assertThat(switchPreference.isChecked()).isTrue();
+ }
+
+ @Test
+ public void onResume_disableAlwaysOn_switchPreferenceShouldReturnFalse() {
+ setAlwaysOnSupported(true);
+ setKeyAlwaysOnEnabled(false);
+
+ mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+ final TwoStatePreference switchPreference = mFragController.get().findPreference(
+ MagnificationAlwaysOnPreferenceController.PREF_KEY);
+ assertThat(switchPreference).isNotNull();
+ assertThat(switchPreference.isChecked()).isFalse();
+ }
+
+ @Test
+ public void onResume_defaultStateForJoystick_switchPreferenceShouldReturnFalse() {
+ setJoystickSupported(true);
+
+ mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+ final TwoStatePreference switchPreference = mFragController.get().findPreference(
+ MagnificationJoystickPreferenceController.PREF_KEY);
+ assertThat(switchPreference).isNotNull();
+ assertThat(switchPreference.isChecked()).isFalse();
+ }
+
+ @Test
+ public void onResume_enableJoystick_switchPreferenceShouldReturnTrue() {
+ setJoystickSupported(true);
+ setKeyJoystickEnabled(true);
+
+ mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+ final TwoStatePreference switchPreference = mFragController.get().findPreference(
+ MagnificationJoystickPreferenceController.PREF_KEY);
+ assertThat(switchPreference).isNotNull();
+ assertThat(switchPreference.isChecked()).isTrue();
+ }
+
+ @Test
+ public void onResume_disableJoystick_switchPreferenceShouldReturnFalse() {
+ setJoystickSupported(true);
+ setKeyJoystickEnabled(false);
+
+ mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+ final TwoStatePreference switchPreference = mFragController.get().findPreference(
+ MagnificationJoystickPreferenceController.PREF_KEY);
assertThat(switchPreference).isNotNull();
assertThat(switchPreference.isChecked()).isFalse();
}
@@ -557,6 +676,28 @@
}
@Test
+ public void onCreateView_alwaysOnNotSupported_settingsPreferenceIsNull() {
+ setAlwaysOnSupported(false);
+
+ mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+ final TwoStatePreference switchPreference = mFragController.get().findPreference(
+ MagnificationAlwaysOnPreferenceController.PREF_KEY);
+ assertThat(switchPreference).isNull();
+ }
+
+ @Test
+ public void onCreateView_joystickNotSupported_settingsPreferenceIsNull() {
+ setJoystickSupported(false);
+
+ mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+ final TwoStatePreference switchPreference = mFragController.get().findPreference(
+ MagnificationJoystickPreferenceController.PREF_KEY);
+ assertThat(switchPreference).isNull();
+ }
+
+ @Test
public void onCreateView_setDialogDelegateAndAddTheControllerToLifeCycleObserver() {
Correspondence instanceOf = Correspondence.transforming(
observer -> (observer instanceof MagnificationModePreferenceController),
@@ -690,11 +831,41 @@
enabled ? ON : OFF);
}
+ private void setKeyMagnificationMode(@MagnificationMode int mode) {
+ MagnificationCapabilities.setCapabilities(mContext, mode);
+ }
+
private void setKeyFollowTypingEnabled(boolean enabled) {
Settings.Secure.putInt(mContext.getContentResolver(), KEY_FOLLOW_TYPING,
enabled ? ON : OFF);
}
+ private void setAlwaysOnSupported(boolean supported) {
+ ShadowDeviceConfig.setProperty(
+ DeviceConfig.NAMESPACE_WINDOW_MANAGER,
+ "AlwaysOnMagnifier__enable_always_on_magnifier",
+ supported ? "true" : "false",
+ /* makeDefault= */ false);
+ }
+
+ private void setKeyAlwaysOnEnabled(boolean enabled) {
+ Settings.Secure.putInt(mContext.getContentResolver(), KEY_ALWAYS_ON,
+ enabled ? ON : OFF);
+ }
+
+ private void setJoystickSupported(boolean supported) {
+ ShadowDeviceConfig.setProperty(
+ DeviceConfig.NAMESPACE_WINDOW_MANAGER,
+ "MagnificationJoystick__enable_magnification_joystick",
+ supported ? "true" : "false",
+ /* makeDefault= */ false);
+ }
+
+ private void setKeyJoystickEnabled(boolean enabled) {
+ Settings.Secure.putInt(mContext.getContentResolver(), KEY_JOYSTICK,
+ enabled ? ON : OFF);
+ }
+
private String getStringFromSettings(String key) {
return Settings.Secure.getString(mContext.getContentResolver(), key);
}
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java
index 1aedce5..6df8b8e 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroductionTest.java
@@ -253,6 +253,24 @@
}
@Test
+ public void intro_CheckNullPropsReturnsErrorString() {
+ setupFingerprintEnrollIntroWith(newTokenOnlyIntent());
+ when(mFingerprintManager.getSensorPropertiesInternal()).thenReturn(null);
+ final int result = mFingerprintEnrollIntroduction.checkMaxEnrolled();
+
+ assertThat(result).isEqualTo(R.string.fingerprint_intro_error_unknown);
+ }
+
+ @Test
+ public void intro_CheckEmptyPropsReturnsErrorString() {
+ setupFingerprintEnrollIntroWith(newTokenOnlyIntent());
+ when(mFingerprintManager.getSensorPropertiesInternal()).thenReturn(List.of());
+ final int result = mFingerprintEnrollIntroduction.checkMaxEnrolled();
+
+ assertThat(result).isEqualTo(R.string.fingerprint_intro_error_unknown);
+ }
+
+ @Test
public void intro_CheckGenerateChallenge() {
setupFingerprintEnrollIntroWith(newGkPwHandleAndFromSettingsIntent());
diff --git a/tests/robotests/src/com/android/settings/dashboard/profileselector/ProfileSelectFragmentTest.java b/tests/robotests/src/com/android/settings/dashboard/profileselector/ProfileSelectFragmentTest.java
index 17e0d1c..46e4ea5 100644
--- a/tests/robotests/src/com/android/settings/dashboard/profileselector/ProfileSelectFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/profileselector/ProfileSelectFragmentTest.java
@@ -118,7 +118,9 @@
profileSelectFragment.setViewPager(viewPager);
mFragmentManager.beginTransaction().add(profileSelectFragment, "tag");
- assertThat(mFragment.getTabId(mActivity, bundle)).isEqualTo(WORK_TAB);
+ // The expected position '2' comes from the order in which fragments are added in
+ // TestProfileSelectFragment#getFragments()
+ assertThat(mFragment.getTabId(mActivity, bundle)).isEqualTo(2);
}
@Test
@@ -136,7 +138,9 @@
profileSelectFragment.setViewPager(viewPager);
mFragmentManager.beginTransaction().add(profileSelectFragment, "tag");
- assertThat(mFragment.getTabId(mActivity, bundle)).isEqualTo(PRIVATE_TAB);
+ // The expected position '1' comes from the order in which fragments are added in
+ // TestProfileSelectFragment#getFragments()
+ assertThat(mFragment.getTabId(mActivity, bundle)).isEqualTo(1);
}
@Test
@@ -170,7 +174,8 @@
@Test
public void getTabId_setPrivateId_getCorrectTab() {
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
final Bundle bundle = new Bundle();
bundle.putInt(EXTRA_USER_ID, 11);
mUserManager.setPrivateProfile(11, "private", 0);
@@ -200,7 +205,8 @@
@Test
public void testGetFragments_whenOnlyPersonal_returnsOneFragment() {
- mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mUserManager.addProfile(
new UserInfo(0, PRIMARY_USER_NAME, null, 0, USER_TYPE_FULL_SYSTEM));
Fragment[] fragments = ProfileSelectFragment.getFragments(
@@ -235,7 +241,8 @@
@Test
public void testGetFragments_whenPrivateEnabled_returnsTwoFragments() {
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mUserManager.addProfile(
new UserInfo(0, PRIMARY_USER_NAME, null, 0, USER_TYPE_FULL_SYSTEM));
mUserManager.addProfile(
@@ -257,7 +264,8 @@
@Test
public void testGetFragments_whenManagedProfile_returnsTwoFragments() {
- mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mUserManager.addProfile(
new UserInfo(0, PRIMARY_USER_NAME, null, 0, USER_TYPE_FULL_SYSTEM));
mUserManager.addProfile(
@@ -279,7 +287,8 @@
@Test
public void testGetFragments_whenAllProfiles_returnsThreeFragments() {
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mUserManager.addProfile(
new UserInfo(0, PRIMARY_USER_NAME, null, 0, USER_TYPE_FULL_SYSTEM));
mUserManager.addProfile(
@@ -303,7 +312,8 @@
@Test
public void testGetFragments_whenAvailableBundle_returnsFragmentsWithCorrectBundles() {
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mUserManager.addProfile(
new UserInfo(0, PRIMARY_USER_NAME, null, 0, USER_TYPE_FULL_SYSTEM));
mUserManager.addProfile(
@@ -343,10 +353,25 @@
@Override
public Fragment[] getFragments() {
+ Fragment personalFragment = new SettingsPreferenceFragmentTest.TestFragment();
+ Bundle personalBundle = new Bundle();
+ personalBundle.putInt(EXTRA_PROFILE, ProfileType.PERSONAL);
+ personalFragment.setArguments(personalBundle);
+
+ Fragment workFragment = new SettingsPreferenceFragmentTest.TestFragment();
+ Bundle workBundle = new Bundle();
+ workBundle.putInt(EXTRA_PROFILE, ProfileType.WORK);
+ workFragment.setArguments(workBundle);
+
+ Fragment privateFragment = new SettingsPreferenceFragmentTest.TestFragment();
+ Bundle privateBundle = new Bundle();
+ privateBundle.putInt(EXTRA_PROFILE, ProfileType.PRIVATE);
+ privateFragment.setArguments(privateBundle);
+
return new Fragment[]{
- new SettingsPreferenceFragmentTest.TestFragment(), //0
- new SettingsPreferenceFragmentTest.TestFragment(),
- new SettingsPreferenceFragmentTest.TestFragment()
+ personalFragment, //0
+ privateFragment,
+ workFragment
};
}
}
diff --git a/tests/robotests/src/com/android/settings/location/LocationForPrivateProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationForPrivateProfilePreferenceControllerTest.java
new file mode 100644
index 0000000..bf6261f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/location/LocationForPrivateProfilePreferenceControllerTest.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.location;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.UserInfo;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.provider.Settings;
+
+import androidx.lifecycle.LifecycleOwner;
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+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.util.ReflectionHelpers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class LocationForPrivateProfilePreferenceControllerTest {
+
+ @Mock
+ private RestrictedSwitchPreference mPreference;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private UserManager mUserManager;
+ @Mock
+ private LocationEnabler mEnabler;
+ @Mock
+ private UserHandle mUserHandle;
+
+ private Context mContext;
+ private LocationForPrivateProfilePreferenceController mController;
+ private LifecycleOwner mLifecycleOwner;
+ private Lifecycle mLifecycle;
+ private LocationSettings mLocationSettings;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(ApplicationProvider.getApplicationContext());
+ doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
+ mockPrivateProfile();
+ mLifecycleOwner = () -> mLifecycle;
+ mLifecycle = new Lifecycle(mLifecycleOwner);
+ mLocationSettings = spy(new LocationSettings());
+ when(mLocationSettings.getSettingsLifecycle()).thenReturn(mLifecycle);
+ mController = new LocationForPrivateProfilePreferenceController(mContext, "key");
+ mController.init(mLocationSettings);
+ ReflectionHelpers.setField(mController, "mLocationEnabler", mEnabler);
+ when(mScreen.findPreference(any())).thenReturn(mPreference);
+ final String key = mController.getPreferenceKey();
+ when(mPreference.getKey()).thenReturn(key);
+ when(mPreference.isVisible()).thenReturn(true);
+ }
+
+ @Test
+ public void handlePreferenceTreeClick_preferenceChecked_shouldSetRestrictionAndOnSummary() {
+ mController.displayPreference(mScreen);
+ when(mPreference.isChecked()).thenReturn(true);
+
+ mController.handlePreferenceTreeClick(mPreference);
+
+ verify(mUserManager)
+ .setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, false, mUserHandle);
+ verify(mPreference).setSummary(R.string.switch_on_text);
+ }
+
+ @Test
+ public void handlePreferenceTreeClick_preferenceUnchecked_shouldSetRestritionAndOffSummary() {
+ mController.displayPreference(mScreen);
+ when(mPreference.isChecked()).thenReturn(false);
+
+ mController.handlePreferenceTreeClick(mPreference);
+
+ verify(mUserManager)
+ .setUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, true, mUserHandle);
+ verify(mPreference).setSummary(R.string.switch_off_text);
+ }
+
+ @Test
+ public void onLocationModeChanged_disabledByAdmin_shouldDisablePreference() {
+ mController.displayPreference(mScreen);
+ final EnforcedAdmin admin = mock(EnforcedAdmin.class);
+ doReturn(admin).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
+ doReturn(false).when(mEnabler).hasShareLocationRestriction(anyInt());
+
+ mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
+
+ verify(mPreference).setDisabledByAdmin(any());
+ }
+
+ @Test
+ public void onLocationModeChanged_locationOff_shouldDisablePreference() {
+ mController.displayPreference(mScreen);
+ doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
+ doReturn(false).when(mEnabler).hasShareLocationRestriction(anyInt());
+
+ mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_OFF, false);
+
+ verify(mPreference).setEnabled(false);
+ verify(mPreference).setChecked(false);
+ verify(mPreference).setSummary(R.string.location_app_permission_summary_location_off);
+ }
+
+ @Test
+ public void onLocationModeChanged_locationOn_shouldEnablePreference() {
+ mController.displayPreference(mScreen);
+ doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
+ doReturn(false).when(mEnabler).hasShareLocationRestriction(anyInt());
+ doReturn(true).when(mEnabler).isEnabled(anyInt());
+
+ mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
+
+ verify(mPreference, times(2)).setEnabled(true);
+ verify(mPreference).setSummary(R.string.switch_on_text);
+ }
+
+ @Test
+ public void onLocationModeChanged_noRestriction_shouldCheckedPreference() {
+ mController.displayPreference(mScreen);
+ doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
+ doReturn(false).when(mEnabler).hasShareLocationRestriction(anyInt());
+ doReturn(true).when(mEnabler).isEnabled(anyInt());
+
+ mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
+
+ verify(mPreference).setChecked(true);
+ }
+
+ @Test
+ public void onLocationModeChanged_hasRestriction_shouldCheckedPreference() {
+ mController.displayPreference(mScreen);
+ doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
+ doReturn(true).when(mEnabler).hasShareLocationRestriction(anyInt());
+
+ mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
+
+ verify(mPreference).setChecked(false);
+ }
+
+ private void mockPrivateProfile() {
+ final List<UserHandle> userProfiles = new ArrayList<>();
+ doReturn(9).when(mUserHandle).getIdentifier();
+ userProfiles.add(mUserHandle);
+ doReturn(userProfiles).when(mUserManager).getUserProfiles();
+ doReturn(new UserInfo(
+ 9,
+ "user 9",
+ "",
+ 0,
+ UserManager.USER_TYPE_PROFILE_PRIVATE)).when(mUserManager).getUserInfo(9);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/widget/RestrictedButtonTest.java b/tests/robotests/src/com/android/settings/widget/RestrictedButtonTest.java
index d696342..b3c7049 100644
--- a/tests/robotests/src/com/android/settings/widget/RestrictedButtonTest.java
+++ b/tests/robotests/src/com/android/settings/widget/RestrictedButtonTest.java
@@ -34,18 +34,18 @@
import com.android.settings.testutils.shadow.ShadowUserManager;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
+import org.robolectric.annotation.LooperMode;
import java.util.ArrayList;
import java.util.List;
-@Ignore("b/315133235")
@RunWith(RobolectricTestRunner.class)
+@LooperMode(LooperMode.Mode.LEGACY)
@Config(shadows = {ShadowUserManager.class, ShadowDevicePolicyManager.class})
public class RestrictedButtonTest {
diff --git a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
index 35dc666..293c4e4 100644
--- a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
@@ -40,7 +40,6 @@
import com.android.settings.testutils.shadow.ShadowSettingsMediaPlayer;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -48,6 +47,7 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import org.robolectric.annotation.LooperMode;
import org.robolectric.shadows.androidx.fragment.FragmentController;
@RunWith(RobolectricTestRunner.class)
@@ -141,7 +141,7 @@
assertThat(mAnimationController.isPlaying()).isTrue();
}
- @Ignore("b/315133235")
+ @LooperMode(LooperMode.Mode.LEGACY)
@Test
@Config(qualifiers = "mcc999")
public void onViewVisible_createAnimationController() {
diff --git a/tests/spa_unit/src/com/android/settings/network/telephony/SubscriptionRepositoryTest.kt b/tests/spa_unit/src/com/android/settings/network/telephony/SubscriptionRepositoryTest.kt
index a59bf93..80b3175 100644
--- a/tests/spa_unit/src/com/android/settings/network/telephony/SubscriptionRepositoryTest.kt
+++ b/tests/spa_unit/src/com/android/settings/network/telephony/SubscriptionRepositoryTest.kt
@@ -17,12 +17,14 @@
package com.android.settings.network.telephony
import android.content.Context
+import android.telephony.SubscriptionInfo
import android.telephony.SubscriptionManager
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settingslib.spa.testutils.firstWithTimeoutOrNull
import com.android.settingslib.spa.testutils.toListWithTimeout
import com.google.common.truth.Truth.assertThat
+import java.util.UUID
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
@@ -47,16 +49,16 @@
}
private val context: Context = spy(ApplicationProvider.getApplicationContext()) {
- on { getSystemService(SubscriptionManager::class.java) } doReturn mockSubscriptionManager
+ on { subscriptionManager } doReturn mockSubscriptionManager
}
@Test
fun isSubscriptionEnabledFlow() = runBlocking {
mockSubscriptionManager.stub {
- on { isSubscriptionEnabled(SUB_ID) } doReturn true
+ on { isSubscriptionEnabled(SUB_ID_1) } doReturn true
}
- val isEnabled = context.isSubscriptionEnabledFlow(SUB_ID).firstWithTimeoutOrNull()
+ val isEnabled = context.isSubscriptionEnabledFlow(SUB_ID_1).firstWithTimeoutOrNull()
assertThat(isEnabled).isTrue()
}
@@ -80,7 +82,69 @@
assertThat(listDeferred.await()).hasSize(2)
}
+ @Test
+ fun getSelectableSubscriptionInfoList_sortedBySubId() {
+ mockSubscriptionManager.stub {
+ on { getAvailableSubscriptionInfoList() } doReturn listOf(
+ SubscriptionInfo.Builder().apply {
+ setId(SUB_ID_2)
+ }.build(),
+ SubscriptionInfo.Builder().apply {
+ setId(SUB_ID_1)
+ }.build(),
+ )
+ }
+
+ val subInfos = context.getSelectableSubscriptionInfoList()
+
+ assertThat(subInfos.map { it.subscriptionId }).containsExactly(SUB_ID_1, SUB_ID_2).inOrder()
+ }
+
+ @Test
+ fun getSelectableSubscriptionInfoList_sameGroupAndOneHasSlot_returnTheOneWithSimSlotIndex() {
+ mockSubscriptionManager.stub {
+ on { getAvailableSubscriptionInfoList() } doReturn listOf(
+ SubscriptionInfo.Builder().apply {
+ setId(SUB_ID_1)
+ setGroupUuid(GROUP_UUID)
+ }.build(),
+ SubscriptionInfo.Builder().apply {
+ setId(SUB_ID_2)
+ setGroupUuid(GROUP_UUID)
+ setSimSlotIndex(SIM_SLOT_INDEX)
+ }.build(),
+ )
+ }
+
+ val subInfos = context.getSelectableSubscriptionInfoList()
+
+ assertThat(subInfos.map { it.subscriptionId }).containsExactly(SUB_ID_2)
+ }
+
+ @Test
+ fun getSelectableSubscriptionInfoList_sameGroupAndNonHasSlot_returnTheOneWithMinimumSubId() {
+ mockSubscriptionManager.stub {
+ on { getAvailableSubscriptionInfoList() } doReturn listOf(
+ SubscriptionInfo.Builder().apply {
+ setId(SUB_ID_2)
+ setGroupUuid(GROUP_UUID)
+ }.build(),
+ SubscriptionInfo.Builder().apply {
+ setId(SUB_ID_1)
+ setGroupUuid(GROUP_UUID)
+ }.build(),
+ )
+ }
+
+ val subInfos = context.getSelectableSubscriptionInfoList()
+
+ assertThat(subInfos.map { it.subscriptionId }).containsExactly(SUB_ID_1)
+ }
+
private companion object {
- const val SUB_ID = 1
+ const val SUB_ID_1 = 1
+ const val SUB_ID_2 = 2
+ val GROUP_UUID = UUID.randomUUID().toString()
+ const val SIM_SLOT_INDEX = 1
}
}
diff --git a/tests/spa_unit/src/com/android/settings/network/telephony/scan/NetworkScanRepositoryTest.kt b/tests/spa_unit/src/com/android/settings/network/telephony/scan/NetworkScanRepositoryTest.kt
new file mode 100644
index 0000000..070c779
--- /dev/null
+++ b/tests/spa_unit/src/com/android/settings/network/telephony/scan/NetworkScanRepositoryTest.kt
@@ -0,0 +1,265 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network.telephony.scan
+
+import android.content.Context
+import android.telephony.AccessNetworkConstants.AccessNetworkType
+import android.telephony.CellIdentityCdma
+import android.telephony.CellIdentityGsm
+import android.telephony.CellIdentityLte
+import android.telephony.CellInfoCdma
+import android.telephony.CellInfoGsm
+import android.telephony.CellInfoLte
+import android.telephony.NetworkScan
+import android.telephony.NetworkScanRequest
+import android.telephony.PhoneCapability
+import android.telephony.TelephonyManager
+import android.telephony.TelephonyManager.NETWORK_CLASS_BITMASK_5G
+import android.telephony.TelephonyScanManager
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.android.settings.network.telephony.scan.NetworkScanRepository.NetworkScanCellInfos
+import com.android.settings.network.telephony.scan.NetworkScanRepository.NetworkScanComplete
+import com.android.settings.network.telephony.scan.NetworkScanRepository.NetworkScanError
+import com.android.settingslib.spa.testutils.firstWithTimeoutOrNull
+import com.android.settingslib.spa.testutils.toListWithTimeout
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.async
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.kotlin.any
+import org.mockito.kotlin.argThat
+import org.mockito.kotlin.doAnswer
+import org.mockito.kotlin.doReturn
+import org.mockito.kotlin.mock
+import org.mockito.kotlin.spy
+import org.mockito.kotlin.stub
+import org.mockito.kotlin.verify
+
+@RunWith(AndroidJUnit4::class)
+class NetworkScanRepositoryTest {
+
+ private var callback: TelephonyScanManager.NetworkScanCallback? = null
+
+ private val mockTelephonyManager = mock<TelephonyManager> {
+ on { createForSubscriptionId(SUB_ID) } doReturn mock
+ on { requestNetworkScan(any(), any(), any()) } doAnswer {
+ callback = it.arguments[2] as TelephonyScanManager.NetworkScanCallback
+ mock<NetworkScan>()
+ }
+ }
+
+ private val context: Context = spy(ApplicationProvider.getApplicationContext()) {
+ on { getSystemService(TelephonyManager::class.java) } doReturn mockTelephonyManager
+ }
+
+ private val repository = NetworkScanRepository(context, SUB_ID)
+
+ @Test
+ fun networkScanFlow_initial() = runBlocking {
+ val result = repository.networkScanFlow().firstWithTimeoutOrNull()
+
+ assertThat(result).isNull()
+ }
+
+ @Test
+ fun networkScanFlow_onResults(): Unit = runBlocking {
+ val cellInfos = listOf(CellInfoCdma().apply { cellIdentity = CELL_IDENTITY_CDMA })
+ val listDeferred = async {
+ repository.networkScanFlow().toListWithTimeout()
+ }
+ delay(100)
+
+ callback?.onResults(cellInfos)
+
+ assertThat(listDeferred.await()).containsExactly(NetworkScanCellInfos(cellInfos))
+ }
+
+ @Test
+ fun networkScanFlow_onComplete(): Unit = runBlocking {
+ val listDeferred = async {
+ repository.networkScanFlow().toListWithTimeout()
+ }
+ delay(100)
+
+ callback?.onComplete()
+
+ assertThat(listDeferred.await()).containsExactly(NetworkScanComplete)
+ }
+
+ @Test
+ fun networkScanFlow_onError(): Unit = runBlocking {
+ val listDeferred = async {
+ repository.networkScanFlow().toListWithTimeout()
+ }
+ delay(100)
+
+ callback?.onError(1)
+
+ assertThat(listDeferred.await()).containsExactly(NetworkScanError(1))
+ }
+
+ @Test
+ fun networkScanFlow_hasDuplicateItems(): Unit = runBlocking {
+ val cellInfos = listOf(
+ createCellInfoLte("123", false),
+ createCellInfoLte("123", false),
+ createCellInfoLte("124", true),
+ createCellInfoLte("124", true),
+ createCellInfoGsm("123", false),
+ createCellInfoGsm("123", false),
+ )
+ val listDeferred = async {
+ repository.networkScanFlow().toListWithTimeout()
+ }
+ delay(100)
+
+ callback?.onResults(cellInfos)
+
+ assertThat(listDeferred.await()).containsExactly(
+ NetworkScanCellInfos(
+ listOf(
+ createCellInfoLte("123", false),
+ createCellInfoLte("124", true),
+ createCellInfoGsm("123", false),
+ )
+ )
+ )
+ }
+
+
+ @Test
+ fun networkScanFlow_noDuplicateItems(): Unit = runBlocking {
+ val cellInfos = listOf(
+ createCellInfoLte("123", false),
+ createCellInfoLte("123", true),
+ createCellInfoLte("124", false),
+ createCellInfoLte("124", true),
+ createCellInfoGsm("456", false),
+ createCellInfoGsm("456", true),
+ )
+ val listDeferred = async {
+ repository.networkScanFlow().toListWithTimeout()
+ }
+ delay(100)
+
+ callback?.onResults(cellInfos)
+
+ assertThat(listDeferred.await()).containsExactly(
+ NetworkScanCellInfos(
+ listOf(
+ createCellInfoLte("123", false),
+ createCellInfoLte("123", true),
+ createCellInfoLte("124", false),
+ createCellInfoLte("124", true),
+ createCellInfoGsm("456", false),
+ createCellInfoGsm("456", true),
+ )
+ )
+ )
+ }
+
+ @Test
+ fun createNetworkScan_deviceHasNrSa_requestNgran(): Unit = runBlocking {
+ mockTelephonyManager.stub {
+ on { getAllowedNetworkTypesBitmask() } doReturn NETWORK_CLASS_BITMASK_5G
+ on { getPhoneCapability() } doReturn
+ createPhoneCapability(intArrayOf(PhoneCapability.DEVICE_NR_CAPABILITY_SA))
+ }
+
+ repository.networkScanFlow().firstWithTimeoutOrNull()
+
+ verify(mockTelephonyManager).requestNetworkScan(argThat<NetworkScanRequest> {
+ specifiers.any { it.radioAccessNetwork == AccessNetworkType.NGRAN }
+ }, any(), any())
+ }
+
+ @Test
+ fun createNetworkScan_deviceNoNrSa_noNgran(): Unit = runBlocking {
+ mockTelephonyManager.stub {
+ on { getAllowedNetworkTypesBitmask() } doReturn NETWORK_CLASS_BITMASK_5G
+ on { getPhoneCapability() } doReturn
+ createPhoneCapability(intArrayOf(PhoneCapability.DEVICE_NR_CAPABILITY_NSA))
+ }
+
+ repository.networkScanFlow().firstWithTimeoutOrNull()
+
+ verify(mockTelephonyManager).requestNetworkScan(argThat<NetworkScanRequest> {
+ specifiers.none { it.radioAccessNetwork == AccessNetworkType.NGRAN }
+ }, any(), any())
+ }
+
+ private companion object {
+ const val SUB_ID = 1
+ const val LONG = "Long"
+ const val SHORT = "Short"
+
+ val CELL_IDENTITY_CDMA = CellIdentityCdma(
+ /* nid = */ 1,
+ /* sid = */ 2,
+ /* bid = */ 3,
+ /* lon = */ 4,
+ /* lat = */ 5,
+ /* alphal = */ LONG,
+ /* alphas = */ SHORT,
+ )
+
+ private fun createCellInfoLte(alphaLong: String, registered: Boolean): CellInfoLte {
+ val cellIdentityLte = CellIdentityLte(
+ /* ci = */ 1,
+ /* pci = */ 2,
+ /* tac = */ 3,
+ /* earfcn = */ 4,
+ /* bands = */ intArrayOf(1, 2),
+ /* bandwidth = */ 10000,
+ /* mccStr = */ null,
+ /* mncStr = */ null,
+ /* alphal = */ alphaLong,
+ /* alphas = */ null,
+ /* additionalPlmns = */ emptyList(),
+ /* csgInfo = */ null,
+ )
+ return CellInfoLte().apply {
+ cellIdentity = cellIdentityLte
+ isRegistered = registered
+ }
+ }
+
+ private fun createCellInfoGsm(alphaLong: String, registered: Boolean): CellInfoGsm {
+ val cellIdentityGsm = CellIdentityGsm(
+ /* lac = */ 1,
+ /* cid = */ 2,
+ /* arfcn = */ 3,
+ /* bsic = */ 4,
+ /* mccStr = */ "123",
+ /* mncStr = */ "01",
+ /* alphal = */ alphaLong,
+ /* alphas = */ null,
+ /* additionalPlmns = */ emptyList(),
+ )
+ return CellInfoGsm().apply {
+ cellIdentity = cellIdentityGsm
+ isRegistered = registered
+ }
+ }
+
+ private fun createPhoneCapability(deviceNrCapabilities: IntArray) =
+ PhoneCapability.Builder().setDeviceNrCapabilities(deviceNrCapabilities).build()
+ }
+}
diff --git a/tests/uitests/src/com/android/settings/ui/SecuritySettingsTest.kt b/tests/uitests/src/com/android/settings/ui/SecuritySettingsTest.kt
index b5a4fe9..b792959 100644
--- a/tests/uitests/src/com/android/settings/ui/SecuritySettingsTest.kt
+++ b/tests/uitests/src/com/android/settings/ui/SecuritySettingsTest.kt
@@ -49,7 +49,8 @@
}
@Test
- @RequiresFlagsEnabled(Flags.FLAG_ALLOW_PRIVATE_PROFILE)
+ @RequiresFlagsEnabled(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES)
fun privateSpace_ifFlagON() {
device.assertHasTexts(listOf("Private Space"))
}
diff --git a/tests/uitests/src/com/android/settings/ui/privatespace/PrivateSpaceAuthenticationActivityTest.kt b/tests/uitests/src/com/android/settings/ui/privatespace/PrivateSpaceAuthenticationActivityTest.kt
index 8eadd9d..14feb49 100644
--- a/tests/uitests/src/com/android/settings/ui/privatespace/PrivateSpaceAuthenticationActivityTest.kt
+++ b/tests/uitests/src/com/android/settings/ui/privatespace/PrivateSpaceAuthenticationActivityTest.kt
@@ -38,7 +38,8 @@
@RunWith(AndroidJUnit4::class)
-@RequiresFlagsEnabled(Flags.FLAG_ALLOW_PRIVATE_PROFILE)
+@RequiresFlagsEnabled(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES)
class PrivateSpaceAuthenticationActivityTest {
private val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
diff --git a/tests/unit/src/com/android/settings/applications/credentials/CredentialsPickerActivityTest.java b/tests/unit/src/com/android/settings/applications/credentials/CredentialsPickerActivityTest.java
index 044c23d..62e9909 100644
--- a/tests/unit/src/com/android/settings/applications/credentials/CredentialsPickerActivityTest.java
+++ b/tests/unit/src/com/android/settings/applications/credentials/CredentialsPickerActivityTest.java
@@ -19,21 +19,21 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
+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.Intent;
-import android.content.pm.UserInfo;
-import android.os.UserHandle;
+import android.os.Flags;
import android.os.UserManager;
+import android.platform.test.flag.junit.SetFlagsRule;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import com.google.common.collect.Lists;
-
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -41,6 +41,7 @@
@RunWith(AndroidJUnit4.class)
public class CredentialsPickerActivityTest {
+ @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Mock private UserManager mUserManager;
@@ -76,13 +77,11 @@
@Test
public void testInjectFragmentIntoIntent_privateProfile() {
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
Intent intent = new Intent();
// Simulate private profile.
- UserHandle privateUser = new UserHandle(100);
- when(mUserManager.getUserInfo(100))
- .thenReturn(new UserInfo(100, "", "", 0, UserManager.USER_TYPE_PROFILE_PRIVATE));
- when(mUserManager.getUserProfiles()).thenReturn(Lists.newArrayList(privateUser));
+ doReturn(true).when(mUserManager).isPrivateProfile();
assertThat(DefaultCombinedPickerPrivate.isUserHandledByFragment(mUserManager)).isTrue();
CredentialsPickerActivity.injectFragmentIntoIntent(mMockContext, intent);
diff --git a/tests/unit/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceControllerTest.java
index d02240e..99fb7a4 100644
--- a/tests/unit/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/credentials/DefaultCombinedPreferenceControllerTest.java
@@ -117,7 +117,7 @@
// Set the preference back to none and make sure the view was updated.
dcpc.updatePreferenceForProvider(ppp, null, null, null, null, null);
- assertThat(ppp.getTitle().toString()).isEqualTo("None");
+ assertThat(ppp.getTitle().toString()).isEqualTo("None selected");
assertThat(ppp.getSummary()).isNull();
assertThat(ppp.getIcon()).isNull();
}
diff --git a/tests/unit/src/com/android/settings/biometrics/combination/CombinedBiometricStatusUtilsTest.java b/tests/unit/src/com/android/settings/biometrics/combination/CombinedBiometricStatusUtilsTest.java
index a671a45..3a330f2 100644
--- a/tests/unit/src/com/android/settings/biometrics/combination/CombinedBiometricStatusUtilsTest.java
+++ b/tests/unit/src/com/android/settings/biometrics/combination/CombinedBiometricStatusUtilsTest.java
@@ -310,7 +310,8 @@
when(mFaceManager.hasEnrolledTemplates(anyInt())).thenReturn(false);
mSetFlagsRule.enableFlags(
android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_ENABLE_BIOMETRICS_TO_UNLOCK_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_ENABLE_BIOMETRICS_TO_UNLOCK_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
assertThat(mCombinedBiometricStatusUtils.getPrivateProfileSettingsClassName())
.isEqualTo(Settings.PrivateSpaceBiometricSettingsActivity.class.getName());
diff --git a/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsFragmentTest.java b/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsFragmentTest.java
index d00e2dd..cc9e116 100644
--- a/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsFragmentTest.java
+++ b/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsFragmentTest.java
@@ -22,12 +22,16 @@
import android.content.Context;
import android.os.Looper;
+import android.platform.test.flag.junit.SetFlagsRule;
import androidx.test.annotation.UiThreadTest;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import com.android.settings.flags.Flags;
+
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
@@ -36,7 +40,8 @@
@RunWith(AndroidJUnit4.class)
public class NetworkProviderCallsSmsFragmentTest {
-
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
private Context mContext;
private List<String> mPreferenceKeyList;
@@ -49,6 +54,7 @@
if (Looper.myLooper() == null) {
Looper.prepare();
}
+ mSetFlagsRule.disableFlags(Flags.FLAG_IS_DUAL_SIM_ONBOARDING_ENABLED);
}
@Test
diff --git a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
index bca12c1..58a3f3a 100644
--- a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
@@ -148,6 +148,7 @@
when(mUserManager.isAdminUser()).thenReturn(true);
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
+ when(mSubscriptionManager.createForAllUserProfiles()).thenReturn(mSubscriptionManager);
mPreferenceManager = new PreferenceManager(mContext);
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
diff --git a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
index ef5d4a7..42e3a83 100644
--- a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
@@ -26,6 +26,7 @@
import android.content.Context;
import android.os.Looper;
+import android.platform.test.flag.junit.SetFlagsRule;
import android.telecom.TelecomManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
@@ -40,6 +41,7 @@
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import com.android.settings.flags.Flags;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.testutils.ResourcesUtils;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -47,6 +49,7 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -58,6 +61,8 @@
@RunWith(AndroidJUnit4.class)
public class DefaultSubscriptionControllerTest {
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
private static final String SUB_ID_1 = "1";
private static final String SUB_ID_2 = "2";
@@ -105,10 +110,11 @@
if (Looper.myLooper() == null) {
Looper.prepare();
}
-
+ mSetFlagsRule.disableFlags(Flags.FLAG_IS_DUAL_SIM_ONBOARDING_ENABLED);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubMgr);
when(mContext.getSystemService(TelecomManager.class)).thenReturn(mTelecomManager);
+ when(mSubMgr.createForAllUserProfiles()).thenReturn(mSubMgr);
final String key = "prefkey";
mController = new TestDefaultSubscriptionController(mContext, key, mLifecycle,
@@ -312,9 +318,9 @@
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
- mController.onActiveSubInfoChanged(mSubscriptionInfoEntityList);
mController.displayPreference(mScreen);
+ mController.onActiveSubInfoChanged(mSubscriptionInfoEntityList);
assertThat(mListPreference.getEntries().length).isEqualTo(3);
mSubscriptionInfoEntityList.add(mSubInfo3);
diff --git a/tests/unit/src/com/android/settings/network/telephony/DisableSimFooterPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/DisableSimFooterPreferenceControllerTest.java
index 72feb30..bbbee21 100644
--- a/tests/unit/src/com/android/settings/network/telephony/DisableSimFooterPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/DisableSimFooterPreferenceControllerTest.java
@@ -57,6 +57,8 @@
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
+ when(mSubscriptionManager.createForAllUserProfiles()).thenReturn(mSubscriptionManager);
+
when(mInfo.getSubscriptionId()).thenReturn(SUB_ID);
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(mInfo));
mController = new DisableSimFooterPreferenceController(mContext, PREF_KEY);
diff --git a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
index 11a490e..152091a 100644
--- a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
@@ -28,6 +28,7 @@
import android.app.Instrumentation;
import android.content.Context;
import android.os.Looper;
+import android.platform.test.flag.junit.SetFlagsRule;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -41,12 +42,14 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
+import com.android.settings.flags.Flags;
import com.android.settings.testutils.ResourcesUtils;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -54,6 +57,8 @@
@RunWith(AndroidJUnit4.class)
public class MobileDataPreferenceControllerTest {
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
private static final String SUB_ID_1 = "1";
private static final String SUB_ID_2 = "2";
private static final String DISPLAY_NAME_1 = "Sub 1";
@@ -93,6 +98,7 @@
if (Looper.myLooper() == null) {
Looper.prepare();
}
+ mSetFlagsRule.disableFlags(Flags.FLAG_IS_DUAL_SIM_ONBOARDING_ENABLED);
mContext = spy(ApplicationProvider.getApplicationContext());
doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
diff --git a/tests/unit/src/com/android/settings/network/telephony/MobileNetworkSwitchControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/MobileNetworkSwitchControllerTest.java
index 3cdd23a..ae10ca8 100644
--- a/tests/unit/src/com/android/settings/network/telephony/MobileNetworkSwitchControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/MobileNetworkSwitchControllerTest.java
@@ -33,6 +33,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.Looper;
+import android.platform.test.flag.junit.SetFlagsRule;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyCallback;
@@ -47,6 +48,7 @@
import androidx.test.annotation.UiThreadTest;
import androidx.test.core.app.ApplicationProvider;
+import com.android.settings.flags.Flags;
import com.android.settings.network.SubscriptionUtil;
import com.android.settings.widget.SettingsMainSwitchPreference;
@@ -64,6 +66,8 @@
public class MobileNetworkSwitchControllerTest {
@Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
+ @Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@Mock
@@ -82,6 +86,8 @@
@Before
public void setUp() {
+ mSetFlagsRule.disableFlags(Flags.FLAG_IS_DUAL_SIM_ONBOARDING_ENABLED);
+
if (Looper.myLooper() == null) {
Looper.prepare();
}
diff --git a/tests/unit/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java b/tests/unit/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
index 947ba75..a6f8f2d 100644
--- a/tests/unit/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/MobileNetworkUtilsTest.java
@@ -134,6 +134,10 @@
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(
Arrays.asList(mSubscriptionInfo1, mSubscriptionInfo2));
+ when(mSubscriptionManager.getActiveSubscriptionInfo(SUB_ID_1)).thenReturn(
+ mSubscriptionInfo1);
+ when(mSubscriptionManager.getActiveSubscriptionInfo(SUB_ID_2)).thenReturn(
+ mSubscriptionInfo2);
when(mTelephonyManager.getNetworkOperatorName()).thenReturn(
PLMN_FROM_TELEPHONY_MANAGER_API);
diff --git a/tests/unit/src/com/android/settings/network/telephony/NetworkScanHelperTest.java b/tests/unit/src/com/android/settings/network/telephony/NetworkScanHelperTest.java
deleted file mode 100644
index f046c9a..0000000
--- a/tests/unit/src/com/android/settings/network/telephony/NetworkScanHelperTest.java
+++ /dev/null
@@ -1,260 +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.network.telephony;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.telephony.AccessNetworkConstants;
-import android.telephony.CellInfo;
-import android.telephony.ModemInfo;
-import android.telephony.NetworkScan;
-import android.telephony.NetworkScanRequest;
-import android.telephony.PhoneCapability;
-import android.telephony.RadioAccessSpecifier;
-import android.telephony.TelephonyManager;
-import android.telephony.TelephonyScanManager;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-@RunWith(AndroidJUnit4.class)
-public class NetworkScanHelperTest {
-
- @Mock
- private TelephonyManager mTelephonyManager;
- @Mock
- private List<CellInfo> mCellInfos;
- @Mock
- private NetworkScanHelper.NetworkScanCallback mNetworkScanCallback;
-
- private static final long THREAD_EXECUTION_TIMEOUT_MS = 3000L;
-
- private ExecutorService mNetworkScanExecutor;
- private NetworkScanHelper mNetworkScanHelper;
-
- private static final int SCAN_ID = 1234;
- private static final int SUB_ID = 1;
-
- private NetworkScan mNetworkScan;
-
- public class NetworkScanMock extends NetworkScan {
- NetworkScanMock(int scanId, int subId) {
- super(scanId, subId);
- }
-
- @Override
- public void stopScan() {
- return;
- }
- }
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mNetworkScanExecutor = Executors.newFixedThreadPool(1);
-
- mNetworkScanHelper = new NetworkScanHelper(mTelephonyManager,
- mNetworkScanCallback, mNetworkScanExecutor);
-
- mNetworkScan = spy(new NetworkScanMock(SCAN_ID, SUB_ID));
- }
-
- @Test
- public void startNetworkScan_incrementalAndSuccess_completionWithResult() {
- when(mCellInfos.size()).thenReturn(1);
-
- doAnswer(new Answer() {
- @Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- TelephonyScanManager.NetworkScanCallback callback =
- (TelephonyScanManager.NetworkScanCallback)
- (invocation.getArguments()[2]);
- callback.onResults(mCellInfos);
- callback.onComplete();
- return mNetworkScan;
- }
- }).when(mTelephonyManager).requestNetworkScan(
- any(NetworkScanRequest.class), any(Executor.class),
- any(TelephonyScanManager.NetworkScanCallback.class));
-
- ArgumentCaptor<List<CellInfo>> argument = ArgumentCaptor.forClass(List.class);
-
- startNetworkScan_incremental(true);
-
- verify(mNetworkScanCallback, times(1)).onResults(argument.capture());
- List<CellInfo> actualResult = argument.getValue();
- assertThat(actualResult.size()).isEqualTo(mCellInfos.size());
- verify(mNetworkScanCallback, times(1)).onComplete();
- }
-
- @Test
- public void startNetworkScan_incrementalAndImmediateFailure_failureWithErrorCode() {
- doReturn(null).when(mTelephonyManager).requestNetworkScan(
- any(NetworkScanRequest.class), any(Executor.class),
- any(TelephonyScanManager.NetworkScanCallback.class));
-
- startNetworkScan_incremental(true);
-
- verify(mNetworkScanCallback, times(1)).onError(anyInt());
- }
-
- @Test
- public void startNetworkScan_incrementalAndFailure_failureWithErrorCode() {
- doAnswer(new Answer() {
- @Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- TelephonyScanManager.NetworkScanCallback callback =
- (TelephonyScanManager.NetworkScanCallback)
- (invocation.getArguments()[2]);
- callback.onError(NetworkScan.ERROR_MODEM_ERROR);
- return mNetworkScan;
- }
- }).when(mTelephonyManager).requestNetworkScan(
- any(NetworkScanRequest.class), any(Executor.class),
- any(TelephonyScanManager.NetworkScanCallback.class));
-
- startNetworkScan_incremental(true);
-
- verify(mNetworkScanCallback, times(1)).onError(anyInt());
- }
-
- @Test
- public void startNetworkScan_incrementalAndAbort_doStop() {
- doReturn(mNetworkScan).when(mTelephonyManager).requestNetworkScan(
- any(NetworkScanRequest.class), any(Executor.class),
- any(TelephonyScanManager.NetworkScanCallback.class));
-
- startNetworkScan_incremental(false);
-
- verify(mNetworkScan, times(1)).stopScan();
- }
-
- @Test
- public void createNetworkScanForPreferredAccessNetworks_deviceNoNrSa_noNgran() {
- int[] deviceNrCapabilities = new int[]{PhoneCapability.DEVICE_NR_CAPABILITY_NSA};
- PhoneCapability phoneCapability = createPhoneCapability(deviceNrCapabilities);
- doReturn(TelephonyManager.NETWORK_CLASS_BITMASK_2G
- | TelephonyManager.NETWORK_CLASS_BITMASK_3G
- | TelephonyManager.NETWORK_CLASS_BITMASK_4G
- | TelephonyManager.NETWORK_CLASS_BITMASK_5G).when(
- mTelephonyManager).getPreferredNetworkTypeBitmask();
- doReturn(phoneCapability).when(mTelephonyManager).getPhoneCapability();
- List<RadioAccessSpecifier> radioAccessSpecifiers = new ArrayList<>();
- radioAccessSpecifiers.add(
- new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.GERAN, null,
- null));
- radioAccessSpecifiers.add(
- new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.UTRAN, null,
- null));
- radioAccessSpecifiers.add(
- new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.EUTRAN, null,
- null));
- NetworkScanRequest expectedNetworkScanRequest = createNetworkScanRequest(
- radioAccessSpecifiers);
-
- assertEquals(expectedNetworkScanRequest,
- mNetworkScanHelper.createNetworkScanForPreferredAccessNetworks());
- }
-
- @Test
- public void createNetworkScanForPreferredAccessNetworks_deviceHasNrSa_hasNgran() {
- int[] deviceNrCapabilities = new int[]{PhoneCapability.DEVICE_NR_CAPABILITY_NSA,
- PhoneCapability.DEVICE_NR_CAPABILITY_SA};
- PhoneCapability phoneCapability = createPhoneCapability(deviceNrCapabilities);
- doReturn(TelephonyManager.NETWORK_CLASS_BITMASK_2G
- | TelephonyManager.NETWORK_CLASS_BITMASK_3G
- | TelephonyManager.NETWORK_CLASS_BITMASK_4G
- | TelephonyManager.NETWORK_CLASS_BITMASK_5G).when(
- mTelephonyManager).getPreferredNetworkTypeBitmask();
- doReturn(phoneCapability).when(mTelephonyManager).getPhoneCapability();
- List<RadioAccessSpecifier> radioAccessSpecifiers = new ArrayList<>();
- radioAccessSpecifiers.add(
- new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.GERAN, null,
- null));
- radioAccessSpecifiers.add(
- new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.UTRAN, null,
- null));
- radioAccessSpecifiers.add(
- new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.EUTRAN, null,
- null));
- radioAccessSpecifiers.add(
- new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.NGRAN, null,
- null));
- NetworkScanRequest expectedNetworkScanRequest = createNetworkScanRequest(
- radioAccessSpecifiers);
-
- assertEquals(expectedNetworkScanRequest,
- mNetworkScanHelper.createNetworkScanForPreferredAccessNetworks());
- }
-
- private PhoneCapability createPhoneCapability(int[] deviceNrCapabilities) {
- int maxActiveVoiceCalls = 1;
- int maxActiveData = 2;
- ModemInfo modemInfo = new ModemInfo(1, 2, true, false);
- List<ModemInfo> logicalModemList = new ArrayList<>();
- logicalModemList.add(modemInfo);
- return new PhoneCapability(maxActiveVoiceCalls, maxActiveData,
- logicalModemList, false, deviceNrCapabilities);
- }
-
- private NetworkScanRequest createNetworkScanRequest(
- List<RadioAccessSpecifier> radioAccessSpecifiers) {
- return new NetworkScanRequest(
- NetworkScanRequest.SCAN_TYPE_ONE_SHOT,
- radioAccessSpecifiers.toArray(
- new RadioAccessSpecifier[radioAccessSpecifiers.size()]),
- mNetworkScanHelper.SEARCH_PERIODICITY_SEC,
- mNetworkScanHelper.MAX_SEARCH_TIME_SEC,
- mNetworkScanHelper.INCREMENTAL_RESULTS,
- mNetworkScanHelper.INCREMENTAL_RESULTS_PERIODICITY_SEC,
- null /* List of PLMN ids (MCC-MNC) */);
- }
-
- private void startNetworkScan_incremental(boolean waitForCompletion) {
- mNetworkScanHelper.startNetworkScan(
- NetworkScanHelper.NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS);
- if (!waitForCompletion) {
- mNetworkScanHelper.stopNetworkQuery();
- }
- }
-
-}
diff --git a/tests/unit/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java b/tests/unit/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java
index 080534e..a4657ce 100644
--- a/tests/unit/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/NetworkSelectSettingsTest.java
@@ -83,7 +83,6 @@
public Context mContext;
public PreferenceCategory mPreferenceCategory;
- public boolean mIsAggregationEnabled = true;
private TargetClass mNetworkSelectSettings;
@@ -104,12 +103,13 @@
doReturn(mCellId2).when(mCellInfo2).getCellIdentity();
doReturn(mock(CellSignalStrength.class)).when(mCellInfo2).getCellSignalStrength();
doReturn(CARRIER_NAME2).when(mCellId2).getOperatorAlphaLong();
- mIsAggregationEnabled = true;
mNetworkSelectSettings = spy(new TargetClass(this));
PersistableBundle config = new PersistableBundle();
config.putBoolean(CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL, true);
- doReturn(config).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
+ doReturn(config).when(mCarrierConfigManager).getConfigForSubId(SUB_ID,
+ CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL,
+ CarrierConfigManager.KEY_REMOVE_SATELLITE_PLMN_IN_MANUAL_NETWORK_SCAN_BOOL);
doReturn(TelephonyManager.DATA_CONNECTED).when(mTelephonyManager).getDataState();
}
@@ -175,11 +175,6 @@
}
@Override
- protected boolean enableAggregation(Context context) {
- return mTestEnv.mIsAggregationEnabled;
- }
-
- @Override
protected int getSubId() {
return SUB_ID;
}
@@ -210,77 +205,7 @@
}
@Test
- public void doAggregation_hasDuplicateItemsDiffCellIdCase1_removeSamePlmnRatItem() {
- mNetworkSelectSettings.onCreateInitialization();
- List<CellInfo> testList = Arrays.asList(
- createLteCellInfo(true, 123, "123", "232", "CarrierA"),
- createLteCellInfo(true, 1234, "123", "232", "CarrierA"),
- createGsmCellInfo(false, 123, "123", "232", "CarrierB"));
- List<CellInfo> expected = Arrays.asList(
- createLteCellInfo(true, 123, "123", "232", "CarrierA"),
- createGsmCellInfo(false, 123, "123", "232", "CarrierB"));
- assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
- }
-
- @Test
- public void doAggregation_hasDuplicateItemsDiffCellIdCase2_removeSamePlmnRatItem() {
- mNetworkSelectSettings.onCreateInitialization();
- List<CellInfo> testList = Arrays.asList(
- createLteCellInfo(true, 123, "123", "232", "CarrierA"),
- createGsmCellInfo(false, 123, "123", "232", "CarrierB"),
- createLteCellInfo(false, 1234, "123", "232", "CarrierB"),
- createGsmCellInfo(false, 1234, "123", "232", "CarrierB"));
- List<CellInfo> expected = Arrays.asList(
- createLteCellInfo(true, 123, "123", "232", "CarrierA"),
- createGsmCellInfo(false, 123, "123", "232", "CarrierB"),
- createLteCellInfo(false, 1234, "123", "232", "CarrierB"));
- assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
- }
-
- @Test
- public void doAggregation_hasDuplicateItemsDiffMccMncCase1_removeSamePlmnRatItem() {
- mNetworkSelectSettings.onCreateInitialization();
- List<CellInfo> testList = Arrays.asList(
- createLteCellInfo(true, 123, "123", "232", "CarrierA"),
- createLteCellInfo(true, 123, "456", "232", "CarrierA"),
- createGsmCellInfo(false, 123, "123", "232", "CarrierB"));
- List<CellInfo> expected = Arrays.asList(
- createLteCellInfo(true, 123, "123", "232", "CarrierA"),
- createGsmCellInfo(false, 123, "123", "232", "CarrierB"));
- assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
- }
-
- @Test
- public void doAggregation_hasDuplicateItemsDiffMccMncCase2_removeSamePlmnRatItem() {
- mNetworkSelectSettings.onCreateInitialization();
- List<CellInfo> testList = Arrays.asList(
- createLteCellInfo(true, 123, "123", "232", "CarrierA"),
- createGsmCellInfo(false, 123, "123", "232", "CarrierB"),
- createLteCellInfo(false, 1234, "123", "232", "CarrierB"),
- createGsmCellInfo(false, 123, "456", "232", "CarrierB"));
- List<CellInfo> expected = Arrays.asList(
- createLteCellInfo(true, 123, "123", "232", "CarrierA"),
- createGsmCellInfo(false, 123, "123", "232", "CarrierB"),
- createLteCellInfo(false, 1234, "123", "232", "CarrierB"));
- assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
- }
-
- @Test
- public void doAggregation_hasDuplicateItemsDiffMccMncCase3_removeSamePlmnRatItem() {
- mNetworkSelectSettings.onCreateInitialization();
- List<CellInfo> testList = Arrays.asList(
- createLteCellInfo(false, 123, "123", "232", "CarrierA"),
- createLteCellInfo(false, 124, "123", "233", "CarrierA"),
- createLteCellInfo(true, 125, "123", "234", "CarrierA"),
- createGsmCellInfo(false, 126, "456", "232", "CarrierA"));
- List<CellInfo> expected = Arrays.asList(
- createLteCellInfo(true, 125, "123", "234", "CarrierA"),
- createGsmCellInfo(false, 126, "456", "232", "CarrierA"));
- assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
- }
-
- @Test
- public void doAggregation_filterOutSatellitePlmn_whenKeyIsTrue() {
+ public void filterOutSatellitePlmn_filterOutSatellitePlmn_whenKeyIsTrue() {
PersistableBundle config = new PersistableBundle();
config.putBoolean(
CarrierConfigManager.KEY_REMOVE_SATELLITE_PLMN_IN_MANUAL_NETWORK_SCAN_BOOL, true);
@@ -304,11 +229,11 @@
List<CellInfo> expected = Arrays.asList(
createGsmCellInfo(false, 123, "123", "233", "CarrierB"),
createLteCellInfo(false, 1234, "123", "234", "CarrierC"));
- assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
+ assertThat(mNetworkSelectSettings.filterOutSatellitePlmn(testList)).isEqualTo(expected);
}
@Test
- public void doAggregation_filterOutSatellitePlmn_whenNoSatellitePlmnIsAvailable() {
+ public void filterOutSatellitePlmn_filterOutSatellitePlmn_whenNoSatellitePlmnIsAvailable() {
PersistableBundle config = new PersistableBundle();
config.putBoolean(
CarrierConfigManager.KEY_REMOVE_SATELLITE_PLMN_IN_MANUAL_NETWORK_SCAN_BOOL, true);
@@ -336,17 +261,17 @@
createGsmCellInfo(false, 123, "123", "233", "CarrierB"),
createLteCellInfo(false, 1234, "123", "234", "CarrierC"),
createGsmCellInfo(false, 12345, "123", "235", "CarrierD"));
- assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
+ assertThat(mNetworkSelectSettings.filterOutSatellitePlmn(testList)).isEqualTo(expected);
// Expect no filter out when KEY_REMOVE_SATELLITE_PLMN_IN_MANUAL_NETWORK_SCAN_BOOL is false.
config.putBoolean(
CarrierConfigManager.KEY_REMOVE_SATELLITE_PLMN_IN_MANUAL_NETWORK_SCAN_BOOL, false);
mNetworkSelectSettings.onCreateInitialization();
- assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
+ assertThat(mNetworkSelectSettings.filterOutSatellitePlmn(testList)).isEqualTo(expected);
}
@Test
- public void doAggregation_filterOutSatellitePlmn_whenKeyIsFalse() {
+ public void filterOutSatellitePlmn_filterOutSatellitePlmn_whenKeyIsFalse() {
PersistableBundle config = new PersistableBundle();
config.putBoolean(
CarrierConfigManager.KEY_REMOVE_SATELLITE_PLMN_IN_MANUAL_NETWORK_SCAN_BOOL, true);
@@ -372,7 +297,7 @@
createGsmCellInfo(false, 123, "123", "233", "CarrierB"),
createLteCellInfo(false, 1234, "123", "234", "CarrierC"),
createGsmCellInfo(false, 12345, "123", "235", "CarrierD"));
- assertThat(mNetworkSelectSettings.doAggregation(testList)).isEqualTo(expected);
+ assertThat(mNetworkSelectSettings.filterOutSatellitePlmn(testList)).isEqualTo(expected);
}
private CellInfoLte createLteCellInfo(boolean registered, int cellId, String mcc, String mnc,
diff --git a/tests/unit/src/com/android/settings/privatespace/FaceFingerprintUnlockControllerTest.java b/tests/unit/src/com/android/settings/privatespace/FaceFingerprintUnlockControllerTest.java
index f1da363..857135f 100644
--- a/tests/unit/src/com/android/settings/privatespace/FaceFingerprintUnlockControllerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/FaceFingerprintUnlockControllerTest.java
@@ -75,7 +75,8 @@
public void getAvailabilityStatus_whenFlagsEnabled_returnsAvailable() {
mSetFlagsRule.enableFlags(
android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_ENABLE_BIOMETRICS_TO_UNLOCK_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_ENABLE_BIOMETRICS_TO_UNLOCK_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
assertThat(mFaceFingerprintUnlockController.isAvailable()).isEqualTo(true);
}
@@ -83,18 +84,33 @@
/** Tests that the controller is not available when Biometrics flag is not enabled. */
@Test
public void getAvailabilityStatus_whenBiometricFlagDisabled_returnsFalse() {
- mSetFlagsRule.enableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mSetFlagsRule.disableFlags(
android.multiuser.Flags.FLAG_ENABLE_BIOMETRICS_TO_UNLOCK_PRIVATE_SPACE);
assertThat(mFaceFingerprintUnlockController.isAvailable()).isEqualTo(false);
}
- /** Tests that the controller is not available when private feature flag is not enabled. */
+ /**
+ * Tests that the controller is not available when the main private space flag is not
+ * enabled.
+ */
@Test
- public void getAvailabilityStatus_whenPrivateFlagDisabled_returnsFalse() {
+ public void getAvailabilityStatus_whenPsMainFlagDisabled_returnsFalse() {
mSetFlagsRule.disableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE);
mSetFlagsRule.enableFlags(
+ android.multiuser.Flags.FLAG_ENABLE_BIOMETRICS_TO_UNLOCK_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+
+ assertThat(mFaceFingerprintUnlockController.isAvailable()).isEqualTo(false);
+ }
+
+ /** Tests that the controller is not available when private features flag is not enabled. */
+ @Test
+ public void getAvailabilityStatus_whenPsFeaturesFlagDisabled_returnsFalse() {
+ mSetFlagsRule.disableFlags(android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
+ mSetFlagsRule.enableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
android.multiuser.Flags.FLAG_ENABLE_BIOMETRICS_TO_UNLOCK_PRIVATE_SPACE);
assertThat(mFaceFingerprintUnlockController.isAvailable()).isEqualTo(false);
@@ -106,7 +122,8 @@
doReturn(false).when(mLockPatternUtils).isSeparateProfileChallengeEnabled(anyInt());
mSetFlagsRule.enableFlags(
android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_ENABLE_BIOMETRICS_TO_UNLOCK_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_ENABLE_BIOMETRICS_TO_UNLOCK_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mFaceFingerprintUnlockController.updateState(mPreference);
assertThat(mPreference.isEnabled()).isFalse();
@@ -119,7 +136,8 @@
doReturn(true).when(mLockPatternUtils).isSeparateProfileChallengeEnabled(anyInt());
mSetFlagsRule.enableFlags(
android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_ENABLE_BIOMETRICS_TO_UNLOCK_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_ENABLE_BIOMETRICS_TO_UNLOCK_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mFaceFingerprintUnlockController.updateState(mPreference);
assertThat(mPreference.isEnabled()).isTrue();
diff --git a/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceControllerTest.java b/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceControllerTest.java
index 0abe314..b71547b 100644
--- a/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceControllerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceControllerTest.java
@@ -40,7 +40,8 @@
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
-@RequiresFlagsEnabled(Flags.FLAG_ALLOW_PRIVATE_PROFILE)
+@RequiresFlagsEnabled({Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES})
public class HidePrivateSpaceControllerTest {
@Rule
public final CheckFlagsRule mCheckFlagsRule =
diff --git a/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsControllerTest.java b/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsControllerTest.java
index 1430dfd..88503a5 100644
--- a/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsControllerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceSensitiveNotificationsControllerTest.java
@@ -67,7 +67,8 @@
mSetFlagsRule.enableFlags(
android.multiuser.Flags.FLAG_ENABLE_PS_SENSITIVE_NOTIFICATIONS_TOGGLE);
- mSetFlagsRule.enableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mPrivateProfileId = PrivateSpaceMaintainer.getInstance(
mContext).getPrivateProfileHandle().getIdentifier();
@@ -143,7 +144,8 @@
public void getAvailabilityStatus_flagDisabled() {
mSetFlagsRule.disableFlags(
android.multiuser.Flags.FLAG_ENABLE_PS_SENSITIVE_NOTIFICATIONS_TOGGLE);
- mSetFlagsRule.disableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.disableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
Settings.Secure.putInt(mContext.getContentResolver(),
diff --git a/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceSummaryControllerTest.java b/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceSummaryControllerTest.java
index 39f7b9c..ed072d3 100644
--- a/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceSummaryControllerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/HidePrivateSpaceSummaryControllerTest.java
@@ -40,7 +40,8 @@
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
-@RequiresFlagsEnabled(Flags.FLAG_ALLOW_PRIVATE_PROFILE)
+@RequiresFlagsEnabled({Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES})
public class HidePrivateSpaceSummaryControllerTest {
@Rule
public final CheckFlagsRule mCheckFlagsRule =
diff --git a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivityTest.java b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivityTest.java
index 4c6feea..8a7bd70 100644
--- a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivityTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceAuthenticationActivityTest.java
@@ -88,7 +88,8 @@
/** Tests that when Private does not exist setup flow is started. */
//TODO(b/307729746) Plan to add more tests for complete setup flow
@Test
- @RequiresFlagsEnabled(Flags.FLAG_ALLOW_PRIVATE_PROFILE)
+ @RequiresFlagsEnabled({Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES})
public void whenPrivateProfileDoesNotExist_triggersSetupFlow() {
when(mPrivateSpaceMaintainer.doesPrivateSpaceExist()).thenReturn(false);
diff --git a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceLockControllerTest.java b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceLockControllerTest.java
index 0d9db7e..c203a3c 100644
--- a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceLockControllerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceLockControllerTest.java
@@ -80,7 +80,8 @@
/** Tests that the controller is always available. */
@Test
public void getAvailabilityStatus_returnsAvailable() {
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
assertThat(mPrivateSpaceLockController.isAvailable()).isEqualTo(true);
}
@@ -89,7 +90,8 @@
@Test
public void getSummary_whenScreenLock() {
doReturn(false).when(mLockPatternUtils).isSeparateProfileChallengeEnabled(anyInt());
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mPrivateSpaceLockController.updateState(mPreference);
assertThat(mPreference.isEnabled()).isFalse();
@@ -103,7 +105,8 @@
.when(mLockPatternUtils).isSeparateProfileChallengeEnabled(anyInt());
doReturn(CREDENTIAL_TYPE_PATTERN)
.when(mLockPatternUtils).getCredentialTypeForUser(anyInt());
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mPrivateSpaceLockController.updateState(mPreference);
assertThat(mPreference.isEnabled()).isTrue();
@@ -115,7 +118,8 @@
public void getSummary_whenProfileLockPin() {
doReturn(true).when(mLockPatternUtils).isSeparateProfileChallengeEnabled(anyInt());
doReturn(CREDENTIAL_TYPE_PIN).when(mLockPatternUtils).getCredentialTypeForUser(anyInt());
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mPrivateSpaceLockController.updateState(mPreference);
assertThat(mPreference.isEnabled()).isTrue();
@@ -129,7 +133,8 @@
.when(mLockPatternUtils).isSeparateProfileChallengeEnabled(anyInt());
doReturn(CREDENTIAL_TYPE_PASSWORD)
.when(mLockPatternUtils).getCredentialTypeForUser(anyInt());
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mPrivateSpaceLockController.updateState(mPreference);
assertThat(mPreference.isEnabled()).isTrue();
diff --git a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
index 8510b11..50f67d3 100644
--- a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceMaintainerTest.java
@@ -148,7 +148,8 @@
public void createPrivateSpace_psDoesNotExist_setsDefaultPsSensitiveNotificationsValue() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_ENABLE_PS_SENSITIVE_NOTIFICATIONS_TOGGLE);
+ android.multiuser.Flags.FLAG_ENABLE_PS_SENSITIVE_NOTIFICATIONS_TOGGLE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
privateSpaceMaintainer.deletePrivateSpace();
@@ -259,7 +260,8 @@
public void createPrivateSpace_psDoesNotExist_resetsPSAutoLockSettings() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
final int autoLockOption = 2;
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
@@ -282,7 +284,8 @@
public void createPrivateSpace_psExists_doesNotResetPSAutoLockSettings() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
final int privateSpaceAutLockValue = 1;
PrivateSpaceMaintainer privateSpaceMaintainer =
PrivateSpaceMaintainer.getInstance(mContext);
diff --git a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceSafetySourceTest.java b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceSafetySourceTest.java
index cf9ea05..940f70d 100644
--- a/tests/unit/src/com/android/settings/privatespace/PrivateSpaceSafetySourceTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/PrivateSpaceSafetySourceTest.java
@@ -86,7 +86,8 @@
@Test
public void onDeviceRebootedEvent_whenSafetyCenterEnabled_setsData() {
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
@@ -98,7 +99,8 @@
@Test
public void setSafetySourceData_whenFeatureDisabled_setsNullData() {
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
- mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
@@ -113,7 +115,8 @@
@Test
public void setSafetySourceData_setsEnabled() {
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
@@ -129,7 +132,8 @@
@Test
public void setSafetySourceData_setsPsAuthenticatorIntent() {
when(mSafetyCenterManagerWrapper.isEnabled(mContext)).thenReturn(true);
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
PrivateSpaceSafetySource.setSafetySourceData(mContext, EVENT_TYPE_DEVICE_REBOOTED);
diff --git a/tests/unit/src/com/android/settings/privatespace/UseOneLockControllerTest.java b/tests/unit/src/com/android/settings/privatespace/UseOneLockControllerTest.java
index 744a8ec..5c2a15c 100644
--- a/tests/unit/src/com/android/settings/privatespace/UseOneLockControllerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/UseOneLockControllerTest.java
@@ -74,7 +74,8 @@
/** Tests that the controller is always available. */
@Test
public void getAvailabilityStatus_returnsAvailable() {
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
assertThat(mUseOneLockController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@@ -87,7 +88,8 @@
.when(mLockPatternUtils).isSeparateProfileChallengeEnabled(anyInt());
doReturn(CREDENTIAL_TYPE_PATTERN)
.when(mLockPatternUtils).getCredentialTypeForUser(anyInt());
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mUseOneLockController.updateState(mPreference);
assertThat(mUseOneLockController.getSummary().toString()).isEqualTo("Pattern");
@@ -99,7 +101,8 @@
doReturn(true)
.when(mLockPatternUtils).isSeparateProfileChallengeEnabled(anyInt());
doReturn(CREDENTIAL_TYPE_PIN).when(mLockPatternUtils).getCredentialTypeForUser(anyInt());
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mUseOneLockController.updateState(mPreference);
assertThat(mUseOneLockController.getSummary().toString()).isEqualTo("PIN");
@@ -112,7 +115,8 @@
.when(mLockPatternUtils).isSeparateProfileChallengeEnabled(anyInt());
doReturn(CREDENTIAL_TYPE_PASSWORD)
.when(mLockPatternUtils).getCredentialTypeForUser(anyInt());
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mUseOneLockController.updateState(mPreference);
assertThat(mUseOneLockController.getSummary().toString()).isEqualTo("Password");
diff --git a/tests/unit/src/com/android/settings/privatespace/autolock/AutoLockPreferenceControllerTest.java b/tests/unit/src/com/android/settings/privatespace/autolock/AutoLockPreferenceControllerTest.java
index 01381d8..45c2c75 100644
--- a/tests/unit/src/com/android/settings/privatespace/autolock/AutoLockPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/autolock/AutoLockPreferenceControllerTest.java
@@ -75,7 +75,8 @@
public void getAvailabilityStatus_withAutoLockFlagEnabled_returnsAvailable() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
assertThat(mAutoLockPreferenceController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@@ -83,7 +84,8 @@
/** Tests that the controller is not available when auto lock flag is off. */
@Test
public void getAvailabilityStatus_withAutoLockFlagDisabled_returnsNull() {
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mSetFlagsRule.disableFlags(android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE);
assertThat(mAutoLockPreferenceController.getAvailabilityStatus())
@@ -98,7 +100,8 @@
public void getSummary_whenOptionEveryTimeDeviceLocks_returnsEveryTimeDeviceLocks() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
Settings.Secure.putInt(
mContentResolver,
@@ -116,7 +119,8 @@
public void getSummary_whenOptionAfter5MinutesOfInactivity_returnsAfter5MinutesOfInactivity() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
Settings.Secure.putInt(
mContentResolver,
@@ -131,7 +135,8 @@
public void getSummary_whenOptionNever_returnsNever() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
Settings.Secure.putInt(
mContentResolver,
diff --git a/tests/unit/src/com/android/settings/privatespace/autolock/AutoLockSettingsFragmentTest.java b/tests/unit/src/com/android/settings/privatespace/autolock/AutoLockSettingsFragmentTest.java
index 971ca40..1c620c0 100644
--- a/tests/unit/src/com/android/settings/privatespace/autolock/AutoLockSettingsFragmentTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/autolock/AutoLockSettingsFragmentTest.java
@@ -94,7 +94,8 @@
public void verifyMetricsConstant() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
assertThat(mFragment.getMetricsCategory()).isEqualTo(SettingsEnums.PRIVATE_SPACE_SETTINGS);
}
@@ -103,7 +104,8 @@
public void getCandidates_returnsCandidateInfoListWithAllKeys() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mFragment.onAttach(mContext);
final List<? extends CandidateInfo> candidates = mFragment.getCandidates();
@@ -120,7 +122,8 @@
public void getDefaultKey_returnsStoredAutoLockOptionsValue() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mFragment.onAttach(mContext);
@@ -144,7 +147,8 @@
public void setDefaultKey_storesCorrectAutoLockOptionValue() {
mSetFlagsRule.enableFlags(
Flags.FLAG_ALLOW_PRIVATE_PROFILE,
- android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE);
+ android.multiuser.Flags.FLAG_SUPPORT_AUTOLOCK_FOR_PRIVATE_SPACE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mFragment.onAttach(mContext);
mFragment.setDefaultKey("2");
diff --git a/tests/unit/src/com/android/settings/privatespace/delete/DeletePrivateSpaceControllerTest.java b/tests/unit/src/com/android/settings/privatespace/delete/DeletePrivateSpaceControllerTest.java
index 371ca24..ed8decd 100644
--- a/tests/unit/src/com/android/settings/privatespace/delete/DeletePrivateSpaceControllerTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/delete/DeletePrivateSpaceControllerTest.java
@@ -58,7 +58,8 @@
/** Tests that the controller is available when private space flag is enabled. */
@Test
public void getAvailabilityStatus_whenPrivateFlagEnabled_returnsAvailable() {
- mSetFlagsRule.enableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
assertThat(mDeletePrivateSpaceController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@@ -66,7 +67,8 @@
/** Tests that the controller is not available when private space flag is disabled. */
@Test
public void getAvailabilityStatus_whenPrivateFlagDisabled_returnsUnsupportedOnDevice() {
- mSetFlagsRule.disableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.disableFlags(android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
assertThat(mDeletePrivateSpaceController.getAvailabilityStatus())
.isEqualTo(UNSUPPORTED_ON_DEVICE);
diff --git a/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteFragmentTest.java b/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteFragmentTest.java
index 16ccbc4..5c48375 100644
--- a/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteFragmentTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeleteFragmentTest.java
@@ -39,7 +39,8 @@
@Test
@UiThreadTest
public void verifyMetricsConstant() {
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mFragment = spy(new PrivateSpaceDeleteFragment());
assertThat(mFragment.getMetricsCategory()).isEqualTo(SettingsEnums.PRIVATE_SPACE_SETTINGS);
}
diff --git a/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragmentTest.java b/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragmentTest.java
index 5c2ef23..ffc1edf 100644
--- a/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragmentTest.java
+++ b/tests/unit/src/com/android/settings/privatespace/delete/PrivateSpaceDeletionProgressFragmentTest.java
@@ -77,7 +77,8 @@
@Test
@UiThreadTest
public void verifyMetricsConstant() {
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
assertThat(mFragment.getMetricsCategory()).isEqualTo(SettingsEnums.PRIVATE_SPACE_SETTINGS);
}
@@ -87,7 +88,8 @@
public void deletePrivateSpace_deletesPS() {
PrivateSpaceDeletionProgressFragment spyFragment = spy(mFragment);
doNothing().when(spyFragment).showSuccessfulDeletionToast();
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mPrivateSpaceMaintainer.createPrivateSpace();
spyFragment.deletePrivateSpace();
@@ -100,7 +102,8 @@
public void deletePrivateSpace_onDeletion_showsDeletedToast() {
PrivateSpaceDeletionProgressFragment spyFragment = spy(mFragment);
doNothing().when(spyFragment).showSuccessfulDeletionToast();
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
mPrivateSpaceMaintainer.createPrivateSpace();
spyFragment.deletePrivateSpace();
@@ -123,7 +126,8 @@
spyFragment.setPrivateSpaceMaintainer(injector);
doReturn(DELETE_PS_ERROR_INTERNAL).when(mPrivateSpaceMaintainerMock).deletePrivateSpace();
doNothing().when(spyFragment).showDeletionInternalErrorToast();
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
spyFragment.deletePrivateSpace();
diff --git a/tests/unit/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiverTest.java b/tests/unit/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiverTest.java
index 85bd0e2..cd4c3c6 100644
--- a/tests/unit/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiverTest.java
+++ b/tests/unit/src/com/android/settings/safetycenter/SafetySourceBroadcastReceiverTest.java
@@ -247,7 +247,8 @@
@Test
public void onReceive_onRefresh_withPrivateSpaceFeatureDisabled_setsNullData() {
when(mSafetyCenterManagerWrapper.isEnabled(mApplicationContext)).thenReturn(true);
- mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE);
+ mSetFlagsRule.disableFlags(Flags.FLAG_ALLOW_PRIVATE_PROFILE,
+ android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
Intent intent =
new Intent()