Merge "Pass in active device to all BluetoothA2dp APIs in packages/apps/Settings as null input is no longer supported"
diff --git a/res/drawable/ic_add_to_home.xml b/res/drawable/ic_add_to_home.xml
new file mode 100644
index 0000000..1f55b71
--- /dev/null
+++ b/res/drawable/ic_add_to_home.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M18,1.01L8,1c-1.1,0 -2,0.9 -2,2v3h2V5h10v14H8v-1H6v3c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-1.99 -2,-1.99zM10,15h2V8H5v2h3.59L3,15.59 4.41,17 10,11.41V15z"/>
+</vector>
diff --git a/res/drawable/ic_create_bubble.xml b/res/drawable/ic_create_bubble.xml
new file mode 100644
index 0000000..e943355
--- /dev/null
+++ b/res/drawable/ic_create_bubble.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:pathData="M12,3c-4.97,0 -9,4.03 -9,9c0,1.39 0.32,2.69 0.88,3.86l1.53,-1.53C5.15,13.6 5,12.82 5,12c0,-3.86 3.14,-7 7,-7s7,3.14 7,7s-3.14,7 -7,7c-0.83,0 -1.62,-0.15 -2.35,-0.42l-1.53,1.53C9.3,20.67 10.61,21 12,21c4.97,0 9,-4.03 9,-9C21,7.03 16.97,3 12,3z"
+ android:fillColor="#000000"/>
+ <path
+ android:pathData="M12.99,15.99l2,0l0,-7l-7,0l0,2l3.59,0l-8.79,8.8l1.41,1.41l8.79,-8.79z"
+ android:fillColor="#000000"/>
+</vector>
diff --git a/res/drawable/ic_demote_conversation.xml b/res/drawable/ic_demote_conversation.xml
new file mode 100644
index 0000000..ef25bad
--- /dev/null
+++ b/res/drawable/ic_demote_conversation.xml
@@ -0,0 +1,26 @@
+<!--
+ Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M20,2L4.83,2l2,2L20,4v12h-1.17l1.87,1.87c0.75,-0.29 1.3,-1.02 1.3,-1.87L22,4c0,-1.1 -0.9,-2 -2,-2zM6,12h2v2L6,14zM18,11L18,9h-6.17l2,2zM18,6h-8v1.17l0.83,0.83L18,8zM0.69,3.51l1.32,1.32L2,22l4,-4h9.17l5.31,5.31 1.41,-1.41L2.1,2.1 0.69,3.51zM6,16h-0.83l-0.59,0.59 -0.58,0.58L4,6.83l2,2L6,11h2.17l5,5L6,16z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_important_outline.xml b/res/drawable/ic_important_outline.xml
new file mode 100644
index 0000000..7a628bb
--- /dev/null
+++ b/res/drawable/ic_important_outline.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M15,19L3,19l4.5,-7L3,5h12c0.65,0 1.26,0.31 1.63,0.84L21,12l-4.37,6.16c-0.37,0.52 -0.98,0.84 -1.63,0.84zM6.5,17L15,17l3.5,-5L15,7L6.5,7l3.5,5 -3.5,5z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_notification_alert.xml b/res/drawable/ic_notification_alert.xml
index 927f7cc..c8efc7f 100644
--- a/res/drawable/ic_notification_alert.xml
+++ b/res/drawable/ic_notification_alert.xml
@@ -14,28 +14,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item
- android:id="@+id/back">
- <shape android:shape="oval">
- <solid
- android:color="@color/notification_alert_color" />
- <size
- android:height="24dp"
- android:width="24dp"/>
- </shape>
- </item>
- <item
- android:id="@+id/fore"
- android:gravity="center">
- <vector
- android:width="13dp"
- android:height="13dp"
- android:viewportWidth="24"
- android:viewportHeight="24">
- <path
- android:fillColor="#FFFFFFFF"
- android:pathData="M8.98,16.65c-0.47,0 -0.91,-0.27 -1.12,-0.69l-1.93,-4.61L5.46,12.3c-0.21,0.43 -0.64,0.69 -1.12,0.69H2v-2h1.88l1,-2C5.1,8.56 5.52,8.3 6,8.3s0.9,0.26 1.12,0.69l1.73,4.14l2,-7c0.2,-0.46 0.65,-0.76 1.15,-0.76s0.95,0.3 1.15,0.76l0.04,0.12l1.96,6.88l1.7,-4.08c0.49,-0.98 1.84,-0.91 2.26,-0.06l1,2H22v2h-2.35c-0.47,0 -0.91,-0.27 -1.12,-0.7l-0.47,-0.95l-1.9,4.55c-0.25,0.5 -0.69,0.77 -1.18,0.75c-0.48,-0.01 -0.92,-0.31 -1.11,-0.76l-0.04,-0.12L12,9.37l-1.87,6.52c-0.19,0.45 -0.63,0.74 -1.11,0.76C9.01,16.65 9,16.65 8.98,16.65zM20.32,11.4L20.32,11.4C20.32,11.4 20.32,11.4 20.32,11.4z" />
- </vector>
- </item>
-</layer-list>
\ No newline at end of file
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M18 17v-6c0-3.07-1.63-5.64-4.5-6.32V4c0-0.83-0.67-1.5-1.5-1.5s-1.5 0.67 -1.5 1.5v0.68C7.64 5.36 6 7.92 6 11v6H4v2h16v-2h-2zm-2 0H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6zm-6 3h4c0 1.1-0.9 2-2 2s-2-0.9-2-2zm12-9h-2c0-2.74-1.23-5.19-3.16-6.84l1.41-1.41C20.54 4.77 22 7.71 22 11zM5.75 2.75l1.41 1.41C5.23 5.81 4 8.26 4 11H2c0-3.29 1.46-6.23 3.75-8.25z" />
+</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_notifications_alert.xml b/res/drawable/ic_notifications_alert.xml
index 5a25459..5df6b4f 100644
--- a/res/drawable/ic_notifications_alert.xml
+++ b/res/drawable/ic_notifications_alert.xml
@@ -14,10 +14,10 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24"
- android:viewportHeight="24">
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M18 17v-6c0-3.07-1.63-5.64-4.5-6.32V4c0-0.83-0.67-1.5-1.5-1.5s-1.5 0.67 -1.5 1.5v0.68C7.64 5.36 6 7.92 6 11v6H4v2h16v-2h-2zm-2 0H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6zm-6 3h4c0 1.1-0.9 2-2 2s-2-0.9-2-2zm12-9h-2c0-2.74-1.23-5.19-3.16-6.84l1.41-1.41C20.54 4.77 22 7.71 22 11zM5.75 2.75l1.41 1.41C5.23 5.81 4 8.26 4 11H2c0-3.29 1.46-6.23 3.75-8.25z" />
diff --git a/res/drawable/ic_promote_conversation.xml b/res/drawable/ic_promote_conversation.xml
new file mode 100644
index 0000000..39f7658
--- /dev/null
+++ b/res/drawable/ic_promote_conversation.xml
@@ -0,0 +1,25 @@
+<!--
+ Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M20,2H4c-1.1,0 -2,0.9 -2,2v18l4,-4h14c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2z"/>
+</vector>
diff --git a/res/layout/preference_static_text.xml b/res/layout/preference_static_text.xml
index b36fd58..41968a2 100644
--- a/res/layout/preference_static_text.xml
+++ b/res/layout/preference_static_text.xml
@@ -34,7 +34,7 @@
android:paddingTop="16dp"
android:paddingBottom="4dp">
<ImageView
- android:id="@+android:id/icon"
+ android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
@@ -45,11 +45,11 @@
android:paddingBottom="16dp"
android:paddingTop="16dp">
- <TextView android:id="@+android:id/title"
+ <TextView android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
- <TextView android:id="@+android:id/summary"
+ <TextView android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
@@ -57,9 +57,10 @@
android:textColor="?android:attr/textColorSecondary"/>
</RelativeLayout>
- <LinearLayout android:id="@+android:id/widget_frame"
+ <LinearLayout android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" />
+
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 18ad3b5..a3ad4207 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -470,7 +470,7 @@
<EditText android:id="@+id/proxy_pac"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/wifi_item_edit_content"
+ style="@style/wifi_item_content"
android:hint="@string/proxy_url_hint"
android:inputType="textNoSuggestions"
android:singleLine="true"/>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index bfffce0..c19b948 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -276,24 +276,14 @@
<item>Require all non-trusted certificate statuses</item>
</string-array>
- <!-- Wi-Fi AP band settings. Either Auto, 2.4GHz or 5GHz. -->
+ <!-- Wi-Fi AP band settings. Either 2.4GHz or 5GHz prefer. -->
<!-- Note that adding/removing/moving the items will need wifi settings code change. -->
- <string-array translatable="false" name="wifi_ap_band_config_full">
- <item>1</item>
- <item>2</item>
- </string-array>
-
- <string-array translatable="false" name="wifi_ap_band_summary_full">
- <item>@string/wifi_ap_choose_2G</item>
- <item>@string/wifi_ap_choose_5G</item>
- </string-array>
-
- <string-array translatable="false" name="wifi_ap_band_dual_mode">
+ <string-array translatable="false" name="wifi_ap_band">
<item>1</item>
<item>3</item>
</string-array>
- <string-array translatable="false" name="wifi_ap_band_dual_mode_summary">
+ <string-array translatable="false" name="wifi_ap_band_summary">
<item>@string/wifi_ap_choose_2G</item>
<item>@string/wifi_ap_prefer_5G</item>
</string-array>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e8cff1f..bf97f1d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2126,7 +2126,7 @@
<!-- Warning message displayed if user does not specify a user certification for
WPA3-Enterprise 192-bit. Only displayed if the user does not specify user certificate
for WPA3-Enterprise 192-bit [CHAR LIMIT=80]-->
- <string name="wifi_no_user_cert_warning">This option requires a user certificate.</string>
+ <string name="wifi_no_user_cert_warning">Certificate required.</string>
<!-- Substring of status line when Wi-Fi Protected Setup (WPS) is available and
string is listed first [CHAR LIMIT=20]-->
<string name="wifi_wps_available_first_item">WPS available</string>
@@ -2333,7 +2333,7 @@
<!-- Title for the toggle to turn off hotspot automatically [CHAR LIMIT=NONE]-->
<string name="wifi_hotspot_auto_off_title">Turn off hotspot automatically</string>
<!-- Summary for the toggle to turn off hotspot automatically [CHAR LIMIT=NONE]-->
- <string name="wifi_hotspot_auto_off_summary">Wi\u2011Fi hotspot will turn off if no devices are connected</string>
+ <string name="wifi_hotspot_auto_off_summary">When no devices are connected</string>
<!-- Summary text when turning hotspot on -->
<string name="wifi_tether_starting">Turning hotspot on\u2026</string>
@@ -2354,17 +2354,21 @@
<!-- Title for the panel of add Wi-Fi network from APP [CHAR LIMIT=50] -->
<string name="wifi_add_app_single_network_title">Save this network?</string>
<!-- Summary for the panel of add Wi-Fi network from APP [CHAR LIMIT=NONE] -->
- <string name="wifi_add_app_single_network_summary"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save a network to your phone</string>
+ <string name="wifi_add_app_single_network_summary" product="default"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save a network to your phone</string>
+ <!-- Summary for the panel of add Wi-Fi network from APP [CHAR LIMIT=NONE] -->
+ <string name="wifi_add_app_single_network_summary" product="tablet"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save a network to your tablet</string>
<!-- Summary for saving status when saving single network [CHAR LIMIT=30] -->
<string name="wifi_add_app_single_network_saving_summary">Saving\u2026</string>
<!-- Summary for saved status when saving single network [CHAR LIMIT=30] -->
<string name="wifi_add_app_single_network_saved_summary">Saved</string>
<!-- Summary for save failed status when saving single network [CHAR LIMIT=50] -->
- <string name="wifi_add_app_network_save_failed_summary">Couldn\u2019t save. Try again.</string>
+ <string name="wifi_add_app_network_save_failed_summary">Can\u2019t save. Try again.</string>
<!-- Title for the panel of add multiple Wi-Fi networks from APP [CHAR LIMIT=50] -->
<string name="wifi_add_app_networks_title">Save networks?</string>
<!-- Summary for the panel of add multiple Wi-Fi networks from APP [CHAR LIMIT=NONE] -->
- <string name="wifi_add_app_networks_summary"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save these networks to your phone</string>
+ <string name="wifi_add_app_networks_summary" product="default"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save these networks to your phone</string>
+ <!-- Summary for the panel of add multiple Wi-Fi networks from APP [CHAR LIMIT=NONE] -->
+ <string name="wifi_add_app_networks_summary" product="tablet"><xliff:g id="appName" example="ThirdPartyAppName">%1$s</xliff:g> wants to save these networks to your tablet</string>
<!-- Summary for the panel of add Wi-Fi networks from APP [CHAR LIMIT=NONE] -->
<string name="wifi_add_app_networks_saving_summary">Saving <xliff:g id="number" example="3">%d</xliff:g> networks\u2026</string>
<!-- Summary for saved status when saving multiple networks [CHAR LIMIT=NONE] -->
@@ -2529,6 +2533,8 @@
<!-- Message to display when carrier does not support wifi calling or doesn't want the user
to modify the settings [CHAR LIMIT=NONE] -->
<string name="wifi_calling_not_supported">Wi\u2011Fi calling is not supported for %1$s</string>
+ <!-- Hint for a Wi-Fi network is disconnected successfully [CHAR LIMIT=NONE] -->
+ <string name="wifi_disconnected_from">Disconnected from <xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g></string>
<!-- Carrier string to use in other messages -->
<string name="carrier">Carrier</string>
<!-- Sound and alerts settings -->
@@ -2856,7 +2862,7 @@
<!-- Wallpaper settings fragment title [CHAR LIMIT=30] -->
<string name="wallpaper_settings_fragment_title">Choose wallpaper from</string>
<!-- Styles and Wallpaper settings title [CHAR_LIMIT=46] -->
- <string name="style_suggestion_title">Customize your Pixel</string>
+ <string name="style_suggestion_title">Customize your phone</string>
<!-- Styles and Wallpapers summary [CHAR_LIMIT=70] -->
<string name="style_suggestion_summary">Try different styles, wallpapers, and more</string>
<!-- Display settings screen, trigger for screen saver options -->
@@ -4806,7 +4812,7 @@
<!-- Summary for the accessibility magnification setting indicating both "Magnify with button" and "Magnify with triple-tap" are enabled [CHAR LIMIT=50] -->
<string name="accessibility_screen_magnification_state_navbar_gesture">Magnify with shortcut & triple-tap</string>
<!-- Title for the footer text to explain what accessibility service does. [CHAR LIMIT=35] -->
- <string name="accessibility_footer_title">About <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
+ <string name="accessibility_introduction_title">About <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
<!-- Title for the footer text to explain what option accessibility service does. [CHAR LIMIT=35] -->
<string name="accessibility_screen_option">Options</string>
<!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->
@@ -5028,28 +5034,28 @@
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_extremely_short_delay">
- <item quantity="one">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
- <item quantity="other">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
+ <item quantity="one">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
+ <item quantity="other">Extremely short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_very_short_delay">
- <item quantity="one">Very short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
- <item quantity="other">Very short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
+ <item quantity="one">Very short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
+ <item quantity="other">Very short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_short_delay">
- <item quantity="one">Short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
- <item quantity="other">Short delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
+ <item quantity="one">Short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
+ <item quantity="other">Short delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_long_delay">
- <item quantity="one">Long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
- <item quantity="other">Long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
+ <item quantity="one">Long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
+ <item quantity="other">Long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals>
<!-- Subtitle for the accessibility preference to configure feature that performs click action soon after mouse/trackpad pointer stops moving, in case delay before click is extremely short. Placeholder will be set to the number of milliseconds to which the delay amounts. [CHAR LIMIT=NONE] -->
<plurals name="accessibilty_autoclick_preference_subtitle_very_long_delay">
- <item quantity="one">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
- <item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
+ <item quantity="one">Very long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> second)</item>
+ <item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$s</xliff:g> seconds)</item>
</plurals>
<!-- Summary for autoclick seekbar settings preference when user selected custom item. [CHAR LIMIT=35] -->
@@ -8051,6 +8057,8 @@
<string name="bubbles_feature_education">Some notifications and other content can appear as bubbles on the screen. To open a bubble, tap it. To dismiss it, drag it down the screen.</string>
<!-- Title for the toggle shown on the app-level bubbles page [CHAR LIMIT=60] -->
<string name="bubbles_app_toggle_title">Bubbles</string>
+ <!-- Summary for bubbles option on the conversation level screen -->
+ <string name="bubbles_conversation_toggle_summary">New messages will appear on screen</string>
<!-- Description for the toggle shown on the app-level bubbles page [CHAR LIMIT=NONE] -->
<string name="bubbles_app_toggle_summary">Allow <xliff:g id="app_name" example="YouTube">%1$s</xliff:g> to show some notifications as bubbles</string>
<!-- Title of the dialog shown when the user has disabled bubbles at the feature level but tries to enable it for an app. [CHAR LIMIT=NONE] -->
@@ -8205,6 +8213,27 @@
<!-- [CHAR LIMIT=100] Notification Importance template for the channel importance summary -->
<string name="notification_importance_divider" translatable="false"><xliff:g id="importance_title">%1$s</xliff:g>: <xliff:g id="importance_summary">%2$s</xliff:g></string>
+ <!-- [CHAR LIMIT=100] Header for a grouping on conversations-->
+ <string name="conversations_category_title">Conversations</string>
+
+ <!-- [CHAR LIMIT=100] Header for an individual conversation-->
+ <string name="conversation_category_title">Conversation</string>
+
+ <!-- [CHAR LIMIT=NONE] Conversation preference summary, the parent channel this conversation was spawned from (separator) the parent channel group (e.g. an account name)-->
+ <string name="notification_conversation_summary" translatable="false">"<xliff:g id="parent_category_name">%1$s</xliff:g> • <xliff:g id="parent_category_group_name">%2$s</xliff:g>"</string>
+
+ <!-- [CHAR LIMIT=100] Field on conversation settings page -->
+ <string name="demote_conversation_title">Not a conversation</string>
+
+ <!-- [CHAR LIMIT=NONE] Summary for demote_conversation_title on conversation settings page -->
+ <string name="demote_conversation_summary">Remove from the conversation section</string>
+
+ <!-- [CHAR LIMIT=100] Field on notification channel settings page -->
+ <string name="promote_conversation_title">This is a conversation</string>
+
+ <!-- [CHAR LIMIT=NONE] Summary for promote_conversation_title on notifications settings page -->
+ <string name="promote_conversation_summary">Add to the conversation section</string>
+
<!-- Importance title strings for the Importance page. Also the second part of the importance
summary on the channel page-->
@@ -8526,11 +8555,17 @@
<string name="notification_show_lights_title">Blink light</string>
<!-- [CHAR LIMIT=180] Notification settings: vibration -->
- <string name="notification_vibrate_title">Vibrate</string>
+ <string name="notification_vibrate_title">Vibration</string>
<!-- [CHAR LIMIT=180] Notification settings: sound -->
<string name="notification_channel_sound_title">Sound</string>
+ <!-- [CHAR LIMIT=180] Notification conversation: important -->
+ <string name="notification_conversation_important">Important</string>
+
+ <!-- [CHAR LIMIT=180] Notification conversation: add to home screen -->
+ <string name="notification_conversation_add_to_home">Add to home</string>
+
<!-- [CHAR LIMIT=40] Zen mode settings: Rule delete button -->
<string name="zen_mode_rule_delete_button">Delete</string>
@@ -9103,6 +9138,8 @@
<string name="app_permissions">Permission manager</string>
<!-- Summary of permissions currently granted to apps [CHAR LIMIT=60] -->
<string name="app_permissions_summary">Apps using <xliff:g id="apps" example="location">%1$s</xliff:g></string>
+ <!-- Summary of permissions currently granted to apps [CHAR LIMIT=60] -->
+ <string name="app_permissions_summary_more">Apps using <xliff:g id="apps" example="location">%1$s</xliff:g>, and more</string>
<!-- Label for tap to wake setting [CHAR LIMIT=30] -->
<string name="tap_to_wake">Tap to wake</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 33a2022..a4c82b2 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -141,7 +141,7 @@
<item name="android:textSize">14sp</item>
</style>
- <style name="wifi_item_edit_content" parent="@android:style/TextAppearance.Widget.EditText">
+ <style name="wifi_item_edit_content">
<item name="android:paddingStart">4dip</item>
<item name="android:layout_marginStart">4dip</item>
<item name="android:textSize">18sp</item>
diff --git a/res/xml/accessibility_daltonizer_settings.xml b/res/xml/accessibility_daltonizer_settings.xml
index 0d9911c..b2ab5ef 100644
--- a/res/xml/accessibility_daltonizer_settings.xml
+++ b/res/xml/accessibility_daltonizer_settings.xml
@@ -53,7 +53,7 @@
</PreferenceCategory>
<PreferenceCategory
- android:key="daltonizer_footer_category" >
+ android:key="daltonizer_footer_category">
<com.android.settingslib.widget.FooterPreference
android:key="daltonizer_footer"
diff --git a/res/xml/accessibility_shortcut_settings.xml b/res/xml/accessibility_shortcut_settings.xml
index f431dec..0bfd6b6 100644
--- a/res/xml/accessibility_shortcut_settings.xml
+++ b/res/xml/accessibility_shortcut_settings.xml
@@ -14,21 +14,22 @@
limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/accessibility_global_gesture_preference_title" >
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:title="@string/accessibility_global_gesture_preference_title">
<Preference
- android:key="accessibility_shortcut_service"
- android:title="@string/accessibility_shortcut_service_title"
- android:fragment="com.android.settings.accessibility.ShortcutServicePickerFragment"/>
+ android:fragment="com.android.settings.accessibility.ShortcutServicePickerFragment"
+ android:key="accessibility_shortcut_service"
+ android:title="@string/accessibility_shortcut_service_title" />
<SwitchPreference
- android:key="accessibility_shortcut_on_lock_screen"
- android:title="@string/accessibility_shortcut_service_on_lock_screen_title"/>
+ android:key="accessibility_shortcut_on_lock_screen"
+ android:title="@string/accessibility_shortcut_service_on_lock_screen_title" />
<com.android.settingslib.widget.FooterPreference
android:key="accessibility_shortcut_footer"
- android:title="@string/accessibility_shortcut_description"
android:selectable="false"
- settings:searchable="false"/>
-</PreferenceScreen>
\ No newline at end of file
+ android:title="@string/accessibility_shortcut_description"
+ settings:searchable="false" />
+
+</PreferenceScreen>
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index d6122af..ceb08a2 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -29,6 +29,14 @@
<com.android.settings.notification.app.NotificationFooterPreference
android:key="block_desc" />
+ <!-- Conversations added here -->
+ <PreferenceCategory
+ android:title="@string/conversations_category_title"
+ android:key="conversations"
+ android:visibility="gone"
+ settings:allowDividerAbove="false"
+ settings:allowDividerBelow="false" />
+
<!-- Channels/Channel groups added here -->
<PreferenceCategory
android:key="channels"
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index 2ecbec4..1117921 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -58,6 +58,14 @@
android:title="@string/notification_importance_high_title"
android:summary="@string/notification_channel_summary_high"/>
+ <Preference
+ android:key="convo_promote"
+ android:order="7"
+ android:icon="@drawable/ic_promote_conversation"
+ android:title="@string/promote_conversation_title"
+ android:summary="@string/promote_conversation_summary"
+ settings:allowDividerAbove="true"/>
+
<PreferenceCategory
android:key="channel_advanced"
android:order="50"
diff --git a/res/xml/conversation_notification_settings.xml b/res/xml/conversation_notification_settings.xml
new file mode 100644
index 0000000..d0db428
--- /dev/null
+++ b/res/xml/conversation_notification_settings.xml
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:key="conversation_settings"
+ android:title="" >
+
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="pref_app_header"
+ android:layout="@layout/settings_entity_header"
+ settings:allowDividerBelow="true"/>
+
+ <!-- important conversation -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="important"
+ android:title="@string/notification_conversation_important"
+ android:icon="@drawable/ic_important_outline"
+ settings:restrictedSwitchSummary="@string/enabled_by_admin"
+ settings:allowDividerAbove="true"/>
+
+ <!-- silence -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="alerting"
+ android:icon="@drawable/ic_notification_alert"
+ android:title="@string/notification_alert_title"
+ android:summary="@string/notification_channel_summary_default"/>
+
+ <!-- bubbles -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="bubble_pref"
+ android:title="@string/notification_bubbles_title"
+ android:summary="@string/bubbles_conversation_toggle_summary"
+ android:icon="@drawable/ic_create_bubble"
+ settings:restrictedSwitchSummary="@string/enabled_by_admin" />
+
+ <!-- peeking -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="high_importance"
+ android:title="@string/notification_importance_high_title"
+ android:summary="@string/notification_channel_summary_high"/>
+
+ <!-- Visibility Override -->
+ <com.android.settings.RestrictedListPreference
+ android:key="visibility_override"
+ android:icon="@drawable/ic_lock"
+ android:title="@string/app_notification_visibility_override_title"/>
+
+ <!-- Show badge -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="badge"
+ android:title="@string/notification_channel_badge_title"
+ settings:useAdditionalSummary="true"
+ settings:restrictedSwitchSummary="@string/enabled_by_admin"/>
+
+ <!-- Lights -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="lights"
+ android:title="@string/notification_show_lights_title"
+ settings:useAdditionalSummary="true"/>
+
+ <!-- Vibration -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="vibrate"
+ android:icon="@drawable/ic_volume_ringer_vibrate"
+ android:title="@string/notification_vibrate_title"
+ settings:useAdditionalSummary="true" />
+
+ <!-- ringtone -->
+ <com.android.settings.notification.app.NotificationSoundPreference
+ android:key="ringtone"
+ android:title="@string/notification_channel_sound_title"
+ android:dialogTitle="@string/notification_channel_sound_title"
+ android:icon="@drawable/ic_media_stream"
+ android:showSilent="true"
+ android:showDefault="true"/>
+
+ <!-- demote -->
+ <Preference
+ android:key="demote"
+ android:icon="@drawable/ic_demote_conversation"
+ android:title="@string/demote_conversation_title"
+ android:summary="@string/demote_conversation_summary"
+ settings:allowDividerAbove="true"/>
+
+ <Preference
+ android:key="add_to_home"
+ android:title="@string/notification_conversation_add_to_home"
+ android:icon="@drawable/ic_add_to_home"
+ settings:allowDividerAbove="true"/>
+
+ <Preference
+ android:key="app_link"
+ android:title="@string/app_settings_link"
+ settings:allowDividerAbove="true"/>
+
+ <com.android.settings.notification.app.NotificationFooterPreference
+ android:key="desc" />
+
+ <com.android.settings.notification.app.NotificationFooterPreference
+ android:key="block_desc"
+ settings:allowDividerAbove="false"/>
+
+</PreferenceScreen>
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
index 55edf50..659eaca 100644
--- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
@@ -15,6 +15,9 @@
*/
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.accessibilityservice.AccessibilityServiceInfo;
import android.annotation.Nullable;
import android.app.settings.SettingsEnums;
@@ -28,15 +31,14 @@
import android.provider.Settings;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
-import android.widget.Switch;
import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import com.android.internal.accessibility.AccessibilityShortcutController;
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.SwitchBar;
import com.android.settingslib.accessibility.AccessibilityUtils;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
@@ -79,7 +81,7 @@
mOnLockScreenSwitchPreference.setOnPreferenceChangeListener((Preference p, Object o) -> {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
- ((Boolean) o) ? 1 : 0);
+ ((Boolean) o) ? ON : OFF);
return true;
});
}
@@ -87,7 +89,12 @@
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mShortcutPreference.setVisible(false);
+
+ final PreferenceScreen preferenceScreen = getPreferenceScreen();
+ preferenceScreen.findPreference(KEY_GENERAL_CATEGORY).setVisible(false);
+
+ preferenceScreen.setOrderingAsAdded(false);
+ mToggleServiceDividerSwitchPreference.setOrder(mServicePreference.getOrder() - 1);
}
@Override
@@ -111,34 +118,42 @@
}
@Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
- mSwitchBar.addOnSwitchChangeListener((Switch switchView, boolean enabled) -> {
+ protected void onRemoveSwitchPreferenceToggleSwitch() {
+ super.onRemoveSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(null);
+ }
+
+ @Override
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener((preference) -> {
+ boolean enabled = ((SwitchPreference) preference).isChecked();
Context context = getContext();
if (enabled && !shortcutFeatureAvailable(context)) {
- // If no service is configured, we'll disable the shortcut shortly. Give the
- // user a chance to select a service. We'll update the preferences when we resume.
- Settings.Secure.putInt(
- getContentResolver(), Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, 1);
+ // If no service is configured, we'll disable the shortcut shortly. Give the user
+ // a chance to select a service. We'll update the preferences when we resume.
+ Settings.Secure.putInt(getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, ON);
mServicePreference.setEnabled(true);
mServicePreference.performClick();
} else {
onPreferenceToggled(Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, enabled);
}
+ return true;
});
}
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
- Settings.Secure.putInt(getContentResolver(), preferenceKey, enabled ? 1 : 0);
+ Settings.Secure.putInt(getContentResolver(), preferenceKey, enabled ? ON : OFF);
updatePreferences();
}
@Override
- protected void updateSwitchBarText(SwitchBar switchBar) {
+ protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
getString(R.string.accessibility_global_gesture_preference_title));
- switchBar.setSwitchBarText(switchBarText, switchBarText);
+ switchPreference.setTitle(switchBarText);
}
private void updatePreferences() {
@@ -148,21 +163,21 @@
if (!shortcutFeatureAvailable(context)) {
// If no service is configured, make sure the overall shortcut is turned off
Settings.Secure.putInt(
- getContentResolver(), Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, 0);
+ getContentResolver(), Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, OFF);
}
boolean isEnabled = Settings.Secure
- .getInt(cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, 1) == 1;
- mSwitchBar.setChecked(isEnabled);
+ .getInt(cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, ON) == ON;
+ mToggleServiceDividerSwitchPreference.setChecked(isEnabled);
// The shortcut is enabled by default on the lock screen as long as the user has
// enabled the shortcut with the warning dialog
final int dialogShown = Settings.Secure.getInt(
- cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, 0);
+ cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, OFF);
final boolean enabledFromLockScreen = Settings.Secure.getInt(
- cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, dialogShown) == 1;
+ cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, dialogShown) == ON;
mOnLockScreenSwitchPreference.setChecked(enabledFromLockScreen);
// Only enable changing the service and lock screen behavior if the shortcut is on
- mServicePreference.setEnabled(mToggleSwitch.isChecked());
- mOnLockScreenSwitchPreference.setEnabled(mToggleSwitch.isChecked());
+ mServicePreference.setEnabled(mToggleServiceDividerSwitchPreference.isChecked());
+ mOnLockScreenSwitchPreference.setEnabled(mToggleServiceDividerSwitchPreference.isChecked());
}
/**
diff --git a/src/com/android/settings/accessibility/AnimatedImagePreference.java b/src/com/android/settings/accessibility/AnimatedImagePreference.java
index ea9e1f8..1609a3c 100644
--- a/src/com/android/settings/accessibility/AnimatedImagePreference.java
+++ b/src/com/android/settings/accessibility/AnimatedImagePreference.java
@@ -33,7 +33,6 @@
*/
public class AnimatedImagePreference extends Preference {
- private boolean mDividerAllowedAbove = false;
private Uri mImageUri;
AnimatedImagePreference(Context context) {
@@ -44,7 +43,6 @@
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- holder.setDividerAllowedAbove(mDividerAllowedAbove);
final ImageView imageView = holder.itemView.findViewById(R.id.animated_img);
if (imageView != null && mImageUri != null) {
@@ -60,18 +58,6 @@
}
/**
- * Sets divider whether to show in preference above.
- *
- * @param allowed true will be drawn on above this item
- */
- public void setDividerAllowedAbove(boolean allowed) {
- if (allowed != mDividerAllowedAbove) {
- mDividerAllowedAbove = allowed;
- notifyChanged();
- }
- }
-
- /**
* Set image uri to display image in {@link ImageView}
*
* @param imageUri the Uri of an image
diff --git a/src/com/android/settings/accessibility/DividerSwitchPreference.java b/src/com/android/settings/accessibility/DividerSwitchPreference.java
new file mode 100644
index 0000000..34b0429
--- /dev/null
+++ b/src/com/android/settings/accessibility/DividerSwitchPreference.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.Context;
+
+import androidx.preference.PreferenceViewHolder;
+import androidx.preference.SwitchPreference;
+
+/**
+ * A switch preference that has a divider below and above. Used for Accessibility Settings use
+ * service.
+ */
+public final class DividerSwitchPreference extends SwitchPreference {
+
+ private Boolean mDividerAllowedAbove;
+ private Boolean mDividerAllowBelow;
+
+ public DividerSwitchPreference(Context context) {
+ super(context);
+ mDividerAllowedAbove = true;
+ mDividerAllowBelow = true;
+ }
+
+ /**
+ * Sets divider whether to show in preference above.
+ *
+ * @param allowed true will be drawn on above this item
+ */
+ public void setDividerAllowedAbove(boolean allowed) {
+ if (mDividerAllowedAbove != allowed) {
+ mDividerAllowedAbove = allowed;
+ notifyChanged();
+ }
+ }
+
+ /**
+ * Sets divider whether to show in preference below.
+ *
+ * @param allowed true will be drawn on below this item
+ */
+ public void setDividerAllowedBelow(boolean allowed) {
+ if (mDividerAllowedAbove != allowed) {
+ mDividerAllowBelow = allowed;
+ notifyChanged();
+ }
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+ holder.setDividerAllowedAbove(mDividerAllowedAbove);
+ holder.setDividerAllowedBelow(mDividerAllowBelow);
+ }
+}
diff --git a/src/com/android/settings/accessibility/HtmlTextPreference.java b/src/com/android/settings/accessibility/HtmlTextPreference.java
index 0c295e3..fcf4725 100644
--- a/src/com/android/settings/accessibility/HtmlTextPreference.java
+++ b/src/com/android/settings/accessibility/HtmlTextPreference.java
@@ -32,7 +32,6 @@
*/
public final class HtmlTextPreference extends StaticTextPreference {
- private boolean mDividerAllowedAbove = false;
private int mFlag = Html.FROM_HTML_MODE_COMPACT;
private Html.ImageGetter mImageGetter;
private Html.TagHandler mTagHandler;
@@ -45,7 +44,6 @@
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- holder.setDividerAllowedAbove(mDividerAllowedAbove);
final TextView summaryView = holder.itemView.findViewById(android.R.id.summary);
if (summaryView != null && !TextUtils.isEmpty(getSummary())) {
@@ -55,18 +53,6 @@
}
/**
- * Sets divider whether to show in preference above.
- *
- * @param allowed true will be drawn on above this item
- */
- public void setDividerAllowedAbove(boolean allowed) {
- if (allowed != mDividerAllowedAbove) {
- mDividerAllowedAbove = allowed;
- notifyChanged();
- }
- }
-
- /**
* Sets the flag to which text format to be applied.
*
* @param flag to indicate that html text format
diff --git a/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java
index a48b71f..93064c5 100644
--- a/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/InvisibleToggleAccessibilityServicePreferenceFragment.java
@@ -17,29 +17,27 @@
package com.android.settings.accessibility;
import android.accessibilityservice.AccessibilityServiceInfo;
-import android.os.Bundle;
import android.view.View;
import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.widget.SwitchBar;
import com.android.settingslib.accessibility.AccessibilityUtils;
/**
- * For accessibility services that target SDK > Q, and
- * {@link AccessibilityServiceInfo#FLAG_REQUEST_ACCESSIBILITY_BUTTON}
- * is set.
+ * Fragment that does not have toggle bar to turn on service to use.
+ *
+ * <p>The child {@link ToggleAccessibilityServicePreferenceFragment} shows the actual UI for
+ * providing basic accessibility service setup.
+ *
+ * <p>For accessibility services that target SDK > Q, and
+ * {@link AccessibilityServiceInfo#FLAG_REQUEST_ACCESSIBILITY_BUTTON} is set.
*/
public class InvisibleToggleAccessibilityServicePreferenceFragment extends
ToggleAccessibilityServicePreferenceFragment implements ShortcutPreference.OnClickListener{
@Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- final SettingsActivity activity = (SettingsActivity) getActivity();
- final SwitchBar mSwitchBar = activity.getSwitchBar();
- mSwitchBar.hide();
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setVisible(false);
}
/**
diff --git a/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
index 0a65709..2739b6b 100644
--- a/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/LegacyAccessibilityServicePreferenceFragment.java
@@ -25,7 +25,14 @@
import com.google.common.collect.ImmutableSet;
-/** For accessibility services that target SDK <= Q. */
+/**
+ * Fragment that only allowed hardware {@link UserShortcutType} for shortcut to open.
+ *
+ * <p>The child {@link ToggleAccessibilityServicePreferenceFragment} shows the actual UI for
+ * providing basic accessibility service setup.
+ *
+ * <p>For accessibility services that target SDK <= Q.
+ */
public class LegacyAccessibilityServicePreferenceFragment extends
ToggleAccessibilityServicePreferenceFragment {
@@ -38,7 +45,6 @@
mShortcutPreference.setSummary(hardwareTitle);
mShortcutPreference.setSettingsVisibility(View.GONE);
- // Only allowed hardware PreferredShortcutType in this fragment.
setAllowedPreferredShortcutType(UserShortcutType.HARDWARE);
}
diff --git a/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
index c9257a9..82d80e0 100644
--- a/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
@@ -28,7 +28,7 @@
@Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
- mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ mToggleSwitchWasInitiallyChecked = mToggleServiceDividerSwitchPreference.isChecked();
}
@Override
@@ -39,10 +39,10 @@
@Override
public void onStop() {
// Log the final choice in value if it's different from the previous value.
- if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() != mToggleSwitchWasInitiallyChecked) {
mMetricsFeatureProvider.action(getContext(),
SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER,
- mToggleSwitch.isChecked());
+ mToggleServiceDividerSwitchPreference.isChecked());
}
super.onStop();
diff --git a/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
index 2c8485b..9953faf 100644
--- a/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -28,7 +28,7 @@
@Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
- mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ mToggleSwitchWasInitiallyChecked = mToggleServiceDividerSwitchPreference.isChecked();
}
@Override
@@ -39,10 +39,10 @@
@Override
public void onStop() {
// Log the final choice in value if it's different from the previous value.
- if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() != mToggleSwitchWasInitiallyChecked) {
mMetricsFeatureProvider.action(getContext(),
SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK,
- mToggleSwitch.isChecked());
+ mToggleServiceDividerSwitchPreference.isChecked());
}
super.onStop();
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 6d64a23..a75c536 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -39,12 +39,13 @@
import android.view.View;
import android.view.accessibility.AccessibilityManager;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.password.ConfirmDeviceCredentialActivity;
-import com.android.settings.widget.SwitchBar;
-import com.android.settings.widget.ToggleSwitch;
import com.android.settingslib.accessibility.AccessibilityUtils;
import java.util.List;
@@ -186,21 +187,21 @@
}
@Override
- protected void updateSwitchBarText(SwitchBar switchBar) {
+ protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
final String switchBarText = (info == null) ? "" :
getString(R.string.accessibility_service_master_switch_title,
info.getResolveInfo().loadLabel(getPackageManager()));
- switchBar.setSwitchBarText(switchBarText, switchBarText);
+ switchPreference.setTitle(switchBarText);
}
private void updateSwitchBarToggleSwitch() {
final boolean checked = AccessibilityUtils.getEnabledServicesFromSettings(getPrefContext())
.contains(mComponentName);
- if (mSwitchBar.isChecked() == checked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
return;
}
- mSwitchBar.setCheckedInternal(checked);
+ mToggleServiceDividerSwitchPreference.setChecked(checked);
}
/**
@@ -251,7 +252,7 @@
}
private void handleConfirmServiceEnabled(boolean confirmed) {
- mSwitchBar.setCheckedInternal(confirmed);
+ mToggleServiceDividerSwitchPreference.setChecked(confirmed);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, confirmed);
onPreferenceToggled(mPreferenceKey, confirmed);
}
@@ -274,9 +275,9 @@
}
@Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener(this::onBeforeCheckedChanged);
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(this::onPreferenceClick);
}
@Override
@@ -410,9 +411,10 @@
mDialog.dismiss();
}
- private boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
+ private boolean onPreferenceClick(Preference preference) {
+ boolean checked = ((DividerSwitchPreference) preference).isChecked();
if (checked) {
- mSwitchBar.setCheckedInternal(false);
+ mToggleServiceDividerSwitchPreference.setChecked(false);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED,
/* disableService */ false);
if (!mShortcutPreference.getChecked()) {
@@ -424,7 +426,7 @@
}
}
} else {
- mSwitchBar.setCheckedInternal(true);
+ mToggleServiceDividerSwitchPreference.setChecked(true);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED,
/* enableService */ true);
showDialog(DialogEnums.DISABLE_WARNING_FROM_TOGGLE);
diff --git a/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java b/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java
index 9079c31..301d8dc 100644
--- a/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java
+++ b/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java
@@ -19,10 +19,8 @@
import static android.content.Context.MODE_PRIVATE;
import static com.android.settings.accessibility.ToggleAutoclickPreferenceController.KEY_DELAY_MODE;
+import static com.android.settings.accessibility.ToggleAutoclickPreferenceFragment.Quantity;
-import static java.lang.annotation.RetentionPolicy.SOURCE;
-
-import android.annotation.IntDef;
import android.content.ContentResolver;
import android.content.Context;
import android.content.SharedPreferences;
@@ -42,8 +40,6 @@
import com.android.settingslib.core.lifecycle.events.OnResume;
import com.android.settingslib.widget.LayoutPreference;
-import java.lang.annotation.Retention;
-
/**
* Controller class that controls accessibility autoclick seekbar settings.
*/
@@ -51,16 +47,6 @@
implements LifecycleObserver, OnResume, OnPause,
SharedPreferences.OnSharedPreferenceChangeListener {
- @Retention(SOURCE)
- @IntDef({
- Quantity.OTHER,
- Quantity.ONE
- })
- @interface Quantity {
- int OTHER = 0;
- int ONE = 1;
- }
-
private static final String CONTROL_AUTOCLICK_DELAY_SECURE =
Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY;
private static final String KEY_CUSTOM_DELAY_VALUE = "custom_delay_value";
diff --git a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
index 4a88956..5e09b2a 100644
--- a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
@@ -19,6 +19,9 @@
import static com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController.MAX_AUTOCLICK_DELAY_MS;
import static com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController.MIN_AUTOCLICK_DELAY_MS;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import android.annotation.IntDef;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.res.Resources;
@@ -32,6 +35,7 @@
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;
+import java.lang.annotation.Retention;
import java.util.ArrayList;
import java.util.List;
@@ -46,6 +50,16 @@
private static final String TAG = "AutoclickPrefFragment";
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
+ @Retention(SOURCE)
+ @IntDef({
+ Quantity.OTHER,
+ Quantity.ONE
+ })
+ @interface Quantity {
+ int OTHER = 0;
+ int ONE = 1;
+ }
+
/**
* Resource ids from which autoclick preference summaries should be derived. The strings have
* placeholder for integer delay value.
@@ -63,12 +77,17 @@
* delay.
*
* @param resources Resources from which string should be retrieved.
- * @param delay Delay for whose value summary should be retrieved.
+ * @param delayMillis Delay for whose value summary should be retrieved.
*/
- static CharSequence getAutoclickPreferenceSummary(Resources resources, int delay) {
- int summaryIndex = getAutoclickPreferenceSummaryIndex(delay);
- return resources.getQuantityString(
- mAutoclickPreferenceSummaries[summaryIndex], delay, delay);
+ static CharSequence getAutoclickPreferenceSummary(Resources resources, int delayMillis) {
+ final int summaryIndex = getAutoclickPreferenceSummaryIndex(delayMillis);
+ final int quantity = (delayMillis == 1000) ? Quantity.ONE : Quantity.OTHER;
+ final float delaySecond = (float) delayMillis / 1000;
+ // Only show integer when delay time is 1.
+ final String decimalFormat = (delaySecond == 1) ? "%.0f" : "%.1f";
+
+ return resources.getQuantityString(mAutoclickPreferenceSummaries[summaryIndex],
+ quantity, String.format(decimalFormat, delaySecond));
}
/**
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index d25be83..ffde1e3 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -31,10 +31,10 @@
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.SwitchBar;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
@@ -66,22 +66,22 @@
}
@Override
- protected void onRemoveSwitchBarToggleSwitch() {
- super.onRemoveSwitchBarToggleSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener(null);
+ protected void onRemoveSwitchPreferenceToggleSwitch() {
+ super.onRemoveSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(null);
}
@Override
- protected void updateSwitchBarText(SwitchBar switchBar) {
- switchBar.setSwitchBarText(R.string.accessibility_display_inversion_switch_title,
- R.string.accessibility_display_inversion_switch_title);
+ protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
+ switchPreference.setTitle(R.string.accessibility_display_inversion_switch_title);
}
@Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
updateSwitchBarToggleSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener((toggleSwitch, checked) -> {
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener((preference) -> {
+ boolean checked = ((SwitchPreference) preference).isChecked();
onPreferenceToggled(mPreferenceKey, checked);
return false;
});
@@ -135,10 +135,10 @@
private void updateSwitchBarToggleSwitch() {
final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
- if (mSwitchBar.isChecked() == checked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
return;
}
- mSwitchBar.setCheckedInternal(checked);
+ mToggleServiceDividerSwitchPreference.setChecked(checked);
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index 9a6aefd..f2b84e5 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -34,10 +34,10 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.SwitchBar;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;
@@ -51,6 +51,7 @@
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
private static final String CATEGORY_FOOTER_KEY = "daltonizer_footer_category";
+ private static final String CATEGORY_MODE_KEY = "daltonizer_mode_category";
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
private final Handler mHandler = new Handler();
private SettingsContentObserver mSettingsContentObserver;
@@ -98,6 +99,11 @@
super.onViewCreated(view, savedInstanceState);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.setOrderingAsAdded(false);
+
+ final PreferenceCategory modeCategory = preferenceScreen.findPreference(
+ CATEGORY_MODE_KEY);
+ modeCategory.setOrder(Integer.MAX_VALUE - 1);
+
final PreferenceCategory footerCategory = preferenceScreen.findPreference(
CATEGORY_FOOTER_KEY);
footerCategory.setOrder(Integer.MAX_VALUE);
@@ -148,22 +154,22 @@
}
@Override
- protected void onRemoveSwitchBarToggleSwitch() {
- super.onRemoveSwitchBarToggleSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener(null);
+ protected void onRemoveSwitchPreferenceToggleSwitch() {
+ super.onRemoveSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(null);
}
@Override
- protected void updateSwitchBarText(SwitchBar switchBar) {
- switchBar.setSwitchBarText(R.string.accessibility_daltonizer_master_switch_title,
- R.string.accessibility_daltonizer_master_switch_title);
+ protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
+ switchPreference.setTitle(R.string.accessibility_daltonizer_master_switch_title);
}
@Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
updateSwitchBarToggleSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener((toggleSwitch, checked) -> {
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener((preference) -> {
+ boolean checked = ((SwitchPreference) preference).isChecked();
onPreferenceToggled(mPreferenceKey, checked);
return false;
});
@@ -177,10 +183,10 @@
private void updateSwitchBarToggleSwitch() {
final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
- if (mSwitchBar.isChecked() == checked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
return;
}
- mSwitchBar.setCheckedInternal(checked);
+ mToggleServiceDividerSwitchPreference.setChecked(checked);
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 8764b12..5571591 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -40,13 +40,14 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.widget.SwitchBar;
-import com.android.settings.widget.ToggleSwitch;
+import com.android.settingslib.widget.FooterPreference;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -64,8 +65,7 @@
public abstract class ToggleFeaturePreferenceFragment extends SettingsPreferenceFragment
implements ShortcutPreference.OnClickListener {
- protected SwitchBar mSwitchBar;
- protected ToggleSwitch mToggleSwitch;
+ protected DividerSwitchPreference mToggleServiceDividerSwitchPreference;
protected ShortcutPreference mShortcutPreference;
protected Preference mSettingsPreference;
protected String mPreferenceKey;
@@ -76,11 +76,10 @@
protected ComponentName mComponentName;
protected CharSequence mPackageName;
protected Uri mImageUri;
- protected CharSequence mStaticDescription;
protected CharSequence mHtmlDescription;
private static final String ANCHOR_TAG = "a";
private static final String DRAWABLE_FOLDER = "drawable";
-
+ protected static final String KEY_GENERAL_CATEGORY = "categories";
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
@@ -133,28 +132,32 @@
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- SettingsActivity activity = (SettingsActivity) getActivity();
- mSwitchBar = activity.getSwitchBar();
- mToggleSwitch = mSwitchBar.getSwitch();
-
- onProcessArguments(getArguments());
- updateSwitchBarText(mSwitchBar);
+ final SettingsActivity activity = (SettingsActivity) getActivity();
+ final SwitchBar switchBar = activity.getSwitchBar();
+ switchBar.hide();
PreferenceScreen preferenceScreen = getPreferenceScreen();
if (mImageUri != null) {
final AnimatedImagePreference animatedImagePreference = new AnimatedImagePreference(
getPrefContext());
animatedImagePreference.setImageUri(mImageUri);
- animatedImagePreference.setDividerAllowedAbove(true);
+ animatedImagePreference.setSelectable(false);
preferenceScreen.addPreference(animatedImagePreference);
}
- final PreferenceCategory category = new PreferenceCategory(getPrefContext());
- category.setTitle(R.string.accessibility_screen_option);
- preferenceScreen.addPreference(category);
+ mToggleServiceDividerSwitchPreference = new DividerSwitchPreference(getPrefContext());
+ preferenceScreen.addPreference(mToggleServiceDividerSwitchPreference);
+
+ onProcessArguments(getArguments());
+ updateToggleServiceTitle(mToggleServiceDividerSwitchPreference);
+
+ final PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
+ groupCategory.setKey(KEY_GENERAL_CATEGORY);
+ groupCategory.setTitle(R.string.accessibility_screen_option);
+ preferenceScreen.addPreference(groupCategory);
initShortcutPreference(savedInstanceState);
- category.addPreference(mShortcutPreference);
+ groupCategory.addPreference(mShortcutPreference);
// Show the "Settings" menu as if it were a preference screen.
if (mSettingsTitle != null && mSettingsIntent != null) {
@@ -166,37 +169,27 @@
// The downloaded app may not show Settings. The framework app has Settings.
if (mSettingsPreference != null) {
- category.addPreference(mSettingsPreference);
+ groupCategory.addPreference(mSettingsPreference);
}
- if (mStaticDescription != null || mHtmlDescription != null) {
- final PreferenceCategory footerCategory = new PreferenceCategory(getPrefContext());
- final CharSequence title = getString(R.string.accessibility_footer_title, mPackageName);
- footerCategory.setTitle(title);
- preferenceScreen.addPreference(footerCategory);
+ if (mHtmlDescription != null) {
+ final PreferenceCategory introductionCategory = new PreferenceCategory(
+ getPrefContext());
+ final CharSequence title = getString(R.string.accessibility_introduction_title,
+ mPackageName);
+ introductionCategory.setTitle(title);
+ preferenceScreen.addPreference(introductionCategory);
- if (mStaticDescription != null) {
- final StaticTextPreference staticTextPreference = new StaticTextPreference(
- getPrefContext());
- staticTextPreference.setSummary(mStaticDescription);
- staticTextPreference.setSelectable(/* selectable= */ false);
- footerCategory.addPreference(staticTextPreference);
- }
+ // For accessibility service, avoid malicious links made by third party developer.
+ final List<String> unsupportedTagList = new ArrayList<>();
+ unsupportedTagList.add(ANCHOR_TAG);
- if (mHtmlDescription != null) {
- // For accessibility service, avoid malicious links made by third party developer.
- final List<String> unsupportedTagList = new ArrayList<>();
- unsupportedTagList.add(ANCHOR_TAG);
-
- final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(
- getPrefContext());
- htmlTextPreference.setSummary(mHtmlDescription);
- htmlTextPreference.setImageGetter(mImageGetter);
- htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
- htmlTextPreference.setDividerAllowedAbove(true);
- htmlTextPreference.setSelectable(/* selectable= */ false);
- footerCategory.addPreference(htmlTextPreference);
- }
+ final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(getPrefContext());
+ htmlTextPreference.setSummary(mHtmlDescription);
+ htmlTextPreference.setImageGetter(mImageGetter);
+ htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
+ htmlTextPreference.setSelectable(false);
+ introductionCategory.addPreference(htmlTextPreference);
}
}
@@ -311,31 +304,27 @@
removeActionBarToggleSwitch();
}
- protected void updateSwitchBarText(SwitchBar switchBar) {
- // Implement this to provide meaningful text in switch bar.
- switchBar.setSwitchBarText(R.string.accessibility_service_master_switch_title,
- R.string.accessibility_service_master_switch_title);
+ protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
+ switchPreference.setTitle(R.string.accessibility_service_master_switch_title);
}
protected abstract void onPreferenceToggled(String preferenceKey, boolean enabled);
- protected void onInstallSwitchBarToggleSwitch() {
+ protected void onInstallSwitchPreferenceToggleSwitch() {
// Implement this to set a checked listener.
}
- protected void onRemoveSwitchBarToggleSwitch() {
+ protected void onRemoveSwitchPreferenceToggleSwitch() {
// Implement this to reset a checked listener.
}
private void installActionBarToggleSwitch() {
- mSwitchBar.show();
- onInstallSwitchBarToggleSwitch();
+ onInstallSwitchPreferenceToggleSwitch();
}
private void removeActionBarToggleSwitch() {
- mToggleSwitch.setOnBeforeCheckedChangeListener(null);
- onRemoveSwitchBarToggleSwitch();
- mSwitchBar.hide();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(null);
+ onRemoveSwitchPreferenceToggleSwitch();
}
public void setTitle(String title) {
@@ -349,7 +338,7 @@
// Enabled.
if (arguments.containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
final boolean enabled = arguments.getBoolean(AccessibilitySettings.EXTRA_CHECKED);
- mSwitchBar.setCheckedInternal(enabled);
+ mToggleServiceDividerSwitchPreference.setChecked(enabled);
}
// Title.
@@ -363,11 +352,11 @@
// Summary.
if (arguments.containsKey(AccessibilitySettings.EXTRA_SUMMARY_RES)) {
final int summary = arguments.getInt(AccessibilitySettings.EXTRA_SUMMARY_RES);
- mStaticDescription = getText(summary);
+ createFooterPreference(getText(summary));
} else if (arguments.containsKey(AccessibilitySettings.EXTRA_SUMMARY)) {
final CharSequence summary = arguments.getCharSequence(
AccessibilitySettings.EXTRA_SUMMARY);
- mStaticDescription = summary;
+ createFooterPreference(summary);
}
}
@@ -493,8 +482,9 @@
if (info.isEmpty()) {
info = new HashSet<>();
} else {
- final Set<String> filtered = info.stream().filter(
- str -> str.contains(componentName)).collect(Collectors.toSet());
+ final Set<String> filtered = info.stream()
+ .filter(str -> str.contains(componentName))
+ .collect(Collectors.toSet());
info.removeAll(filtered);
}
final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(
@@ -538,9 +528,9 @@
final Set<String> info = SharedPreferenceUtils.getUserShortcutType(context);
final String componentName = mComponentName.flattenToString();
- final Set<String> filtered = info.stream().filter(
- str -> str.contains(componentName)).collect(
- Collectors.toSet());
+ final Set<String> filtered = info.stream()
+ .filter(str -> str.contains(componentName))
+ .collect(Collectors.toSet());
if (filtered.isEmpty()) {
return defaultValue;
}
@@ -635,4 +625,10 @@
public void onSettingsClicked(ShortcutPreference preference) {
mUserShortcutTypeCache = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
}
+
+ private void createFooterPreference(CharSequence title) {
+ final PreferenceScreen preferenceScreen = getPreferenceScreen();
+ preferenceScreen.addPreference(new FooterPreference.Builder(getActivity()).setTitle(
+ title).build());
+ }
}
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 5182593..7ca2abf 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -60,10 +60,13 @@
import java.util.StringJoiner;
import java.util.stream.Collectors;
+/**
+ * Fragment that shows the actual UI for providing basic magnification accessibility service setup
+ * and does not have toggle bar to turn on service to use.
+ */
public class ToggleScreenMagnificationPreferenceFragment extends
ToggleFeaturePreferenceFragment {
- private static final String SETTINGS_KEY = "screen_magnification_settings";
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
@@ -429,11 +432,9 @@
}
@Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
-
- // Magnify is temporary-use app which uses shortcut to magnify screen, not by toggle.
- mSwitchBar.hide();
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setVisible(false);
}
@Override
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
index 5fe62a7..3b786ff 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
@@ -32,11 +32,12 @@
// Log the final choice in value if it's different from the previous value.
Bundle args = getArguments();
if ((args != null) && args.containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
- if (mToggleSwitch.isChecked() != args.getBoolean(AccessibilitySettings.EXTRA_CHECKED)) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() != args.getBoolean(
+ AccessibilitySettings.EXTRA_CHECKED)) {
// TODO: Distinguish between magnification modes
mMetricsFeatureProvider.action(getContext(),
SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION,
- mToggleSwitch.isChecked());
+ mToggleServiceDividerSwitchPreference.isChecked());
}
}
super.onStop();
diff --git a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
index 29c031d..0f114fd 100644
--- a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
@@ -27,7 +27,7 @@
@Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
- mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ mToggleSwitchWasInitiallyChecked = mToggleServiceDividerSwitchPreference.isChecked();
}
@Override
@@ -38,11 +38,11 @@
@Override
public void onStop() {
// Log the final choice in value if it's different from the previous value.
- if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() != mToggleSwitchWasInitiallyChecked) {
mMetricsFeatureProvider.action(getContext(),
- SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER, mToggleSwitch.isChecked());
+ SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER,
+ mToggleServiceDividerSwitchPreference.isChecked());
}
-
super.onStop();
}
}
diff --git a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
index da94abc..09598f6 100644
--- a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -27,7 +27,7 @@
@Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
- mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
+ mToggleSwitchWasInitiallyChecked = mToggleServiceDividerSwitchPreference.isChecked();
}
@Override
@@ -38,10 +38,10 @@
@Override
public void onStop() {
// Log the final choice in value if it's different from the previous value.
- if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ if (mToggleServiceDividerSwitchPreference.isChecked() != mToggleSwitchWasInitiallyChecked) {
mMetricsFeatureProvider.action(getContext(),
SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK,
- mToggleSwitch.isChecked());
+ mToggleServiceDividerSwitchPreference.isChecked());
}
super.onStop();
diff --git a/src/com/android/settings/applications/AppPermissionsPreferenceController.java b/src/com/android/settings/applications/AppPermissionsPreferenceController.java
index 0a3bba7..4458ea4 100644
--- a/src/com/android/settings/applications/AppPermissionsPreferenceController.java
+++ b/src/com/android/settings/applications/AppPermissionsPreferenceController.java
@@ -33,7 +33,7 @@
public class AppPermissionsPreferenceController extends BasePreferenceController {
private static final String TAG = "AppPermissionPrefCtrl";
- private static int NUM_PACKAGE_TO_CHECK = 3;
+ private static final int NUM_PACKAGE_TO_CHECK = 4;
@VisibleForTesting
static int NUM_PERMISSIONS_TO_SHOW = 3;
@@ -78,7 +78,7 @@
void queryPermissionSummary() {
final List<PackageInfo> installedPackages =
mPackageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);
- // Here we only get the first three apps and check their permissions.
+ // Here we only get the first four apps and check their permissions.
final List<PackageInfo> packagesWithPermission = installedPackages.stream()
.filter(pInfo -> pInfo.permissions != null)
.limit(NUM_PACKAGE_TO_CHECK)
@@ -102,10 +102,21 @@
final List<CharSequence> permissionsToShow = mPermissionGroups.stream()
.limit(NUM_PERMISSIONS_TO_SHOW)
.collect(Collectors.toList());
- final CharSequence summary = !permissionsToShow.isEmpty()
- ? mContext.getString(R.string.app_permissions_summary,
- ListFormatter.getInstance().format(permissionsToShow).toLowerCase())
- : mContext.getString(R.string.runtime_permissions_summary_no_permissions_granted);
+ final boolean isMoreShowed = mPermissionGroups.size() > NUM_PERMISSIONS_TO_SHOW;
+ CharSequence summary;
+
+ if (!permissionsToShow.isEmpty()) {
+ if (isMoreShowed) {
+ summary = mContext.getString(R.string.app_permissions_summary_more,
+ ListFormatter.getInstance().format(permissionsToShow).toLowerCase());
+ } else {
+ summary = mContext.getString(R.string.app_permissions_summary,
+ ListFormatter.getInstance().format(permissionsToShow).toLowerCase());
+ }
+ } else {
+ summary = mContext.getString(
+ R.string.runtime_permissions_summary_no_permissions_granted);
+ }
mPreference.setSummary(summary);
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
index 6893c25..9a327ed 100644
--- a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.util.Log;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.connecteddevice.DevicePreferenceCallback;
@@ -38,24 +39,25 @@
private static final String PREF_KEY = "saved_bt";
+ @VisibleForTesting
+ BluetoothAdapter mBluetoothAdapter;
+
public SavedBluetoothDeviceUpdater(Context context, DashboardFragment fragment,
DevicePreferenceCallback devicePreferenceCallback) {
super(context, fragment, devicePreferenceCallback);
+
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
}
@Override
public void forceUpdate() {
- if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
+ if (mBluetoothAdapter.isEnabled()) {
final CachedBluetoothDeviceManager cachedManager =
mLocalManager.getCachedDeviceManager();
- for (BluetoothDevice device
- : BluetoothAdapter.getDefaultAdapter().getMostRecentlyConnectedDevices()) {
+ for (BluetoothDevice device : mBluetoothAdapter.getMostRecentlyConnectedDevices()) {
final CachedBluetoothDevice cachedDevice = cachedManager.findDevice(device);
- if (isFilterMatched(cachedDevice)) {
- // Add the preference if it is new one
- addPreference(cachedDevice, BluetoothDevicePreference.SortType.TYPE_NO_SORT);
- } else {
- removePreference(cachedDevice);
+ if (cachedDevice != null) {
+ update(cachedDevice);
}
}
} else {
@@ -64,6 +66,16 @@
}
@Override
+ public void update(CachedBluetoothDevice cachedDevice) {
+ if (isFilterMatched(cachedDevice)) {
+ // Add the preference if it is new one
+ addPreference(cachedDevice, BluetoothDevicePreference.SortType.TYPE_NO_SORT);
+ } else {
+ removePreference(cachedDevice);
+ }
+ }
+
+ @Override
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
final BluetoothDevice device = cachedDevice.getDevice();
if (DBG) {
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index 8e6158b..08d6ca4 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -737,7 +737,7 @@
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setMessage(getContext().getString(R.string.storage_detail_dialog_system,
- Build.VERSION.RELEASE))
+ Build.VERSION.RELEASE_OR_CODENAME))
.setPositiveButton(android.R.string.ok, null)
.create();
}
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
index 3f93303..d6cf442 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceController.java
@@ -75,7 +75,7 @@
@Override
public CharSequence getSummary() {
- return Build.VERSION.RELEASE;
+ return Build.VERSION.RELEASE_OR_CODENAME;
}
@Override
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
index a63c206..eefa1f9 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
@@ -34,6 +34,6 @@
@Override
public CharSequence getSummary() {
- return Build.VERSION.RELEASE;
+ return Build.VERSION.RELEASE_OR_CODENAME;
}
}
diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java
index 36dba22..8e6da80 100644
--- a/src/com/android/settings/media/MediaOutputSlice.java
+++ b/src/com/android/settings/media/MediaOutputSlice.java
@@ -89,20 +89,28 @@
final MediaDevice topDevice = isTouched ? worker.getTopDevice() : connectedDevice;
if (topDevice != null) {
- listBuilder.addInputRange(getActiveDeviceHeaderRow(topDevice));
+ addRow(topDevice, connectedDevice, listBuilder);
worker.setTopDevice(topDevice);
}
for (MediaDevice device : devices) {
if (topDevice == null
|| !TextUtils.equals(topDevice.getId(), device.getId())) {
- listBuilder.addRow(getMediaDeviceRow(device));
+ addRow(device, connectedDevice, listBuilder);
}
}
return listBuilder.build();
}
+ private void addRow(MediaDevice device, MediaDevice connectedDevice, ListBuilder listBuilder) {
+ if (TextUtils.equals(device.getId(), connectedDevice.getId())) {
+ listBuilder.addInputRange(getActiveDeviceHeaderRow(device));
+ } else {
+ listBuilder.addRow(getMediaDeviceRow(device));
+ }
+ }
+
private ListBuilder.InputRangeBuilder getActiveDeviceHeaderRow(MediaDevice device) {
final String title = device.getName();
final IconCompat icon = getDeviceIconCompat(device);
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index f749764..c8fb7e3 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -17,6 +17,8 @@
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
+import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC;
+import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED;
import android.app.INotificationManager;
import android.app.NotificationChannel;
@@ -29,13 +31,17 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
+import android.content.pm.LauncherApps;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
+import android.content.pm.ShortcutInfo;
+import android.content.pm.ShortcutManager;
import android.graphics.drawable.Drawable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
+import android.service.notification.ConversationChannelWrapper;
import android.service.notification.NotifyingApp;
import android.text.format.DateUtils;
import android.util.IconDrawableFactory;
@@ -48,6 +54,7 @@
import com.android.settingslib.utils.StringUtil;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -154,7 +161,7 @@
try {
if (onlyHasDefaultChannel(pkg, uid)) {
NotificationChannel defaultChannel =
- getChannel(pkg, uid, NotificationChannel.DEFAULT_CHANNEL_ID);
+ getChannel(pkg, uid, NotificationChannel.DEFAULT_CHANNEL_ID, null);
defaultChannel.setImportance(enabled ? IMPORTANCE_UNSPECIFIED : IMPORTANCE_NONE);
updateChannel(pkg, uid, defaultChannel);
}
@@ -204,13 +211,17 @@
}
}
-
public NotificationChannel getChannel(String pkg, int uid, String channelId) {
+ return getChannel(pkg, uid, channelId, null);
+ }
+
+ public NotificationChannel getChannel(String pkg, int uid, String channelId,
+ String conversationId) {
if (channelId == null) {
return null;
}
try {
- return sINM.getNotificationChannelForPackage(pkg, uid, channelId, true);
+ return sINM.getNotificationChannelForPackage(pkg, uid, channelId, conversationId, true);
} catch (Exception e) {
Log.w(TAG, "Error calling NoMan", e);
return null;
@@ -238,6 +249,15 @@
}
}
+ public ParceledListSlice<ConversationChannelWrapper> getConversations(String pkg, int uid) {
+ try {
+ return sINM.getConversationsForPackage(pkg, uid);
+ } catch (Exception e) {
+ Log.w(TAG, "Error calling NoMan", e);
+ return ParceledListSlice.emptyList();
+ }
+ }
+
/**
* Returns all notification channels associated with the package and uid that will bypass DND
*/
@@ -474,6 +494,32 @@
}
}
+ public ShortcutInfo getConversationInfo(Context context, String pkg, int uid, String id) {
+ LauncherApps la = context.getSystemService(LauncherApps.class);
+
+ LauncherApps.ShortcutQuery query = new LauncherApps.ShortcutQuery()
+ .setPackage(pkg)
+ .setQueryFlags(FLAG_MATCH_DYNAMIC | FLAG_MATCH_PINNED)
+ .setShortcutIds(Arrays.asList(id));
+ List<ShortcutInfo> shortcuts = la.getShortcuts(
+ query, UserHandle.of(UserHandle.getUserId(uid)));
+ if (shortcuts != null && !shortcuts.isEmpty()) {
+ return shortcuts.get(0);
+ }
+ return null;
+ }
+
+ public Drawable getConversationDrawable(Context context, ShortcutInfo info) {
+ LauncherApps la = context.getSystemService(LauncherApps.class);
+ return la.getShortcutBadgedIconDrawable(info,
+ context.getResources().getDisplayMetrics().densityDpi);
+ }
+
+ public void requestPinShortcut(Context context, ShortcutInfo shortcutInfo) {
+ ShortcutManager sm = context.getSystemService(ShortcutManager.class);
+ sm.requestPinShortcut(shortcutInfo, null);
+ }
+
/**
* NotificationsSentState contains how often an app sends notifications and how recently it sent
* one.
diff --git a/src/com/android/settings/notification/RemoteVolumeGroupController.java b/src/com/android/settings/notification/RemoteVolumeGroupController.java
new file mode 100644
index 0000000..c36035a
--- /dev/null
+++ b/src/com/android/settings/notification/RemoteVolumeGroupController.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.media.LocalMediaManager;
+import com.android.settingslib.media.MediaDevice;
+import com.android.settingslib.media.MediaOutputSliceConstants;
+import com.android.settingslib.utils.ThreadUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A group preference controller to add/remove/update preference
+ * {@link com.android.settings.notification.RemoteVolumeSeekBarPreference}
+ **/
+public class RemoteVolumeGroupController extends BasePreferenceController implements
+ Preference.OnPreferenceChangeListener, LifecycleObserver, LocalMediaManager.DeviceCallback {
+
+ private static final String KEY_REMOTE_VOLUME_GROUP = "remote_media_group";
+ private static final String TAG = "RemoteVolumePrefCtr";
+ @VisibleForTesting
+ static final String SWITCHER_PREFIX = "OUTPUT_SWITCHER";
+
+ private PreferenceCategory mPreferenceCategory;
+ private List<MediaDevice> mActiveRemoteMediaDevices = new ArrayList<>();
+
+ @VisibleForTesting
+ LocalMediaManager mLocalMediaManager;
+
+ public RemoteVolumeGroupController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ if (mLocalMediaManager == null) {
+ mLocalMediaManager = new LocalMediaManager(mContext, null, null);
+ mLocalMediaManager.registerCallback(this);
+ mLocalMediaManager.startScan();
+ }
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (mActiveRemoteMediaDevices.isEmpty()) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ return AVAILABLE_UNSEARCHABLE;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreferenceCategory = screen.findPreference(getPreferenceKey());
+ mActiveRemoteMediaDevices.clear();
+ mActiveRemoteMediaDevices.addAll(mLocalMediaManager.getActiveMediaDevice(
+ MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE));
+ refreshPreference();
+ }
+
+ /**
+ * onDestroy()
+ * {@link androidx.lifecycle.OnLifecycleEvent}
+ **/
+ @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
+ public void onDestroy() {
+ mLocalMediaManager.unregisterCallback(this);
+ mLocalMediaManager.stopScan();
+ }
+
+ private void refreshPreference() {
+ mPreferenceCategory.removeAll();
+ if (!isAvailable()) {
+ mPreferenceCategory.setVisible(false);
+ return;
+ }
+ final CharSequence outputTitle = mContext.getText(R.string.media_output_title);
+ final CharSequence castVolume = mContext.getText(R.string.remote_media_volume_option_title);
+ mPreferenceCategory.setVisible(true);
+ int i = 0;
+ for (MediaDevice device : mActiveRemoteMediaDevices) {
+ if (mPreferenceCategory.findPreference(device.getId()) != null) {
+ continue;
+ }
+ // Add slider
+ final RemoteVolumeSeekBarPreference seekBarPreference =
+ new RemoteVolumeSeekBarPreference(mContext);
+ seekBarPreference.setKey(device.getId());
+ seekBarPreference.setTitle(castVolume + " (" + device.getClientAppLabel() + ")");
+ seekBarPreference.setMax(device.getMaxVolume());
+ seekBarPreference.setProgress(device.getCurrentVolume());
+ seekBarPreference.setMin(0);
+ seekBarPreference.setOnPreferenceChangeListener(this);
+ seekBarPreference.setIcon(R.drawable.ic_volume_remote);
+ mPreferenceCategory.addPreference(seekBarPreference);
+ // Add output indicator
+ final Preference preference = new Preference(mContext);
+ preference.setKey(SWITCHER_PREFIX + device.getId());
+ preference.setTitle(outputTitle);
+ preference.setSummary(device.getName());
+ mPreferenceCategory.addPreference(preference);
+ }
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final MediaDevice device = mLocalMediaManager.getMediaDeviceById(preference.getKey());
+ if (device == null) {
+ Log.e(TAG, "Unable to find " + preference.getKey() + " to set volume");
+ return false;
+ }
+ ThreadUtils.postOnBackgroundThread(() -> {
+ device.requestSetVolume((int) newValue);
+ });
+ return true;
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!preference.getKey().startsWith(SWITCHER_PREFIX)) {
+ return false;
+ }
+ final String key = preference.getKey().substring(SWITCHER_PREFIX.length());
+ final MediaDevice device = mLocalMediaManager.getMediaDeviceById(key);
+ if (device == null) {
+ return false;
+ }
+ final Intent intent = new Intent()
+ .setAction(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT)
+ .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ .putExtra(MediaOutputSliceConstants.EXTRA_PACKAGE_NAME,
+ device.getClientPackageName());
+ mContext.startActivity(intent);
+ return true;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_REMOTE_VOLUME_GROUP;
+ }
+
+ @Override
+ public void onDeviceListUpdate(List<MediaDevice> devices) {
+ if (mPreferenceCategory == null) {
+ // Preference group is not ready.
+ return;
+ }
+ mActiveRemoteMediaDevices.clear();
+ mActiveRemoteMediaDevices.addAll(mLocalMediaManager.getActiveMediaDevice(
+ MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE));
+ refreshPreference();
+ }
+
+ @Override
+ public void onSelectedDeviceStateChanged(MediaDevice device, int state) {
+
+ }
+}
diff --git a/src/com/android/settings/notification/RemoteVolumeSeekBarPreference.java b/src/com/android/settings/notification/RemoteVolumeSeekBarPreference.java
index e99af6a..8714351 100644
--- a/src/com/android/settings/notification/RemoteVolumeSeekBarPreference.java
+++ b/src/com/android/settings/notification/RemoteVolumeSeekBarPreference.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.util.AttributeSet;
+import android.widget.SeekBar;
/**
* A slider preference that controls remote volume, which doesn't go through
@@ -50,7 +51,17 @@
@Override
protected void init() {
if (mSeekBar == null) return;
+ setContinuousUpdates(true);
updateIconView();
updateSuppressionText();
+ notifyHierarchyChanged();
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ super.onProgressChanged(seekBar, progress, fromUser);
+ if (fromUser) {
+ notifyChanged();
+ }
}
}
diff --git a/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
new file mode 100644
index 0000000..15b8388
--- /dev/null
+++ b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import android.content.Context;
+import android.util.Slog;
+
+import androidx.preference.Preference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.notification.NotificationBackend;
+
+public class AddToHomeScreenPreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin {
+
+ private static final String TAG = "HomeScreenPref";
+ private static final String KEY = "add_to_home";
+
+ public AddToHomeScreenPreferenceController(Context context, NotificationBackend backend) {
+ super(context, backend);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
+ }
+ return mConversationInfo != null;
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (KEY.equals(preference.getKey())) {
+ try {
+ mBackend.requestPinShortcut(mContext, mConversationInfo);
+ return true;
+ } catch (SecurityException e) {
+ Slog.e(TAG, "Cannot add to home screen", e);
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java b/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
index fdb257e..0ed1b84 100644
--- a/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
+++ b/src/com/android/settings/notification/app/AppBubbleNotificationSettings.java
@@ -84,7 +84,7 @@
}
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, mChannel, mChannelGroup, null, null, mSuspendedAppsAdmin);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
diff --git a/src/com/android/settings/notification/app/AppNotificationSettings.java b/src/com/android/settings/notification/app/AppNotificationSettings.java
index 7f6c4ab..e6ccd89 100644
--- a/src/com/android/settings/notification/app/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/app/AppNotificationSettings.java
@@ -80,7 +80,7 @@
}
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, mChannel, mChannelGroup, null, null, mSuspendedAppsAdmin);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
@@ -123,6 +123,7 @@
mControllers.add(new DeletedChannelsPreferenceController(context, mBackend));
mControllers.add(new BubbleSummaryPreferenceController(context, mBackend));
mControllers.add(new ChannelListPreferenceController(context, mBackend));
+ mControllers.add(new ConversationListPreferenceController(context, mBackend));
return new ArrayList<>(mControllers);
}
}
diff --git a/src/com/android/settings/notification/app/BubblePreferenceController.java b/src/com/android/settings/notification/app/BubblePreferenceController.java
index 930bab3..879f17a 100644
--- a/src/com/android/settings/notification/app/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/app/BubblePreferenceController.java
@@ -22,15 +22,15 @@
import android.content.Context;
import android.provider.Settings;
+import androidx.annotation.VisibleForTesting;
+import androidx.fragment.app.FragmentManager;
+import androidx.preference.Preference;
+
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.RestrictedSwitchPreference;
-import androidx.annotation.VisibleForTesting;
-import androidx.fragment.app.FragmentManager;
-import androidx.preference.Preference;
-
public class BubblePreferenceController extends NotificationPreferenceController
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
diff --git a/src/com/android/settings/notification/app/ChannelListPreferenceController.java b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
index 7cf836a..187e7e1 100644
--- a/src/com/android/settings/notification/app/ChannelListPreferenceController.java
+++ b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
@@ -31,6 +31,7 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.Settings;
+import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.Utils;
@@ -132,9 +133,7 @@
groupCategory.setOrderingAsAdded(true);
mPreference.addPreference(groupCategory);
if (group.getId() == null) {
- if (mChannelGroupList.size() > 1) {
- groupCategory.setTitle(R.string.notification_channels_other);
- }
+ groupCategory.setTitle(R.string.notification_channels_other);
groupCategory.setKey(KEY_GENERAL_CATEGORY);
} else {
groupCategory.setTitle(group.getName());
@@ -147,7 +146,10 @@
int N = channels.size();
for (int i = 0; i < N; i++) {
final NotificationChannel channel = channels.get(i);
- populateSingleChannelPrefs(groupCategory, channel, group.isBlocked());
+ // conversations get their own section
+ if (TextUtils.isEmpty(channel.getConversationId()) || channel.isDemoted()) {
+ populateSingleChannelPrefs(groupCategory, channel, group.isBlocked());
+ }
}
}
}
diff --git a/src/com/android/settings/notification/app/ChannelNotificationSettings.java b/src/com/android/settings/notification/app/ChannelNotificationSettings.java
index b4d67b9..b5212c9 100644
--- a/src/com/android/settings/notification/app/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/app/ChannelNotificationSettings.java
@@ -30,6 +30,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
+import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.ArrayList;
@@ -65,8 +66,20 @@
return;
}
+ if (mChannel != null && !TextUtils.isEmpty(mChannel.getConversationId())
+ && !mChannel.isDemoted()) {
+ startActivity(new SubSettingLauncher(mContext)
+ .setDestination(ConversationNotificationSettings.class.getName())
+ .setArguments(getArguments())
+ .setExtras(getIntent() != null ? getIntent().getExtras(): null)
+ .setSourceMetricsCategory(SettingsEnums.NOTIFICATION_TOPIC_NOTIFICATION)
+ .toIntent());
+ finish();
+ return;
+ }
+
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, mChannel, mChannelGroup, null, null, mSuspendedAppsAdmin);
controller.displayPreference(getPreferenceScreen());
}
updatePreferenceStates();
@@ -118,6 +131,7 @@
mControllers.add(new NotificationsOffPreferenceController(context));
mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(),
mBackend, false /* isAppPage */));
+ mControllers.add(new ConversationPromotePreferenceController(context, this, mBackend));
return new ArrayList<>(mControllers);
}
}
diff --git a/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java b/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
new file mode 100644
index 0000000..6583a23
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import android.content.Context;
+import android.text.TextUtils;
+
+import androidx.preference.Preference;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+public class ConversationDemotePreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin {
+
+ private static final String KEY = "demote";
+
+ SettingsPreferenceFragment mHostFragment;
+
+ public ConversationDemotePreferenceController(Context context,
+ SettingsPreferenceFragment hostFragment,
+ NotificationBackend backend) {
+ super(context, backend);
+ mHostFragment = hostFragment;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
+ }
+ if (mAppRow == null || mChannel == null) {
+ return false;
+ }
+ return !TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted();
+ }
+
+ public void updateState(Preference preference) {
+ preference.setEnabled(mAdmin == null);
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (KEY.equals(preference.getKey())) {
+ mChannel.setDemoted(true);
+ saveChannel();
+
+ mHostFragment.getActivity().finish();
+
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
new file mode 100644
index 0000000..369f3af
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import static com.android.settings.widget.EntityHeaderController.PREF_KEY_APP_HEADER;
+
+import android.app.Activity;
+import android.content.Context;
+import android.text.BidiFormatter;
+import android.text.SpannableStringBuilder;
+import android.text.TextUtils;
+import android.view.View;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.widget.EntityHeaderController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.widget.LayoutPreference;
+
+public class ConversationHeaderPreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin, LifecycleObserver {
+
+ private final DashboardFragment mFragment;
+ private EntityHeaderController mHeaderController;
+ private boolean mStarted = false;
+
+ public ConversationHeaderPreferenceController(Context context, DashboardFragment fragment) {
+ super(context, null);
+ mFragment = fragment;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return PREF_KEY_APP_HEADER;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return mAppRow != null;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ if (mAppRow != null && mFragment != null) {
+
+ Activity activity = null;
+ if (mStarted) {
+ // don't call done on an activity if it hasn't started yet
+ activity = mFragment.getActivity();
+ }
+
+ if (activity == null) {
+ return;
+ }
+
+ LayoutPreference pref = (LayoutPreference) preference;
+ mHeaderController = EntityHeaderController.newInstance(
+ activity, mFragment, pref.findViewById(R.id.entity_header));
+ pref = mHeaderController.setIcon(mConversationDrawable)
+ .setLabel(getLabel())
+ .setSummary(getSummary())
+ .setPackageName(mAppRow.pkg)
+ .setUid(mAppRow.uid)
+ .setButtonActions(EntityHeaderController.ActionType.ACTION_NOTIF_PREFERENCE,
+ EntityHeaderController.ActionType.ACTION_NONE)
+ .setHasAppInfoLink(true)
+ .setRecyclerView(mFragment.getListView(), mFragment.getSettingsLifecycle())
+ .done(activity, mContext);
+ pref.findViewById(R.id.entity_header).setVisibility(View.VISIBLE);
+ }
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ if (mChannel != null && !isDefaultChannel()) {
+ if (mChannelGroup != null
+ && !TextUtils.isEmpty(mChannelGroup.getName())) {
+ final SpannableStringBuilder summary = new SpannableStringBuilder();
+ BidiFormatter bidi = BidiFormatter.getInstance();
+ summary.append(bidi.unicodeWrap(mAppRow.label.toString()));
+ summary.append(bidi.unicodeWrap(mContext.getText(
+ R.string.notification_header_divider_symbol_with_spaces)));
+ summary.append(bidi.unicodeWrap(mChannelGroup.getName().toString()));
+ return summary.toString();
+ } else {
+ return mAppRow.label.toString();
+ }
+ } else if (mChannelGroup != null) {
+ return mAppRow.label.toString();
+ } else {
+ return "";
+ }
+ }
+
+ @OnLifecycleEvent(Lifecycle.Event.ON_START)
+ public void onStart() {
+ mStarted = true;
+ if (mHeaderController != null) {
+ mHeaderController.styleActionBar(mFragment.getActivity());
+ }
+ }
+
+ @VisibleForTesting
+ CharSequence getLabel() {
+ return mConversationInfo != null
+ ? mConversationInfo.getShortLabel()
+ : mChannel.getName();
+ }
+}
diff --git a/src/com/android/settings/notification/app/ConversationImportantPreferenceController.java b/src/com/android/settings/notification/app/ConversationImportantPreferenceController.java
new file mode 100644
index 0000000..71fa231
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationImportantPreferenceController.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import android.content.Context;
+
+import androidx.preference.Preference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+public class ConversationImportantPreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+ private static final String TAG = "ConvoImpPC";
+ private static final String KEY = "important";
+
+ public ConversationImportantPreferenceController(Context context,
+ NotificationBackend backend) {
+ super(context, backend);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
+ }
+ if (mAppRow == null || mChannel == null) {
+ return false;
+ }
+ return true;
+ }
+
+ public void updateState(Preference preference) {
+ if (mAppRow != null) {
+ RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
+ pref.setDisabledByAdmin(mAdmin);
+ pref.setChecked(mChannel.isImportantConversation());
+ pref.setEnabled(!pref.isDisabledByAdmin());
+ }
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (mChannel == null) {
+ return false;
+ }
+ final boolean value = (Boolean) newValue;
+ mChannel.setImportantConversation(value);
+ saveChannel();
+
+ return true;
+ }
+}
diff --git a/src/com/android/settings/notification/app/ConversationListPreferenceController.java b/src/com/android/settings/notification/app/ConversationListPreferenceController.java
new file mode 100644
index 0000000..fa1b050
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationListPreferenceController.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import android.app.NotificationChannel;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.pm.ShortcutInfo;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.service.notification.ConversationChannelWrapper;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+
+import com.android.settings.R;
+import com.android.settings.applications.AppInfoBase;
+import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.notification.NotificationBackend;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+public class ConversationListPreferenceController extends NotificationPreferenceController {
+
+ private static final String KEY = "conversations";
+ public static final String ARG_FROM_SETTINGS = "fromSettings";
+
+ private List<ConversationChannelWrapper> mConversations;
+ private PreferenceCategory mPreference;
+
+ public ConversationListPreferenceController(Context context, NotificationBackend backend) {
+ super(context, backend);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (mAppRow == null) {
+ return false;
+ }
+ if (mAppRow.banned) {
+ return false;
+ }
+ if (mChannel != null) {
+ if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)
+ || NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ mPreference = (PreferenceCategory) preference;
+ // Load channel settings
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... unused) {
+ mConversations = mBackend.getConversations(mAppRow.pkg, mAppRow.uid).getList();
+ Collections.sort(mConversations, mConversationComparator);
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void unused) {
+ if (mContext == null) {
+ return;
+ }
+ populateList();
+ }
+ }.execute();
+ }
+
+ private void populateList() {
+ // TODO: if preference has children, compare with newly loaded list
+ mPreference.removeAll();
+ mPreference.setTitle(R.string.conversations_category_title);
+
+ if (mConversations.isEmpty()) {
+ mPreference.setVisible(false);
+ } else {
+ mPreference.setVisible(true);
+ populateConversations();
+ }
+ }
+
+ private void populateConversations() {
+ for (ConversationChannelWrapper conversation : mConversations) {
+ if (conversation.getNotificationChannel().isDemoted()) {
+ continue;
+ }
+ mPreference.addPreference(createConversationPref(conversation));
+ }
+ }
+
+ protected Preference createConversationPref(final ConversationChannelWrapper conversation) {
+ Preference pref = new Preference(mContext);
+ ShortcutInfo si = conversation.getShortcutInfo();
+
+ pref.setTitle(si != null
+ ? si.getShortLabel()
+ : conversation.getNotificationChannel().getName());
+ pref.setSummary(conversation.getNotificationChannel().getGroup() != null
+ ? mContext.getString(R.string.notification_conversation_summary,
+ conversation.getParentChannelLabel(), conversation.getGroupLabel())
+ : conversation.getParentChannelLabel());
+ if (si != null) {
+ pref.setIcon(mBackend.getConversationDrawable(mContext, si));
+ }
+ pref.setKey(conversation.getNotificationChannel().getId());
+
+ Bundle channelArgs = new Bundle();
+ channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mAppRow.uid);
+ channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mAppRow.pkg);
+ channelArgs.putString(Settings.EXTRA_CHANNEL_ID,
+ conversation.getNotificationChannel().getParentChannelId());
+ channelArgs.putString(Settings.EXTRA_CONVERSATION_ID,
+ conversation.getNotificationChannel().getConversationId());
+ channelArgs.putBoolean(ARG_FROM_SETTINGS, true);
+ pref.setIntent(new SubSettingLauncher(mContext)
+ .setDestination(ChannelNotificationSettings.class.getName())
+ .setArguments(channelArgs)
+ .setExtras(channelArgs)
+ .setTitleText(pref.getTitle())
+ .setSourceMetricsCategory(SettingsEnums.NOTIFICATION_APP_NOTIFICATION)
+ .toIntent());
+ return pref;
+ }
+
+ protected Comparator<ConversationChannelWrapper> mConversationComparator =
+ (left, right) -> {
+ if (left.getNotificationChannel().isImportantConversation()
+ != right.getNotificationChannel().isImportantConversation()) {
+ // important first
+ return Boolean.compare(right.getNotificationChannel().isImportantConversation(),
+ left.getNotificationChannel().isImportantConversation());
+ }
+ return left.getNotificationChannel().getId().compareTo(
+ right.getNotificationChannel().getId());
+ };
+}
diff --git a/src/com/android/settings/notification/app/ConversationNotificationSettings.java b/src/com/android/settings/notification/app/ConversationNotificationSettings.java
new file mode 100644
index 0000000..3f25037
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationNotificationSettings.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.Intent;
+import android.preference.PreferenceManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.R;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ConversationNotificationSettings extends NotificationSettings {
+ private static final String TAG = "ConvoSettings";
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.NOTIFICATION_CONVERSATION_SETTINGS;
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null || mChannel == null) {
+ Log.w(TAG, "Missing package or uid or packageinfo or channel");
+ finish();
+ return;
+ }
+
+ for (NotificationPreferenceController controller : mControllers) {
+ controller.onResume(mAppRow, mChannel, mChannelGroup, mConversationDrawable,
+ mConversationInfo, mSuspendedAppsAdmin);
+ controller.displayPreference(getPreferenceScreen());
+ }
+ updatePreferenceStates();
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ for (NotificationPreferenceController controller : mControllers) {
+ if (controller instanceof PreferenceManager.OnActivityResultListener) {
+ ((PreferenceManager.OnActivityResultListener) controller)
+ .onActivityResult(requestCode, resultCode, data);
+ }
+ }
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.conversation_notification_settings;
+ }
+
+ @Override
+ protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ mControllers = new ArrayList<>();
+ mControllers.add(new ConversationHeaderPreferenceController(context, this));
+ mControllers.add(new ConversationImportantPreferenceController(context, mBackend));
+ mControllers.add(new DefaultImportancePreferenceController(
+ context, mImportanceListener, mBackend));
+ mControllers.add(new AddToHomeScreenPreferenceController(context, mBackend));
+ mControllers.add(new HighImportancePreferenceController(
+ context, mImportanceListener, mBackend));
+ mControllers.add(new SoundPreferenceController(context, this,
+ mImportanceListener, mBackend));
+ mControllers.add(new VibrationPreferenceController(context, mBackend));
+ mControllers.add(new AppLinkPreferenceController(context));
+ mControllers.add(new DescriptionPreferenceController(context));
+ mControllers.add(new VisibilityPreferenceController(context, new LockPatternUtils(context),
+ mBackend));
+ mControllers.add(new LightsPreferenceController(context, mBackend));
+ mControllers.add(new BadgePreferenceController(context, mBackend));
+ mControllers.add(new NotificationsOffPreferenceController(context));
+ mControllers.add(new BubblePreferenceController(context, getChildFragmentManager(),
+ mBackend, false /* isAppPage */));
+ mControllers.add(new ConversationDemotePreferenceController(context, this, mBackend));
+ return new ArrayList<>(mControllers);
+ }
+}
diff --git a/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
new file mode 100644
index 0000000..5ef9246
--- /dev/null
+++ b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import android.content.Context;
+import android.text.TextUtils;
+
+import androidx.preference.Preference;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+public class ConversationPromotePreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin {
+
+ private static final String KEY = "convo_promote";
+
+ SettingsPreferenceFragment mHostFragment;
+
+ public ConversationPromotePreferenceController(Context context,
+ SettingsPreferenceFragment hostFragment,
+ NotificationBackend backend) {
+ super(context, backend);
+ mHostFragment = hostFragment;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
+ }
+ if (mAppRow == null || mChannel == null) {
+ return false;
+ }
+ return !TextUtils.isEmpty(mChannel.getConversationId()) && mChannel.isDemoted();
+ }
+
+ public void updateState(Preference preference) {
+ preference.setEnabled(mAdmin == null);
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (mChannel == null) {
+ return false;
+ }
+ mChannel.setDemoted(false);
+ saveChannel();
+
+ if (mHostFragment != null) {
+ mHostFragment.getActivity().finish();
+ }
+
+ return true;
+ }
+}
diff --git a/src/com/android/settings/notification/app/DefaultImportancePreferenceController.java b/src/com/android/settings/notification/app/DefaultImportancePreferenceController.java
new file mode 100644
index 0000000..e664101
--- /dev/null
+++ b/src/com/android/settings/notification/app/DefaultImportancePreferenceController.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+import static android.app.NotificationManager.IMPORTANCE_LOW;
+
+import android.app.NotificationChannel;
+import android.content.Context;
+
+import androidx.preference.Preference;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+public class DefaultImportancePreferenceController extends NotificationPreferenceController
+ implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
+
+ private static final String KEY = "alerting";
+ private NotificationSettings.ImportanceListener mImportanceListener;
+
+ public DefaultImportancePreferenceController(Context context,
+ NotificationSettings.ImportanceListener importanceListener,
+ NotificationBackend backend) {
+ super(context, backend);
+ mImportanceListener = importanceListener;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
+ }
+ if (mChannel == null) {
+ return false;
+ }
+ if (isDefaultChannel()) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ if (mAppRow != null && mChannel != null) {
+ preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
+
+ RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
+ pref.setChecked(mChannel.getImportance() >= IMPORTANCE_DEFAULT);
+ }
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (mChannel != null) {
+ final boolean checked = (boolean) newValue;
+
+ mChannel.setImportance(checked ? IMPORTANCE_DEFAULT : IMPORTANCE_LOW);
+ mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
+ saveChannel();
+ mImportanceListener.onImportanceChanged();
+ }
+ return true;
+ }
+}
diff --git a/src/com/android/settings/notification/app/NotificationPreferenceController.java b/src/com/android/settings/notification/app/NotificationPreferenceController.java
index e82f420..be1ce1b 100644
--- a/src/com/android/settings/notification/app/NotificationPreferenceController.java
+++ b/src/com/android/settings/notification/app/NotificationPreferenceController.java
@@ -24,6 +24,8 @@
import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.content.pm.ShortcutInfo;
+import android.graphics.drawable.Drawable;
import android.os.UserManager;
import android.util.Log;
@@ -53,6 +55,10 @@
protected final UserManager mUm;
protected final PackageManager mPm;
protected Preference mPreference;
+ @Nullable
+ protected Drawable mConversationDrawable;
+ @Nullable
+ protected ShortcutInfo mConversationInfo;
public NotificationPreferenceController(Context context, NotificationBackend backend) {
super(context);
@@ -87,11 +93,15 @@
protected void onResume(NotificationBackend.AppRow appRow,
@Nullable NotificationChannel channel, @Nullable NotificationChannelGroup group,
+ Drawable conversationDrawable,
+ ShortcutInfo conversationInfo,
RestrictedLockUtils.EnforcedAdmin admin) {
mAppRow = appRow;
mChannel = channel;
mChannelGroup = group;
mAdmin = admin;
+ mConversationDrawable = conversationDrawable;
+ mConversationInfo = conversationInfo;
}
protected boolean checkCanBeVisible(int minImportanceVisible) {
diff --git a/src/com/android/settings/notification/app/NotificationSettings.java b/src/com/android/settings/notification/app/NotificationSettings.java
index 79b2567..983ad2b 100644
--- a/src/com/android/settings/notification/app/NotificationSettings.java
+++ b/src/com/android/settings/notification/app/NotificationSettings.java
@@ -32,6 +32,8 @@
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
+import android.content.pm.ShortcutInfo;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
@@ -46,8 +48,6 @@
import com.android.settings.applications.AppInfoBase;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.HeaderPreferenceController;
-import com.android.settings.notification.app.NotificationPreferenceController;
import com.android.settingslib.RestrictedLockUtilsInternal;
import java.util.ArrayList;
@@ -71,6 +71,8 @@
protected NotificationChannelGroup mChannelGroup;
protected NotificationChannel mChannel;
protected NotificationBackend.AppRow mAppRow;
+ protected Drawable mConversationDrawable;
+ protected ShortcutInfo mConversationInfo;
protected boolean mShowLegacyChannelConfig = false;
protected boolean mListeningToPackageRemove;
@@ -118,10 +120,17 @@
loadChannelGroup();
collectConfigActivities();
- getSettingsLifecycle().addObserver(use(HeaderPreferenceController.class));
+ if (use(HeaderPreferenceController.class) != null) {
+ getSettingsLifecycle().addObserver(use(HeaderPreferenceController.class));
+ }
+ if (use(ConversationHeaderPreferenceController.class) != null) {
+ getSettingsLifecycle().addObserver(
+ use(ConversationHeaderPreferenceController.class));
+ }
for (NotificationPreferenceController controller : mControllers) {
- controller.onResume(mAppRow, mChannel, mChannelGroup, mSuspendedAppsAdmin);
+ controller.onResume(mAppRow, mChannel, mChannelGroup, null, null,
+ mSuspendedAppsAdmin);
}
}
}
@@ -169,6 +178,7 @@
return;
}
loadChannel();
+ loadConversation();
loadChannelGroup();
collectConfigActivities();
}
@@ -180,7 +190,21 @@
Bundle args = intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
channelId = args != null ? args.getString(Settings.EXTRA_CHANNEL_ID) : null;
}
- mChannel = mBackend.getChannel(mPkg, mUid, channelId);
+ String conversationId = intent != null
+ ? intent.getStringExtra(Settings.EXTRA_CONVERSATION_ID) : null;
+ mChannel = mBackend.getChannel(mPkg, mUid, channelId, conversationId);
+ }
+
+ private void loadConversation() {
+ if (mChannel == null || TextUtils.isEmpty(mChannel.getConversationId())
+ || mChannel.isDemoted()) {
+ return;
+ }
+ mConversationInfo = mBackend.getConversationInfo(
+ mContext, mPkg, mUid, mChannel.getConversationId());
+ if (mConversationInfo != null) {
+ mConversationDrawable = mBackend.getConversationDrawable(mContext, mConversationInfo);
+ }
}
private void loadAppRow() {
@@ -194,7 +218,7 @@
if (mShowLegacyChannelConfig) {
mChannel = mBackend.getChannel(
- mAppRow.pkg, mAppRow.uid, NotificationChannel.DEFAULT_CHANNEL_ID);
+ mAppRow.pkg, mAppRow.uid, NotificationChannel.DEFAULT_CHANNEL_ID, null);
}
if (mChannel != null && !TextUtils.isEmpty(mChannel.getGroup())) {
NotificationChannelGroup group = mBackend.getGroup(mPkg, mUid, mChannel.getGroup());
diff --git a/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java b/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java
index d2310c3..170c699 100644
--- a/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java
+++ b/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java
@@ -24,12 +24,16 @@
import android.os.Bundle;
import android.service.notification.ConditionProviderService;
import android.util.Log;
+import android.view.View;
import android.widget.Toast;
+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.core.SubSettingLauncher;
public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase {
@@ -108,6 +112,12 @@
}
@Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ Utils.setActionBarShadowAnimation(getActivity(), getSettingsLifecycle(), getListView());
+ }
+
+ @Override
public int getHelpResource() {
return R.string.help_uri_interruptions;
}
diff --git a/src/com/android/settings/system/SystemUpdatePreferenceController.java b/src/com/android/settings/system/SystemUpdatePreferenceController.java
index 38a88b9..92819d6 100644
--- a/src/com/android/settings/system/SystemUpdatePreferenceController.java
+++ b/src/com/android/settings/system/SystemUpdatePreferenceController.java
@@ -89,7 +89,7 @@
@Override
public CharSequence getSummary() {
CharSequence summary = mContext.getString(R.string.android_version_summary,
- Build.VERSION.RELEASE);
+ Build.VERSION.RELEASE_OR_CODENAME);
final FutureTask<Bundle> bundleFutureTask = new FutureTask<>(
// Put the API call in a future to avoid StrictMode violation.
() -> mUpdateManager.retrieveSystemUpdateInfo());
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 64814fa..9d075a7 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -1020,8 +1020,7 @@
final Context context = getContext();
final PowerManager powerManager = context.getSystemService(PowerManager.class);
final ContentResolver contentResolver = context.getContentResolver();
- return Settings.Global.getInt(contentResolver,
- Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1
+ return mWifiManager.isAutoWakeupEnabled()
&& Settings.Global.getInt(contentResolver,
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1
&& Settings.Global.getInt(contentResolver,
diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java
index 1a7d572..86effea 100644
--- a/src/com/android/settings/wifi/WifiSettings2.java
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -851,8 +851,7 @@
final Context context = getContext();
final PowerManager powerManager = context.getSystemService(PowerManager.class);
final ContentResolver contentResolver = context.getContentResolver();
- return Settings.Global.getInt(contentResolver,
- Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1
+ return mWifiManager.isAutoWakeupEnabled()
&& Settings.Global.getInt(contentResolver,
Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1
&& Settings.Global.getInt(contentResolver,
diff --git a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
index 855b329..d2a4a98 100644
--- a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
@@ -24,6 +24,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
+import android.net.wifi.WifiManager;
import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
@@ -57,6 +58,9 @@
@VisibleForTesting
LocationManager mLocationManager;
+ @VisibleForTesting
+ WifiManager mWifiManager;
+
private final BroadcastReceiver mLocationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -70,6 +74,7 @@
public WifiWakeupPreferenceController(Context context) {
super(context, KEY_ENABLE_WIFI_WAKEUP);
mLocationManager = (LocationManager) context.getSystemService(Service.LOCATION_SERVICE);
+ mWifiManager = context.getSystemService(WifiManager.class);
}
public void setFragment(Fragment hostFragment) {
@@ -160,13 +165,11 @@
}
private boolean getWifiWakeupEnabled() {
- return Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_WAKEUP_ENABLED, 0) == 1;
+ return mWifiManager.isAutoWakeupEnabled();
}
private void setWifiWakeupEnabled(boolean enabled) {
- Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.WIFI_WAKEUP_ENABLED,
- enabled ? 1 : 0);
+ mWifiManager.setAutoWakeupEnabled(enabled);
}
@Override
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index b9e39bc..f1cb2f3 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -904,7 +904,14 @@
*/
@Override
public void onDisconnectResult(@DisconnectStatus int status) {
- if (status != DisconnectCallback.DISCONNECT_STATUS_SUCCESS) {
+ if (status == DisconnectCallback.DISCONNECT_STATUS_SUCCESS) {
+ final Activity activity = mFragment.getActivity();
+ if (activity != null) {
+ Toast.makeText(activity,
+ activity.getString(R.string.wifi_disconnected_from, mWifiEntry.getTitle()),
+ Toast.LENGTH_SHORT).show();
+ }
+ } else {
Log.e(TAG, "Disconnect Wi-Fi network failed");
}
}
diff --git a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
index 3a571d7..8a4be10 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceController.java
@@ -39,12 +39,10 @@
private String[] mBandEntries;
private String[] mBandSummaries;
private int mBandIndex;
- private boolean isDualMode;
public WifiTetherApBandPreferenceController(Context context,
OnTetherConfigUpdateListener listener) {
super(context, listener);
- isDualMode = mWifiManager.isStaApConcurrencySupported();
updatePreferenceEntries();
}
@@ -106,16 +104,12 @@
private int validateSelection(int band) {
// unsupported states:
- // 1: no dual mode means we can't have multiband - default to 5GHZ
+ // 1: BAND_5GHZ only - include 2GHZ since some of countries doesn't support 5G hotspot
// 2: no 5 GHZ support means we can't have BAND_5GHZ - default to 2GHZ
- // 3: With Dual mode support we can't have BAND_5GHZ only - include 2GHZ
- if (!isDualMode
- && ((band & SoftApConfiguration.BAND_5GHZ) != 0)
- && ((band & SoftApConfiguration.BAND_2GHZ) != 0)) {
- return SoftApConfiguration.BAND_5GHZ;
- } else if (!is5GhzBandSupported() && SoftApConfiguration.BAND_5GHZ == band) {
- return SoftApConfiguration.BAND_2GHZ;
- } else if (isDualMode && SoftApConfiguration.BAND_5GHZ == band) {
+ if (SoftApConfiguration.BAND_5GHZ == band) {
+ if (!is5GhzBandSupported()) {
+ return SoftApConfiguration.BAND_2GHZ;
+ }
return SoftApConfiguration.BAND_5GHZ | SoftApConfiguration.BAND_2GHZ;
}
@@ -125,13 +119,8 @@
@VisibleForTesting
void updatePreferenceEntries() {
Resources res = mContext.getResources();
- int entriesRes = R.array.wifi_ap_band_config_full;
- int summariesRes = R.array.wifi_ap_band_summary_full;
- // change the list options if this is a dual mode device
- if (isDualMode) {
- entriesRes = R.array.wifi_ap_band_dual_mode;
- summariesRes = R.array.wifi_ap_band_dual_mode_summary;
- }
+ int entriesRes = R.array.wifi_ap_band;
+ int summariesRes = R.array.wifi_ap_band_summary;
mBandEntries = res.getStringArray(entriesRes);
mBandSummaries = res.getStringArray(summariesRes);
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
index 9bebc9a..35a2d19 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
@@ -32,7 +32,6 @@
import com.android.settings.R;
import com.android.settings.accessibility.ToggleFeaturePreferenceFragment.AccessibilityUserShortcutType;
-import com.android.settings.widget.SwitchBar;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -82,9 +81,9 @@
mySet.add(TEST_SERVICE_KEY_2);
mySet.add(TEST_SERVICE_KEY_3);
- final Set<String> filtered = mySet.stream().filter(
- str -> str.contains(TEST_SERVICE_NAME_1)).collect(
- Collectors.toSet());
+ final Set<String> filtered = mySet.stream()
+ .filter(str -> str.contains(TEST_SERVICE_NAME_1))
+ .collect(Collectors.toSet());
mySet.removeAll(filtered);
assertThat(mySet).doesNotContain(TEST_SERVICE_KEY_1);
@@ -93,28 +92,26 @@
@Test
public void stringSet_convertA11yUserShortcutType_shouldReturnPreferredShortcut() {
- int type = 0;
Set<String> mySet = new HashSet<>();
mySet.add(TEST_SERVICE_KEY_1);
mySet.add(TEST_SERVICE_KEY_2);
mySet.add(TEST_SERVICE_KEY_3);
- final Set<String> filtered = mySet.stream().filter(
- str -> str.contains(TEST_SERVICE_NAME_1)).collect(
- Collectors.toSet());
- for (String str : filtered) {
- final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(str);
- type = shortcut.getUserShortcutType();
- }
+ final Set<String> filtered = mySet.stream()
+ .filter(str -> str.contains(TEST_SERVICE_NAME_1))
+ .collect(Collectors.toSet());
+ final String str = (String) filtered.toArray()[0];
+ final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(str);
+ final int type = shortcut.getUserShortcutType();
assertThat(type).isEqualTo(TEST_SERVICE_VALUE_1);
}
@Test
public void createFragment_shouldOnlyAddPreferencesOnce() {
mFragment = spy(new ToggleFeaturePreferenceFragmentTestable());
- FragmentController.setupFragment(mFragment, FragmentActivity.class, 0 /* containerViewId*/,
- null /* bundle */);
+ FragmentController.setupFragment(mFragment, FragmentActivity.class,
+ /* containerViewId= */ 0, /* bundle= */null);
// execute exactly once
verify(mFragment).addPreferencesFromResource(R.xml.placeholder_prefs);
@@ -152,11 +149,5 @@
public void onViewCreated(View view, Bundle savedInstanceState) {
// do nothing
}
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- mSwitchBar = mock(SwitchBar.class);
- super.onActivityCreated(savedInstanceState);
- }
}
}
diff --git a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
index a1a0ee1..a161f84 100644
--- a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
@@ -39,7 +39,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
-import com.android.settings.testutils.shadow.ShadowUtils;
+import com.android.settings.testutils.shadow.ShadowSettingsLibUtils;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.applications.AppUtils;
import com.android.settingslib.applications.ApplicationsState;
@@ -59,7 +59,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowEntityHeaderController.class, ShadowUtils.class})
+@Config(shadows = {ShadowEntityHeaderController.class, ShadowSettingsLibUtils.class})
public class AppInfoWithHeaderTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
index f0fdc9c..dfa9383 100644
--- a/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppPermissionsPreferenceControllerTest.java
@@ -16,8 +16,6 @@
package com.android.settings.applications;
-import static com.android.settings.applications.AppPermissionsPreferenceController.NUM_PERMISSIONS_TO_SHOW;
-
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
@@ -75,7 +73,7 @@
public void updateSummary_noGrantedPermission_shouldSetNoPermissionGrantedSummary() {
doNothing().when(mController).queryPermissionSummary();
mController.updateState(mPreference);
- mController.mNumPackageChecked = 2;
+ mController.mNumPackageChecked = 3;
mController.updateSummary(new ArrayList<>());
@@ -84,14 +82,14 @@
}
@Test
- public void updateSummary_hasPermissionGroups_shouldSetPermissionAsSummary() {
+ public void updateSummary_hasOnePermission_shouldSetPermissionAsSummary() {
doNothing().when(mController).queryPermissionSummary();
mController.updateState(mPreference);
final String permission = "location";
final ArrayList<CharSequence> labels = new ArrayList<>();
labels.add(permission);
final String summary = "Apps using " + permission;
- mController.mNumPackageChecked = 2;
+ mController.mNumPackageChecked = 3;
mController.updateSummary(labels);
@@ -99,6 +97,41 @@
}
@Test
+ public void updateSummary_hasThreePermissions_shouldShowThreePermissionAsSummary() {
+ doNothing().when(mController).queryPermissionSummary();
+ mController.updateState(mPreference);
+ mController.mNumPackageChecked = 3;
+ final List<CharSequence> labels = new ArrayList<>();
+ labels.add("Phone");
+ labels.add("SMS");
+ labels.add("Microphone");
+
+ mController.updateSummary(labels);
+
+ final String summary = "Apps using microphone, sms, and phone";
+ assertThat(mPreference.getSummary()).isEqualTo(summary);
+ }
+
+ @Test
+ public void updateSummary_hasFivePermissions_shouldShowThreePermissionsAndMoreAsSummary() {
+ doNothing().when(mController).queryPermissionSummary();
+ mController.updateState(mPreference);
+ mController.mNumPackageChecked = 3;
+ final List<CharSequence> labels = new ArrayList<>();
+ labels.add("Phone");
+ labels.add("SMS");
+ labels.add("Microphone");
+ labels.add("Contacts");
+ labels.add("Camera");
+ labels.add("Location");
+
+ mController.updateSummary(labels);
+
+ final String summary = "Apps using microphone, contacts, and sms, and more";
+ assertThat(mPreference.getSummary()).isEqualTo(summary);
+ }
+
+ @Test
public void updateSummary_notReachCallbackCount_shouldNotSetSummary() {
doNothing().when(mController).queryPermissionSummary();
mController.updateState(mPreference);
@@ -110,29 +143,4 @@
verify(mPreference, never()).setSummary(anyString());
}
-
- @Test
- public void updateSummary_hasFiveItems_shouldShowCertainNumItems() {
- doNothing().when(mController).queryPermissionSummary();
- mController.updateState(mPreference);
- mController.mNumPackageChecked = 2;
-
- mController.updateSummary(getPermissionGroupsSet());
-
- final CharSequence summary = mPreference.getSummary();
- final int items = summary.toString().split(",").length;
- assertThat(items).isEqualTo(NUM_PERMISSIONS_TO_SHOW);
- }
-
- private List<CharSequence> getPermissionGroupsSet() {
- final List<CharSequence> labels = new ArrayList<>();
- labels.add("Phone");
- labels.add("SMS");
- labels.add("Microphone");
- labels.add("Contacts");
- labels.add("Camera");
- labels.add("Location");
-
- return labels;
- }
}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
index 55890c9..6684e1a 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
@@ -42,7 +42,7 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.testutils.shadow.ShadowUtils;
+import com.android.settings.testutils.shadow.ShadowSettingsLibUtils;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.widget.LayoutPreference;
@@ -58,7 +58,7 @@
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowUtils.class)
+@Config(shadows = ShadowSettingsLibUtils.class)
public class AppHeaderViewPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
index d329f5c..3993475 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
@@ -18,10 +18,12 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
@@ -30,6 +32,8 @@
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
+import com.android.settingslib.bluetooth.LocalBluetoothManager;
import org.junit.Before;
import org.junit.Test;
@@ -40,6 +44,10 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowBluetoothAdapter.class})
public class SavedBluetoothDeviceUpdaterTest {
@@ -54,6 +62,12 @@
private CachedBluetoothDevice mCachedBluetoothDevice;
@Mock
private BluetoothDevice mBluetoothDevice;
+ @Mock
+ private BluetoothAdapter mBluetoothAdapter;
+ @Mock
+ private CachedBluetoothDeviceManager mDeviceManager;
+ @Mock
+ private LocalBluetoothManager mBluetoothManager;
private Context mContext;
private SavedBluetoothDeviceUpdater mBluetoothDeviceUpdater;
@@ -72,6 +86,8 @@
mBluetoothDeviceUpdater = spy(new SavedBluetoothDeviceUpdater(mContext, mDashboardFragment,
mDevicePreferenceCallback));
mBluetoothDeviceUpdater.setPrefContext(mContext);
+ mBluetoothDeviceUpdater.mBluetoothAdapter = mBluetoothAdapter;
+ mBluetoothDeviceUpdater.mLocalManager = mBluetoothManager;
mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
false, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
doNothing().when(mBluetoothDeviceUpdater).addPreference(any());
@@ -85,7 +101,8 @@
mBluetoothDeviceUpdater.update(mCachedBluetoothDevice);
- verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
+ verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice,
+ BluetoothDevicePreference.SortType.TYPE_NO_SORT);
}
@Test
@@ -115,7 +132,8 @@
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.A2DP);
- verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
+ verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice,
+ BluetoothDevicePreference.SortType.TYPE_NO_SORT);
}
@Test
@@ -124,4 +142,70 @@
verify(mCachedBluetoothDevice).connect();
}
+
+ @Test
+ public void forceUpdate_findCachedBluetoothDeviceIsMatched_addPreference() {
+ final List<BluetoothDevice> bluetoothDevices = new ArrayList<>();
+ bluetoothDevices.add(mBluetoothDevice);
+
+ when(mBluetoothAdapter.isEnabled()).thenReturn(true);
+ when(mBluetoothAdapter.getMostRecentlyConnectedDevices()).thenReturn(bluetoothDevices);
+ when(mBluetoothManager.getCachedDeviceManager()).thenReturn(mDeviceManager);
+ when(mDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedBluetoothDevice);
+ when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
+ when(mBluetoothDevice.isConnected()).thenReturn(false);
+
+ mBluetoothDeviceUpdater.forceUpdate();
+
+ verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice,
+ BluetoothDevicePreference.SortType.TYPE_NO_SORT);
+ }
+
+ @Test
+ public void forceUpdate_findCachedBluetoothDeviceNotMatched_removePreference() {
+ final List<BluetoothDevice> bluetoothDevices = new ArrayList<>();
+ bluetoothDevices.add(mBluetoothDevice);
+
+ when(mBluetoothAdapter.isEnabled()).thenReturn(true);
+ when(mBluetoothAdapter.getMostRecentlyConnectedDevices()).thenReturn(bluetoothDevices);
+ when(mBluetoothManager.getCachedDeviceManager()).thenReturn(mDeviceManager);
+ when(mDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedBluetoothDevice);
+ when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
+ when(mBluetoothDevice.isConnected()).thenReturn(true);
+
+ mBluetoothDeviceUpdater.forceUpdate();
+
+ verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
+ }
+
+ @Test
+ public void forceUpdate_notFindCachedBluetoothDevice_doNothing() {
+ final List<BluetoothDevice> bluetoothDevices = new ArrayList<>();
+ bluetoothDevices.add(mBluetoothDevice);
+
+ when(mBluetoothAdapter.isEnabled()).thenReturn(true);
+ when(mBluetoothAdapter.getMostRecentlyConnectedDevices()).thenReturn(bluetoothDevices);
+ when(mBluetoothManager.getCachedDeviceManager()).thenReturn(mDeviceManager);
+ when(mDeviceManager.findDevice(mBluetoothDevice)).thenReturn(null);
+
+ mBluetoothDeviceUpdater.forceUpdate();
+
+ verify(mBluetoothDeviceUpdater, never()).removePreference(mCachedBluetoothDevice);
+ verify(mBluetoothDeviceUpdater, never()).addPreference(mCachedBluetoothDevice,
+ BluetoothDevicePreference.SortType.TYPE_NO_SORT);
+ }
+
+ @Test
+ public void forceUpdate_bluetoothAdapterNotEnable_removeAllDevicesFromPreference() {
+ final Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
+ cachedDevices.add(mCachedBluetoothDevice);
+
+ when(mBluetoothManager.getCachedDeviceManager()).thenReturn(mDeviceManager);
+ when(mDeviceManager.getCachedDevicesCopy()).thenReturn(cachedDevices);
+ when(mBluetoothAdapter.isEnabled()).thenReturn(false);
+
+ mBluetoothDeviceUpdater.forceUpdate();
+
+ verify(mBluetoothDeviceUpdater).removeAllDevicesFromPreference();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java
index a3606e8..9fca65d 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionDetailPreferenceControllerTest.java
@@ -63,7 +63,7 @@
@Test
public void getSummary_shouldGetBuildVersion() {
- assertThat(mController.getSummary()).isEqualTo(Build.VERSION.RELEASE);
+ assertThat(mController.getSummary()).isEqualTo(Build.VERSION.RELEASE_OR_CODENAME);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java
index d000c91..903b88b 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java
@@ -65,6 +65,6 @@
public void updatePreference_shouldSetSummaryToBuildNumber() {
mController.updateState(mPreference);
- assertThat(mPreference.getSummary()).isEqualTo(Build.VERSION.RELEASE);
+ assertThat(mPreference.getSummary()).isEqualTo(Build.VERSION.RELEASE_OR_CODENAME);
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/RemoteVolumeGroupControllerTest.java b/tests/robotests/src/com/android/settings/notification/RemoteVolumeGroupControllerTest.java
new file mode 100644
index 0000000..d81f30f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/RemoteVolumeGroupControllerTest.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
+import com.android.settings.widget.SeekBarPreference;
+import com.android.settingslib.media.LocalMediaManager;
+import com.android.settingslib.media.MediaDevice;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowBluetoothAdapter.class})
+public class RemoteVolumeGroupControllerTest {
+
+ private static final String KEY_REMOTE_VOLUME_GROUP = "remote_media_group";
+ private static final String TEST_PACKAGE_LABEL = "music";
+ private static final String TEST_DEVICE_1_ID = "test_device_1_id";
+ private static final String TEST_DEVICE_1_NAME = "test_device_1_name";
+ private static final int CURRENT_VOLUME = 30;
+ private static final int MAX_VOLUME = 100;
+
+ @Mock
+ private LocalMediaManager mLocalMediaManager;
+ @Mock
+ private MediaDevice mDevice;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private PreferenceManager mPreferenceManager;
+ @Mock
+ private SharedPreferences mSharedPreferences;
+
+ private final List<MediaDevice> mDevices = new ArrayList<>();
+
+ private Context mContext;
+ private RemoteVolumeGroupController mController;
+ private PreferenceCategory mPreferenceCategory;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new RemoteVolumeGroupController(mContext, KEY_REMOTE_VOLUME_GROUP);
+ mController.mLocalMediaManager = mLocalMediaManager;
+ mPreferenceCategory = spy(new PreferenceCategory(mContext));
+ mPreferenceCategory.setKey(mController.getPreferenceKey());
+
+ when(mPreferenceCategory.getPreferenceManager()).thenReturn(mPreferenceManager);
+ when(mPreferenceManager.getSharedPreferences()).thenReturn(mSharedPreferences);
+ when(mLocalMediaManager.getActiveMediaDevice(
+ MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE)).thenReturn(mDevices);
+ when(mDevice.getId()).thenReturn(TEST_DEVICE_1_ID);
+ when(mDevice.getName()).thenReturn(TEST_DEVICE_1_NAME);
+ when(mDevice.getMaxVolume()).thenReturn(MAX_VOLUME);
+ when(mDevice.getCurrentVolume()).thenReturn(CURRENT_VOLUME);
+ when(mDevice.getClientAppLabel()).thenReturn(TEST_PACKAGE_LABEL);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(
+ mPreferenceCategory);
+ }
+
+ @Test
+ public void getAvailabilityStatus_withActiveDevice_returnAvailableUnsearchable() {
+ mDevices.add(mDevice);
+ mController.displayPreference(mScreen);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_noActiveDevice_returnConditionallyUnavailable() {
+ mController.displayPreference(mScreen);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void displayPreference_noActiveDevice_checkPreferenceCount() {
+ mController.displayPreference(mScreen);
+
+ assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(0);
+ }
+
+ @Test
+ public void displayPreference_withActiveDevice_checkPreferenceCount() {
+ mDevices.add(mDevice);
+ mController.displayPreference(mScreen);
+
+ assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(2);
+ }
+
+ @Test
+ public void displayPreference_withActiveDevice_checkSeekBarTitle() {
+ mDevices.add(mDevice);
+ mController.displayPreference(mScreen);
+ final Preference preference = mPreferenceCategory.findPreference(TEST_DEVICE_1_ID);
+
+ assertThat(preference.getTitle()).isEqualTo(mContext.getText(
+ R.string.remote_media_volume_option_title) + " (" + TEST_PACKAGE_LABEL + ")");
+ }
+
+ @Test
+ public void displayPreference_withActiveDevice_checkSeekBarMaxVolume() {
+ mDevices.add(mDevice);
+ mController.displayPreference(mScreen);
+ final SeekBarPreference preference = mPreferenceCategory.findPreference(TEST_DEVICE_1_ID);
+
+ assertThat(preference.getMax()).isEqualTo(MAX_VOLUME);
+ }
+
+ @Test
+ public void displayPreference_withActiveDevice_checkSeekBarCurrentVolume() {
+ mDevices.add(mDevice);
+ mController.displayPreference(mScreen);
+ final SeekBarPreference preference = mPreferenceCategory.findPreference(TEST_DEVICE_1_ID);
+
+ assertThat(preference.getProgress()).isEqualTo(CURRENT_VOLUME);
+ }
+
+ @Test
+ public void displayPreference_withActiveDevice_checkSwitcherPreferenceTitle() {
+ mDevices.add(mDevice);
+ mController.displayPreference(mScreen);
+ final Preference preference = mPreferenceCategory.findPreference(
+ RemoteVolumeGroupController.SWITCHER_PREFIX + TEST_DEVICE_1_ID);
+
+ assertThat(preference.getTitle()).isEqualTo(mContext.getText(R.string.media_output_title));
+ }
+
+ @Test
+ public void displayPreference_withActiveDevice_checkSwitcherPreferenceSummary() {
+ mDevices.add(mDevice);
+ mController.displayPreference(mScreen);
+ final Preference preference = mPreferenceCategory.findPreference(
+ RemoteVolumeGroupController.SWITCHER_PREFIX + TEST_DEVICE_1_ID);
+
+ assertThat(preference.getSummary()).isEqualTo(TEST_DEVICE_1_NAME);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/AddToHomeScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/AddToHomeScreenPreferenceControllerTest.java
new file mode 100644
index 0000000..342f3ad
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/AddToHomeScreenPreferenceControllerTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.content.pm.ShortcutInfo;
+
+import androidx.preference.Preference;
+
+import com.android.settings.notification.NotificationBackend;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class AddToHomeScreenPreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationBackend mBackend;
+
+ private AddToHomeScreenPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mController = new AddToHomeScreenPreferenceController(mContext, mBackend);
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(Preference.class));
+ }
+
+ @Test
+ public void testIsAvailable_notIfNull() {
+ mController.onResume(null, null, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, si, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testHandlePreferenceTreeClick() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, si, null);
+
+ Preference pref = new Preference(RuntimeEnvironment.application);
+ pref.setKey("add_to_home");
+ mController.handlePreferenceTreeClick(pref);
+
+ verify(mBackend).requestPinShortcut(any(), eq(si));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
index d829286..e121cfe 100644
--- a/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/AllowSoundPreferenceControllerTest.java
@@ -92,10 +92,10 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, mock(NotificationChannel.class), null, null);
+ mController.onResume(null, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
- mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -103,7 +103,7 @@
public void testIsAvailable_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -112,7 +112,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something new");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -122,7 +122,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -130,7 +130,7 @@
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext);
@@ -145,7 +145,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("");
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -158,7 +158,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -170,7 +170,7 @@
public void testUpdateState_checkedForHighImportanceChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -181,7 +181,7 @@
public void testUpdateState_checkedForUnspecifiedImportanceChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_UNSPECIFIED);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -192,7 +192,7 @@
public void testUpdateState_notCheckedForLowImportanceChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -203,7 +203,7 @@
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -220,7 +220,7 @@
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java
index c48f142..41aeacb 100644
--- a/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/AppLinkPreferenceControllerTest.java
@@ -36,7 +36,6 @@
import androidx.preference.Preference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.AppLinkPreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -76,7 +75,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -84,7 +83,7 @@
public void testIsAvailable_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -93,7 +92,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -103,7 +102,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -114,7 +113,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -123,7 +122,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
Intent intent = new Intent("action");
appRow.settingsIntent = intent;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java
index 5dfd393..277e6b2 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BadgePreferenceControllerTest.java
@@ -44,7 +44,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.BadgePreferenceController;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -94,7 +93,7 @@
public void testIsAvailable_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -103,7 +102,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -113,7 +112,7 @@
appRow.showBadge = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -123,7 +122,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 0);
assertFalse(mController.isAvailable());
@@ -132,7 +131,7 @@
@Test
public void testIsAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertTrue(mController.isAvailable());
@@ -145,7 +144,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertTrue(mController.isAvailable());
@@ -157,7 +156,7 @@
appRow.showBadge = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertTrue(mController.isAvailable());
@@ -169,7 +168,7 @@
appRow.showBadge = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BADGING, 1);
assertFalse(mController.isAvailable());
@@ -180,7 +179,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null,
- mock(RestrictedLockUtils.EnforcedAdmin.class));
+ null, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -194,7 +193,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("");
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -207,7 +206,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canShowBadge()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -215,7 +214,7 @@
assertTrue(pref.isChecked());
when(channel.canShowBadge()).thenReturn(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(pref);
assertFalse(pref.isChecked());
@@ -225,14 +224,14 @@
public void testUpdateState_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.showBadge = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
assertTrue(pref.isChecked());
appRow.showBadge = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(pref);
assertFalse(pref.isChecked());
@@ -245,7 +244,7 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
channel.setShowBadge(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -264,7 +263,7 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
channel.setShowBadge(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -280,7 +279,7 @@
public void testOnPreferenceChange_on_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.showBadge = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -297,7 +296,7 @@
public void testOnPreferenceChange_off_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.showBadge = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
index d819a18..e73ee5a 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BlockPreferenceControllerTest.java
@@ -45,8 +45,6 @@
import com.android.settings.R;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.BlockPreferenceController;
-import com.android.settings.notification.app.NotificationSettings;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.widget.LayoutPreference;
@@ -99,7 +97,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -109,7 +107,7 @@
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -119,7 +117,7 @@
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -129,7 +127,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -137,7 +135,7 @@
public void testIsAvailable_GroupNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null);
+ mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null);
assertTrue(mController.isAvailable());
}
@@ -145,7 +143,7 @@
public void testIsAvailable_AppNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -155,7 +153,7 @@
appRow.systemApp = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -165,7 +163,7 @@
appRow.systemApp = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -174,7 +172,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedImportance = true;
appRow.systemApp = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isEnabled());
}
@@ -183,7 +181,7 @@
public void testIsEnabled_GroupNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null);
+ mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isEnabled());
}
@@ -192,7 +190,7 @@
public void testIsEnabled_systemAppNotBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isEnabled());
}
@@ -203,7 +201,7 @@
appRow.systemApp = true;
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
channel.setBlockableSystem(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
assertTrue(mSwitch.isEnabled());
}
@@ -214,7 +212,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
@@ -227,7 +225,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
@@ -239,7 +237,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
@@ -249,7 +247,7 @@
@Test
public void testIsEnabled_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(mPreference);
@@ -260,7 +258,7 @@
public void testUpdateState_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(mPreference);
assertNotNull(mPreference.findViewById(R.id.switch_bar));
@@ -268,7 +266,7 @@
assertFalse(mSwitch.isChecked());
appRow.banned = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(mPreference);
assertTrue(mSwitch.isChecked());
@@ -279,20 +277,20 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isChecked());
appRow.banned = true;
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
when(group.isBlocked()).thenReturn(true);
mController.updateState(mPreference);
assertFalse(mSwitch.isChecked());
appRow.banned = false;
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
when(group.isBlocked()).thenReturn(false);
mController.updateState(mPreference);
@@ -303,21 +301,21 @@
public void testUpdateState_channelBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isChecked());
appRow.banned = true;
channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isChecked());
appRow.banned = false;
channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
assertTrue(mSwitch.isChecked());
@@ -327,7 +325,7 @@
public void testUpdateState_noCrashIfCalledTwice() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
mController.updateState(mPreference);
}
@@ -336,7 +334,7 @@
public void testUpdateState_doesNotResetImportance() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
assertEquals(IMPORTANCE_LOW, channel.getImportance());
@@ -349,7 +347,7 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_UNSPECIFIED);
when(mBackend.onlyHasDefaultChannel(anyString(), anyInt())).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
mController.onSwitchChanged(null, false);
@@ -370,7 +368,7 @@
public void testOnSwitchChanged_channel_nonDefault() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(mPreference);
mController.onSwitchChanged(null, false);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java
index 5fd5123..404625e 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BubblePreferenceControllerTest.java
@@ -45,7 +45,6 @@
import android.provider.Settings;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.BubblePreferenceController;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -108,7 +107,7 @@
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -118,7 +117,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -129,7 +128,7 @@
appRow.allowBubbles = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -137,7 +136,7 @@
@Test
public void testIsNotAvailable_ifOffGlobally_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
@@ -149,7 +148,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
@@ -159,7 +158,7 @@
@Test
public void testIsAvailable_app_evenIfOffGlobally() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mAppPageController.onResume(appRow, null, null, null);
+ mAppPageController.onResume(appRow, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF);
@@ -169,7 +168,7 @@
@Test
public void testIsAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -182,7 +181,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -194,7 +193,7 @@
appRow.allowBubbles = true;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -206,7 +205,7 @@
appRow.allowBubbles = false;
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertFalse(mController.isAvailable());
@@ -217,7 +216,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null,
- mock(RestrictedLockUtils.EnforcedAdmin.class));
+ null, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -231,7 +230,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -245,7 +244,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canBubble()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -253,7 +252,7 @@
assertTrue(pref.isChecked());
when(channel.canBubble()).thenReturn(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.updateState(pref);
assertFalse(pref.isChecked());
@@ -265,14 +264,14 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "App!";
appRow.allowBubbles = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
assertTrue(pref.isChecked());
appRow.allowBubbles = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
mController.updateState(pref);
assertFalse(pref.isChecked());
@@ -288,7 +287,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "App!";
appRow.allowBubbles = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -303,7 +302,7 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
channel.setAllowBubbles(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -323,7 +322,7 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
channel.setAllowBubbles(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -340,7 +339,7 @@
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -358,7 +357,7 @@
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -377,7 +376,7 @@
SYSTEM_WIDE_OFF);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java
index 1bd9600..80abfbb 100644
--- a/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/BubbleSummaryPreferenceControllerTest.java
@@ -40,7 +40,6 @@
import android.provider.Settings;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.BubbleSummaryPreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -80,7 +79,7 @@
public void testIsAvailable_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -89,7 +88,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
SYSTEM_WIDE_OFF);
@@ -99,7 +98,7 @@
@Test
public void testIsAvailable_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -108,7 +107,7 @@
@Test
public void testIsNotAvailable_app_globalOff() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
SYSTEM_WIDE_OFF);
@@ -122,7 +121,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
assertTrue(mController.isAvailable());
@@ -132,7 +131,7 @@
public void testUpdateState() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Preference pref = new Preference(mContext);
mController.updateState(pref);
@@ -144,7 +143,7 @@
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.allowBubbles = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertEquals("On", mController.getSummary());
@@ -154,7 +153,7 @@
Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, SYSTEM_WIDE_ON);
appRow.allowBubbles = false;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertEquals("Off", mController.getSummary());
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationDemotePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationDemotePreferenceControllerTest.java
new file mode 100644
index 0000000..89007f0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationDemotePreferenceControllerTest.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationChannel;
+import android.content.Context;
+
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.Preference;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.notification.NotificationBackend;
+
+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.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(RobolectricTestRunner.class)
+public class ConversationDemotePreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationBackend mBackend;
+ @Mock
+ SettingsPreferenceFragment mFragment;
+
+ private ConversationDemotePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ mContext = RuntimeEnvironment.application;
+ when(mFragment.getActivity()).thenReturn(mock(FragmentActivity.class));
+ mController = spy(new ConversationDemotePreferenceController(
+ mContext, mFragment, mBackend));
+
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(Preference.class));
+ mController.handlePreferenceTreeClick(mock(Preference.class));
+ }
+
+ @Test
+ public void testIsAvailable_notConversation() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_conversation_demoted() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(true);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_conversation_notDemoted() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(false);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testHandlePreferenceClick() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(false);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ Preference pref = mock(Preference.class);
+ when(pref.getKey()).thenReturn("demote");
+ assertTrue(mController.handlePreferenceTreeClick(pref));
+
+ ArgumentCaptor<NotificationChannel> captor =
+ ArgumentCaptor.forClass(NotificationChannel.class);
+
+ verify(mBackend).updateChannel(eq(null), anyInt(), captor.capture());
+ assertTrue(captor.getValue().isDemoted());
+
+ verify(mFragment).getActivity();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java
new file mode 100644
index 0000000..96f4e0b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import static android.app.NotificationManager.IMPORTANCE_NONE;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationChannel;
+import android.app.NotificationChannelGroup;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.content.pm.ShortcutInfo;
+import android.os.UserManager;
+import android.view.View;
+
+import androidx.fragment.app.FragmentActivity;
+
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.widget.LayoutPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(RobolectricTestRunner.class)
+public class ConversationHeaderPreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationManager mNm;
+ @Mock
+ private UserManager mUm;
+
+ private ConversationHeaderPreferenceController mController;
+ @Mock
+ private LayoutPreference mPreference;
+ @Mock
+ private View mView;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
+ shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
+ mContext = RuntimeEnvironment.application;
+ DashboardFragment fragment = mock(DashboardFragment.class);
+ when(fragment.getContext()).thenReturn(mContext);
+ FragmentActivity activity = mock(FragmentActivity.class);
+ when(activity.getApplicationContext()).thenReturn(mContext);
+ when(fragment.getActivity()).thenReturn(activity);
+ mController = spy(new ConversationHeaderPreferenceController(mContext, fragment));
+ when(mPreference.findViewById(anyInt())).thenReturn(mView);
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(LayoutPreference.class));
+ }
+
+ @Test
+ public void testIsAvailable_notIfNull() {
+ mController.onResume(null, null, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.banned = true;
+ mController.onResume(appRow, null, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testGetLabel() {
+ ShortcutInfo si = mock(ShortcutInfo.class);
+ when(si.getShortLabel()).thenReturn("hello");
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ mController.onResume(appRow, null, null, null, si, null);
+ assertEquals(si.getShortLabel(), mController.getLabel());
+
+ NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertEquals(channel.getName(), mController.getLabel());
+ }
+
+ @Test
+ public void testGetSummary() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.label = "bananas";
+ mController.onResume(appRow, null, null, null, null, null);
+ assertEquals("", mController.getSummary());
+
+ NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
+ mController.onResume(appRow, null, group, null, null, null);
+ assertEquals(appRow.label, mController.getSummary());
+
+ NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
+ mController.onResume(appRow, channel, group, null, null, null);
+ assertTrue(mController.getSummary().toString().contains(group.getName()));
+ assertTrue(mController.getSummary().toString().contains(appRow.label));
+
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.getSummary().toString().contains(group.getName()));
+ assertTrue(mController.getSummary().toString().contains(appRow.label));
+
+ NotificationChannel defaultChannel = new NotificationChannel(
+ NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
+ mController.onResume(appRow, defaultChannel, null, null, null, null);
+ assertEquals("", mController.getSummary());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationImportantPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationImportantPreferenceControllerTest.java
new file mode 100644
index 0000000..d1dd0a6
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationImportantPreferenceControllerTest.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.os.UserManager;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(RobolectricTestRunner.class)
+public class ConversationImportantPreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationBackend mBackend;
+ @Mock
+ private NotificationManager mNm;
+ @Mock
+ private UserManager mUm;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private PreferenceScreen mScreen;
+
+ private ConversationImportantPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
+ shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
+ mContext = RuntimeEnvironment.application;
+ mController = spy(new ConversationImportantPreferenceController(mContext, mBackend));
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(Preference.class));
+ mController.onPreferenceChange(mock(Preference.class), true);
+ }
+
+ @Test
+ public void testIsAvailable_notChannelNull() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ mController.onResume(appRow, null, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testUpdateState_disabledByAdmin() {
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getId()).thenReturn("something");
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
+ RestrictedLockUtils.EnforcedAdmin.class));
+
+ Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
+ mController.updateState(pref);
+
+ assertFalse(pref.isEnabled());
+ }
+
+ @Test
+ public void testUpdateState() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setImportantConversation(true);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref =
+ new RestrictedSwitchPreference(RuntimeEnvironment.application);
+ mController.updateState(pref);
+
+ assertTrue(pref.isChecked());
+
+ channel.setImportantConversation(false);
+ mController.onResume(appRow, channel, null, null, null, null);
+ mController.updateState(pref);
+ assertFalse(pref.isChecked());
+ }
+
+ @Test
+ public void testOnPreferenceChange_on() {
+ NotificationChannel channel =
+ new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_DEFAULT);
+ channel.setImportantConversation(false);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref =
+ new RestrictedSwitchPreference(RuntimeEnvironment.application);
+ mController.updateState(pref);
+
+ mController.onPreferenceChange(pref, true);
+
+ assertTrue(channel.isImportantConversation());
+ verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
+ }
+
+ @Test
+ public void testOnPreferenceChange_off() {
+ NotificationChannel channel =
+ new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
+ channel.setImportantConversation(true);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref =
+ new RestrictedSwitchPreference(RuntimeEnvironment.application);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
+ mController.displayPreference(mScreen);
+ mController.updateState(pref);
+
+ mController.onPreferenceChange(pref, false);
+
+ assertFalse(channel.isImportantConversation());
+ verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java
new file mode 100644
index 0000000..725be3d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.notification.app;
+
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationChannel;
+import android.content.Context;
+
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.Preference;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.notification.NotificationBackend;
+
+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.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(RobolectricTestRunner.class)
+public class ConversationPromotePreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationBackend mBackend;
+ @Mock
+ SettingsPreferenceFragment mFragment;
+
+ private ConversationPromotePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ mContext = RuntimeEnvironment.application;
+ when(mFragment.getActivity()).thenReturn(mock(FragmentActivity.class));
+ mController = spy(new ConversationPromotePreferenceController(
+ mContext, mFragment, mBackend));
+
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(Preference.class));
+ mController.handlePreferenceTreeClick(mock(Preference.class));
+ }
+
+ @Test
+ public void testIsAvailable_notConversation() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_conversation_notDemoted() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_conversation_demoted() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(true);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testHandlePreferenceClick() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ channel.setConversationId("a", "a");
+ channel.setDemoted(true);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ Preference pref = mock(Preference.class);
+ when(pref.getKey()).thenReturn("convo_promote");
+ assertTrue(mController.handlePreferenceTreeClick(pref));
+
+ ArgumentCaptor<NotificationChannel> captor =
+ ArgumentCaptor.forClass(NotificationChannel.class);
+
+ verify(mBackend).updateChannel(eq(null), anyInt(), captor.capture());
+ assertFalse(captor.getValue().isDemoted());
+
+ verify(mFragment).getActivity();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/DefaultImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/DefaultImportancePreferenceControllerTest.java
new file mode 100644
index 0000000..dc2303f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/app/DefaultImportancePreferenceControllerTest.java
@@ -0,0 +1,246 @@
+/*
+ * Copyright (C) 2017 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.notification.app;
+
+import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+import static android.app.NotificationManager.IMPORTANCE_LOW;
+import static android.app.NotificationManager.IMPORTANCE_NONE;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+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.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.os.UserManager;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.notification.NotificationBackend;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedSwitchPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+
+@RunWith(RobolectricTestRunner.class)
+public class DefaultImportancePreferenceControllerTest {
+
+ private Context mContext;
+ @Mock
+ private NotificationManager mNm;
+ @Mock
+ private NotificationBackend mBackend;
+ @Mock
+ private NotificationSettings.ImportanceListener mImportanceListener;
+ @Mock
+ private UserManager mUm;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private PreferenceScreen mScreen;
+
+ private DefaultImportancePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
+ shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
+ mContext = RuntimeEnvironment.application;
+ mController = spy(new DefaultImportancePreferenceController(
+ mContext, mImportanceListener, mBackend));
+ }
+
+ @Test
+ public void testNoCrashIfNoOnResume() {
+ mController.isAvailable();
+ mController.updateState(mock(Preference.class));
+ }
+
+ @Test
+ public void testIsAvailable_notIfNull() {
+ mController.onResume(null, null, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_ifAppBlocked() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.banned = true;
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_notIfChannelBlocked() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable_notForDefaultChannel() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertFalse(mController.isAvailable());
+ }
+
+ @Test
+ public void testIsAvailable() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null);
+ assertTrue(mController.isAvailable());
+ }
+
+ @Test
+ public void testUpdateState_disabledByAdmin() {
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
+ RestrictedLockUtils.EnforcedAdmin.class));
+
+ Preference pref = new RestrictedSwitchPreference(mContext, null);
+ mController.updateState(pref);
+
+ assertFalse(pref.isEnabled());
+ }
+
+ @Test
+ public void testUpdateState_notConfigurable() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.isImportanceLockedByOEM()).thenReturn(true);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ Preference pref = new RestrictedSwitchPreference(mContext, null);
+ mController.updateState(pref);
+
+ assertFalse(pref.isEnabled());
+ }
+
+ @Test
+ public void testUpdateState_systemButConfigurable() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.systemApp = true;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.isImportanceLockedByOEM()).thenReturn(false);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ Preference pref = new RestrictedSwitchPreference(mContext, null);
+ mController.updateState(pref);
+
+ assertTrue(pref.isEnabled());
+ }
+
+ @Test
+ public void testUpdateState_defaultApp() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ appRow.systemApp = true;
+ NotificationChannel channel = mock(NotificationChannel.class);
+ when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
+ when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ Preference pref = new RestrictedSwitchPreference(mContext, null);
+ mController.updateState(pref);
+
+ assertTrue(pref.isEnabled());
+ }
+
+ @Test
+ public void testUpdateState_default() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
+ mController.updateState(pref);
+
+ assertTrue(pref.isChecked());
+ }
+
+ @Test
+ public void testUpdateState_low() {
+ NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+ NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
+ mController.onResume(appRow, channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
+ mController.updateState(pref);
+
+ assertFalse(pref.isChecked());
+ }
+
+ @Test
+ public void onPreferenceChange_onToOff() {
+ NotificationChannel channel =
+ new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext, null);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
+ mController.displayPreference(mScreen);
+ mController.updateState(pref);
+
+ mController.onPreferenceChange(pref, false);
+
+ assertEquals(IMPORTANCE_LOW, channel.getImportance());
+ verify(mImportanceListener, times(1)).onImportanceChanged();
+ }
+
+ @Test
+ public void onPreferenceChange_offToOn() {
+ NotificationChannel channel =
+ new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
+
+ RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext, null);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
+ mController.displayPreference(mScreen);
+ mController.updateState(pref);
+
+ mController.onPreferenceChange(pref, true);
+
+ assertEquals(IMPORTANCE_DEFAULT, channel.getImportance());
+ verify(mImportanceListener, times(1)).onImportanceChanged();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java
index c2868ce..5515a55 100644
--- a/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/DeletedChannelsPreferenceControllerTest.java
@@ -35,7 +35,6 @@
import androidx.preference.Preference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.DeletedChannelsPreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -80,42 +79,43 @@
public void isAvailable_appScreen_notIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_groupScreen_never() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null);
+ mController.onResume(appRow, null, mock(NotificationChannelGroup.class), null, null, null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_channelScreen_never() {
mController.onResume(
- new NotificationBackend.AppRow(), mock(NotificationChannel.class), null, null);
+ new NotificationBackend.AppRow(), mock(NotificationChannel.class), null, null, null,
+ null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_appScreen_notIfNoDeletedChannels() {
when(mBackend.getDeletedChannelCount(any(), anyInt())).thenReturn(0);
- mController.onResume(new NotificationBackend.AppRow(), null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@Test
public void isAvailable_appScreen() {
when(mBackend.getDeletedChannelCount(any(), anyInt())).thenReturn(1);
- mController.onResume(new NotificationBackend.AppRow(), null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@Test
public void updateState() {
when(mBackend.getDeletedChannelCount(any(), anyInt())).thenReturn(1);
- mController.onResume(new NotificationBackend.AppRow(), null, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), null, null, null, null, null);
Preference pref = mock(Preference.class);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java
index e078e58..3e37327 100644
--- a/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/DescriptionPreferenceControllerTest.java
@@ -35,7 +35,6 @@
import androidx.preference.Preference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.DescriptionPreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -75,7 +74,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -83,7 +82,7 @@
public void testIsAvailable_notIfChannelGroupBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -92,7 +91,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -101,7 +100,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -109,7 +108,7 @@
public void testIsAvailable_notIfNoChannelGroupDesc() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -119,7 +118,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getDescription()).thenReturn("AAA");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -129,7 +128,7 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.getDescription()).thenReturn("something");
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -139,7 +138,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getDescription()).thenReturn("AAA");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -154,7 +153,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.getDescription()).thenReturn("something");
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java
index 2f1b913..4220bed 100644
--- a/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/DndPreferenceControllerTest.java
@@ -41,7 +41,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.DndPreferenceController;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -84,7 +83,7 @@
public void testIsAvailable_app() {
when(mNm.getNotificationPolicy()).thenReturn(new NotificationManager.Policy(0, 0, 0, 0));
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -94,7 +93,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_MIN);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -102,7 +101,7 @@
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -116,7 +115,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -129,7 +128,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -141,7 +140,7 @@
public void testUpdateState_bypassDnd() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canBypassDnd()).thenReturn(true);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -153,7 +152,7 @@
public void testUpdateState_noBypassDnd() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.canBypassDnd()).thenReturn(false);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -165,7 +164,7 @@
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -183,7 +182,7 @@
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
index 7b8ad48..c4e94a9 100644
--- a/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java
@@ -37,7 +37,6 @@
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.HeaderPreferenceController;
import com.android.settingslib.widget.LayoutPreference;
import org.junit.Before;
@@ -88,7 +87,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -96,7 +95,7 @@
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -104,20 +103,20 @@
public void testGetLabel() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "bananas";
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertEquals(appRow.label, mController.getLabel());
NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertEquals(group.getName(), mController.getLabel());
NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
assertEquals(channel.getName(), mController.getLabel());
NotificationChannel defaultChannel = new NotificationChannel(
NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
- mController.onResume(appRow, defaultChannel, null, null);
+ mController.onResume(appRow, defaultChannel, null, null, null, null);
assertEquals(appRow.label, mController.getLabel());
}
@@ -125,25 +124,25 @@
public void testGetSummary() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.label = "bananas";
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertEquals("", mController.getSummary());
NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertEquals(appRow.label, mController.getSummary());
NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
assertTrue(mController.getSummary().toString().contains(group.getName()));
assertTrue(mController.getSummary().toString().contains(appRow.label));
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.getSummary().toString().contains(group.getName()));
assertTrue(mController.getSummary().toString().contains(appRow.label));
NotificationChannel defaultChannel = new NotificationChannel(
NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
- mController.onResume(appRow, defaultChannel, null, null);
+ mController.onResume(appRow, defaultChannel, null, null, null, null);
assertEquals("", mController.getSummary());
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java
index bed6ccc..8dc7421 100644
--- a/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/HighImportancePreferenceControllerTest.java
@@ -36,8 +36,6 @@
import android.os.UserManager;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.HighImportancePreferenceController;
-import com.android.settings.notification.app.NotificationSettings;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -90,7 +88,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -98,7 +96,7 @@
public void testIsAvailable_ifAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -107,7 +105,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -117,7 +115,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -126,7 +124,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -134,7 +132,7 @@
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext, null);
@@ -149,7 +147,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -164,7 +162,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -179,7 +177,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -191,7 +189,7 @@
public void testUpdateState_high() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -203,7 +201,7 @@
public void testUpdateState_default() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -215,7 +213,7 @@
public void onPreferenceChange() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java
index b8fc6c4..2c7e17f 100644
--- a/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/ImportancePreferenceControllerTest.java
@@ -46,9 +46,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.ImportancePreference;
-import com.android.settings.notification.app.ImportancePreferenceController;
-import com.android.settings.notification.app.NotificationSettings;
import com.android.settingslib.RestrictedLockUtils;
import org.junit.Before;
@@ -97,7 +94,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -105,7 +102,7 @@
public void testIsAvailable_ifAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -116,7 +113,7 @@
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -125,7 +122,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -135,7 +132,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -144,7 +141,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -152,7 +149,7 @@
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new ImportancePreference(mContext, null);
@@ -167,7 +164,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new ImportancePreference(mContext, null);
mController.updateState(pref);
@@ -182,7 +179,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new ImportancePreference(mContext, null);
mController.updateState(pref);
@@ -197,7 +194,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new ImportancePreference(mContext, null);
mController.updateState(pref);
@@ -209,7 +206,7 @@
public void testUpdateState() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
ImportancePreference pref = mock(ImportancePreference.class);
mController.updateState(pref);
@@ -224,7 +221,7 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
channel.setSound(null, Notification.AUDIO_ATTRIBUTES_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
ImportancePreference pref = new ImportancePreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -242,7 +239,7 @@
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
channel.setSound(null, Notification.AUDIO_ATTRIBUTES_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
ImportancePreference pref = new ImportancePreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java
index 547880e..4f3b496 100644
--- a/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/LightsPreferenceControllerTest.java
@@ -42,7 +42,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.LightsPreferenceController;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -108,7 +107,7 @@
com.android.internal.R.bool.config_intrusiveNotificationLed, false);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -117,7 +116,7 @@
Settings.System.putInt(mContext.getContentResolver(), NOTIFICATION_LIGHT_PULSE, 0);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -125,7 +124,7 @@
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -134,7 +133,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -142,7 +141,7 @@
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -151,7 +150,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
mController.onResume(new NotificationBackend.AppRow(), channel, null,
- mock(RestrictedLockUtils.EnforcedAdmin.class));
+ null, null, mock(RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -164,7 +163,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -176,7 +175,7 @@
public void testUpdateState_lightsOn() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldShowLights()).thenReturn(true);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -187,7 +186,7 @@
public void testUpdateState_lightsOff() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldShowLights()).thenReturn(false);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -198,7 +197,7 @@
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
@@ -215,7 +214,7 @@
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(mContext);
diff --git a/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java
index 2a06fa8..bed12af 100644
--- a/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/MinImportancePreferenceControllerTest.java
@@ -36,8 +36,6 @@
import android.os.UserManager;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.MinImportancePreferenceController;
-import com.android.settings.notification.app.NotificationSettings;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -90,7 +88,7 @@
@Test
public void testIsAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -98,7 +96,7 @@
public void testIsAvailable_ifAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, mock(NotificationChannel.class), null, null);
+ mController.onResume(appRow, mock(NotificationChannel.class), null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -107,7 +105,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -117,7 +115,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.getId()).thenReturn(DEFAULT_CHANNEL_ID);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -126,7 +124,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -134,7 +132,7 @@
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(mContext, null);
@@ -149,7 +147,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -164,7 +162,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -179,7 +177,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(mContext, null);
mController.updateState(pref);
@@ -191,7 +189,7 @@
public void testUpdateState_min() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_MIN);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -203,7 +201,7 @@
public void testUpdateState_low() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext);
mController.updateState(pref);
@@ -215,7 +213,7 @@
public void onPreferenceChange() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref = new RestrictedSwitchPreference(mContext, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
index 6a6818f..170a5e0 100644
--- a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java
@@ -42,7 +42,6 @@
import androidx.preference.Preference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.NotificationPreferenceController;
import com.android.settingslib.RestrictedLockUtils;
import org.junit.Before;
@@ -91,7 +90,7 @@
@Test
public void isAvailable_notIfNull() {
- mController.onResume(null, null, null, null);
+ mController.onResume(null, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -100,7 +99,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
mController.onResume(appRow, mock(NotificationChannel.class),
- mock(NotificationChannelGroup.class), null);
+ mock(NotificationChannelGroup.class), null, null, null);
assertFalse(mController.isAvailable());
}
@@ -112,7 +111,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -123,7 +122,7 @@
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
when(group.isBlocked()).thenReturn(true);
assertFalse(mController.isAvailable());
}
@@ -136,7 +135,7 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, channel, group, null);
+ mController.onResume(appRow, channel, group, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -147,7 +146,7 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
RestrictedLockUtils.EnforcedAdmin admin = mock(RestrictedLockUtils.EnforcedAdmin.class);
- mController.onResume(appRow, channel, group, admin);
+ mController.onResume(appRow, channel, group, null, null, admin);
assertEquals(appRow, mController.mAppRow);
assertEquals(channel, mController.mChannel);
@@ -161,7 +160,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_UNSPECIFIED);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.checkCanBeVisible(IMPORTANCE_MIN));
}
@@ -171,7 +170,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.checkCanBeVisible(IMPORTANCE_LOW));
}
@@ -181,7 +180,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.checkCanBeVisible(IMPORTANCE_MIN));
}
@@ -191,7 +190,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.checkCanBeVisible(IMPORTANCE_DEFAULT));
}
@@ -201,7 +200,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
mController.saveChannel();
verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
}
@@ -213,11 +212,11 @@
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isChannelBlockable());
when(channel.isImportanceLockedByOEM()).thenReturn(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -228,7 +227,7 @@
when(channel.getImportance()).thenReturn(IMPORTANCE_LOW);
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -239,7 +238,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isBlockableSystem()).thenReturn(false);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -251,7 +250,7 @@
when(channel.isBlockableSystem()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -262,7 +261,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isBlockableSystem()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -274,7 +273,7 @@
when(channel.isBlockableSystem()).thenReturn(false);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isChannelBlockable());
}
@@ -285,7 +284,7 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertTrue(mController.isChannelGroupBlockable());
}
@@ -297,7 +296,7 @@
when(channel.isImportanceLockedByOEM()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -309,7 +308,7 @@
when(channel.isImportanceLockedByCriticalDeviceFunction()).thenReturn(true);
when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isChannelBlockable());
}
@@ -320,7 +319,7 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(false);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertFalse(mController.isChannelGroupBlockable());
}
@@ -331,13 +330,13 @@
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertTrue(mController.isChannelGroupBlockable());
}
@Test
public void testIsDefaultChannel_noChannel() {
- mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null, null, null);
assertFalse(mController.isDefaultChannel());
}
@@ -345,7 +344,7 @@
@Test
public void testIsDefaultChannel_nonDefaultChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null, null, null);
assertFalse(mController.isDefaultChannel());
}
@@ -354,7 +353,7 @@
public void testIsDefaultChannel() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn(NotificationChannel.DEFAULT_CHANNEL_ID);
- mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null);
+ mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null, null, null);
assertTrue(mController.isDefaultChannel());
}
diff --git a/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java
index 6dd71a3..cfbe5f7 100644
--- a/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/NotificationsOffPreferenceControllerTest.java
@@ -33,7 +33,6 @@
import androidx.preference.Preference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.NotificationsOffPreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -73,7 +72,7 @@
public void testIsAvailable_yesIfAppBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertThat(mController.isAvailable()).isTrue();
}
@@ -82,7 +81,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
assertThat(mController.isAvailable()).isTrue();
}
@@ -91,7 +90,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertThat(mController.isAvailable()).isTrue();
}
@@ -100,7 +99,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -114,7 +113,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
- mController.onResume(appRow, null, group, null);
+ mController.onResume(appRow, null, group, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -127,7 +126,7 @@
public void testUpdateState_app() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.banned = true;
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
Preference pref = new Preference(RuntimeEnvironment.application);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java
index ba4b5f0..157e666 100644
--- a/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/SoundPreferenceControllerTest.java
@@ -108,7 +108,7 @@
@Test
public void testIsAvailable_notIfChannelNull() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
- mController.onResume(appRow, null, null, null);
+ mController.onResume(appRow, null, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -116,7 +116,7 @@
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -125,7 +125,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -133,7 +133,7 @@
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -151,7 +151,7 @@
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
@@ -166,7 +166,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
Preference pref = new NotificationSoundPreference(mContext, attributeSet);
@@ -182,7 +182,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
when(channel.getSound()).thenReturn(sound);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref = new NotificationSoundPreference(mContext, attributeSet);
@@ -198,7 +198,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(sound, Notification.AUDIO_ATTRIBUTES_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
@@ -238,7 +238,7 @@
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(null, new AudioAttributes.Builder().setUsage(
AudioAttributes.USAGE_ALARM).build());
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
@@ -259,7 +259,7 @@
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(null, new AudioAttributes.Builder().setUsage(
AudioAttributes.USAGE_NOTIFICATION_RINGTONE).build());
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
@@ -280,7 +280,7 @@
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
channel.setSound(null, new AudioAttributes.Builder().setUsage(
AudioAttributes.USAGE_UNKNOWN).build());
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
NotificationSoundPreference pref =
diff --git a/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java
index 38d4dce..06a319f 100644
--- a/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/VibrationPreferenceControllerTest.java
@@ -42,7 +42,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.VibrationPreferenceController;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -99,7 +98,7 @@
when(mVibrator.hasVibrator()).thenReturn(false);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -107,7 +106,7 @@
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_LOW);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -116,7 +115,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -124,7 +123,7 @@
public void testIsAvailable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -132,7 +131,7 @@
public void testUpdateState_disabledByAdmin() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -146,7 +145,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.isImportanceLockedByOEM()).thenReturn(true);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -159,7 +158,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
Preference pref = new RestrictedSwitchPreference(RuntimeEnvironment.application);
mController.updateState(pref);
@@ -171,7 +170,7 @@
public void testUpdateState_vibrateOn() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldVibrate()).thenReturn(true);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -183,7 +182,7 @@
public void testUpdateState_vibrateOff() {
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.shouldVibrate()).thenReturn(false);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -195,7 +194,7 @@
public void testOnPreferenceChange_on() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_DEFAULT);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
@@ -211,7 +210,7 @@
public void testOnPreferenceChange_off() {
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
- mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, null);
RestrictedSwitchPreference pref =
new RestrictedSwitchPreference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java
index 9de12ce..2150c82 100644
--- a/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/VisibilityPreferenceControllerTest.java
@@ -48,7 +48,6 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.RestrictedListPreference;
import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.VisibilityPreferenceController;
import com.android.settings.testutils.shadow.ShadowRestrictionUtils;
import com.android.settingslib.RestrictedLockUtils;
@@ -122,7 +121,7 @@
when(mLockUtils.isSecure(anyInt())).thenReturn(false);
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -130,7 +129,7 @@
public void testIsAvailable_notIfNotImportant() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_MIN);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertFalse(mController.isAvailable());
}
@@ -139,11 +138,11 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel =
new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
assertTrue(mController.isAvailable());
}
@@ -160,7 +159,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
RestrictedListPreference pref = mock(RestrictedListPreference.class);
@@ -182,7 +181,7 @@
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getId()).thenReturn("something");
- mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
+ mController.onResume(new NotificationBackend.AppRow(), channel, null, null, null, mock(
RestrictedLockUtils.EnforcedAdmin.class));
RestrictedListPreference pref = mock(RestrictedListPreference.class);
@@ -198,7 +197,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -223,7 +222,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -246,7 +245,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -263,7 +262,7 @@
public void testUpdateState_noGlobalRestriction() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -294,7 +293,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getLockscreenVisibility()).thenReturn(VISIBILITY_NO_OVERRIDE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -313,7 +312,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getLockscreenVisibility()).thenReturn(Notification.VISIBILITY_SECRET);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -332,7 +331,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", 4);
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
@@ -351,7 +350,7 @@
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = new NotificationChannel("", "", 4);
channel.setLockscreenVisibility(VISIBILITY_NO_OVERRIDE);
- mController.onResume(appRow, channel, null, null);
+ mController.onResume(appRow, channel, null, null, null, null);
RestrictedListPreference pref = mock(RestrictedListPreference.class);
mController.updateState(pref);
diff --git a/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
index fbd87c9..95c95bb 100644
--- a/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
@@ -139,7 +139,7 @@
assertThat(mPreference.getSummary())
.isEqualTo(mContext.getString(R.string.android_version_summary,
- Build.VERSION.RELEASE));
+ Build.VERSION.RELEASE_OR_CODENAME));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSettingsLibUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSettingsLibUtils.java
new file mode 100644
index 0000000..2fce5ad
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSettingsLibUtils.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.testutils.shadow;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+
+import com.android.settingslib.Utils;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@Implements(Utils.class)
+public class ShadowSettingsLibUtils {
+
+ @Implementation
+ protected static Drawable getBadgedIcon(Context context, ApplicationInfo appInfo) {
+ return new ColorDrawable(0);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
index 320d767..e5b5eb1 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
@@ -33,6 +33,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
+import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.UserManager;
@@ -71,6 +72,8 @@
@Mock
private PowerManager mPowerManager;
@Mock
+ private WifiManager mWifiManager;
+ @Mock
private DataUsagePreference mDataUsagePreference;
private Context mContext;
private WifiSettings2 mWifiSettings2;
@@ -85,10 +88,12 @@
mWifiSettings2 = spy(new WifiSettings2());
doReturn(mContext).when(mWifiSettings2).getContext();
doReturn(mPowerManager).when(mContext).getSystemService(PowerManager.class);
+ doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
mWifiSettings2.mAddWifiNetworkPreference = new AddWifiNetworkPreference(mContext);
mWifiSettings2.mSavedNetworksPreference = new Preference(mContext);
mWifiSettings2.mConfigureWifiSettingsPreference = new Preference(mContext);
mWifiSettings2.mWifiPickerTracker = mMockWifiPickerTracker;
+ mWifiSettings2.mWifiManager = mWifiManager;
}
@Test
@@ -157,7 +162,7 @@
@Test
public void setAdditionalSettingsSummaries_wifiWakeupEnabled_displayOn() {
final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putInt(contentResolver, Settings.Global.WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(contentResolver, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1);
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0);
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
@@ -171,7 +176,7 @@
@Test
public void setAdditionalSettingsSummaries_wifiWakeupDisabled_displayOff() {
final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putInt(contentResolver, Settings.Global.WIFI_WAKEUP_ENABLED, 0);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);
mWifiSettings2.setAdditionalSettingsSummaries();
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
index 5145cc1..0ae3465 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
@@ -32,9 +32,11 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
+import android.net.wifi.EAPConstants;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.net.wifi.hotspot2.PasspointConfiguration;
+import android.net.wifi.hotspot2.pps.Credential;
import android.net.wifi.hotspot2.pps.HomeSp;
import android.os.Bundle;
import android.os.PowerManager;
@@ -124,6 +126,13 @@
sp.setFqdn("fqdn");
final PasspointConfiguration config = new PasspointConfiguration();
config.setHomeSp(sp);
+ Credential.SimCredential simCredential = new Credential.SimCredential();
+ Credential credential = new Credential();
+ credential.setRealm("test.example.com");
+ simCredential.setImsi("12345*");
+ simCredential.setEapType(EAPConstants.EAP_SIM);
+ credential.setSimCredential(simCredential);
+ config.setCredential(credential);
mockConfigs.add(config);
}
return mockConfigs;
@@ -186,7 +195,7 @@
@Test
public void setAdditionalSettingsSummaries_wifiWakeupEnabled_displayOn() {
final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putInt(contentResolver, Settings.Global.WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(contentResolver, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1);
Settings.Global.putInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0);
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
@@ -200,7 +209,7 @@
@Test
public void setAdditionalSettingsSummaries_wifiWakeupDisabled_displayOff() {
final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putInt(contentResolver, Settings.Global.WIFI_WAKEUP_ENABLED, 0);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);
mWifiSettings.setAdditionalSettingsSummaries();
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java
index 4266c84..a41d7c8 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiWakeupPreferenceControllerTest.java
@@ -17,15 +17,17 @@
package com.android.settings.wifi;
import static android.provider.Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE;
-import static android.provider.Settings.Global.WIFI_WAKEUP_ENABLED;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.content.Context;
import android.location.LocationManager;
+import android.net.wifi.WifiManager;
import android.provider.Settings;
import android.text.TextUtils;
@@ -53,6 +55,8 @@
@Mock
private LocationManager mLocationManager;
@Mock
+ private WifiManager mWifiManager;
+ @Mock
private SwitchPreference mPreference;
@Before
@@ -63,6 +67,7 @@
mController.setFragment(mFragment);
mController.mLocationManager = mLocationManager;
mController.mPreference = mPreference;
+ mController.mWifiManager = mWifiManager;
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 1);
doReturn(true).when(mLocationManager).isLocationEnabled();
@@ -70,20 +75,19 @@
@Test
public void setChecked_scanEnableLocationEnable_wifiWakeupEnable() {
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 1);
doReturn(true).when(mLocationManager).isLocationEnabled();
mController.setChecked(true);
- assertThat(Settings.Global.getInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0))
- .isEqualTo(1);
+ verify(mWifiManager).setAutoWakeupEnabled(true);
}
@Test
public void updateState_wifiWakeupEnableScanningDisable_wifiWakeupDisabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
doReturn(true).when(mLocationManager).isLocationEnabled();
@@ -97,7 +101,7 @@
@Test
public void updateState_preferenceSetCheckedWhenWakeupSettingEnabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 1);
doReturn(true).when(mLocationManager).isLocationEnabled();
@@ -111,7 +115,7 @@
@Test
public void updateState_preferenceSetUncheckedWhenWakeupSettingDisabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);
mController.updateState(preference);
@@ -123,7 +127,7 @@
@Test
public void updateState_preferenceSetUncheckedWhenWifiScanningDisabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
mController.updateState(preference);
@@ -134,7 +138,7 @@
@Test
public void updateState_preferenceSetUncheckedWhenWakeupSettingEnabledNoLocation() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
doReturn(false).when(mLocationManager).isLocationEnabled();
mController.updateState(preference);
@@ -147,7 +151,7 @@
@Test
public void updateState_preferenceSetUncheckedWhenWakeupSettingDisabledLocationEnabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(false);
doReturn(false).when(mLocationManager).isLocationEnabled();
mController.updateState(preference);
@@ -160,7 +164,7 @@
@Test
public void updateState_preferenceSetUncheckedWhenWifiScanningDisabledLocationEnabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
- Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 1);
+ when(mWifiManager.isAutoWakeupEnabled()).thenReturn(true);
Settings.Global.putInt(mContext.getContentResolver(), WIFI_SCAN_ALWAYS_AVAILABLE, 0);
doReturn(false).when(mLocationManager).isLocationEnabled();
diff --git a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
index b28498b..74f94e9 100644
--- a/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/savedaccesspoints/SubscribedAccessPointsPreferenceControllerTest.java
@@ -25,9 +25,11 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.net.wifi.EAPConstants;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.net.wifi.hotspot2.PasspointConfiguration;
+import android.net.wifi.hotspot2.pps.Credential;
import android.net.wifi.hotspot2.pps.HomeSp;
import androidx.preference.PreferenceCategory;
@@ -35,7 +37,6 @@
import com.android.settings.testutils.shadow.ShadowAccessPoint;
import com.android.settings.testutils.shadow.ShadowWifiManager;
-import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPointPreference;
import org.junit.Before;
@@ -111,6 +112,13 @@
homeSp.setFqdn("FQDN");
homeSp.setFriendlyName("TESTPASSPOINT");
config.setHomeSp(homeSp);
+ final Credential.SimCredential simCredential = new Credential.SimCredential();
+ final Credential credential = new Credential();
+ credential.setRealm("test.example.com");
+ simCredential.setImsi("12345*");
+ simCredential.setEapType(EAPConstants.EAP_SIM);
+ credential.setSimCredential(simCredential);
+ config.setCredential(credential);
return config;
}
}
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
index b5645b4..32cec68 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherApBandPreferenceControllerTest.java
@@ -81,7 +81,6 @@
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
when(mWifiManager.getSoftApConfiguration()).thenReturn(
new SoftApConfiguration.Builder().build());
- when(mWifiManager.isStaApConcurrencySupported()).thenReturn(false);
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
}
@@ -90,9 +89,8 @@
public void display_5GhzSupported_shouldDisplayFullList() {
when(mWifiManager.getCountryCode()).thenReturn("US");
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
- when(mWifiManager.isStaApConcurrencySupported()).thenReturn(true);
- // Create a new instance to pick the proper value of isDualModeSupported()
+ // Create a new instance
mController = new WifiTetherApBandPreferenceController(mContext, mListener);
mController.displayPreference(mScreen);
@@ -126,38 +124,10 @@
}
@Test
- public void changePreference_noDualModeWith5G_shouldUpdateValue() {
+ public void changePreference_With5G_shouldUpdateValue() {
when(mWifiManager.getCountryCode()).thenReturn("US");
when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
- mController.displayPreference(mScreen);
-
- // 'Auto' option should be prevented from being set since
- // it is invalid for this configuration
- mController.onPreferenceChange(mPreference, VAL_2_5_GHZ_STR);
- assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
- assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
- verify(mListener, times(1)).onTetherConfigUpdated(mController);
-
- // set to 5 Ghz
- mController.onPreferenceChange(mPreference, VAL_5GHZ_STR);
- assertThat(mController.getBandIndex()).isEqualTo(VAL_5GHZ_INT);
- assertThat(mPreference.getSummary()).isEqualTo(FIVE_GHZ_STRING);
- verify(mListener, times(2)).onTetherConfigUpdated(mController);
-
- // set to 2 Ghz
- mController.onPreferenceChange(mPreference, VAL_2GHZ_STR);
- assertThat(mController.getBandIndex()).isEqualTo(VAL_2GHZ_INT);
- assertThat(mPreference.getSummary()).isEqualTo(TWO_GHZ_STRING);
- verify(mListener, times(3)).onTetherConfigUpdated(mController);
- }
-
- @Test
- public void changePreference_dualModeWith5G_shouldUpdateValue() {
- when(mWifiManager.getCountryCode()).thenReturn("US");
- when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
- when(mWifiManager.isStaApConcurrencySupported()).thenReturn(true);
-
// Create a new instance to pick the proper value of isDualModeSupported()
mController = new WifiTetherApBandPreferenceController(mContext, mListener);