Merge "Reland: Rework platform version to hide codenames."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3cabb0e..c73ee8d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2472,6 +2472,28 @@
</activity>
<activity
+ android:name="Settings$InteractAcrossProfilesSettingsActivity"
+ android:label="@string/interact_across_profiles_title">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.MANAGE_CROSS_PROFILE_ACCESS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesSettings" />
+ </activity>
+
+ <activity android:name="Settings$AppInteractAcrossProfilesSettingsActivity"
+ android:label="@string/interact_across_profiles_title">
+ <intent-filter>
+ <action android:name="android.settings.MANAGE_CROSS_PROFILE_ACCESS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="package" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesDetails" />
+ </activity>
+
+ <activity
android:name="Settings$ZenAccessDetailSettingsActivity"
android:label="@string/manage_zen_access_title"
android:excludeFromRecents="true">
@@ -3010,7 +3032,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
<service
@@ -3022,7 +3044,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
<service
@@ -3034,7 +3056,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
<service
@@ -3046,7 +3068,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
@@ -3059,7 +3081,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
@@ -3072,7 +3094,7 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
- <meta-data android:name="android.service.quicksettings.BOOLEAN_TILE"
+ <meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
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/accessibility_autoclick_custom_seekbar.xml b/res/layout/accessibility_autoclick_custom_seekbar.xml
new file mode 100644
index 0000000..7483759
--- /dev/null
+++ b/res/layout/accessibility_autoclick_custom_seekbar.xml
@@ -0,0 +1,69 @@
+<?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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="60dp"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
+
+ <TextView
+ android:id="@+id/current_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.TextView" />
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical">
+
+ <ImageView
+ android:id="@+id/smaller"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:background="?android:attr/selectableItemBackgroundBorderless"
+ android:src="@drawable/ic_remove_24dp"
+ android:tint="?android:attr/textColorPrimary"
+ android:tintMode="src_in"
+ android:scaleType="center"
+ android:focusable="true"
+ android:contentDescription="@string/accessibility_autoclick_shorter_desc" />
+
+ <SeekBar
+ android:id="@+id/autoclick_delay"
+ android:layout_width="260dp"
+ android:layout_height="48dp" />
+
+ <ImageView
+ android:id="@+id/larger"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:background="?android:attr/selectableItemBackgroundBorderless"
+ android:src="@drawable/ic_add_24dp"
+ android:tint="?android:attr/textColorPrimary"
+ android:tintMode="src_in"
+ android:scaleType="center"
+ android:focusable="true"
+ android:contentDescription="@string/accessibility_autoclick_longer_desc" />
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/res/layout/accessibility_shortcut_secondary_action.xml b/res/layout/accessibility_shortcut_secondary_action.xml
index 1b575da..84c8e6b 100644
--- a/res/layout/accessibility_shortcut_secondary_action.xml
+++ b/res/layout/accessibility_shortcut_secondary_action.xml
@@ -94,8 +94,9 @@
android:id="@android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:minWidth="58dp"
+ android:contentDescription="@string/accessibility_shortcut_settings"
android:gravity="end|center_vertical"
+ android:minWidth="58dp"
android:orientation="vertical" />
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/daltonizer_preview.xml b/res/layout/daltonizer_preview.xml
index 24c0f76..bdf1070 100644
--- a/res/layout/daltonizer_preview.xml
+++ b/res/layout/daltonizer_preview.xml
@@ -24,6 +24,6 @@
android:id="@+id/palette_listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:contentDescription="@null" />
+ android:importantForAccessibility="noHideDescendants" />
</FrameLayout>
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/values/arrays.xml b/res/values/arrays.xml
index 9c3a622..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>
@@ -1175,6 +1165,19 @@
<item>zen_mode_from_none</item>
</string-array>
+ <string-array name="zen_mode_conversations_entries" translatable="false">
+ <item>@string/zen_mode_from_all_conversations</item>
+ <item>@string/zen_mode_from_important_conversations</item>
+ <item>@string/zen_mode_from_no_conversations</item>
+ </string-array>
+
+ <!-- these values correspond with ZenPolicy.ConversationSenders -->
+ <string-array name="zen_mode_conversations_values" translatable="false">
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ </string-array>
+
<!--String arrays for notification swipe direction -->
<string-array name="swipe_direction_titles">
<item>@string/swipe_direction_rtl</item>
diff --git a/res/values/config.xml b/res/values/config.xml
index fc2ca1f..42bc0d6 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -416,9 +416,11 @@
<string-array name="config_suppress_injected_tile_keys" translatable="false"/>
<!-- Reset application package name -->
- <string-array name="config_reset_app_package_name" translatable="false">
- <item>com.android.systemui</item>
+ <string-array name="config_skip_reset_apps_package_name" translatable="false">
<item>android</item>
+ <item>com.android.providers.downloads</item>
+ <item>com.android.systemui</item>
+ <item>com.android.vending</item>
</string-array>
<!-- Settings panel keeps observe this uri -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0ddc62a..618aead 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1791,7 +1791,7 @@
<string name="nfc_disclaimer_content">NFC exchanges data between this device and other nearby devices or targets, such as payment terminals, access readers, and interactive ads or tags.</string>
<!-- Used in the settings screen to secure NFC [CHAR LIMIT=NONE] -->
- <string name="nfc_secure_settings_title">Secure NFC</string>
+ <string name="nfc_secure_settings_title">Require device unlock for NFC</string>
<!-- Description of Secure NFC in the 1st level settings screen. [CHAR LIMIT=NONE] -->
<string name="nfc_secure_toggle_summary" product="default">Allow NFC Payment and Transit use only when screen is unlocked</string>
@@ -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 -->
@@ -4780,7 +4786,7 @@
<!-- Title for the accessibility preference screen to enable video captioning. [CHAR LIMIT=35] -->
<string name="accessibility_captioning_title">Caption preferences</string>
<!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
- <string name="accessibility_screen_magnification_title">Magnify</string>
+ <string name="accessibility_screen_magnification_title">Magnification</string>
<!-- Title for the accessibility preference screen to edit magnification area. [CHAR LIMIT=35] -->
<string name="accessibility_magnification_mode_title">Magnification area</string>
<!-- Title for the accessibility preference screen to edit magnification enable mode. [CHAR LIMIT=35] -->
@@ -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] -->
@@ -4816,7 +4822,7 @@
<!-- Short summary for nav bar Magnification. Tells the user that this feature allows the user to magnify the screen using a button in the nav bar -->
<string name="accessibility_screen_magnification_navbar_short_summary">Tap a button to zoom</string>
<!-- Summary for the accessibility preference screen to enable screen magnification gestures. [CHAR LIMIT=none] -->
- <string name="accessibility_screen_magnification_summary"><b>To zoom</b>, quickly tap the screen 3 times.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, quickly tap the screen 3 times and hold down your finger on the third tap.\n<ul><li>Drag to move around the screen</li>\n<li>Lift finger to zoom out</li></ul>\n\nYou can\'t zoom in on the keyboard and navigation bar.</string>
+ <string name="accessibility_screen_magnification_summary">Quickly zoom in on the screen to see content more clearly.\n\n<b>To zoom in:</b>\n\t1. Use shortcut to start magnification\n\t2. Tap the screen\n\t3. Drag 2 fingers to move around screen\n\t4. Pinch with 2 fingers to adjust zoom\n\t5. Use shortcut to stop magnification</string>
<!-- Summary for the accessibility preference screen to enable screen magnification via the nav bar. [CHAR LIMIT=none] -->
<string name="accessibility_screen_magnification_navbar_summary">When magnification is turned on, you can zoom in on your screen.\n\n<b>To zoom</b>, start magnification, then tap anywhere on the screen.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, start magnification, then touch & hold anywhere on the screen.\n<ul><li>Drag to move around the screen</li>\n<li>Lift finger to zoom out</li></ul>\n\nYou can’t zoom in on the keyboard or navigation bar.</string>
<!-- Title for the Accessibility tutorial dialog in Accessibility service with button. [CHAR LIMIT=50] -->
@@ -4838,35 +4844,29 @@
<!-- Button for the Accessibility tutorial dialog to dismiss the dialog when user clicks it. [CHAR LIMIT=10] -->
<string name="accessibility_tutorial_dialog_button">Got it</string>
<!-- Title for accessibility shortcut preference for accessibility apps. [CHAR LIMIT=40] -->
- <string name="accessibility_shortcut_title">Use shortcut to open</string>
- <!-- Title for accessibility shortcut preference for magnification. [CHAR LIMIT=40] -->
- <string name="accessibility_magnification_shortcut_title">Use shortcut to magnify</string>
- <!-- Title for Accessibility edit shortcut dialog. [CHAR LIMIT=40] -->
- <string name="accessibility_shortcut_edit_dialog_title">Shortcut to open <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
- <!-- Title for Accessibility edit shortcut dialog in Magnify. [CHAR LIMIT=40] -->
- <string name="accessibility_shortcut_edit_dialog_title_magnification">Shortcut to magnify</string>
- <!-- Title for Accessibility edit shortcut dialog in Color correction. [CHAR LIMIT=40] -->
- <string name="accessibility_shortcut_edit_dialog_title_daltonizer">Shortcut to open Color correction</string>
+ <string name="accessibility_shortcut_title"><xliff:g id="service" example="Select to Speak">%1$s</xliff:g> shortcut</string>
<!-- Title for software shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
- <string name="accessibility_shortcut_edit_dialog_title_software">Accessibility Button</string>
+ <string name="accessibility_shortcut_edit_summary_software">Accessibility Button</string>
<!-- Title for software shortcut in gesture mode in Accessibility edit shortcut dialog while using gesture navigation is enabled. [CHAR LIMIT=NONE] -->
- <string name="accessibility_shortcut_edit_dialog_title_software_gesture">2-finger swipe up from bottom</string>
+ <string name="accessibility_shortcut_edit_dialog_title_software_gesture">Swipe up with 2 fingers</string>
<!-- Title for software shortcut in gesture mode in Accessibility edit shortcut dialog while using gesture navigation and touch exploration are enabled. [CHAR LIMIT=NONE] -->
- <string name="accessibility_shortcut_edit_dialog_title_software_gesture_talkback">3-finger swipe up from bottom</string>
+ <string name="accessibility_shortcut_edit_dialog_title_software_gesture_talkback">Swipe up with 3 fingers</string>
+ <!-- Summary for accessibility shortcut preference for software shortcut type. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_shortcut_edit_dialog_title_software">Tap accessibility button</string>
<!-- Summary for software shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
- <string name="accessibility_shortcut_edit_dialog_summary_software">Tap the <xliff:g id="accessibility_icon" example="[Icon]">%s</xliff:g> button at the bottom of your screen</string>
+ <string name="accessibility_shortcut_edit_dialog_summary_software">Tap the accessibility button <xliff:g id="accessibility_icon" example="[Icon]">%s</xliff:g> at the bottom of your screen</string>
<!-- Summary for software shortcut in gesture mode in Accessibility edit shortcut dialog while using gesture navigation is enabled. [CHAR LIMIT=NONE] -->
- <string name="accessibility_shortcut_edit_dialog_summary_software_gesture">Swipe up with 2 fingers from edge of screen</string>
+ <string name="accessibility_shortcut_edit_dialog_summary_software_gesture">Swipe up from the bottom of the screen with 2 fingers</string>
<!-- Summary for software shortcut in gesture mode in Accessibility edit shortcut dialog while using gesture navigation and touch exploration are enabled [CHAR LIMIT=NONE] -->
- <string name="accessibility_shortcut_edit_dialog_summary_software_gesture_talkback">Swipe up with 3 fingers from edge of screen</string>
+ <string name="accessibility_shortcut_edit_dialog_summary_software_gesture_talkback">Swipe up from the bottom of the screen with 3 fingers</string>
<!-- Title for hardware shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_edit_dialog_title_hardware">Hold volume keys</string>
<!-- Summary for hardware shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
- <string name="accessibility_shortcut_edit_dialog_summary_hardware">Press and hold both volume keys for 1 second</string>
+ <string name="accessibility_shortcut_edit_dialog_summary_hardware">Press & hold both volume keys for 1 second</string>
<!-- Title for triple tap shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
- <string name="accessibility_shortcut_edit_dialog_title_triple_tap">Triple tap screen</string>
+ <string name="accessibility_shortcut_edit_dialog_title_triple_tap">Triple-tap screen</string>
<!-- Summary for triple tap shortcut in Accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
- <string name="accessibility_shortcut_edit_dialog_summary_triple_tap">Quickly tap screen 3 times (this can slow down your device)</string>
+ <string name="accessibility_shortcut_edit_dialog_summary_triple_tap">Quickly tap screen 3 times. This shortcut may slow down your device.</string>
<!-- Title for the Accessibility edit shortcut dialog to save the preference when user clicks it. [CHAR LIMIT=10] -->
<string name="accessibility_shortcut_edit_dialog_title_advance">Advanced</string>
<!-- Summary text appearing on the accessibility preference screen to enable screen magnification from the nav bar when the feature is enabled, but the accessibility button is not configured correctly for the feature to be used [CHAR LIMIT=none] -->
@@ -4877,6 +4877,8 @@
<string name="accessibility_global_gesture_preference_title">Volume key shortcut</string>
<!-- Title for the preference to choose the service that is turned on and off by the accessibility shortcut. [CHAR LIMIT=35] -->
<string name="accessibility_shortcut_service_title">Shortcut service</string>
+ <!-- Label for shortcut settings button. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_shortcut_settings">Shortcut settings</string>
<!-- Title for the switch preference that controls whether or not the accessibility shortcut works on the lock screen. [CHAR LIMIT=35] -->
<string name="accessibility_shortcut_service_on_lock_screen_title">Allow from lock screen</string>
<!-- Description of accessibility shortcut. [CHAR LIMIT=NONE] -->
@@ -4928,15 +4930,15 @@
<!-- Title for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
<string name="accessibility_display_inversion_preference_title">Color inversion</string>
<!-- Used in the accessibility service settings to control turning display color inversion on/off entirely. [CHAR LIMIT=NONE] -->
- <string name="accessibility_display_inversion_switch_title">Invert colors</string>
+ <string name="accessibility_display_inversion_switch_title">Use color inversion</string>
<!-- Subtitle for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
- <string name="accessibility_display_inversion_preference_subtitle">Turn light screens dark so people who are sensitive to bright light can have a better viewing experience.\n\nNote: dark colors will turn light. Images will also be inverted.</string>
+ <string name="accessibility_display_inversion_preference_subtitle">Color inversion turns light screens dark. This helps people who are sensitive to bright light see the screen more easily.\n\nNote: Dark colors will turn light. Colors will change in media and images. You can also use Dark theme (Settings > Display).</string>
<!-- Title for accessibility preference for configuring feature that performs click action soon after mouse/trackpad pointer stops moving. [CHAR LIMIT=NONE] -->
<string name="accessibility_autoclick_preference_title">Auto click (dwell timing)</string>
<!-- Footer text to explain what autoclick does -->
<string name="accessibility_autoclick_description">If you are using a mouse, you can set the cursor to take action automatically when it stops moving for a certain amount of time.</string>
<!-- Option heading to leave the auto click requirement for accessibility users at its default level. [CHAR LIMIT=35] -->
- <string name="accessibility_autoclick_default_title">None</string>
+ <string name="accessibility_autoclick_default_title">Don\u2019t use auto click (default)</string>
<!-- Option heading to leave the auto click requirement for accessibility users at its short level. [CHAR LIMIT=35] -->
<string name="accessibility_autoclick_short_title">Short</string>
<!-- Option summary text for the auto click delay 0.2 seconds radio button. [CHAR LIMIT=35] -->
@@ -4951,6 +4953,10 @@
<string name="accessibility_autoclick_long_summary">1 second</string>
<!-- Option heading to leave the auto click requirement for accessibility users at its custom level. [CHAR LIMIT=35] -->
<string name="accessibility_autoclick_custom_title">Custom</string>
+ <!-- Description for the button that shorter delay time. [CHAR_LIMIT=NONE] -->
+ <string name="accessibility_autoclick_shorter_desc">Shorter</string>
+ <!-- Description for the button that longer time. [CHAR_LIMIT=NONE] -->
+ <string name="accessibility_autoclick_longer_desc">Longer</string>
<!-- Title for accessibility preference screen for configuring vibrations. -->
<string name="accessibility_vibration_settings_title">Vibration & haptic strength</string>
<!-- Title for accessibility preference for configuring notification vibrations. -->
@@ -4962,7 +4968,7 @@
<!-- Used in the accessibility service settings to control turning on/off the service entirely -->
<string name="accessibility_service_master_switch_title">Use <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g></string>
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
- <string name="accessibility_daltonizer_master_switch_title">Correct colors</string>
+ <string name="accessibility_daltonizer_master_switch_title">Use color correction</string>
<!-- Used in the Captions settings screen to control turning on/off the feature entirely -->
<string name="accessibility_caption_master_switch_title">Show captions</string>
<!-- Title for Caption preference settings screen for configuring font style. [CHAR LIMIT=NONE] -->
@@ -5052,6 +5058,12 @@
<item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
</plurals>
+ <!-- Summary for autoclick seekbar settings preference when user selected custom item. [CHAR LIMIT=35] -->
+ <plurals name="accessibilty_autoclick_delay_unit_second">
+ <item quantity="one"><xliff:g id="click_delay_label" example="1">%1$s</xliff:g> second</item>
+ <item quantity="other"><xliff:g id="click_delay_label" example="0.6">%1$s</xliff:g> seconds</item>
+ </plurals>
+
<!-- Summary for vibration settings preference when notification vibration and haptic feedback intensity are set. [CHAR LIMIT=50] -->
<string name="accessibility_vibration_summary">Ring <xliff:g id="summary_ring" example="Medium">%1$s</xliff:g>, notification <xliff:g id="summary_notification" example="Low">%2$s</xliff:g>, touch <xliff:g id="summary_touch" example="High">%3$s</xliff:g></string>
@@ -5079,7 +5091,7 @@
<!-- Label describing a high intensity vibration option. [CHAR LIMIT=15] -->
<string name="accessibility_vibration_intensity_high">High</string>
- <!-- Title for accessibility menu item to lauch a settings activity. [CHAR LIMIT=15] -->
+ <!-- Title for accessibility menu item to launch a settings activity. [CHAR LIMIT=15] -->
<string name="accessibility_menu_item_settings">Settings</string>
<!-- Summary for the enabled state of an accessibility feature. [CHAR LIMIT=10] -->
@@ -5532,13 +5544,9 @@
<!-- Title for the smart battery toggle [CHAR LIMIT=NONE] -->
<string name="smart_battery_title">Manage apps automatically</string>
<!-- Summary for the smart battery toggle [CHAR LIMIT=NONE] -->
- <string name="smart_battery_summary">Limit battery for apps that you don\u2019t use often</string>
+ <string name="smart_battery_summary" product="default">Limit battery for apps that you don\u2019t use often</string>
<!-- Footer for the aosp smart battery page -->
- <string name="smart_battery_footer" product="default">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
- <!-- Footer for the aosp smart battery page -->
- <string name="smart_battery_footer" product="tablet">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
- <!-- Footer for the aosp smart battery page -->
- <string name="smart_battery_footer" product="device">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
+ <string name="smart_battery_footer">When Battery Manager detects that apps are draining battery, you\u2019ll have the option to restrict these apps. Restricted apps may not work properly and notifications may be delayed.</string>
<!-- Title for restricted app preference, clicking it will goes to restricted app list [CHAR LIMIT=NONE] -->
<string name="restricted_app_title">Restricted apps</string>
<!-- Summary for restricted app preference, clicking it will goes to restricted app list [CHAR LIMIT=NONE] -->
@@ -5559,7 +5567,8 @@
<string name="battery_auto_restriction_summary">Detect when apps drain battery</string>
<!-- Summary for battery manager when it is on -->
- <string name="battery_manager_on">On / Detecting when apps drain battery</string>
+ <string name="battery_manager_on" product="default">On / Detecting when apps drain battery</string>
+
<!-- Summary for battery manager when it is off -->
<string name="battery_manager_off">Off</string>
<!-- Summary for battery manager, showing app restricted -->
@@ -7108,6 +7117,8 @@
<string name="help_uri_bluetooth_screen" translatable="false"></string>
<!-- url for the SIM combination warning required dialog help page -->
<string name="help_uri_sim_combination_warning" translatable="false"></string>
+ <!-- url for the NFC and payment settings page -->
+ <string name="help_uri_nfc_and_payment_settings" translatable="false"></string>
<!-- User account title [CHAR LIMIT=30] -->
<string name="user_account_title">Account for content</string>
@@ -7338,6 +7349,8 @@
<string name="connected_devices_dashboard_no_driving_mode_summary">Bluetooth, NFC</string>
<!-- Summary for Connected devices settings, explaning a few important settings under it [CHAR LIMIT=NONE]-->
<string name="connected_devices_dashboard_no_driving_mode_no_nfc_summary">Bluetooth</string>
+ <!-- Summary for Tap & pay settings, explaning a few important settings under it [CHAR LIMIT=NONE]-->
+ <string name="nfc_and_payment_settings_payment_off_nfc_off_summary">Unavailable because NFC is off</string>
<!-- Title for setting tile leading to Apps & Notification settings [CHAR LIMIT=40]-->
<string name="app_and_notification_dashboard_title">Apps & notifications</string>
<!-- Summary for Apps & Notification settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
@@ -7574,6 +7587,15 @@
<!-- Sound: Title for the option managing whether or not to vibrate when ringing. [CHAR LIMIT=30] -->
<string name="vibrate_when_ringing_title">Vibrate for calls</string>
+ <!-- Sound: Option for vibrate when ringing setting: Never vibrate. [CHAR LIMIT=40] -->
+ <string name="vibrate_when_ringing_option_never_vibrate">Never vibrate</string>
+
+ <!-- Sound: Option for vibrate when ringing setting: Always vibrate. [CHAR LIMIT=40] -->
+ <string name="vibrate_when_ringing_option_always_vibrate">Always vibrate</string>
+
+ <!-- Sound: Option for vibrate when ringing setting: Ramping ringer. [CHAR LIMIT=80] -->
+ <string name="vibrate_when_ringing_option_ramping_ringer">Vibrate first then ring gradually</string>
+
<!-- Sound: Title for the other sounds option and associated settings page. [CHAR LIMIT=30] -->
<string name="other_sound_settings">Other sounds</string>
@@ -7784,7 +7806,7 @@
<!-- Do not disturb: what to block summary, all effects -->
<string name="zen_mode_block_effect_summary_all">Sound, vibration, and visual signs of notifications</string>
- <string name="zen_mode_blocked_effects_footer">Notifications needed for basic phone activity and status will never be hidden</string>
+ <string name="zen_mode_blocked_effects_footer">Notifications needed for basic phone activity and status will never be hidden.</string>
<!-- Do not disturb: Zen mode no sounds are exceptions to bypass do not disturb-->
<string name="zen_mode_no_exceptions">None</string>
@@ -8035,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] -->
@@ -8189,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-->
@@ -8375,6 +8420,36 @@
<!-- Apps > App Details > Picture-in-picture > Description. [CHAR LIMIT=NONE] -->
<string name="picture_in_picture_app_detail_summary">Allow this app to create a picture-in-picture window while the app is open or after you leave it (for example, to continue watching a video). This window displays on top of other apps you\'re using.</string>
+ <!-- Special access > Title for managing the settings where users opt-in to connect a work app
+ to its personal equivalent, allowing cross-profile communication. [CHAR LIMIT=50] -->
+ <string name="interact_across_profiles_title" translatable="false">Connected work and personal apps</string>
+
+ <!-- Special access > Connected work and personal apps > Text to display when the list is empty. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_empty_text" translatable="false">No connected apps</string>
+
+ <!-- Special access > Connected work and personal apps > Additional keywords to search for. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_keywords" translatable="false">cross profile connected app apps work and personal</string>
+
+ <!-- Apps > App Details > Advanced section string title. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_app_detail_title" translatable="false">Connected work and personal apps</string>
+
+ <!-- Apps > App Details > Connected work and personal apps > Switch title. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_app_detail_switch" translatable="false">Connect these apps</string>
+
+ <!-- Apps > App Details > Connected work and personal apps > Description. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_summary_1" translatable="false">Connected apps share permissions and can access each other\u2019s data.</string>
+
+ <!-- Apps > App Details > Connected work and personal apps > Description. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_summary_2" translatable="false">Only connect apps that you trust with your personal data.Your data may be exposed to your IT admin.</string>
+
+ <!-- TODO(b/148594054): Replace calendar with actual app name -->
+ <!-- Apps > App Details > Connected work and personal apps > Consent dialog title. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_title" translatable="false">Trust work Calendar with your personal data?</string>
+
+ <!-- TODO(b/148594054): Replace calendar with actual app name -->
+ <!-- Apps > App Details > Connected work and personal apps > Consent dialog description. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_summary" translatable="false">Calendar may expose your personal data to your IT admin</string>
+
<!-- Sound & notification > Advanced section: Title for managing Do Not Disturb access option. [CHAR LIMIT=40] -->
<string name="manage_zen_access_title">Do Not Disturb access</string>
@@ -8480,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>
@@ -8639,6 +8720,9 @@
</plurals>
<string name="zen_mode_conversations_title">Conversations</string>
+ <string name="zen_mode_from_all_conversations">From all conversations</string>
+ <string name="zen_mode_from_important_conversations">From important conversations</string>
+ <string name="zen_mode_from_no_conversations">Don\u2019t allow any conversations</string>
<!-- [CHAR LIMIT=40] Zen mode settings: Messages option -->
<string name="zen_mode_messages">Allow messages</string>
@@ -10795,34 +10879,34 @@
<!-- UI debug setting: ANGLE enabled app has been set [CHAR LIMIT=NONE] -->
<string name="angle_enabled_app_set">ANGLE enabled application: <xliff:g id="app_name" example="com.company.app">%1$s</xliff:g></string>
- <!-- Title for Game Driver dashboard where developers can configure apps to use game driver or not [CHAR LIMIT=50] -->
- <string name="game_driver_dashboard_title">Game Driver Preferences</string>
- <!-- Summary for Game Driver dashboard [CHAR LIMIT=50] -->
- <string name="game_driver_dashboard_summary">Modify Game Driver settings</string>
- <!-- Footer text for Game Driver dashboard [CHAR LIMIT=NONE] -->
- <string name="game_driver_footer_text">When Game Driver is turned on, you can pick to use the updated graphics driver for Apps installed on the device.</string>
- <!-- Title for Game Driver all apps preference [CHAR LIMIT=50] -->
- <string name="game_driver_all_apps_preference_title">Enable for all apps</string>
- <!-- Title for Game Driver app preference [CHAR LIMIT=50] -->
- <string name="game_driver_app_preference_title">Select Graphics Driver</string>
- <!-- The default value for Game Driver app preference [CHAR LIMIT=50] -->
- <string name="game_driver_app_preference_default">Default</string>
+ <!-- Title for graphics driver dashboard where developers can configure apps to choose graphics driver [CHAR LIMIT=50] -->
+ <string name="graphics_driver_dashboard_title">Graphics Driver Preferences</string>
+ <!-- Summary for graphics driver dashboard [CHAR LIMIT=50] -->
+ <string name="graphics_driver_dashboard_summary">Modify graphics driver settings</string>
+ <!-- Footer text for graphics driver dashboard [CHAR LIMIT=NONE] -->
+ <string name="graphics_driver_footer_text">When there are multiple graphics drivers, you can pick to use the updated graphics driver for Apps installed on the device.</string>
+ <!-- Title for graphics Driver all apps preference [CHAR LIMIT=50] -->
+ <string name="graphics_driver_all_apps_preference_title">Enable for all apps</string>
+ <!-- Title for graphics driver preference for app [CHAR LIMIT=50] -->
+ <string name="graphics_driver_app_preference_title">Select Graphics Driver</string>
+ <!-- The default value of graphics driver preference for app [CHAR LIMIT=50] -->
+ <string name="graphics_driver_app_preference_default">Default</string>
<!-- The game driver value for Game Driver app preference [CHAR LIMIT=50] -->
- <string name="game_driver_app_preference_game_driver">Game Driver</string>
- <!-- The game driver value for Prerelease Game Driver app preference [CHAR LIMIT=50] -->
- <string name="game_driver_app_preference_prerelease_driver">Prerelease Driver</string>
- <!-- The system value for Game Driver app preference [CHAR LIMIT=50] -->
- <string name="game_driver_app_preference_system">System Graphics Driver</string>
- <!-- All the values for Game Driver all apps preference [CHAR LIMIT=50] -->
- <string-array name="game_driver_all_apps_preference_values">
- <item>@string/game_driver_app_preference_default</item>
- <item>@string/game_driver_app_preference_game_driver</item>
+ <string name="graphics_driver_app_preference_game_driver">Game Driver</string>
+ <!-- The prerelase driver value for Prerelease Driver app preference [CHAR LIMIT=50] -->
+ <string name="graphics_driver_app_preference_prerelease_driver">Prerelease Driver</string>
+ <!-- The system driver value for system graphics driver app preference [CHAR LIMIT=50] -->
+ <string name="graphics_driver_app_preference_system">System Graphics Driver</string>
+ <!-- All the graphics driver preference values for all apps globally [CHAR LIMIT=50] -->
+ <string-array name="graphics_driver_all_apps_preference_values">
+ <item>@string/graphics_driver_app_preference_default</item>
+ <item>@string/graphics_driver_app_preference_game_driver</item>
</string-array>
- <!-- All the values for Game Driver app preference [CHAR LIMIT=50] -->
- <string-array name="game_driver_app_preference_values">
- <item>@string/game_driver_app_preference_default</item>
- <item>@string/game_driver_app_preference_game_driver</item>
- <item>@string/game_driver_app_preference_system</item>
+ <!-- All the values of graphics driver for app preference [CHAR LIMIT=50] -->
+ <string-array name="graphics_driver_app_preference_values">
+ <item>@string/graphics_driver_app_preference_default</item>
+ <item>@string/graphics_driver_app_preference_game_driver</item>
+ <item>@string/graphics_driver_app_preference_system</item>
</string-array>
<!-- Title for App Compatibility Changes dashboard where developers can configure per-app overrides for compatibility changes [CHAR LIMIT=50] -->
diff --git a/res/xml/about_legal.xml b/res/xml/about_legal.xml
index 6c59cac..d30ceaa 100644
--- a/res/xml/about_legal.xml
+++ b/res/xml/about_legal.xml
@@ -16,8 +16,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/legal_information"
- android:key="legal_screen">
+ android:title="@string/legal_information">
<!-- Note: The titles given here probably won't be used. Instead, we programmatically
fill the title with the label of the activity with the corresponding action.
diff --git a/res/xml/accessibility_autoclick_settings.xml b/res/xml/accessibility_autoclick_settings.xml
index 70cb9c8..ad588f6 100644
--- a/res/xml/accessibility_autoclick_settings.xml
+++ b/res/xml/accessibility_autoclick_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="autoclick_preference_screen"
android:title="@string/accessibility_autoclick_preference_title">
<com.android.settingslib.widget.RadioButtonPreference
@@ -44,13 +43,17 @@
android:key="accessibility_control_autoclick_custom"
android:title="@string/accessibility_autoclick_custom_title" />
- <com.android.settings.widget.SeekBarPreference
- android:key="autoclick_delay" />
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="autoclick_custom_seekbar"
+ android:layout="@layout/accessibility_autoclick_custom_seekbar"
+ android:selectable="false"
+ settings:allowDividerBelow="true"
+ settings:controller="com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController" />
<com.android.settingslib.widget.FooterPreference
android:key="autoclick_footer"
android:title="@string/accessibility_autoclick_description"
android:selectable="false"
- settings:searchable="false"/>
+ settings:searchable="false" />
</PreferenceScreen>
diff --git a/res/xml/accessibility_color_inversion_settings.xml b/res/xml/accessibility_color_inversion_settings.xml
index 9e31ff9..9681001 100644
--- a/res/xml/accessibility_color_inversion_settings.xml
+++ b/res/xml/accessibility_color_inversion_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="color_inversion_preference_screen"
android:persistent="false"
android:title="@string/accessibility_display_inversion_preference_title">
diff --git a/res/xml/accessibility_control_timeout_settings.xml b/res/xml/accessibility_control_timeout_settings.xml
index 77bbfd8..0f14cd5 100644
--- a/res/xml/accessibility_control_timeout_settings.xml
+++ b/res/xml/accessibility_control_timeout_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="accessibility_control_timeout_preference"
android:title="@string/accessibility_control_timeout_preference_title"
android:persistent="false" >
diff --git a/res/xml/accessibility_daltonizer_settings.xml b/res/xml/accessibility_daltonizer_settings.xml
index 976f912..b2ab5ef 100644
--- a/res/xml/accessibility_daltonizer_settings.xml
+++ b/res/xml/accessibility_daltonizer_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="daltonizer_preference_screen"
android:persistent="false"
android:title="@string/accessibility_display_daltonizer_preference_title">
@@ -54,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_magnification_settings.xml b/res/xml/accessibility_magnification_settings.xml
index bb40394..6731dba 100644
--- a/res/xml/accessibility_magnification_settings.xml
+++ b/res/xml/accessibility_magnification_settings.xml
@@ -16,9 +16,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="magnification_preference_screen_title"
- android:title="@string/accessibility_screen_magnification_title"
- settings:searchable="false">
+ android:title="@string/accessibility_screen_magnification_title">
<Preference
android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
android:key="screen_magnification_gestures_preference_screen"
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index be644d4..b7b88ed 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="accessibility_settings_screen"
android:persistent="false"
android:title="@string/accessibility_settings">
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/accessibility_vibration_settings.xml b/res/xml/accessibility_vibration_settings.xml
index dc2b16a..87c2988 100644
--- a/res/xml/accessibility_vibration_settings.xml
+++ b/res/xml/accessibility_vibration_settings.xml
@@ -18,7 +18,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="accessibility_settings_vibration_screen"
android:title="@string/accessibility_vibration_settings_title">
<Preference
diff --git a/res/xml/accounts_dashboard_settings.xml b/res/xml/accounts_dashboard_settings.xml
index d2affc7..c42e1c7 100644
--- a/res/xml/accounts_dashboard_settings.xml
+++ b/res/xml/accounts_dashboard_settings.xml
@@ -17,9 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="user_and_account_settings_screen"
- android:title="@string/account_dashboard_title"
- settings:keywords="@string/keywords_accounts">
+ android:title="@string/account_dashboard_title">
<PreferenceCategory
android:key="dashboard_tile_placeholder"
diff --git a/res/xml/adaptive_sleep_detail.xml b/res/xml/adaptive_sleep_detail.xml
index 4b46fae..0ea31ff 100644
--- a/res/xml/adaptive_sleep_detail.xml
+++ b/res/xml/adaptive_sleep_detail.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="adaptive_sleep_detail"
android:title="@string/adaptive_sleep_title">
<com.android.settings.widget.VideoPreference
@@ -52,4 +51,4 @@
android:selectable="false"
settings:searchable="false" />
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index f75bd86..aa1a6ee 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="apps_and_notification_screen"
android:title="@string/app_and_notification_dashboard_title"
settings:initialExpandedChildrenCount="4">
<!-- the initial count should include the dynamic tiles -->
diff --git a/res/xml/app_info_settings.xml b/res/xml/app_info_settings.xml
index 435a7ef..a76f0d9 100644
--- a/res/xml/app_info_settings.xml
+++ b/res/xml/app_info_settings.xml
@@ -150,6 +150,12 @@
android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.applications.appinfo.ExternalSourceDetailPreferenceController" />
+ <Preference
+ android:key="interact_across_profiles"
+ android:title="@string/interact_across_profiles_title"
+ android:summary="@string/summary_placeholder"
+ settings:controller="com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesDetailsPreferenceController" />
+
</PreferenceCategory>
<!-- App installer info -->
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/assist_gesture_settings.xml b/res/xml/assist_gesture_settings.xml
index 7cbd483..5f7918f 100644
--- a/res/xml/assist_gesture_settings.xml
+++ b/res/xml/assist_gesture_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- android:key="gesture_assist_settings_page"
android:title="@string/assist_gesture_title">
<com.android.settings.widget.VideoPreference
diff --git a/res/xml/auto_brightness_detail.xml b/res/xml/auto_brightness_detail.xml
index 7c66ab5..6b304ef 100644
--- a/res/xml/auto_brightness_detail.xml
+++ b/res/xml/auto_brightness_detail.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="auto_brightness_detail"
android:title="@string/auto_brightness_title">
<com.android.settings.widget.VideoPreference
@@ -45,4 +44,4 @@
android:selectable="false"
settings:searchable="false" />
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/available_virtual_keyboard.xml b/res/xml/available_virtual_keyboard.xml
index 9a0b3c6..6be06a2 100644
--- a/res/xml/available_virtual_keyboard.xml
+++ b/res/xml/available_virtual_keyboard.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="available_virtual_keyboard_page"
android:title="@string/add_virtual_keyboard">
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index 0436105..6009f6a 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -17,8 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/battery_saver"
- android:key="battery_saver_page">
+ android:title="@string/battery_saver">
<Preference
android:key="battery_saver_schedule"
diff --git a/res/xml/bluetooth_screen.xml b/res/xml/bluetooth_screen.xml
index 2a52a7c..cce114b 100644
--- a/res/xml/bluetooth_screen.xml
+++ b/res/xml/bluetooth_screen.xml
@@ -16,7 +16,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="bluetooth_switchbar_screen"
android:title="@string/bluetooth_settings_title">
<Preference
@@ -40,4 +39,4 @@
android:key="bluetooth_screen_footer"
android:selectable="false"
settings:searchable="false"/>
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/captioning_appearance.xml b/res/xml/captioning_appearance.xml
index 66b298d..3e0e804 100644
--- a/res/xml/captioning_appearance.xml
+++ b/res/xml/captioning_appearance.xml
@@ -18,8 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:fragment="com.android.settings.accessibility.CaptionAppearanceFragment"
- android:key="captioning_appearance_screen"
android:title="@string/captioning_caption_appearance_title">
<com.android.settingslib.widget.LayoutPreference
diff --git a/res/xml/captioning_more_options.xml b/res/xml/captioning_more_options.xml
index 9e5a18a..d4111d2 100644
--- a/res/xml/captioning_more_options.xml
+++ b/res/xml/captioning_more_options.xml
@@ -18,8 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:fragment="com.android.settings.accessibility.CaptionMoreOptionsFragment"
- android:key="captioning_more_options_screen"
android:title="@string/captioning_more_options_title" >
<com.android.settings.accessibility.LocalePreference
diff --git a/res/xml/captioning_settings.xml b/res/xml/captioning_settings.xml
index 1a8ed55..c8cb46c 100644
--- a/res/xml/captioning_settings.xml
+++ b/res/xml/captioning_settings.xml
@@ -18,8 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
- android:key="captioning_preference_screen"
android:title="@string/accessibility_captioning_title" >
<SwitchPreference
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/color_mode_settings.xml b/res/xml/color_mode_settings.xml
index b7f58d2..6044141 100644
--- a/res/xml/color_mode_settings.xml
+++ b/res/xml/color_mode_settings.xml
@@ -17,5 +17,4 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="color_mode_settings_screen"
android:title="@string/color_mode_title" />
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index 6e8f701..0217057 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -16,8 +16,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/configure_notification_settings"
- android:key="configure_notification_settings">
+ android:title="@string/configure_notification_settings">
<com.android.settings.widget.VideoPreference
android:key="notification_model_illustration"
diff --git a/res/xml/connected_devices.xml b/res/xml/connected_devices.xml
index 0e5afc3..444b35c 100644
--- a/res/xml/connected_devices.xml
+++ b/res/xml/connected_devices.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="connected_devices_screen"
android:title="@string/connected_devices_dashboard_title">
<com.android.settings.slices.SlicePreference
@@ -57,6 +56,7 @@
android:title="@string/previous_connected_see_all"
android:icon="@drawable/ic_chevron_right_24dp"
android:order="10"
+ settings:searchable="false"
android:fragment="com.android.settings.connecteddevice.PreviouslyConnectedDeviceDashboardFragment"/>
</PreferenceCategory>
diff --git a/res/xml/connected_devices_advanced.xml b/res/xml/connected_devices_advanced.xml
index 7c50bcc..ba62380 100644
--- a/res/xml/connected_devices_advanced.xml
+++ b/res/xml/connected_devices_advanced.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="connected_devices_advanced_screen"
android:title="@string/connected_device_connections_title">
<Preference
@@ -25,24 +24,15 @@
android:key="bluetooth_settings"
android:title="@string/bluetooth_settings_title"
android:icon="@*android:drawable/ic_settings_bluetooth"
- android:order="-9"
- settings:searchable="false"/>
+ android:order="-9"/>
- <SwitchPreference
- android:key="toggle_nfc"
+ <Preference
+ android:fragment="com.android.settings.connecteddevice.NfcAndPaymentFragment"
+ android:key="nfc_and_payment_settings"
android:title="@string/nfc_quick_toggle_title"
android:icon="@drawable/ic_nfc"
- android:summary="@string/nfc_quick_toggle_summary"
- settings:controller="com.android.settings.nfc.NfcPreferenceController"
- android:order="-7"/>
-
- <SwitchPreference
- android:key="nfc_secure_settings"
- android:title="@string/nfc_secure_settings_title"
- settings:controller="com.android.settings.nfc.SecureNfcPreferenceController"
- android:icon="@drawable/ic_nfc"
- android:summary="@string/nfc_secure_toggle_summary"
- android:order="-7"/>
+ android:order="-7"
+ settings:controller="com.android.settings.connecteddevice.NfcAndPaymentFragmentController"/>
<Preference
android:fragment="com.android.settings.wfd.WifiDisplaySettings"
@@ -50,7 +40,6 @@
android:title="@string/wifi_display_settings_title"
android:icon="@drawable/ic_cast_24dp"
android:order="-6"
- settings:searchable="false"
settings:controller="com.android.settings.wfd.WifiDisplayPreferenceController"/>
<com.android.settingslib.RestrictedPreference
@@ -67,8 +56,7 @@
android:summary="@string/summary_placeholder"
android:icon="@*android:drawable/ic_settings_print"
android:fragment="com.android.settings.print.PrintSettingsFragment"
- android:order="-3"
- settings:searchable="false"/>
+ android:order="-3"/>
<Preference
android:key="bt_received_files"
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/res/xml/dark_mode_settings.xml b/res/xml/dark_mode_settings.xml
index cf91186..a5f03d2 100644
--- a/res/xml/dark_mode_settings.xml
+++ b/res/xml/dark_mode_settings.xml
@@ -18,7 +18,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/dark_ui_mode"
- android:key="dark_ui_mode_screen"
settings:keywords="@string/keywords_dark_ui_mode">
<DropDownPreference
@@ -56,4 +55,4 @@
settings:searchable="false"
settings:allowDividerAbove="true"/>
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/data_saver.xml b/res/xml/data_saver.xml
index e884d6d..4a917f6 100644
--- a/res/xml/data_saver.xml
+++ b/res/xml/data_saver.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="data_saver_screen"
android:title="@string/data_saver_title">
<Preference
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index a1e512f..20fac45 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="date_time_settings_screen"
android:title="@string/date_and_time"
settings:keywords="@string/keywords_date_and_time">
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index acd50ad..a49d85b 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -125,8 +125,7 @@
<Preference
android:key="quick_settings_tiles"
android:title="@string/quick_settings_developer_tiles"
- android:fragment="com.android.settings.development.qstile.DevelopmentTileConfigFragment"
- settings:searchable="false" />
+ android:fragment="com.android.settings.development.qstile.DevelopmentTileConfigFragment" />
</PreferenceCategory>
<PreferenceCategory
@@ -208,8 +207,7 @@
<Preference
android:key="feature_flags_dashboard"
android:title="@string/feature_flags_dashboard_title"
- android:fragment="com.android.settings.development.featureflags.FeatureFlagsDashboard"
- settings:searchable="false" />
+ android:fragment="com.android.settings.development.featureflags.FeatureFlagsDashboard" />
<SwitchPreference
android:key="enable_gpu_debug_layers"
@@ -217,11 +215,10 @@
android:summary="@string/enable_gpu_debug_layers_summary" />
<Preference
- android:key="game_driver_dashboard"
- android:title="@string/game_driver_dashboard_title"
- android:summary="@string/game_driver_dashboard_summary"
- android:fragment="com.android.settings.development.gamedriver.GameDriverDashboard"
- settings:searchable="false" />
+ android:key="graphics_driver_dashboard"
+ android:title="@string/graphics_driver_dashboard_title"
+ android:summary="@string/graphics_driver_dashboard_summary"
+ android:fragment="com.android.settings.development.gamedriver.GameDriverDashboard" />
<Preference
android:key="platform_compat_dashboard"
diff --git a/res/xml/development_tile_settings.xml b/res/xml/development_tile_settings.xml
index 3ce6694..e5bfbbf 100644
--- a/res/xml/development_tile_settings.xml
+++ b/res/xml/development_tile_settings.xml
@@ -18,6 +18,5 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="development_tile_settings"
android:title="@string/quick_settings_developer_tiles"
settings:controller="com.android.settings.development.qstile.DevelopmentTilePreferenceController" />
diff --git a/res/xml/device_admin_settings.xml b/res/xml/device_admin_settings.xml
index 1837251..9a48761 100644
--- a/res/xml/device_admin_settings.xml
+++ b/res/xml/device_admin_settings.xml
@@ -19,7 +19,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/manage_device_admin"
- android:key="device_admin_settings"
settings:controller="com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminListPreferenceController">
<com.android.settingslib.widget.FooterPreference
@@ -27,4 +26,4 @@
android:title="@string/no_device_admins"
android:selectable="false"
settings:searchable="false"/>
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 9bc6710..4bf0c82 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -17,9 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="display_settings_screen"
android:title="@string/display_settings"
- settings:keywords="@string/keywords_display"
settings:initialExpandedChildrenCount="5">
<com.android.settingslib.RestrictedPreference
@@ -37,8 +35,7 @@
android:fragment="com.android.settings.display.darkmode.DarkModeSettingsFragment"
android:widgetLayout="@null"
settings:widgetLayout="@null"
- settings:controller="com.android.settings.display.DarkUIPreferenceController"
- settings:searchable="false"/>
+ settings:controller="com.android.settings.display.DarkUIPreferenceController"/>
<com.android.settings.display.NightDisplayPreference
android:key="night_display"
@@ -107,8 +104,7 @@
<com.android.settings.display.ScreenZoomPreference
android:key="display_settings_screen_zoom"
android:title="@string/screen_zoom_title"
- android:fragment="com.android.settings.display.ScreenZoomSettings"
- settings:searchable="false"/>
+ android:fragment="com.android.settings.display.ScreenZoomSettings"/>
<SwitchPreference
android:key="show_operator_name"
@@ -118,13 +114,13 @@
<Preference
android:key="screensaver"
android:title="@string/screensaver_settings_title"
- android:fragment="com.android.settings.dream.DreamSettings"
- settings:searchable="false" />
+ android:fragment="com.android.settings.dream.DreamSettings" />
<Preference
android:key="lockscreen_from_display_settings"
android:title="@string/lockscreen_settings_title"
android:fragment="com.android.settings.security.LockscreenDashboardFragment"
+ settings:keywords="@string/keywords_ambient_display_screen"
settings:controller="com.android.settings.security.screenlock.LockScreenPreferenceController" />
<SwitchPreference
diff --git a/res/xml/double_tap_power_settings.xml b/res/xml/double_tap_power_settings.xml
index c04a90b..cb7bcbe 100644
--- a/res/xml/double_tap_power_settings.xml
+++ b/res/xml/double_tap_power_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- android:key="gesture_double_tap_power_screen"
android:title="@string/double_tap_power_for_camera_title">
<com.android.settings.widget.VideoPreference
@@ -34,4 +33,4 @@
app:controller="com.android.settings.gestures.DoubleTapPowerPreferenceController"
app:allowDividerAbove="true" />
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/double_tap_screen_settings.xml b/res/xml/double_tap_screen_settings.xml
index 2734143..e9eeb3a 100644
--- a/res/xml/double_tap_screen_settings.xml
+++ b/res/xml/double_tap_screen_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- android:key="gesture_double_tap_screen_screen"
android:title="@string/ambient_display_title">
<com.android.settings.widget.VideoPreference
@@ -34,4 +33,4 @@
app:controller="com.android.settings.gestures.DoubleTapScreenPreferenceController"
app:allowDividerAbove="true" />
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/double_twist_gesture_settings.xml b/res/xml/double_twist_gesture_settings.xml
index f91bd35..ad82df3 100644
--- a/res/xml/double_twist_gesture_settings.xml
+++ b/res/xml/double_twist_gesture_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- android:key="gesture_double_twist_screen"
android:title="@string/double_twist_for_camera_mode_title">
<com.android.settings.widget.VideoPreference
@@ -34,4 +33,4 @@
app:controller="com.android.settings.gestures.DoubleTwistPreferenceController"
app:allowDividerAbove="true" />
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/dream_fragment_overview.xml b/res/xml/dream_fragment_overview.xml
index e4c2eb5..3cb49f9 100644
--- a/res/xml/dream_fragment_overview.xml
+++ b/res/xml/dream_fragment_overview.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="dream_overview_screen"
android:title="@string/screensaver_settings_title">
<com.android.settings.widget.GearPreference
@@ -41,4 +40,4 @@
android:layout="@layout/dream_start_button" />
</PreferenceCategory>
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/encryption_and_credential.xml b/res/xml/encryption_and_credential.xml
index f7e7184..b0906c1 100644
--- a/res/xml/encryption_and_credential.xml
+++ b/res/xml/encryption_and_credential.xml
@@ -17,8 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/encryption_and_credential_settings_title"
- android:key="encryption_and_credentials_screen">
+ android:title="@string/encryption_and_credential_settings_title">
<PreferenceCategory
android:key="encryption_and_credentials_status_category"
diff --git a/res/xml/enterprise_privacy_settings.xml b/res/xml/enterprise_privacy_settings.xml
index e0631df..aebd130 100644
--- a/res/xml/enterprise_privacy_settings.xml
+++ b/res/xml/enterprise_privacy_settings.xml
@@ -16,7 +16,6 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="enterprise_privacy_settings"
android:title="@string/enterprise_privacy_settings">
<PreferenceCategory android:key="exposure_category"
diff --git a/res/xml/enterprise_set_default_apps_settings.xml b/res/xml/enterprise_set_default_apps_settings.xml
index 474a5c9..92a38f9 100644
--- a/res/xml/enterprise_set_default_apps_settings.xml
+++ b/res/xml/enterprise_set_default_apps_settings.xml
@@ -16,8 +16,7 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="enterprise_set_default_apps_settings">
+ xmlns:settings="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="dashboard_tile_placeholder"/>
</PreferenceScreen>
diff --git a/res/xml/feature_flags_settings.xml b/res/xml/feature_flags_settings.xml
index 0e509a8..a6cc0a9 100644
--- a/res/xml/feature_flags_settings.xml
+++ b/res/xml/feature_flags_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="feature_flags_settings"
android:title="@string/feature_flags_dashboard_title">
<PreferenceCategory
android:key="feature_flag_category"
diff --git a/res/xml/firmware_version.xml b/res/xml/firmware_version.xml
index 443ae35..f800f0d 100644
--- a/res/xml/firmware_version.xml
+++ b/res/xml/firmware_version.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="firmware_version_screen"
android:title="@string/firmware_version"
settings:keywords="@string/keywords_android_version">
@@ -43,7 +42,6 @@
android:key="module_version"
android:title="@string/module_version"
android:summary="@string/summary_placeholder"
- android:selectable="false"
settings:enableCopying="true"
settings:controller="com.android.settings.deviceinfo.firmwareversion.MainlineModuleVersionPreferenceController"/>
diff --git a/res/xml/gestures.xml b/res/xml/gestures.xml
index ff3a6b5..5ac27e0 100644
--- a/res/xml/gestures.xml
+++ b/res/xml/gestures.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="gesture_settings_screen"
android:title="@string/gesture_preference_title">
<Preference
diff --git a/res/xml/global_actions_panel_settings.xml b/res/xml/global_actions_panel_settings.xml
index 2dc0fe9..3b7bef3 100644
--- a/res/xml/global_actions_panel_settings.xml
+++ b/res/xml/global_actions_panel_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- android:key="gesture_global_actions_panel"
android:title="@string/global_actions_panel_title">
<com.android.settings.widget.VideoPreference
diff --git a/res/xml/game_driver_settings.xml b/res/xml/graphics_driver_settings.xml
similarity index 68%
rename from res/xml/game_driver_settings.xml
rename to res/xml/graphics_driver_settings.xml
index e467320..bc2759f 100644
--- a/res/xml/game_driver_settings.xml
+++ b/res/xml/graphics_driver_settings.xml
@@ -18,27 +18,26 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="game_driver_settings"
- android:title="@string/game_driver_dashboard_title">
+ android:title="@string/graphics_driver_dashboard_title">
<ListPreference
- android:key="game_driver_all_apps_preference"
- android:title="@string/game_driver_all_apps_preference_title"
- android:dialogTitle="@string/game_driver_all_apps_preference_title"
- android:entries="@array/game_driver_all_apps_preference_values"
- android:entryValues="@array/game_driver_all_apps_preference_values"
+ android:key="graphics_driver_all_apps_preference"
+ android:title="@string/graphics_driver_all_apps_preference_title"
+ android:dialogTitle="@string/graphics_driver_all_apps_preference_title"
+ android:entries="@array/graphics_driver_all_apps_preference_values"
+ android:entryValues="@array/graphics_driver_all_apps_preference_values"
settings:controller="com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController">
</ListPreference>
<PreferenceCategory
- android:key="game_driver_category"
- android:title="@string/game_driver_app_preference_title"
+ android:key="graphics_driver_category"
+ android:title="@string/graphics_driver_app_preference_title"
settings:controller="com.android.settings.development.gamedriver.GameDriverAppPreferenceController">
</PreferenceCategory>
<com.android.settingslib.widget.FooterPreference
- android:key="game_driver_footer"
- android:title="@string/game_driver_footer_text"
+ android:key="graphics_driver_footer"
+ android:title="@string/graphics_driver_footer_text"
android:selectable="false"
settings:controller="com.android.settings.development.gamedriver.GameDriverFooterPreferenceController">
</com.android.settingslib.widget.FooterPreference>
diff --git a/res/xml/hardware_info.xml b/res/xml/hardware_info.xml
index 4ed914d..10de299 100644
--- a/res/xml/hardware_info.xml
+++ b/res/xml/hardware_info.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="hardware_info_screen"
android:title="@string/hardware_info"
settings:keywords="@string/keywords_model_and_hardware">
diff --git a/res/xml/install_certificate_from_storage.xml b/res/xml/install_certificate_from_storage.xml
index 640cb56..8227ead 100644
--- a/res/xml/install_certificate_from_storage.xml
+++ b/res/xml/install_certificate_from_storage.xml
@@ -17,8 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/credentials_install"
- android:key="install_certificate_from_storage">
+ android:title="@string/credentials_install">
<PreferenceCategory
android:key="certificate_types">
@@ -76,4 +75,4 @@
</PreferenceCategory>
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/interact_across_profiles.xml b/res/xml/interact_across_profiles.xml
new file mode 100644
index 0000000..6fd1885
--- /dev/null
+++ b/res/xml/interact_across_profiles.xml
@@ -0,0 +1,23 @@
+<?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:title="@string/interact_across_profiles_title"
+ settings:controller="com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesController" />
+
diff --git a/res/xml/interact_across_profiles_permissions_details.xml b/res/xml/interact_across_profiles_permissions_details.xml
new file mode 100644
index 0000000..e9a4803
--- /dev/null
+++ b/res/xml/interact_across_profiles_permissions_details.xml
@@ -0,0 +1,38 @@
+<?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"
+ android:title="@string/interact_across_profiles_title">
+
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="interact_across_profiles_header"
+ android:layout="@layout/cross_profiles_settings_entity_header"
+ android:selectable="false"/>
+
+ <SwitchPreference
+ android:key="interact_across_profiles_settings_switch"
+ android:title="@string/interact_across_profiles_app_detail_switch"/>
+
+ <Preference
+ android:summary="@string/interact_across_profiles_summary_1"
+ android:selectable="false"/>
+
+ <Preference
+ android:summary="@string/interact_across_profiles_summary_2"
+ android:selectable="false"/>
+
+</PreferenceScreen>
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index 03c83d4..c3848e3 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="language_and_input_settings_screen"
android:title="@string/language_settings"
settings:initialExpandedChildrenCount="3">
@@ -39,8 +38,7 @@
android:key="physical_keyboard_pref"
android:title="@string/physical_keyboard_title"
android:summary="@string/summary_placeholder"
- android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"
- settings:searchable="false"/>
+ android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"/>
</PreferenceCategory>
<PreferenceCategory
diff --git a/res/xml/location_scanning.xml b/res/xml/location_scanning.xml
index 5e7bd24..f82500b 100644
--- a/res/xml/location_scanning.xml
+++ b/res/xml/location_scanning.xml
@@ -15,8 +15,7 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/location_scanning_screen_title"
- android:key="scanning_screen">
+ android:title="@string/location_scanning_screen_title">
<SwitchPreference
android:title="@string/location_scanning_wifi_always_scanning_title"
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index fb03f4c..6662c2f 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -17,9 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="location_settings"
- android:title="@string/location_settings_title"
- settings:keywords="@string/keywords_location">
+ android:title="@string/location_settings_title">
<PreferenceCategory
android:key="recent_location_requests"
diff --git a/res/xml/module_licenses.xml b/res/xml/module_licenses.xml
index 005b483..def4d49 100644
--- a/res/xml/module_licenses.xml
+++ b/res/xml/module_licenses.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="module_licenses"
android:title="@string/module_license_title">
<PreferenceCategory
android:key="module_licenses_category"
diff --git a/res/xml/my_device_info.xml b/res/xml/my_device_info.xml
index 3f22a7b..dbf1623 100644
--- a/res/xml/my_device_info.xml
+++ b/res/xml/my_device_info.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="my_device_info_pref_screen"
android:title="@string/about_settings">
<com.android.settingslib.widget.LayoutPreference
@@ -68,8 +67,7 @@
android:order="15"
android:title="@string/legal_information"
android:fragment="com.android.settings.LegalSettings"
- settings:allowDividerAbove="true"
- settings:searchable="false"/>
+ settings:allowDividerAbove="true"/>
<!-- Regulatory labels -->
<Preference
diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml
index 5280221..c57c5b0 100644
--- a/res/xml/network_and_internet.xml
+++ b/res/xml/network_and_internet.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="network_and_internet_screen"
android:title="@string/network_dashboard_title"
settings:initialExpandedChildrenCount="5">
diff --git a/res/xml/nfc_and_payment_settings.xml b/res/xml/nfc_and_payment_settings.xml
new file mode 100644
index 0000000..f240388
--- /dev/null
+++ b/res/xml/nfc_and_payment_settings.xml
@@ -0,0 +1,40 @@
+<?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:title="@string/nfc_quick_toggle_title">
+
+ <SwitchPreference
+ android:key="toggle_nfc"
+ android:title="@string/nfc_quick_toggle_title"
+ android:summary="@string/nfc_quick_toggle_summary"
+ settings:controller="com.android.settings.nfc.NfcPreferenceController"/>
+
+ <SwitchPreference
+ android:key="nfc_secure_settings"
+ android:title="@string/nfc_secure_settings_title"
+ settings:controller="com.android.settings.nfc.SecureNfcPreferenceController"
+ android:summary="@string/nfc_secure_toggle_summary"/>
+
+ <Preference
+ android:key="default_payment_app"
+ android:title="@string/nfc_payment_settings_title"
+ android:fragment="com.android.settings.nfc.PaymentSettings"
+ settings:keywords="@string/keywords_default_payment_app"
+ settings:controller="com.android.settings.applications.specialaccess.DefaultPaymentSettingsPreferenceController"/>
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/nfc_payment_settings.xml b/res/xml/nfc_payment_settings.xml
index 2508c39..8e55a39 100644
--- a/res/xml/nfc_payment_settings.xml
+++ b/res/xml/nfc_payment_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="nfc_payment_settings_screen"
android:title="@string/nfc_payment_settings_title">
<com.android.settings.nfc.NfcPaymentPreference
diff --git a/res/xml/night_display_settings.xml b/res/xml/night_display_settings.xml
index 1a769f5..eed5c77 100644
--- a/res/xml/night_display_settings.xml
+++ b/res/xml/night_display_settings.xml
@@ -18,7 +18,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/night_display_title"
- android:key="night_display_title"
settings:keywords="@string/keywords_display_night_display">
<DropDownPreference
@@ -60,4 +59,4 @@
settings:allowDividerAbove="true"
settings:controller="com.android.settings.display.NightDisplayFooterPreferenceController"/>
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/notification_access_settings.xml b/res/xml/notification_access_settings.xml
index 4dbaf88..ca84f1b 100644
--- a/res/xml/notification_access_settings.xml
+++ b/res/xml/notification_access_settings.xml
@@ -18,6 +18,5 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="notification_access_screen"
android:title="@string/manage_notification_access_title"
settings:controller="com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessScreenPreferenceController" />
diff --git a/res/xml/physical_keyboard_settings.xml b/res/xml/physical_keyboard_settings.xml
index a2d9a6b..96946a9 100644
--- a/res/xml/physical_keyboard_settings.xml
+++ b/res/xml/physical_keyboard_settings.xml
@@ -15,7 +15,6 @@
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="physical_keyboard_screen"
android:title="@string/physical_keyboard_title">
<!-- Additional preference screens are inserted here programmatically
with low order values to set the key map of each attached keyboard. -->
diff --git a/res/xml/pick_up_gesture_settings.xml b/res/xml/pick_up_gesture_settings.xml
index 47f707a..178ddf5 100644
--- a/res/xml/pick_up_gesture_settings.xml
+++ b/res/xml/pick_up_gesture_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- android:key="gesture_pick_up_screen"
android:title="@string/ambient_display_pickup_title">
<com.android.settings.widget.VideoPreference
@@ -34,4 +33,4 @@
app:controller="com.android.settings.gestures.PickupGesturePreferenceController"
app:allowDividerAbove="true" />
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/picture_in_picture_settings.xml b/res/xml/picture_in_picture_settings.xml
index 35839cd..1f08246 100644
--- a/res/xml/picture_in_picture_settings.xml
+++ b/res/xml/picture_in_picture_settings.xml
@@ -18,6 +18,5 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="picture_in_picture_screen"
android:title="@string/picture_in_picture_title"
settings:controller="com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureScreenPreferenceController" />
diff --git a/res/xml/platform_compat_settings.xml b/res/xml/platform_compat_settings.xml
index bee2324..86e62fe 100644
--- a/res/xml/platform_compat_settings.xml
+++ b/res/xml/platform_compat_settings.xml
@@ -18,6 +18,5 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="platform_compat_dashboard"
android:title="@string/platform_compat_dashboard_title">
</PreferenceScreen>
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index 005ce17..869bb94 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -17,9 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="power_usage_summary_screen"
- android:title="@string/power_usage_summary_title"
- settings:keywords="@string/keywords_battery">
+ android:title="@string/power_usage_summary_title">
<com.android.settingslib.widget.LayoutPreference
android:key="battery_header"
diff --git a/res/xml/premium_sms_settings.xml b/res/xml/premium_sms_settings.xml
index 17d1297..82aece3 100644
--- a/res/xml/premium_sms_settings.xml
+++ b/res/xml/premium_sms_settings.xml
@@ -18,6 +18,5 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="premium_sms_screen"
android:title="@string/premium_sms_access"
settings:controller="com.android.settings.applications.specialaccess.premiumsms.PremiumSmsScreenPreferenceController" />
diff --git a/res/xml/prevent_ringing_gesture_settings.xml b/res/xml/prevent_ringing_gesture_settings.xml
index 4b0edc3..cc2f234 100644
--- a/res/xml/prevent_ringing_gesture_settings.xml
+++ b/res/xml/prevent_ringing_gesture_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- android:key="gesture_prevent_ringing_screen"
android:title="@string/gesture_prevent_ringing_screen_title">
<com.android.settings.widget.VideoPreference
@@ -33,4 +32,4 @@
<PreferenceCategory
android:key="gesture_prevent_ringing_category"
android:title="@string/gesture_prevent_ringing_title" />
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/previously_connected_devices.xml b/res/xml/previously_connected_devices.xml
index 8c5509b..435ced7 100644
--- a/res/xml/previously_connected_devices.xml
+++ b/res/xml/previously_connected_devices.xml
@@ -17,11 +17,10 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="connected_devices_screen_previously"
android:title="@string/connected_device_previously_connected_screen_title">
<PreferenceCategory
android:key="saved_device_list"
settings:controller="com.android.settings.connecteddevice.SavedDeviceGroupController"/>
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/print_settings.xml b/res/xml/print_settings.xml
index 8d840d1..1919e53 100644
--- a/res/xml/print_settings.xml
+++ b/res/xml/print_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="print_settings_screen"
android:title="@string/print_settings"
settings:keywords="@string/keywords_printing">
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 623460c..abedc53 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="privacy_dashboard_page"
android:title="@string/privacy_dashboard_title"
settings:initialExpandedChildrenCount="4">
diff --git a/res/xml/reset_dashboard_fragment.xml b/res/xml/reset_dashboard_fragment.xml
index 1b8dc68..ac4ccb5 100644
--- a/res/xml/reset_dashboard_fragment.xml
+++ b/res/xml/reset_dashboard_fragment.xml
@@ -18,8 +18,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/reset_dashboard_title"
- android:key="reset_dashboard_fragment_screen">
+ android:title="@string/reset_dashboard_title">
<!-- Network reset -->
<com.android.settingslib.RestrictedPreference
diff --git a/res/xml/screen_pinning_settings.xml b/res/xml/screen_pinning_settings.xml
index 7ff7f1d..04e5377 100644
--- a/res/xml/screen_pinning_settings.xml
+++ b/res/xml/screen_pinning_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="screen_pinning_settings_screen"
android:title="@string/screen_pinning_title">
<SwitchPreference
diff --git a/res/xml/security_dashboard_settings.xml b/res/xml/security_dashboard_settings.xml
index 6a896ce..cf56d67 100644
--- a/res/xml/security_dashboard_settings.xml
+++ b/res/xml/security_dashboard_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_dashboard_page"
android:title="@string/security_settings_title"
settings:initialExpandedChildrenCount="9">
@@ -147,4 +146,4 @@
android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.security.ScreenPinningSettings" />
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index 8cd4d76..dfc5ce7 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -17,9 +17,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_lockscreen_settings_screen"
- android:title="@string/lockscreen_settings_title"
- settings:keywords="@string/keywords_ambient_display_screen">
+ android:title="@string/lockscreen_settings_title">
<PreferenceCategory
android:key="lockscreen_what_to_show"
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index d82a324..c525ccd 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -18,7 +18,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/sound_settings"
- android:key="sound_settings"
settings:keywords="@string/keywords_sounds"
settings:initialExpandedChildrenCount="9">
@@ -88,11 +87,12 @@
settings:controller="com.android.settings.notification.NotificationVolumePreferenceController"/>
<!-- Also vibrate for calls -->
- <SwitchPreference
- android:key="vibrate_when_ringing"
+ <Preference
+ android:fragment="com.android.settings.sound.VibrateForCallsPreferenceFragment"
+ android:key="vibrate_for_calls"
android:title="@string/vibrate_when_ringing_title"
- settings:controller="com.android.settings.notification.VibrateWhenRingPreferenceController"
- android:order="-130"/>
+ android:order="-130"
+ settings:controller="com.android.settings.sound.VibrateForCallsPreferenceController"/>
<!-- Interruptions -->
<com.android.settingslib.RestrictedPreference
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index e511d17..132d50e 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="special_app_access_screen"
android:title="@string/special_access">
<Preference
@@ -101,13 +100,6 @@
settings:controller="com.android.settings.applications.specialaccess.premiumsms.PremiumSmsController" />
<Preference
- android:key="default_payment_app"
- android:title="@string/nfc_payment_settings_title"
- android:fragment="com.android.settings.nfc.PaymentSettings"
- settings:keywords="@string/keywords_default_payment_app"
- settings:controller="com.android.settings.applications.specialaccess.DefaultPaymentSettingsPreferenceController" />
-
- <Preference
android:key="data_saver"
android:title="@string/unrestricted_data_saver"
android:fragment="com.android.settings.datausage.UnrestrictedDataAccess"
@@ -155,6 +147,13 @@
</Preference>
<Preference
+ android:key="interact_across_profiles"
+ android:title="@string/interact_across_profiles_title"
+ android:fragment="com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesSettings"
+ settings:keywords="@string/interact_across_profiles_keywords"
+ settings:controller="com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesController"/>
+
+ <Preference
android:key="special_access_more"
android:title="@string/special_access_more"
settings:controller="com.android.settings.applications.specialaccess.MoreSpecialAccessPreferenceController" />
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index 66447cd..51d4935 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="storage_dashboard_screen"
android:title="@string/storage_settings"
android:orderingFromXml="false">
<com.android.settings.deviceinfo.storage.StorageSummaryDonutPreference
diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index 88b8d2f..5d0fbcd 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="system_dashboard_screen"
android:title="@string/header_category_system"
settings:initialExpandedChildrenCount="4">
@@ -76,4 +75,4 @@
android:targetClass="@string/additional_system_update_menu"/>
</Preference>
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/system_navigation_gesture_settings.xml b/res/xml/system_navigation_gesture_settings.xml
index b1045fc..a75875b 100644
--- a/res/xml/system_navigation_gesture_settings.xml
+++ b/res/xml/system_navigation_gesture_settings.xml
@@ -18,6 +18,5 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="gesture_system_navigation_screen"
android:title="@string/system_navigation_title"
settings:keywords="@string/keywords_system_navigation"/>
diff --git a/res/xml/tap_screen_gesture_settings.xml b/res/xml/tap_screen_gesture_settings.xml
index 9c0610a..fe31225 100644
--- a/res/xml/tap_screen_gesture_settings.xml
+++ b/res/xml/tap_screen_gesture_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
- android:key="gesture_tap_screen"
android:title="@string/ambient_display_tap_screen_title">
<com.android.settings.widget.VideoPreference
@@ -34,4 +33,4 @@
app:controller="com.android.settings.gestures.TapScreenGesturePreferenceController"
app:allowDividerAbove="true" />
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/tether_prefs.xml b/res/xml/tether_prefs.xml
index 54c49e8..70d55aa 100644
--- a/res/xml/tether_prefs.xml
+++ b/res/xml/tether_prefs.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="tether_prefs_screen"
android:title="@string/tether_settings_title_all">
<com.android.settings.widget.FixedLineSummaryPreference
diff --git a/res/xml/time_zone_prefs.xml b/res/xml/time_zone_prefs.xml
index 6fa43fa..fa5cf97 100644
--- a/res/xml/time_zone_prefs.xml
+++ b/res/xml/time_zone_prefs.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="time_zone_settings_screen"
android:title="@string/date_time_set_timezone">
<PreferenceCategory
diff --git a/res/xml/top_level_settings.xml b/res/xml/top_level_settings.xml
index 367f426..8f8d3d1 100644
--- a/res/xml/top_level_settings.xml
+++ b/res/xml/top_level_settings.xml
@@ -53,6 +53,7 @@
android:icon="@drawable/ic_homepage_battery"
android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
android:order="-90"
+ settings:keywords="@string/keywords_battery"
settings:controller="com.android.settings.fuelgauge.TopLevelBatteryPreferenceController"/>
<Preference
@@ -79,6 +80,7 @@
android:icon="@drawable/ic_homepage_storage"
android:order="-60"
android:fragment="com.android.settings.deviceinfo.StorageSettings"
+ settings:keywords="@string/keywords_display"
settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/>
<Preference
@@ -96,6 +98,7 @@
android:icon="@drawable/ic_homepage_location"
android:order="-50"
android:fragment="com.android.settings.location.LocationSettings"
+ settings:keywords="@string/keywords_location"
settings:controller="com.android.settings.location.TopLevelLocationPreferenceController"/>
<Preference
@@ -114,6 +117,7 @@
android:icon="@drawable/ic_homepage_accounts"
android:order="-30"
android:fragment="com.android.settings.accounts.AccountDashboardFragment"
+ settings:keywords="@string/keywords_accounts"
settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/>
<Preference
diff --git a/res/xml/trust_agent_settings.xml b/res/xml/trust_agent_settings.xml
index c6539c4..88837b8 100644
--- a/res/xml/trust_agent_settings.xml
+++ b/res/xml/trust_agent_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="trust_agents"
android:title="@string/manage_trust_agents"
settings:controller="com.android.settings.security.trustagent.TrustAgentsPreferenceController">
</PreferenceScreen>
diff --git a/res/xml/tts_engine_picker.xml b/res/xml/tts_engine_picker.xml
index 2550fe0..fd431ce 100644
--- a/res/xml/tts_engine_picker.xml
+++ b/res/xml/tts_engine_picker.xml
@@ -15,7 +15,6 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="tts_engine_picker_screen"
android:title="@string/tts_engine_preference_title">
</PreferenceScreen>
diff --git a/res/xml/tts_settings.xml b/res/xml/tts_settings.xml
index 92bf5d7..bcc9c85 100644
--- a/res/xml/tts_settings.xml
+++ b/res/xml/tts_settings.xml
@@ -17,14 +17,12 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="tts_settings_screen"
android:title="@string/tts_settings_title">
<com.android.settings.widget.GearPreference
android:key="tts_engine_preference"
android:title="@string/tts_engine_preference_title"
- android:fragment="com.android.settings.tts.TtsEnginePreferenceFragment"
- settings:searchable="false"/>
+ android:fragment="com.android.settings.tts.TtsEnginePreferenceFragment"/>
<ListPreference
android:key="tts_default_lang"
diff --git a/res/xml/unrestricted_data_access_settings.xml b/res/xml/unrestricted_data_access_settings.xml
index a386d1b..baefa65 100644
--- a/res/xml/unrestricted_data_access_settings.xml
+++ b/res/xml/unrestricted_data_access_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="unrestricted_data_screen"
android:title="@string/unrestricted_data_saver"
settings:controller="com.android.settings.datausage.UnrestrictedDataAccessPreferenceController">
</PreferenceScreen>
diff --git a/res/xml/usb_default_fragment.xml b/res/xml/usb_default_fragment.xml
index b8d5e53..b062b8f 100644
--- a/res/xml/usb_default_fragment.xml
+++ b/res/xml/usb_default_fragment.xml
@@ -16,6 +16,5 @@
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/usb_pref"
- android:key="usb_default_fragment">
+ android:title="@string/usb_pref">
</PreferenceScreen>
diff --git a/res/xml/user_dictionary_list_fragment.xml b/res/xml/user_dictionary_list_fragment.xml
index 46418c1..2f921a0 100644
--- a/res/xml/user_dictionary_list_fragment.xml
+++ b/res/xml/user_dictionary_list_fragment.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="user_dict_list"
android:title="@string/user_dict_settings_title"
settings:controller="com.android.settings.inputmethod.UserDictionaryListPreferenceController">
diff --git a/res/xml/vibrate_for_calls_settings.xml b/res/xml/vibrate_for_calls_settings.xml
new file mode 100644
index 0000000..5b6d217
--- /dev/null
+++ b/res/xml/vibrate_for_calls_settings.xml
@@ -0,0 +1,20 @@
+<?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"
+ android:title="@string/vibrate_when_ringing_title" />
diff --git a/res/xml/virtual_keyboard_settings.xml b/res/xml/virtual_keyboard_settings.xml
index f248236..5a30082 100644
--- a/res/xml/virtual_keyboard_settings.xml
+++ b/res/xml/virtual_keyboard_settings.xml
@@ -16,7 +16,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="virtual_keyboard_category"
android:title="@string/virtual_keyboard_category">
<!-- Enabled input method list will be populated programmatically here. -->
<Preference
diff --git a/res/xml/vr_listeners_settings.xml b/res/xml/vr_listeners_settings.xml
index ffd8545..a35b987 100644
--- a/res/xml/vr_listeners_settings.xml
+++ b/res/xml/vr_listeners_settings.xml
@@ -18,6 +18,5 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="vr_listener_settings"
android:title="@string/vr_listeners_title"
settings:controller="com.android.settings.applications.specialaccess.vrlistener.VrListenerScreenPreferenceController" />
diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml
index 41d101b..cc281fa 100644
--- a/res/xml/wifi_configure_settings.xml
+++ b/res/xml/wifi_configure_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="wifi_configure_settings_screen"
android:title="@string/wifi_configure_settings_preference_title">
<SwitchPreference
diff --git a/res/xml/wifi_display_settings.xml b/res/xml/wifi_display_settings.xml
index 769e9ce..62b75c2 100644
--- a/res/xml/wifi_display_settings.xml
+++ b/res/xml/wifi_display_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="wifi_display_settings_screen"
android:title="@string/wifi_display_settings_title"
settings:keywords="@string/keywords_display_cast_screen">
diff --git a/res/xml/wifi_tether_settings.xml b/res/xml/wifi_tether_settings.xml
index 3a3bdc4..1f43bb5 100644
--- a/res/xml/wifi_tether_settings.xml
+++ b/res/xml/wifi_tether_settings.xml
@@ -18,9 +18,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="wifi_tether_settings_screen"
- android:title="@string/wifi_hotspot_checkbox_text"
- settings:searchable="false">
+ android:title="@string/wifi_hotspot_checkbox_text">
<com.android.settings.wifi.tether.WifiTetherSsidPreference
android:key="wifi_tether_network_name"
diff --git a/res/xml/zen_access_settings.xml b/res/xml/zen_access_settings.xml
index 48dc1af..35cfdb8 100644
--- a/res/xml/zen_access_settings.xml
+++ b/res/xml/zen_access_settings.xml
@@ -17,5 +17,4 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="zen_access_screen"
android:title="@string/manage_zen_access_title" />
diff --git a/res/xml/zen_mode_automation_settings.xml b/res/xml/zen_mode_automation_settings.xml
index 467331d..f00865d 100644
--- a/res/xml/zen_mode_automation_settings.xml
+++ b/res/xml/zen_mode_automation_settings.xml
@@ -16,7 +16,6 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="zen_mode_automation_settings_page"
android:title="@string/zen_mode_automation_settings_page_title" >
<PreferenceCategory
diff --git a/res/xml/zen_mode_bypassing_apps.xml b/res/xml/zen_mode_bypassing_apps.xml
index 0789839..bd46c67 100644
--- a/res/xml/zen_mode_bypassing_apps.xml
+++ b/res/xml/zen_mode_bypassing_apps.xml
@@ -17,5 +17,4 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="zen_mode_bypassing_apps_screen"
android:title="@string/zen_mode_bypassing_apps_title" />
diff --git a/res/xml/zen_mode_people_settings.xml b/res/xml/zen_mode_people_settings.xml
index 5456f6f..7755bb7 100644
--- a/res/xml/zen_mode_people_settings.xml
+++ b/res/xml/zen_mode_people_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="zen_mode_people_settings_page"
android:title="@string/zen_category_people" >
<PreferenceCategory
@@ -59,6 +58,13 @@
<PreferenceCategory
android:title="@string/zen_mode_conversations_title"
android:key="zen_mode_settings_category_conversations">
+
+ <!-- Conversations -->
+ <ListPreference
+ android:key="zen_mode_conversations"
+ android:title="@string/zen_mode_conversations_title"
+ android:entries="@array/zen_mode_conversations_entries"
+ android:entryValues="@array/zen_mode_conversations_values"/>
</PreferenceCategory>
<!-- Footer that shows if user is put into alarms only or total silence mode by an app -->
diff --git a/res/xml/zen_mode_restrict_notifications_settings.xml b/res/xml/zen_mode_restrict_notifications_settings.xml
index b0705cb..ad574d8 100644
--- a/res/xml/zen_mode_restrict_notifications_settings.xml
+++ b/res/xml/zen_mode_restrict_notifications_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="zen_mode_restrict_settings_page"
android:title="@string/zen_mode_restrict_notifications_title">
<PreferenceCategory
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index 13cf945..a55c6be 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -18,7 +18,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="zen_mode_settings"
android:title=" ">
<!-- Turn on DND button -->
diff --git a/res/xml/zen_mode_sound_vibration_settings.xml b/res/xml/zen_mode_sound_vibration_settings.xml
index 4aacda3..26f003f 100644
--- a/res/xml/zen_mode_sound_vibration_settings.xml
+++ b/res/xml/zen_mode_sound_vibration_settings.xml
@@ -17,7 +17,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="zen_mode_sound_vibration_settings_page"
android:title="@string/zen_category_exceptions" >
<PreferenceCategory
diff --git a/src/com/android/settings/AllInOneTetherSettings.java b/src/com/android/settings/AllInOneTetherSettings.java
index 098e6fb..996c434 100644
--- a/src/com/android/settings/AllInOneTetherSettings.java
+++ b/src/com/android/settings/AllInOneTetherSettings.java
@@ -20,7 +20,7 @@
import static android.net.ConnectivityManager.TETHERING_WIFI;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_CHANGED_ACTION;
-import static com.android.settings.network.WifiTetherDisablePreferenceController.KEY_ENABLE_WIFI_TETHERING;
+import static com.android.settings.network.TetherEnabler.KEY_ENABLE_WIFI_TETHERING;
import android.app.settings.SettingsEnums;
import android.bluetooth.BluetoothAdapter;
diff --git a/src/com/android/settings/LinkifyUtils.java b/src/com/android/settings/LinkifyUtils.java
index 5550db5..7da7ed2 100644
--- a/src/com/android/settings/LinkifyUtils.java
+++ b/src/com/android/settings/LinkifyUtils.java
@@ -74,7 +74,7 @@
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
- ds.setUnderlineText(false);
+ ds.setUnderlineText(true);
}
};
spannableContent.setSpan(spannableLink, beginIndex, endIndex,
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 83ee3fd..2fcd949 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -132,6 +132,12 @@
/* empty */
}
public static class GestureNavigationSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class InteractAcrossProfilesSettingsActivity extends SettingsActivity {
+ /* empty */
+ }
+ public static class AppInteractAcrossProfilesSettingsActivity extends SettingsActivity {
+ /* empty */
+ }
public static class ApnSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiCallingSettingsActivity extends SettingsActivity { /* empty */ }
@@ -151,6 +157,7 @@
public static class ManagedProfileSettingsActivity extends SettingsActivity { /* empty */ }
public static class DeletionHelperActivity extends SettingsActivity { /* empty */ }
+
public static class ApnEditorActivity extends SettingsActivity { /* empty */ }
public static class ChooseAccountActivity extends SettingsActivity { /* empty */ }
public static class IccLockSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 8a96484..315cba1 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -688,6 +688,15 @@
return um.getCredentialOwnerProfile(userId);
}
+ /**
+ * Returns the credential type of the given user id.
+ */
+ public static @LockPatternUtils.CredentialType int getCredentialType(Context context,
+ int userId) {
+ final LockPatternUtils lpu = new LockPatternUtils(context);
+ return lpu.getCredentialTypeForUser(userId);
+ }
+
private static final StringBuilder sBuilder = new StringBuilder(50);
private static final java.util.Formatter sFormatter = new java.util.Formatter(
sBuilder, Locale.getDefault());
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
index 159e609..2bcb5b3 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizard.java
@@ -16,6 +16,8 @@
package com.android.settings.accessibility;
+import static com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType.LEGACY;
+
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
@@ -99,9 +101,11 @@
public void onResume() {
super.onResume();
updateAccessibilityServicePreference(mScreenReaderPreference,
- findService(SCREEN_READER_PACKAGE_NAME, SCREEN_READER_SERVICE_NAME));
+ SCREEN_READER_PACKAGE_NAME, SCREEN_READER_SERVICE_NAME,
+ LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.class.getName());
updateAccessibilityServicePreference(mSelectToSpeakPreference,
- findService(SELECT_TO_SPEAK_PACKAGE_NAME, SELECT_TO_SPEAK_SERVICE_NAME));
+ SELECT_TO_SPEAK_PACKAGE_NAME, SELECT_TO_SPEAK_SERVICE_NAME,
+ LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.class.getName());
configureMagnificationPreferenceIfNeeded(mDisplayMagnificationPreference);
}
@@ -143,7 +147,8 @@
}
private void updateAccessibilityServicePreference(Preference preference,
- AccessibilityServiceInfo info) {
+ String packageName, String serviceName, String targetLegacyFragment) {
+ final AccessibilityServiceInfo info = findService(packageName, serviceName);
if (info == null) {
getPreferenceScreen().removePreference(preference);
return;
@@ -154,6 +159,9 @@
preference.setTitle(title);
ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
preference.setKey(componentName.flattenToString());
+ if (AccessibilityUtil.getAccessibilityServiceFragmentType(info) == LEGACY) {
+ preference.setFragment(targetLegacyFragment);
+ }
// Update the extras.
Bundle extras = preference.getExtras();
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/AutoclickPreferenceController.java b/src/com/android/settings/accessibility/AutoclickPreferenceController.java
index 4d85b52..b354aa6 100644
--- a/src/com/android/settings/accessibility/AutoclickPreferenceController.java
+++ b/src/com/android/settings/accessibility/AutoclickPreferenceController.java
@@ -31,7 +31,7 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE_UNSEARCHABLE;
+ return AVAILABLE;
}
@Override
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
new file mode 100644
index 0000000..82d80e0
--- /dev/null
+++ b/src/com/android/settings/accessibility/LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.java
@@ -0,0 +1,50 @@
+/*
+ * 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.app.settings.SettingsEnums;
+import android.os.Bundle;
+
+/** For accessibility services that target SDK <= Q in setup wizard. */
+public class LegacyToggleScreenReaderPreferenceFragmentForSetupWizard
+ extends LegacyAccessibilityServicePreferenceFragment {
+
+ private boolean mToggleSwitchWasInitiallyChecked;
+
+ @Override
+ protected void onProcessArguments(Bundle arguments) {
+ super.onProcessArguments(arguments);
+ mToggleSwitchWasInitiallyChecked = mToggleServiceDividerSwitchPreference.isChecked();
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
+ }
+
+ @Override
+ public void onStop() {
+ // Log the final choice in value if it's different from the previous value.
+ if (mToggleServiceDividerSwitchPreference.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ mMetricsFeatureProvider.action(getContext(),
+ SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER,
+ mToggleServiceDividerSwitchPreference.isChecked());
+ }
+
+ super.onStop();
+ }
+}
diff --git a/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
new file mode 100644
index 0000000..9953faf
--- /dev/null
+++ b/src/com/android/settings/accessibility/LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.java
@@ -0,0 +1,50 @@
+/*
+ * 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.app.settings.SettingsEnums;
+import android.os.Bundle;
+
+/** For accessibility services that target SDK <= Q in setup wizard. */
+public class LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard
+ extends LegacyAccessibilityServicePreferenceFragment {
+
+ private boolean mToggleSwitchWasInitiallyChecked;
+
+ @Override
+ protected void onProcessArguments(Bundle arguments) {
+ super.onProcessArguments(arguments);
+ mToggleSwitchWasInitiallyChecked = mToggleServiceDividerSwitchPreference.isChecked();
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
+ }
+
+ @Override
+ public void onStop() {
+ // Log the final choice in value if it's different from the previous value.
+ if (mToggleServiceDividerSwitchPreference.isChecked() != mToggleSwitchWasInitiallyChecked) {
+ mMetricsFeatureProvider.action(getContext(),
+ SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK,
+ mToggleServiceDividerSwitchPreference.isChecked());
+ }
+
+ super.onStop();
+ }
+}
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index 36b2da1..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;
@@ -89,10 +90,8 @@
@Override
public void onResume() {
super.onResume();
-
- mSettingsContentObserver.register(getContentResolver());
-
updateSwitchBarToggleSwitch();
+ mSettingsContentObserver.register(getContentResolver());
}
@Override
@@ -188,18 +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);
- mSwitchBar.setCheckedInternal(checked);
+ if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
+ return;
+ }
+ mToggleServiceDividerSwitchPreference.setChecked(checked);
}
/**
@@ -250,7 +252,7 @@
}
private void handleConfirmServiceEnabled(boolean confirmed) {
- mSwitchBar.setCheckedInternal(confirmed);
+ mToggleServiceDividerSwitchPreference.setChecked(confirmed);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, confirmed);
onPreferenceToggled(mPreferenceKey, confirmed);
}
@@ -273,9 +275,9 @@
}
@Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
- mToggleSwitch.setOnBeforeCheckedChangeListener(this::onBeforeCheckedChanged);
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(this::onPreferenceClick);
}
@Override
@@ -409,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()) {
@@ -423,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
new file mode 100644
index 0000000..9079c31
--- /dev/null
+++ b/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java
@@ -0,0 +1,230 @@
+/*
+ * 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 static android.content.Context.MODE_PRIVATE;
+
+import static com.android.settings.accessibility.ToggleAutoclickPreferenceController.KEY_DELAY_MODE;
+
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import android.annotation.IntDef;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.provider.Settings;
+import android.view.accessibility.AccessibilityManager;
+import android.widget.ImageView;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+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.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+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.
+ */
+public class ToggleAutoclickCustomSeekbarController extends BasePreferenceController
+ 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";
+
+ // Min allowed autoclick delay value.
+ static final int MIN_AUTOCLICK_DELAY_MS = 200;
+
+ // Max allowed autoclick delay value.
+ static final int MAX_AUTOCLICK_DELAY_MS = 1000;
+
+ // Allowed autoclick delay values are discrete.
+ // This is the difference between two allowed values.
+ private static final int AUTOCLICK_DELAY_STEP = 100;
+
+ private final SharedPreferences mSharedPreferences;
+ private final ContentResolver mContentResolver;
+ private ImageView mShorter;
+ private ImageView mLonger;
+ private SeekBar mSeekBar;
+ private TextView mDelayLabel;
+
+ private final SeekBar.OnSeekBarChangeListener mSeekBarChangeListener =
+ new SeekBar.OnSeekBarChangeListener() {
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ updateCustomDelayValue(seekBarProgressToDelay(progress));
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ // Nothing to do.
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ // Nothing to do.
+ }
+ };
+
+ public ToggleAutoclickCustomSeekbarController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ mSharedPreferences = context.getSharedPreferences(context.getPackageName(), MODE_PRIVATE);
+ mContentResolver = context.getContentResolver();
+ }
+
+ public ToggleAutoclickCustomSeekbarController(Context context, Lifecycle lifecycle,
+ String preferenceKey) {
+ this(context, preferenceKey);
+
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ public void onResume() {
+ if (mSharedPreferences != null) {
+ mSharedPreferences.registerOnSharedPreferenceChangeListener(this);
+ }
+ }
+
+ @Override
+ public void onPause() {
+ if (mSharedPreferences != null) {
+ mSharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
+ }
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final LayoutPreference preference = screen.findPreference(getPreferenceKey());
+
+ if (isAvailable()) {
+ int delayMillis = getSharedPreferenceForDelayValue();
+ // Initialize seek bar preference. Sets seek bar size to the number of possible delay
+ // values.
+ mSeekBar = preference.findViewById(R.id.autoclick_delay);
+ mSeekBar.setMax(delayToSeekBarProgress(MAX_AUTOCLICK_DELAY_MS));
+ mSeekBar.setProgress(delayToSeekBarProgress(delayMillis));
+ mSeekBar.setOnSeekBarChangeListener(mSeekBarChangeListener);
+
+ mDelayLabel = preference.findViewById(R.id.current_label);
+ mDelayLabel.setText(delayTimeToString(delayMillis));
+
+ mShorter = preference.findViewById(R.id.smaller);
+ mShorter.setOnClickListener(v -> {
+ minusDelayByImageView();
+ });
+
+ mLonger = preference.findViewById(R.id.larger);
+ mLonger.setOnClickListener(v -> {
+ plusDelayByImageView();
+ });
+ }
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if (KEY_DELAY_MODE.equals(key)) {
+ int delayMillis = getSharedPreferenceForDelayValue();
+ updateCustomDelayValue(delayMillis);
+ }
+ }
+
+ /** Converts seek bar preference progress value to autoclick delay associated with it. */
+ private int seekBarProgressToDelay(int progress) {
+ return progress * AUTOCLICK_DELAY_STEP + MIN_AUTOCLICK_DELAY_MS;
+ }
+
+ /**
+ * Converts autoclick delay value to seek bar preference progress values that represents said
+ * delay.
+ */
+ private int delayToSeekBarProgress(int delayMillis) {
+ return (delayMillis - MIN_AUTOCLICK_DELAY_MS) / AUTOCLICK_DELAY_STEP;
+ }
+
+ private int getSharedPreferenceForDelayValue() {
+ int delayMillis = mSharedPreferences.getInt(KEY_CUSTOM_DELAY_VALUE,
+ AccessibilityManager.AUTOCLICK_DELAY_DEFAULT);
+
+ return delayMillis;
+ }
+
+ private void putSecureInt(String name, int value) {
+ Settings.Secure.putInt(mContentResolver, name, value);
+ }
+
+ private void updateCustomDelayValue(int delayMillis) {
+ putSecureInt(CONTROL_AUTOCLICK_DELAY_SECURE, delayMillis);
+ mSharedPreferences.edit().putInt(KEY_CUSTOM_DELAY_VALUE, delayMillis).apply();
+ mSeekBar.setProgress(delayToSeekBarProgress(delayMillis));
+ mDelayLabel.setText(delayTimeToString(delayMillis));
+ }
+
+ private void minusDelayByImageView() {
+ int delayMillis = getSharedPreferenceForDelayValue();
+ if (delayMillis > MIN_AUTOCLICK_DELAY_MS) {
+ updateCustomDelayValue(delayMillis - AUTOCLICK_DELAY_STEP);
+ }
+ }
+
+ private void plusDelayByImageView() {
+ int delayMillis = getSharedPreferenceForDelayValue();
+ if (delayMillis < MAX_AUTOCLICK_DELAY_MS) {
+ updateCustomDelayValue(delayMillis + AUTOCLICK_DELAY_STEP);
+ }
+ }
+
+ private CharSequence delayTimeToString(int 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 mContext.getResources().getQuantityString(
+ R.plurals.accessibilty_autoclick_delay_unit_second,
+ quantity, String.format(decimalFormat, delaySecond));
+ }
+}
diff --git a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceController.java b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceController.java
index 33ebfc5..45cdf91 100644
--- a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceController.java
+++ b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceController.java
@@ -24,7 +24,6 @@
import android.content.res.Resources;
import android.provider.Settings;
import android.util.ArrayMap;
-import android.view.accessibility.AccessibilityManager;
import androidx.lifecycle.LifecycleObserver;
import androidx.preference.Preference;
@@ -33,8 +32,8 @@
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.widget.SeekBarPreference;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.widget.LayoutPreference;
import com.android.settingslib.widget.RadioButtonPreference;
import java.util.Map;
@@ -43,23 +42,13 @@
* Controller class that controls accessibility autoclick settings.
*/
public class ToggleAutoclickPreferenceController extends BasePreferenceController implements
- LifecycleObserver, RadioButtonPreference.OnClickListener, PreferenceControllerMixin,
- Preference.OnPreferenceChangeListener {
- // Min allowed autoclick delay value.
- static final int MIN_AUTOCLICK_DELAY_MS = 200;
-
- // Max allowed autoclick delay value.
- static final int MAX_AUTOCLICK_DELAY_MS = 1000;
+ LifecycleObserver, RadioButtonPreference.OnClickListener, PreferenceControllerMixin {
private static final String CONTROL_AUTOCLICK_DELAY_SECURE =
Settings.Secure.ACCESSIBILITY_AUTOCLICK_DELAY;
- private static final String KEY_AUTOCLICK_DELA = "autoclick_delay";
- private static final String KEY_CUSTOM_DELAY_VALUE = "custom_delay_value";
- private static final String KEY_DELAY_MODE = "delay_mode";
+ private static final String KEY_AUTOCLICK_CUSTOM_SEEKBAR = "autoclick_custom_seekbar";
+ static final String KEY_DELAY_MODE = "delay_mode";
- // Allowed autoclick delay values are discrete.
- // This is the difference between two allowed values.
- private static final int AUTOCLICK_DELAY_STEP = 100;
private static final int AUTOCLICK_OFF_MODE = 0;
private static final int AUTOCLICK_CUSTOM_MODE = 2000;
@@ -77,7 +66,7 @@
* number of possible discrete autoclick delay values. These will have to be converted to actual
* delay values before saving them in settings.
*/
- private SeekBarPreference mCustomDelayPref;
+ private LayoutPreference mSeekBerPreference;
private int mCurrentUiAutoClickMode;
public ToggleAutoclickPreferenceController(Context context, String preferenceKey) {
@@ -121,16 +110,7 @@
mDelayModePref = (RadioButtonPreference)
screen.findPreference(getPreferenceKey());
mDelayModePref.setOnClickListener(this);
-
- int delay = getSharedPreferenceForDelayValue();
-
- // Initialize seek bar preference. Sets seek bar size to the number of possible delay
- // values.
- mCustomDelayPref = (SeekBarPreference) screen.findPreference(KEY_AUTOCLICK_DELA);
- mCustomDelayPref.setMax(delayToSeekBarProgress(MAX_AUTOCLICK_DELAY_MS));
- mCustomDelayPref.setProgress(delayToSeekBarProgress(delay));
- mCustomDelayPref.setOnPreferenceChangeListener(this);
-
+ mSeekBerPreference = (LayoutPreference) screen.findPreference(KEY_AUTOCLICK_CUSTOM_SEEKBAR);
updateState((Preference) mDelayModePref);
}
@@ -150,14 +130,7 @@
}
private void updatePreferenceVisibleState(int mode) {
- mCustomDelayPref.setVisible(mCurrentUiAutoClickMode == mode);
- }
-
- private void updateSeekBarProgressState() {
- if (mCurrentUiAutoClickMode == AUTOCLICK_CUSTOM_MODE) {
- int delay = getSharedPreferenceForDelayValue();
- mCustomDelayPref.setProgress(delayToSeekBarProgress(delay));
- }
+ mSeekBerPreference.setVisible(mCurrentUiAutoClickMode == mode);
}
@Override
@@ -169,22 +142,10 @@
// Reset RadioButton.
mDelayModePref.setChecked(false);
int mode = mAccessibilityAutoclickKeyToValueMap.get(mDelayModePref.getKey());
- updateSeekBarProgressState();
updatePreferenceCheckedState(mode);
updatePreferenceVisibleState(mode);
}
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- if (preference == mCustomDelayPref && newValue instanceof Integer) {
- putSecureInt(CONTROL_AUTOCLICK_DELAY_SECURE, seekBarProgressToDelay((int) newValue));
- mSharedPreferences.edit().putInt(KEY_CUSTOM_DELAY_VALUE,
- seekBarProgressToDelay((int) newValue)).apply();
- return true;
- }
- return false;
- }
-
/** Listener interface handles checked event. */
public interface OnChangeListener {
/**
@@ -216,37 +177,16 @@
mSharedPreferences.edit().putInt(KEY_DELAY_MODE, preference).apply();
if (preference == AUTOCLICK_CUSTOM_MODE) {
- putSecureInt(CONTROL_AUTOCLICK_DELAY_SECURE, getSharedPreferenceForDelayValue());
- } else {
- putSecureInt(CONTROL_AUTOCLICK_DELAY_SECURE, preference);
+ return;
}
- }
- /** Converts seek bar preference progress value to autoclick delay associated with it. */
- private int seekBarProgressToDelay(int progress) {
- return progress * AUTOCLICK_DELAY_STEP + MIN_AUTOCLICK_DELAY_MS;
- }
-
- /**
- * Converts autoclick delay value to seek bar preference progress values that represents said
- * delay.
- */
- private int delayToSeekBarProgress(int delay) {
- return (delay - MIN_AUTOCLICK_DELAY_MS) / AUTOCLICK_DELAY_STEP;
+ putSecureInt(CONTROL_AUTOCLICK_DELAY_SECURE, preference);
}
private void putSecureInt(String name, int value) {
Settings.Secure.putInt(mContentResolver, name, value);
}
- private int getSharedPreferenceForDelayValue() {
- int mode = mSharedPreferences.getInt(KEY_DELAY_MODE, AUTOCLICK_OFF_MODE);
- int delay = mSharedPreferences.getInt(KEY_CUSTOM_DELAY_VALUE,
- AccessibilityManager.AUTOCLICK_DELAY_DEFAULT);
-
- return mode == AUTOCLICK_CUSTOM_MODE ? delay : mode;
- }
-
private int getSharedPreferenceForAutoClickMode() {
return mSharedPreferences.getInt(KEY_DELAY_MODE, AUTOCLICK_OFF_MODE);
}
diff --git a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
index 0ba54eb..4a88956 100644
--- a/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAutoclickPreferenceFragment.java
@@ -16,8 +16,8 @@
package com.android.settings.accessibility;
-import static com.android.settings.accessibility.ToggleAutoclickPreferenceController.MAX_AUTOCLICK_DELAY_MS;
-import static com.android.settings.accessibility.ToggleAutoclickPreferenceController.MIN_AUTOCLICK_DELAY_MS;
+import static com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController.MAX_AUTOCLICK_DELAY_MS;
+import static com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController.MIN_AUTOCLICK_DELAY_MS;
import android.app.settings.SettingsEnums;
import android.content.Context;
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index 283fa90..ffde1e3 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -17,6 +17,8 @@
package com.android.settings.accessibility;
import static com.android.internal.accessibility.AccessibilityShortcutController.COLOR_INVERSION_COMPONENT_NAME;
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import android.app.settings.SettingsEnums;
import android.net.Uri;
@@ -26,15 +28,13 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Switch;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.State;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.widget.SwitchBar;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
@@ -42,8 +42,7 @@
/** Settings page for color inversion. */
@SearchIndexable
-public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePreferenceFragment
- implements SwitchBar.OnSwitchChangeListener {
+public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePreferenceFragment {
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
private static final String CATEGORY_FOOTER_KEY = "color_inversion_footer_category";
@@ -58,7 +57,7 @@
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? State.OFF : State.ON);
+ Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? ON : OFF);
}
@Override
@@ -67,28 +66,25 @@
}
@Override
- protected void onRemoveSwitchBarToggleSwitch() {
- super.onRemoveSwitchBarToggleSwitch();
- mSwitchBar.removeOnSwitchChangeListener(this);
+ 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
- public void onSwitchChanged(Switch switchView, boolean isChecked) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
- }
-
- @Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF) == State.ON);
- mSwitchBar.addOnSwitchChangeListener(this);
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
+ updateSwitchBarToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener((preference) -> {
+ boolean checked = ((SwitchPreference) preference).isChecked();
+ onPreferenceToggled(mPreferenceKey, checked);
+ return false;
+ });
}
@Override
@@ -101,9 +97,7 @@
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
@Override
public void onChange(boolean selfChange, Uri uri) {
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF)
- == State.ON);
+ updateSwitchBarToggleSwitch();
}
};
return super.onCreateView(inflater, container, savedInstanceState);
@@ -123,6 +117,7 @@
@Override
public void onResume() {
super.onResume();
+ updateSwitchBarToggleSwitch();
mSettingsContentObserver.register(getContentResolver());
}
@@ -138,6 +133,14 @@
showDialog(DIALOG_ID_EDIT_SHORTCUT);
}
+ private void updateSwitchBarToggleSwitch() {
+ final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
+ if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
+ return;
+ }
+ mToggleServiceDividerSwitchPreference.setChecked(checked);
+ }
+
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.accessibility_color_inversion_settings);
}
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index 493140c..f2b84e5 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -17,6 +17,8 @@
package com.android.settings.accessibility;
import static com.android.internal.accessibility.AccessibilityShortcutController.DALTONIZER_COMPONENT_NAME;
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -28,16 +30,14 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Switch;
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.accessibility.AccessibilityUtil.State;
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;
@@ -47,11 +47,11 @@
@SearchIndexable
public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceFragment
- implements DaltonizerRadioButtonPreferenceController.OnChangeListener,
- SwitchBar.OnSwitchChangeListener{
+ implements DaltonizerRadioButtonPreferenceController.OnChangeListener {
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;
@@ -88,9 +88,7 @@
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
@Override
public void onChange(boolean selfChange, Uri uri) {
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF)
- == State.ON);
+ updateSwitchBarToggleSwitch();
}
};
return super.onCreateView(inflater, container, savedInstanceState);
@@ -101,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);
@@ -109,7 +112,9 @@
@Override
public void onResume() {
super.onResume();
+ updateSwitchBarToggleSwitch();
mSettingsContentObserver.register(getContentResolver());
+
for (AbstractPreferenceController controller :
buildPreferenceControllers(getPrefContext(), getSettingsLifecycle())) {
((DaltonizerRadioButtonPreferenceController) controller).setOnChangeListener(this);
@@ -145,32 +150,29 @@
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? State.OFF : State.ON);
+ Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? ON : OFF);
}
@Override
- protected void onRemoveSwitchBarToggleSwitch() {
- super.onRemoveSwitchBarToggleSwitch();
- mSwitchBar.removeOnSwitchChangeListener(this);
+ 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
- public void onSwitchChanged(Switch switchView, boolean isChecked) {
- Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
- }
-
- @Override
- protected void onInstallSwitchBarToggleSwitch() {
- super.onInstallSwitchBarToggleSwitch();
- mSwitchBar.setCheckedInternal(
- Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF) == State.ON);
- mSwitchBar.addOnSwitchChangeListener(this);
+ protected void onInstallSwitchPreferenceToggleSwitch() {
+ super.onInstallSwitchPreferenceToggleSwitch();
+ updateSwitchBarToggleSwitch();
+ mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener((preference) -> {
+ boolean checked = ((SwitchPreference) preference).isChecked();
+ onPreferenceToggled(mPreferenceKey, checked);
+ return false;
+ });
}
@Override
@@ -179,6 +181,14 @@
showDialog(DialogEnums.EDIT_SHORTCUT);
}
+ private void updateSwitchBarToggleSwitch() {
+ final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
+ if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
+ return;
+ }
+ mToggleServiceDividerSwitchPreference.setChecked(checked);
+ }
+
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.accessibility_daltonizer_settings);
}
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 63d458a..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);
}
}
@@ -235,7 +228,7 @@
switch (dialogId) {
case DialogEnums.EDIT_SHORTCUT:
final CharSequence dialogTitle = getPrefContext().getString(
- R.string.accessibility_shortcut_edit_dialog_title, mPackageName);
+ R.string.accessibility_shortcut_title, mPackageName);
Dialog dialog = AccessibilityEditDialogUtils.showEditShortcutDialog(
getPrefContext(), dialogTitle, this::callOnAlertDialogCheckboxClicked);
initializeDialogCheckBox(dialog);
@@ -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(
@@ -505,7 +495,7 @@
private String getShortcutTypeSummary(Context context) {
final int shortcutType = getUserShortcutType(context, UserShortcutType.SOFTWARE);
- int resId = R.string.accessibility_shortcut_edit_dialog_title_software;
+ int resId = R.string.accessibility_shortcut_edit_summary_software;
if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
resId = AccessibilityUtil.isTouchExploreEnabled(context)
? R.string.accessibility_shortcut_edit_dialog_title_software_gesture_talkback
@@ -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;
}
@@ -593,8 +583,10 @@
mShortcutPreference = new ShortcutPreference(getPrefContext(), null);
mShortcutPreference.setPersistent(false);
mShortcutPreference.setKey(getShortcutPreferenceKey());
- mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
mShortcutPreference.setOnClickListener(this);
+
+ final CharSequence title = getString(R.string.accessibility_shortcut_title, mPackageName);
+ mShortcutPreference.setTitle(title);
}
private void updateShortcutPreference() {
@@ -633,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 b82a344..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;
@@ -188,12 +191,6 @@
initShortcutPreference();
- mSettingsPreference = new Preference(getPrefContext());
- mSettingsPreference.setTitle(R.string.accessibility_magnification_service_settings_title);
- mSettingsPreference.setKey(SETTINGS_KEY);
- mSettingsPreference.setFragment(MagnificationSettingsFragment.class.getName());
- mSettingsPreference.setPersistent(false);
-
super.onViewCreated(view, savedInstanceState);
mConfigWarningPreference = new Preference(getPrefContext());
@@ -246,8 +243,8 @@
return AccessibilityGestureNavigationTutorial
.showAccessibilityButtonTutorialDialog(getPrefContext());
case DialogEnums.MAGNIFICATION_EDIT_SHORTCUT:
- final CharSequence dialogTitle = getPrefContext().getText(
- R.string.accessibility_shortcut_edit_dialog_title_magnification);
+ final CharSequence dialogTitle = getPrefContext().getString(
+ R.string.accessibility_shortcut_title, mPackageName);
final AlertDialog dialog =
AccessibilityEditDialogUtils.showMagnificationEditShortcutDialog(
getPrefContext(), dialogTitle,
@@ -344,7 +341,7 @@
private String getShortcutTypeSummary(Context context) {
final int shortcutType = getUserShortcutType(context, UserShortcutType.DEFAULT);
- int resId = R.string.accessibility_shortcut_edit_dialog_title_software;
+ int resId = R.string.accessibility_shortcut_edit_summary_software;
if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
resId = AccessibilityUtil.isTouchExploreEnabled(context)
? R.string.accessibility_shortcut_edit_dialog_title_software_gesture_talkback
@@ -435,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
@@ -487,9 +482,11 @@
mShortcutPreference = new ShortcutPreference(getPrefContext(), null);
mShortcutPreference.setPersistent(false);
mShortcutPreference.setKey(KEY_SHORTCUT_PREFERENCE);
- mShortcutPreference.setTitle(R.string.accessibility_magnification_shortcut_title);
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
mShortcutPreference.setOnClickListener(this);
+
+ final CharSequence title = getString(R.string.accessibility_shortcut_title, mPackageName);
+ mShortcutPreference.setTitle(title);
}
private void updateShortcutPreference() {
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
index ffa0c41..3b786ff 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java
@@ -18,7 +18,6 @@
import android.app.settings.SettingsEnums;
import android.os.Bundle;
-import android.view.View;
public class ToggleScreenMagnificationPreferenceFragmentForSetupWizard
extends ToggleScreenMagnificationPreferenceFragment {
@@ -33,21 +32,14 @@
// 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();
}
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- // Hide the setting from the vision settings.
- mSettingsPreference.setVisible(false);
- }
}
diff --git a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java
index fc68e03..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,12 +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 5f01e4b..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,13 +38,12 @@
@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/TopLevelAccessibilityPreferenceController.java b/src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceController.java
index 41040a0..7a8ba21 100644
--- a/src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceController.java
+++ b/src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceController.java
@@ -31,8 +31,7 @@
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_top_level_accessibility)
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
}
diff --git a/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java b/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java
index a8d93d5..e4e32e5 100644
--- a/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java
+++ b/src/com/android/settings/accounts/TopLevelAccountEntryPreferenceController.java
@@ -36,7 +36,7 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE_UNSEARCHABLE;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/applications/AppHeaderPreferenceController.java b/src/com/android/settings/applications/AppHeaderPreferenceController.java
index 8a77d6f..0f473e7 100644
--- a/src/com/android/settings/applications/AppHeaderPreferenceController.java
+++ b/src/com/android/settings/applications/AppHeaderPreferenceController.java
@@ -21,11 +21,11 @@
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.util.IconDrawableFactory;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.widget.EntityHeaderController;
@@ -94,8 +94,7 @@
EntityHeaderController
.newInstance(activity, mParent, mHeaderPreference.findViewById(R.id.entity_header))
.setRecyclerView(mParent.getListView(), mLifecycle)
- .setIcon(IconDrawableFactory.newInstance(activity).getBadgedIcon(
- mPackageInfo.applicationInfo))
+ .setIcon(Utils.getBadgedIcon(mParent.getContext(), mPackageInfo.applicationInfo))
.setLabel(mPackageInfo.applicationInfo.loadLabel(packageManager))
.setSummary(mPackageInfo)
.setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
diff --git a/src/com/android/settings/applications/AppInfoWithHeader.java b/src/com/android/settings/applications/AppInfoWithHeader.java
index 9e3842e..7bf9f64 100644
--- a/src/com/android/settings/applications/AppInfoWithHeader.java
+++ b/src/com/android/settings/applications/AppInfoWithHeader.java
@@ -20,11 +20,11 @@
import android.app.Activity;
import android.os.Bundle;
-import android.util.IconDrawableFactory;
import android.util.Log;
import androidx.preference.Preference;
+import com.android.settings.Utils;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.applications.AppUtils;
@@ -47,8 +47,7 @@
final Preference pref = EntityHeaderController
.newInstance(activity, this, null /* header */)
.setRecyclerView(getListView(), getSettingsLifecycle())
- .setIcon(IconDrawableFactory.newInstance(getContext())
- .getBadgedIcon(mPackageInfo.applicationInfo))
+ .setIcon(Utils.getBadgedIcon(getContext(), mPackageInfo.applicationInfo))
.setLabel(mPackageInfo.applicationInfo.loadLabel(mPm))
.setSummary(mPackageInfo)
.setIsInstantApp(AppUtils.isInstant(mPackageInfo.applicationInfo))
diff --git a/src/com/android/settings/applications/RecentAppsPreferenceController.java b/src/com/android/settings/applications/RecentAppsPreferenceController.java
index 7e02065..28a88a2 100644
--- a/src/com/android/settings/applications/RecentAppsPreferenceController.java
+++ b/src/com/android/settings/applications/RecentAppsPreferenceController.java
@@ -22,7 +22,6 @@
import android.content.Context;
import android.icu.text.RelativeDateTimeFormatter;
import android.os.UserHandle;
-import android.util.IconDrawableFactory;
import android.view.View;
import androidx.annotation.NonNull;
@@ -37,6 +36,7 @@
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.Utils;
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.utils.StringUtil;
@@ -65,7 +65,6 @@
private final ApplicationsState mApplicationsState;
private final int mUserId;
- private final IconDrawableFactory mIconDrawableFactory;
private final MetricsFeatureProvider mMetricsFeatureProvider;
private Fragment mHost;
@@ -76,7 +75,6 @@
mApplicationsState = ApplicationsState.getInstance(
(Application) mContext.getApplicationContext());
mUserId = UserHandle.myUserId();
- mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
mMetricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
}
@@ -161,7 +159,7 @@
}
return new AppEntityInfo.Builder()
- .setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info))
+ .setIcon(Utils.getBadgedIcon(mContext, appEntry.info))
.setTitle(appEntry.label)
.setSummary(StringUtil.formatRelativeTime(mContext,
System.currentTimeMillis() - stat.getLastTimeUsed(), false,
diff --git a/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java b/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java
index 1763d84..8c937bc 100644
--- a/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java
+++ b/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java
@@ -63,7 +63,7 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE_UNSEARCHABLE;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index 8274634..8b1f96f 100755
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -46,6 +46,7 @@
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.applications.manageapplications.ManageApplications;
+import com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesDetailsPreferenceController;
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetailPreferenceController;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
@@ -168,13 +169,19 @@
use(PictureInPictureDetailPreferenceController.class);
pip.setPackageName(packageName);
pip.setParentFragment(this);
+
final ExternalSourceDetailPreferenceController externalSource =
use(ExternalSourceDetailPreferenceController.class);
externalSource.setPackageName(packageName);
externalSource.setParentFragment(this);
+ final InteractAcrossProfilesDetailsPreferenceController acrossProfiles =
+ use(InteractAcrossProfilesDetailsPreferenceController.class);
+ acrossProfiles.setPackageName(packageName);
+ acrossProfiles.setParentFragment(this);
+
use(AdvancedAppInfoPreferenceCategoryController.class).setChildren(Arrays.asList(
- writeSystemSettings, drawOverlay, pip, externalSource));
+ writeSystemSettings, drawOverlay, pip, externalSource, acrossProfiles));
}
@Override
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 2597665..0f7a8c2 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -1460,7 +1460,7 @@
ApplicationsState.AppEntry entry = mEntries.get(position);
synchronized (entry) {
holder.setTitle(entry.label);
- holder.setIcon(mIconDrawableFactory.getBadgedIcon(entry.info));
+ holder.setIcon(Utils.getBadgedIcon(mContext, entry.info));
updateSummary(holder, entry);
updateSwitch(holder, entry);
holder.updateDisableView(entry.info);
diff --git a/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java b/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java
index 1fe0d01..270a5c8 100644
--- a/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java
+++ b/src/com/android/settings/applications/manageapplications/ResetAppsHelper.java
@@ -114,7 +114,7 @@
PackageManager.GET_DISABLED_COMPONENTS);
final List<String> whiteList = Arrays.asList(
mContext.getResources().getStringArray(
- R.array.config_reset_app_package_name));
+ R.array.config_skip_reset_apps_package_name));
for (int i = 0; i < apps.size(); i++) {
ApplicationInfo app = apps.get(i);
diff --git a/src/com/android/settings/applications/specialaccess/DataSaverController.java b/src/com/android/settings/applications/specialaccess/DataSaverController.java
index c169d7f..d1fd202 100644
--- a/src/com/android/settings/applications/specialaccess/DataSaverController.java
+++ b/src/com/android/settings/applications/specialaccess/DataSaverController.java
@@ -31,7 +31,6 @@
@AvailabilityStatus
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_data_saver)
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceController.java b/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceController.java
index dbdc9fe..2f03c3d 100644
--- a/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceController.java
@@ -21,11 +21,23 @@
import android.nfc.NfcAdapter;
import android.os.UserManager;
-import com.android.settings.core.BasePreferenceController;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
-public class DefaultPaymentSettingsPreferenceController extends BasePreferenceController {
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+
+/**
+ * This Controller works with PaymentSettingsEnabler to control payment features availability
+ * based on NFC status
+ */
+public class DefaultPaymentSettingsPreferenceController extends BasePreferenceController
+ implements LifecycleObserver, OnResume, OnPause {
private final NfcAdapter mNfcAdapter;
+ private PaymentSettingsEnabler mPaymentSettingsEnabler;
private final PackageManager mPackageManager;
private final UserManager mUserManager;
@@ -38,6 +50,32 @@
}
@Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ if (!isAvailable()) {
+ mPaymentSettingsEnabler = null;
+ return;
+ }
+
+ final Preference preference = screen.findPreference(getPreferenceKey());
+ mPaymentSettingsEnabler = new PaymentSettingsEnabler(mContext, preference);
+ }
+
+ @Override
+ public void onResume() {
+ if (mPaymentSettingsEnabler != null) {
+ mPaymentSettingsEnabler.resume();
+ }
+ }
+
+ @Override
+ public void onPause() {
+ if (mPaymentSettingsEnabler != null) {
+ mPaymentSettingsEnabler.pause();
+ }
+ }
+
+ @Override
public int getAvailabilityStatus() {
if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC)
|| !mPackageManager.hasSystemFeature(
@@ -47,9 +85,12 @@
if (!mUserManager.isAdminUser()) {
return DISABLED_FOR_USER;
}
- if (mNfcAdapter == null || !mNfcAdapter.isEnabled()) {
+ if (mNfcAdapter == null) {
return CONDITIONALLY_UNAVAILABLE;
}
+ if (!mNfcAdapter.isEnabled()) {
+ return DISABLED_DEPENDENT_SETTING;
+ }
return AVAILABLE;
}
}
diff --git a/src/com/android/settings/applications/specialaccess/PaymentSettingsEnabler.java b/src/com/android/settings/applications/specialaccess/PaymentSettingsEnabler.java
new file mode 100644
index 0000000..6c5227d
--- /dev/null
+++ b/src/com/android/settings/applications/specialaccess/PaymentSettingsEnabler.java
@@ -0,0 +1,54 @@
+/*
+ * 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.applications.specialaccess;
+
+import android.content.Context;
+import android.nfc.NfcAdapter;
+
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.nfc.BaseNfcEnabler;
+
+/**
+ * PaymentSettingsEnabler is a helper to manage the payment feature enable / disable state.
+ * It enables / disables payment features based on NFC state, and ensures the summary of the
+ * preference is updated.
+ */
+public class PaymentSettingsEnabler extends BaseNfcEnabler {
+ private final Preference mPreference;
+
+ public PaymentSettingsEnabler(Context context, Preference preference) {
+ super(context);
+ mPreference = preference;
+ }
+
+ @Override
+ protected void handleNfcStateChanged(int newState) {
+ switch (newState) {
+ case NfcAdapter.STATE_OFF:
+ mPreference.setSummary(
+ R.string.nfc_and_payment_settings_payment_off_nfc_off_summary);
+ mPreference.setEnabled(false);
+ break;
+ case NfcAdapter.STATE_ON:
+ mPreference.setSummary(null);
+ mPreference.setEnabled(true);
+ break;
+ }
+ }
+}
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesController.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesController.java
new file mode 100644
index 0000000..0f7c057
--- /dev/null
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesController.java
@@ -0,0 +1,54 @@
+/*
+ * 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.applications.specialaccess.interactacrossprofiles;
+
+import android.content.Context;
+import android.content.pm.UserInfo;
+import android.os.UserHandle;
+import android.os.UserManager;
+
+import com.android.settings.core.BasePreferenceController;
+
+import java.util.List;
+
+/**
+ * Controller to decide when to show the "Connected work and personal apps" option in the
+ * Special access screen.
+ */
+public class InteractAcrossProfilesController extends BasePreferenceController {
+
+ private final Context mContext;
+ private final UserManager mUserManager;
+
+ public InteractAcrossProfilesController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+
+ mContext = context;
+ mUserManager = mContext.getSystemService(UserManager.class);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ final List<UserInfo> profiles = mUserManager.getProfiles(UserHandle.myUserId());
+ for (final UserInfo userInfo : profiles) {
+ if (userInfo.isManagedProfile()) {
+ return AVAILABLE;
+ }
+ }
+ return DISABLED_FOR_USER;
+ }
+}
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
new file mode 100644
index 0000000..ad40d70
--- /dev/null
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
@@ -0,0 +1,201 @@
+/*
+ * 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.applications.specialaccess.interactacrossprofiles;
+
+import android.Manifest;
+import android.app.AppOpsManager;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.PermissionChecker;
+import android.content.pm.CrossProfileApps;
+import android.content.pm.UserInfo;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.util.IconDrawableFactory;
+import android.widget.ImageView;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AlertDialog;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.R;
+import com.android.settings.applications.AppInfoBase;
+import com.android.settingslib.widget.LayoutPreference;
+
+public class InteractAcrossProfilesDetails extends AppInfoBase
+ implements Preference.OnPreferenceClickListener {
+
+ private static final String INTERACT_ACROSS_PROFILES_SETTINGS_SWITCH =
+ "interact_across_profiles_settings_switch";
+ private static final String INTERACT_ACROSS_PROFILES_HEADER = "interact_across_profiles_header";
+
+ private Context mContext;
+ private CrossProfileApps mCrossProfileApps;
+ private UserManager mUserManager;
+ private SwitchPreference mSwitchPref;
+ private LayoutPreference mHeader;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mContext = getContext();
+ mCrossProfileApps = mContext.getSystemService(CrossProfileApps.class);
+ mUserManager = mContext.getSystemService(UserManager.class);
+
+ addPreferencesFromResource(R.xml.interact_across_profiles_permissions_details);
+ mSwitchPref = findPreference(INTERACT_ACROSS_PROFILES_SETTINGS_SWITCH);
+ mSwitchPref.setOnPreferenceClickListener(this);
+ mHeader = findPreference(INTERACT_ACROSS_PROFILES_HEADER);
+
+ // refreshUi checks that the user can still configure the appOp, return to the
+ // previous page if it can't.
+ if (!refreshUi()) {
+ setIntentAndFinish(true/* appChanged */);
+ }
+ final UserHandle workProfile = getWorkProfile();
+ final UserHandle personalProfile = mUserManager.getProfileParent(workProfile);
+ addAppIcons(personalProfile, workProfile);
+ }
+
+ private void addAppIcons(UserHandle personalProfile, UserHandle workProfile) {
+ final ImageView personalIconView = mHeader.findViewById(R.id.entity_header_icon_personal);
+ if (personalIconView != null) {
+ personalIconView.setImageDrawable(IconDrawableFactory.newInstance(mContext)
+ .getBadgedIcon(mPackageInfo.applicationInfo, personalProfile.getIdentifier()));
+ }
+ final ImageView workIconView2 = mHeader.findViewById(R.id.entity_header_icon_work);
+ if (workIconView2 != null) {
+ workIconView2.setImageDrawable(IconDrawableFactory.newInstance(mContext)
+ .getBadgedIcon(mPackageInfo.applicationInfo, workProfile.getIdentifier()));
+ }
+ }
+
+ @Nullable
+ private UserHandle getWorkProfile() {
+ for (UserInfo user : mUserManager.getProfiles(UserHandle.myUserId())) {
+ if (mUserManager.isManagedProfile(user.id)) {
+ return user.getUserHandle();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ if (preference != mSwitchPref) {
+ return false;
+ }
+ // refreshUi checks that the user can still configure the appOp, return to the
+ // previous page if it can't.
+ if (!refreshUi()) {
+ setIntentAndFinish(true/* appChanged */);
+ }
+ if (isInteractAcrossProfilesEnabled()) {
+ enableInteractAcrossProfiles(false);
+ refreshUi();
+ return true;
+ }
+ if (!isInteractAcrossProfilesEnabled()) {
+ // TODO(b/148594054): Create a proper dialogue.
+ new AlertDialog.Builder(getActivity())
+ .setTitle(R.string.interact_across_profiles_consent_dialog_title)
+ .setMessage(R.string.interact_across_profiles_consent_dialog_summary)
+ .setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ enableInteractAcrossProfiles(true);
+ refreshUi();
+ }
+ })
+ .setNegativeButton(R.string.deny, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ refreshUi();
+ }
+ })
+ .create().show();
+ } else {
+ enableInteractAcrossProfiles(false);
+ refreshUi();
+ }
+ return true;
+ }
+
+ private boolean isInteractAcrossProfilesEnabled() {
+ return isInteractAcrossProfilesEnabled(
+ mContext, mPackageName, mPackageInfo.applicationInfo.uid);
+ }
+
+ private static boolean isInteractAcrossProfilesEnabled(Context context, String packageName, int uid) {
+ return PermissionChecker.PERMISSION_GRANTED
+ == PermissionChecker.checkPermissionForPreflight(
+ context,
+ Manifest.permission.INTERACT_ACROSS_PROFILES,
+ PermissionChecker.PID_UNKNOWN,
+ uid,
+ packageName);
+ }
+
+ private void enableInteractAcrossProfiles(boolean newState) {
+ mCrossProfileApps.setInteractAcrossProfilesAppOp(
+ mPackageName, newState ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED);
+ }
+
+ /**
+ * @return the summary for the current state of whether the app associated with the given
+ * {@code packageName} is allowed to interact across profiles.
+ */
+ public static CharSequence getPreferenceSummary(Context context, String packageName, int uid) {
+ return context.getString(isInteractAcrossProfilesEnabled(context, packageName, uid)
+ ? R.string.app_permission_summary_allowed
+ : R.string.app_permission_summary_not_allowed);
+ }
+
+ @Override
+ protected boolean refreshUi() {
+ if (mPackageInfo == null || mPackageInfo.applicationInfo == null) {
+ return false;
+ }
+ if (!mCrossProfileApps.canConfigureInteractAcrossProfiles(mPackageName)) {
+ // Invalid app entry. Should not allow changing permission
+ mSwitchPref.setEnabled(false);
+ return false;
+ }
+
+ mSwitchPref.setChecked(isInteractAcrossProfilesEnabled());
+ final ImageView horizontalArrowIcon = mHeader.findViewById(R.id.entity_header_swap_horiz);
+ if (horizontalArrowIcon != null) {
+ final Drawable icon = mSwitchPref.isChecked()
+ ? mContext.getDrawable(R.drawable.ic_swap_horiz_blue)
+ : mContext.getDrawable(R.drawable.ic_swap_horiz_grey);
+ horizontalArrowIcon.setImageDrawable(icon);
+ }
+ return true;
+ }
+
+ @Override
+ protected AlertDialog createDialog(int id, int errorCode) {
+ return null;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.INTERACT_ACROSS_PROFILES;
+ }
+}
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetailsPreferenceController.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetailsPreferenceController.java
new file mode 100644
index 0000000..41e25a7
--- /dev/null
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetailsPreferenceController.java
@@ -0,0 +1,64 @@
+/*
+ * 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.applications.specialaccess.interactacrossprofiles;
+
+import android.content.Context;
+import android.content.pm.CrossProfileApps;
+
+import androidx.preference.Preference;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.applications.appinfo.AppInfoPreferenceControllerBase;
+
+public class InteractAcrossProfilesDetailsPreferenceController
+ extends AppInfoPreferenceControllerBase {
+
+ private String mPackageName;
+
+ public InteractAcrossProfilesDetailsPreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return canConfigureInteractAcrossProfiles() ? AVAILABLE : DISABLED_FOR_USER;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ preference.setSummary(getPreferenceSummary());
+ }
+
+ @Override
+ protected Class<? extends SettingsPreferenceFragment> getDetailFragmentClass() {
+ return InteractAcrossProfilesDetails.class;
+ }
+
+ private CharSequence getPreferenceSummary() {
+ return InteractAcrossProfilesDetails.getPreferenceSummary(mContext, mPackageName,
+ mParent.getPackageInfo().applicationInfo.uid);
+ }
+
+ private boolean canConfigureInteractAcrossProfiles() {
+ return mContext.getSystemService(CrossProfileApps.class)
+ .canConfigureInteractAcrossProfiles(mPackageName);
+ }
+
+ public void setPackageName(String packageName) {
+ mPackageName = packageName;
+ }
+}
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettings.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettings.java
new file mode 100644
index 0000000..2fd1e9f
--- /dev/null
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettings.java
@@ -0,0 +1,161 @@
+/*
+ * 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.applications.specialaccess.interactacrossprofiles;
+
+import static android.content.pm.PackageManager.GET_ACTIVITIES;
+
+import android.annotation.Nullable;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.CrossProfileApps;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.UserInfo;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.util.IconDrawableFactory;
+import android.util.Pair;
+import android.view.View;
+
+import androidx.preference.Preference;
+import androidx.preference.Preference.OnPreferenceClickListener;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.applications.AppInfoBase;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.widget.EmptyTextSettings;
+import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.widget.apppreference.AppPreference;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@SearchIndexable
+public class InteractAcrossProfilesSettings extends EmptyTextSettings {
+ private Context mContext;
+ private PackageManager mPackageManager;
+ private UserManager mUserManager;
+ private CrossProfileApps mCrossProfileApps;
+ private IconDrawableFactory mIconDrawableFactory;
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ mContext = getContext();
+ mPackageManager = mContext.getPackageManager();
+ mUserManager = mContext.getSystemService(UserManager.class);
+ mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
+ mCrossProfileApps = mContext.getSystemService(CrossProfileApps.class);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ final PreferenceScreen screen = getPreferenceScreen();
+ screen.removeAll();
+
+ final ArrayList<Pair<ApplicationInfo, UserHandle>> crossProfileApps =
+ collectConfigurableApps();
+
+ final Context prefContext = getPrefContext();
+ for (final Pair<ApplicationInfo, UserHandle> appData : crossProfileApps) {
+ final ApplicationInfo appInfo = appData.first;
+ final UserHandle user = appData.second;
+ final String packageName = appInfo.packageName;
+ final CharSequence label = appInfo.loadLabel(mPackageManager);
+
+ final Preference pref = new AppPreference(prefContext);
+ pref.setIcon(mIconDrawableFactory.getBadgedIcon(appInfo, user.getIdentifier()));
+ pref.setTitle(mPackageManager.getUserBadgedLabel(label, user));
+ pref.setSummary(InteractAcrossProfilesDetails.getPreferenceSummary(prefContext,
+ packageName, appInfo.uid));
+ pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ AppInfoBase.startAppInfoFragment(InteractAcrossProfilesDetails.class,
+ R.string.interact_across_profiles_title,
+ packageName,
+ appInfo.uid,
+ InteractAcrossProfilesSettings.this/* source */,
+ -1/* request */,
+ getMetricsCategory());
+ return true;
+ }
+ });
+ screen.addPreference(pref);
+ }
+ }
+
+ @Override
+ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ setEmptyText(R.string.interact_across_profiles_empty_text);
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.interact_across_profiles;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.INTERACT_ACROSS_PROFILES;
+ }
+
+ /**
+ * @return the list of applications for the personal profile in the calling user's profile group
+ * that can configure interact across profiles.
+ */
+ ArrayList<Pair<ApplicationInfo, UserHandle>> collectConfigurableApps() {
+ final UserHandle personalProfile = getPersonalProfileForCallingUser();
+ if (personalProfile == null) {
+ return new ArrayList<>();
+ }
+
+ final ArrayList<Pair<ApplicationInfo, UserHandle>> crossProfileApps = new ArrayList<>();
+ final List<PackageInfo> installedPackages = mPackageManager.getInstalledPackagesAsUser(
+ GET_ACTIVITIES, personalProfile.getIdentifier());
+ for (PackageInfo packageInfo : installedPackages) {
+ if (mCrossProfileApps.canConfigureInteractAcrossProfiles(packageInfo.packageName)) {
+ crossProfileApps.add(new Pair<>(packageInfo.applicationInfo, personalProfile));
+ }
+ }
+ return crossProfileApps;
+ }
+
+ /**
+ * Returns the personal profile in the profile group of the calling user.
+ * Returns null if user is not in a profile group.
+ */
+ @Nullable
+ private UserHandle getPersonalProfileForCallingUser() {
+ final int callingUser = UserHandle.myUserId();
+ if (mUserManager.getProfiles(callingUser).isEmpty()) {
+ return null;
+ }
+ final UserInfo parentProfile = mUserManager.getProfileParent(callingUser);
+ return parentProfile == null
+ ? UserHandle.of(callingUser) : parentProfile.getUserHandle();
+ }
+
+ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider(R.xml.interact_across_profiles);
+}
diff --git a/src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessController.java b/src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessController.java
index 6025da5..32e2e7e 100644
--- a/src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessController.java
+++ b/src/com/android/settings/applications/specialaccess/notificationaccess/NotificationAccessController.java
@@ -31,9 +31,7 @@
@Override
public int getAvailabilityStatus() {
- return !ActivityManager.isLowRamDeviceStatic()
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ return !ActivityManager.isLowRamDeviceStatic() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
public static boolean hasAccess(Context context, ComponentName cn) {
diff --git a/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureController.java b/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureController.java
index dc1dde1..fa8afc9 100644
--- a/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureController.java
+++ b/src/com/android/settings/applications/specialaccess/pictureinpicture/PictureInPictureController.java
@@ -32,7 +32,6 @@
public int getAvailabilityStatus() {
return !ActivityManager.isLowRamDeviceStatic()
&& mContext.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_PICTURE_IN_PICTURE) ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ PackageManager.FEATURE_PICTURE_IN_PICTURE) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
}
diff --git a/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsController.java b/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsController.java
index 158fe3c..9c6ab8c 100644
--- a/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsController.java
+++ b/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsController.java
@@ -30,7 +30,6 @@
@AvailabilityStatus
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_premium_sms)
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/applications/specialaccess/vrlistener/EnabledVrListenersController.java b/src/com/android/settings/applications/specialaccess/vrlistener/EnabledVrListenersController.java
index fd59d8d..adefec8 100644
--- a/src/com/android/settings/applications/specialaccess/vrlistener/EnabledVrListenersController.java
+++ b/src/com/android/settings/applications/specialaccess/vrlistener/EnabledVrListenersController.java
@@ -34,8 +34,6 @@
@AvailabilityStatus
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_enabled_vr_listeners)
- && !mActivityManager.isLowRamDevice()
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ && !mActivityManager.isLowRamDevice() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java
index 9c99254..727870c 100644
--- a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java
+++ b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java
@@ -49,9 +49,7 @@
@Override
public int getAvailabilityStatus() {
- return isSupported(mActivityManager)
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ return isSupported(mActivityManager) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
public static boolean isSupported(ActivityManager activityManager) {
diff --git a/src/com/android/settings/biometrics/OWNERS b/src/com/android/settings/biometrics/OWNERS
index 6332a46..021e89d 100644
--- a/src/com/android/settings/biometrics/OWNERS
+++ b/src/com/android/settings/biometrics/OWNERS
@@ -1,6 +1,7 @@
# Default reviewers for this and subdirectories.
+curtislb@google.com
jaggies@google.com
kchyn@google.com
yukl@google.com
-# Emergency approvers in case the above are not available
\ No newline at end of file
+# Emergency approvers in case the above are not available
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
index 749a38f..aa12409 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
@@ -109,7 +109,7 @@
profilePref.setChecked(profile.getConnectionStatus(device) ==
BluetoothProfile.STATE_CONNECTED);
} else {
- profilePref.setChecked(profile.isPreferred(device));
+ profilePref.setChecked(profile.isEnabled(device));
}
if (profile instanceof A2dpProfile) {
@@ -117,7 +117,7 @@
SwitchPreference highQualityPref = (SwitchPreference) mProfilesContainer.findPreference(
HIGH_QUALITY_AUDIO_PREF_TAG);
if (highQualityPref != null) {
- if (a2dp.isPreferred(device) && a2dp.supportsHighQualityAudio(device)) {
+ if (a2dp.isEnabled(device) && a2dp.supportsHighQualityAudio(device)) {
highQualityPref.setVisible(true);
highQualityPref.setTitle(a2dp.getHighQualityAudioOptionLabel(device));
highQualityPref.setChecked(a2dp.isHighQualityAudioEnabled(device));
@@ -142,8 +142,7 @@
if (profile instanceof MapProfile) {
bluetoothDevice.setMessageAccessPermission(BluetoothDevice.ACCESS_ALLOWED);
}
- profile.setPreferred(bluetoothDevice, true);
- mCachedDevice.connectProfile(profile);
+ profile.setEnabled(bluetoothDevice, true);
}
/**
@@ -151,8 +150,7 @@
*/
private void disableProfile(LocalBluetoothProfile profile) {
final BluetoothDevice bluetoothDevice = mCachedDevice.getDevice();
- mCachedDevice.disconnect(profile);
- profile.setPreferred(bluetoothDevice, false);
+ profile.setEnabled(bluetoothDevice, false);
if (profile instanceof MapProfile) {
bluetoothDevice.setMessageAccessPermission(BluetoothDevice.ACCESS_REJECTED);
} else if (profile instanceof PbapServerProfile) {
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index 4226720..86b72ec 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -60,10 +60,12 @@
@Retention(RetentionPolicy.SOURCE)
@IntDef({SortType.TYPE_DEFAULT,
- SortType.TYPE_FIFO})
+ SortType.TYPE_FIFO,
+ SortType.TYPE_NO_SORT})
public @interface SortType {
int TYPE_DEFAULT = 1;
int TYPE_FIFO = 2;
+ int TYPE_NO_SORT = 3;
}
private final CachedBluetoothDevice mCachedDevice;
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index e2715d3..3778862 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -232,12 +232,21 @@
* Add the {@link Preference} that represents the {@code cachedDevice}
*/
protected void addPreference(CachedBluetoothDevice cachedDevice) {
+ addPreference(cachedDevice, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+ }
+
+ /**
+ * Add the {@link Preference} with {@link BluetoothDevicePreference.SortType} that
+ * represents the {@code cachedDevice}
+ */
+ protected void addPreference(CachedBluetoothDevice cachedDevice,
+ @BluetoothDevicePreference.SortType int type) {
final BluetoothDevice device = cachedDevice.getDevice();
if (!mPreferenceMap.containsKey(device)) {
BluetoothDevicePreference btPreference =
new BluetoothDevicePreference(mPrefContext, cachedDevice,
true /* showDeviceWithoutNames */,
- BluetoothDevicePreference.SortType.TYPE_DEFAULT);
+ type);
btPreference.setKey(getPreferenceKey());
btPreference.setOnGearClickListener(mDeviceProfilesListener);
if (this instanceof Preference.OnPreferenceClickListener) {
diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
index fdd7a1e..9a327ed 100644
--- a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java
@@ -15,15 +15,18 @@
*/
package com.android.settings.bluetooth;
+import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.util.Log;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.connecteddevice.DevicePreferenceCallback;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
/**
* Maintain and update saved bluetooth devices(bonded but not connected)
@@ -36,9 +39,40 @@
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 (mBluetoothAdapter.isEnabled()) {
+ final CachedBluetoothDeviceManager cachedManager =
+ mLocalManager.getCachedDeviceManager();
+ for (BluetoothDevice device : mBluetoothAdapter.getMostRecentlyConnectedDevices()) {
+ final CachedBluetoothDevice cachedDevice = cachedManager.findDevice(device);
+ if (cachedDevice != null) {
+ update(cachedDevice);
+ }
+ }
+ } else {
+ removeAllDevicesFromPreference();
+ }
+ }
+
+ @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
diff --git a/src/com/android/settings/bugreporthandler/BugReportHandlerPicker.java b/src/com/android/settings/bugreporthandler/BugReportHandlerPicker.java
index 94ab5c2..23459d6 100644
--- a/src/com/android/settings/bugreporthandler/BugReportHandlerPicker.java
+++ b/src/com/android/settings/bugreporthandler/BugReportHandlerPicker.java
@@ -176,6 +176,9 @@
if (BugReportHandlerUtil.SHELL_APP_PACKAGE.equals(handlerApp)) {
return context.getString(R.string.system_default_app_subtext);
}
+ if (mUserManager.getUserProfiles().size() < 2) {
+ return "";
+ }
final UserInfo userInfo = mUserManager.getUserInfo(handlerUser);
if (userInfo != null && userInfo.isManagedProfile()) {
return context.getString(R.string.work_profile_app_subtext);
diff --git a/src/com/android/settings/connecteddevice/BluetoothDashboardFragment.java b/src/com/android/settings/connecteddevice/BluetoothDashboardFragment.java
index b16725e..27b5c4a 100644
--- a/src/com/android/settings/connecteddevice/BluetoothDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/BluetoothDashboardFragment.java
@@ -16,8 +16,6 @@
package com.android.settings.connecteddevice;
import android.app.settings.SettingsEnums;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.os.Bundle;
@@ -25,19 +23,14 @@
import com.android.settings.SettingsActivity;
import com.android.settings.bluetooth.BluetoothDeviceRenamePreferenceController;
import com.android.settings.bluetooth.BluetoothSwitchPreferenceController;
-import com.android.settings.core.TogglePreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar;
import com.android.settings.widget.SwitchBarController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.search.SearchIndexable;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.widget.FooterPreference;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Dedicated screen for allowing the user to toggle bluetooth which displays relevant information to
* the user based on related settings such as bluetooth scanning.
@@ -47,7 +40,6 @@
private static final String TAG = "BluetoothDashboardFrag";
private static final String KEY_BLUETOOTH_SCREEN_FOOTER = "bluetooth_screen_footer";
- public static final String KEY_BLUETOOTH_SCREEN = "bluetooth_switchbar_screen";
private FooterPreference mFooterPreference;
private SwitchBar mSwitchBar;
@@ -102,39 +94,5 @@
* For Search.
*/
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableRaw> getRawDataToIndex(Context context,
- boolean enabled) {
- final List<SearchIndexableRaw> result = new ArrayList<>();
-
- // Add the activity title
- final SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = context.getString(R.string.bluetooth_settings_title);
- data.screenTitle = context.getString(R.string.bluetooth_settings_title);
- data.keywords = context.getString(R.string.keywords_bluetooth_settings);
- data.key = KEY_BLUETOOTH_SCREEN;
- result.add(data);
-
- return result;
- }
-
- @Override
- public List<String> getNonIndexableKeys(Context context) {
- final List<String> keys = super.getNonIndexableKeys(context);
- BluetoothManager manager =
- (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
- if (manager != null) {
- BluetoothAdapter adapter = manager.getAdapter();
- final int status = adapter != null
- ? TogglePreferenceController.AVAILABLE
- : TogglePreferenceController.UNSUPPORTED_ON_DEVICE;
- if (status != TogglePreferenceController.AVAILABLE) {
- keys.add(KEY_BLUETOOTH_SCREEN);
- }
- }
-
- return keys;
- }
- };
+ new BaseSearchIndexProvider(R.xml.bluetooth_screen);
}
diff --git a/src/com/android/settings/connecteddevice/NfcAndPaymentFragment.java b/src/com/android/settings/connecteddevice/NfcAndPaymentFragment.java
new file mode 100644
index 0000000..4ebc0cd
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/NfcAndPaymentFragment.java
@@ -0,0 +1,58 @@
+/*
+ * 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.connecteddevice;
+
+import android.app.settings.SettingsEnums;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.search.SearchIndexable;
+
+/**
+ * This fragment contains NFC and payment specific settings.
+ */
+@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
+public class NfcAndPaymentFragment extends DashboardFragment {
+ private static final String TAG = "NfcAndPaymentFragment";
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.nfc_and_payment_settings;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.CONNECTION_DEVICE_ADVANCED_NFC;
+ }
+
+ @Override
+ public int getHelpResource() {
+ return R.string.help_uri_nfc_and_payment_settings;
+ }
+
+ /**
+ * For Search.
+ */
+ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider(R.xml.nfc_and_payment_settings);
+}
diff --git a/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentController.java b/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentController.java
new file mode 100644
index 0000000..fef1922
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentController.java
@@ -0,0 +1,67 @@
+/*
+ * 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.connecteddevice;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.nfc.NfcAdapter;
+import android.os.UserManager;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+/**
+ * Controller that used to show NFC and payment features
+ */
+public class NfcAndPaymentFragmentController extends BasePreferenceController {
+ private final NfcAdapter mNfcAdapter;
+ private final PackageManager mPackageManager;
+ private final UserManager mUserManager;
+
+ public NfcAndPaymentFragmentController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+
+ mPackageManager = context.getPackageManager();
+ mUserManager = context.getSystemService(UserManager.class);
+ mNfcAdapter = NfcAdapter.getDefaultAdapter(context);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC)
+ || !mPackageManager.hasSystemFeature(
+ PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
+ if (!mUserManager.isAdminUser()) {
+ return DISABLED_FOR_USER;
+ }
+ return AVAILABLE;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ if (mNfcAdapter != null) {
+ if (mNfcAdapter.isEnabled()) {
+ return mContext.getText(R.string.switch_on_text);
+ } else {
+ return mContext.getText(R.string.switch_off_text);
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/com/android/settings/connecteddevice/PreviouslyConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/PreviouslyConnectedDeviceDashboardFragment.java
index 7417638..d3f5c28 100644
--- a/src/com/android/settings/connecteddevice/PreviouslyConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/PreviouslyConnectedDeviceDashboardFragment.java
@@ -17,17 +17,12 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.content.res.Resources;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.search.SearchIndexable;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* This fragment contains previously connected device
*/
@@ -67,22 +62,5 @@
* For Search.
*/
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableRaw> getRawDataToIndex(
- Context context, boolean enabled) {
- final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
- final Resources res = context.getResources();
-
- // Add fragment title
- SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.key = KEY_PREVIOUSLY_CONNECTED_DEVICES;
- data.title = res.getString(
- R.string.connected_device_previously_connected_title);
- data.screenTitle = res.getString(
- R.string.connected_device_previously_connected_title);
- result.add(data);
- return result;
- }
- };
+ new BaseSearchIndexProvider(R.xml.previously_connected_devices);
}
\ No newline at end of file
diff --git a/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java b/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java
index 2102283..fd36bca 100644
--- a/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java
+++ b/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java
@@ -31,8 +31,7 @@
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_top_level_connected_devices)
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 5ad8bb2..ae817e7 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -46,6 +46,8 @@
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.applications.managedomainurls.ManageDomainUrls;
import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminSettings;
+import com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesDetails;
+import com.android.settings.applications.specialaccess.interactacrossprofiles.InteractAcrossProfilesSettings;
import com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessDetails;
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureDetails;
import com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureSettings;
@@ -293,7 +295,9 @@
GlobalActionsPanelSettings.class.getName(),
DarkModeSettingsFragment.class.getName(),
BugReportHandlerPicker.class.getName(),
- GestureNavigationSettingsFragment.class.getName()
+ GestureNavigationSettingsFragment.class.getName(),
+ InteractAcrossProfilesSettings.class.getName(),
+ InteractAcrossProfilesDetails.class.getName()
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
diff --git a/src/com/android/settings/development/WifiScanThrottlingPreferenceController.java b/src/com/android/settings/development/WifiScanThrottlingPreferenceController.java
index a069827..2632691 100644
--- a/src/com/android/settings/development/WifiScanThrottlingPreferenceController.java
+++ b/src/com/android/settings/development/WifiScanThrottlingPreferenceController.java
@@ -17,9 +17,8 @@
package com.android.settings.development;
import android.content.Context;
-import android.provider.Settings;
+import android.net.wifi.WifiManager;
-import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
@@ -29,13 +28,12 @@
public class WifiScanThrottlingPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String WIFI_SCAN_THROTTLING_KEY = "wifi_scan_throttling";
- @VisibleForTesting
- static final int SETTING_THROTTLING_ENABLE_VALUE_ON = 1; // default is throttling enabled.
- @VisibleForTesting
- static final int SETTING_THROTTLING_ENABLE_VALUE_OFF = 0;
+
+ private final WifiManager mWifiManager;
public WifiScanThrottlingPreferenceController(Context context) {
super(context);
+ mWifiManager = context.getSystemService(WifiManager.class);
}
@Override
@@ -46,28 +44,19 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_SCAN_THROTTLE_ENABLED,
- isEnabled
- ? SETTING_THROTTLING_ENABLE_VALUE_ON
- : SETTING_THROTTLING_ENABLE_VALUE_OFF);
+ mWifiManager.setScanThrottleEnabled(isEnabled);
return true;
}
@Override
public void updateState(Preference preference) {
- final int scanThrottleEnabled = Settings.Global.getInt(
- mContext.getContentResolver(), Settings.Global.WIFI_SCAN_THROTTLE_ENABLED,
- SETTING_THROTTLING_ENABLE_VALUE_ON);
- ((SwitchPreference) mPreference).setChecked(
- scanThrottleEnabled == SETTING_THROTTLING_ENABLE_VALUE_ON);
+ ((SwitchPreference) mPreference).setChecked(mWifiManager.isScanThrottleEnabled());
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_SCAN_THROTTLE_ENABLED, SETTING_THROTTLING_ENABLE_VALUE_ON);
+ mWifiManager.setScanThrottleEnabled(true);
((SwitchPreference) mPreference).setChecked(true);
}
}
diff --git a/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java b/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
index 489408d..d6bdb54 100644
--- a/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
+++ b/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
@@ -85,14 +85,14 @@
new GameDriverContentObserver(new Handler(Looper.getMainLooper()), this);
final Resources resources = context.getResources();
- mEntryList = resources.getStringArray(R.array.game_driver_app_preference_values);
- mPreferenceTitle = resources.getString(R.string.game_driver_app_preference_title);
- mPreferenceDefault = resources.getString(R.string.game_driver_app_preference_default);
+ mEntryList = resources.getStringArray(R.array.graphics_driver_app_preference_values);
+ mPreferenceTitle = resources.getString(R.string.graphics_driver_app_preference_title);
+ mPreferenceDefault = resources.getString(R.string.graphics_driver_app_preference_default);
mPreferenceGameDriver =
- resources.getString(R.string.game_driver_app_preference_game_driver);
+ resources.getString(R.string.graphics_driver_app_preference_game_driver);
mPreferencePrereleaseDriver =
- resources.getString(R.string.game_driver_app_preference_prerelease_driver);
- mPreferenceSystem = resources.getString(R.string.game_driver_app_preference_system);
+ resources.getString(R.string.graphics_driver_app_preference_prerelease_driver);
+ mPreferenceSystem = resources.getString(R.string.graphics_driver_app_preference_system);
// TODO: Move this task to background if there's potential ANR/Jank.
// Update the UI when all the app infos are ready.
diff --git a/src/com/android/settings/development/gamedriver/GameDriverDashboard.java b/src/com/android/settings/development/gamedriver/GameDriverDashboard.java
index f67c029..4ef0a87 100644
--- a/src/com/android/settings/development/gamedriver/GameDriverDashboard.java
+++ b/src/com/android/settings/development/gamedriver/GameDriverDashboard.java
@@ -49,7 +49,7 @@
@Override
protected int getPreferenceScreenResId() {
- return R.xml.game_driver_settings;
+ return R.xml.graphics_driver_settings;
}
@Override
@@ -71,7 +71,7 @@
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.game_driver_settings) {
+ new BaseSearchIndexProvider(R.xml.graphics_driver_settings) {
@Override
protected boolean isPageSearchEnabled(Context context) {
diff --git a/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceController.java b/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceController.java
index 290e4b2..9c816c5 100644
--- a/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceController.java
+++ b/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceController.java
@@ -64,11 +64,11 @@
mContentResolver = context.getContentResolver();
final Resources resources = context.getResources();
- mPreferenceDefault = resources.getString(R.string.game_driver_app_preference_default);
+ mPreferenceDefault = resources.getString(R.string.graphics_driver_app_preference_default);
mPreferenceGameDriver =
- resources.getString(R.string.game_driver_app_preference_game_driver);
+ resources.getString(R.string.graphics_driver_app_preference_game_driver);
mPreferencePrereleaseDriver =
- resources.getString(R.string.game_driver_app_preference_prerelease_driver);
+ resources.getString(R.string.graphics_driver_app_preference_prerelease_driver);
mGameDriverContentObserver =
new GameDriverContentObserver(new Handler(Looper.getMainLooper()), this);
}
diff --git a/src/com/android/settings/deviceinfo/HardwareInfoPreferenceController.java b/src/com/android/settings/deviceinfo/HardwareInfoPreferenceController.java
index 29f1391..7ee6f89 100644
--- a/src/com/android/settings/deviceinfo/HardwareInfoPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/HardwareInfoPreferenceController.java
@@ -44,7 +44,7 @@
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_device_model)
- ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
+ ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index 5925da9..aedaa4c 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -50,13 +50,13 @@
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.Indexable;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.deviceinfo.PrivateStorageInfo;
import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
+import com.android.settingslib.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.search.SearchIndexableRaw;
import java.util.ArrayList;
import java.util.Collections;
@@ -550,13 +550,6 @@
final List<SearchIndexableRaw> result = new ArrayList<>();
SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = context.getString(R.string.storage_settings);
- data.key = "storage_settings";
- data.screenTitle = context.getString(R.string.storage_settings);
- data.keywords = context.getString(R.string.keywords_storage_settings);
- result.add(data);
-
- data = new SearchIndexableRaw(context);
data.title = context.getString(R.string.internal_storage);
data.key = "storage_settings_internal_storage";
data.screenTitle = context.getString(R.string.storage_settings);
diff --git a/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java b/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java
index fdc5feb..8a2d3ba 100644
--- a/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java
+++ b/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java
@@ -43,7 +43,7 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE_UNSEARCHABLE;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
index dcff4c3..eefa1f9 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
@@ -29,7 +29,7 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE_UNSEARCHABLE;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
index 95f3ae3..76a539f 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceController.java
@@ -86,8 +86,11 @@
mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0 /* flags */);
if (resolved != null) {
preference.setIntent(MODULE_UPDATE_INTENT);
+ preference.setSelectable(true);
} else {
+ Log.d(TAG, "The ResolveInfo of the update intent is null.");
preference.setIntent(null);
+ preference.setSelectable(false);
}
}
diff --git a/src/com/android/settings/display/ColorModePreferenceController.java b/src/com/android/settings/display/ColorModePreferenceController.java
index 234cc98..7a43e5c 100644
--- a/src/com/android/settings/display/ColorModePreferenceController.java
+++ b/src/com/android/settings/display/ColorModePreferenceController.java
@@ -34,7 +34,7 @@
return mContext.getSystemService(ColorDisplayManager.class)
.isDeviceColorManaged()
&& !ColorDisplayManager.areAccessibilityTransformsEnabled(mContext) ?
- AVAILABLE_UNSEARCHABLE : DISABLED_FOR_USER;
+ AVAILABLE : DISABLED_FOR_USER;
}
@Override
diff --git a/src/com/android/settings/display/FontSizePreferenceController.java b/src/com/android/settings/display/FontSizePreferenceController.java
index 680e378..28c7922 100644
--- a/src/com/android/settings/display/FontSizePreferenceController.java
+++ b/src/com/android/settings/display/FontSizePreferenceController.java
@@ -28,7 +28,7 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE_UNSEARCHABLE;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/display/ScreenZoomSettings.java b/src/com/android/settings/display/ScreenZoomSettings.java
index a307136..4c46f01 100644
--- a/src/com/android/settings/display/ScreenZoomSettings.java
+++ b/src/com/android/settings/display/ScreenZoomSettings.java
@@ -20,21 +20,15 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.os.Bundle;
import android.view.Display;
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.Indexable;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.display.DisplayDensityConfiguration;
import com.android.settingslib.display.DisplayDensityUtils;
import com.android.settingslib.search.SearchIndexable;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Preference fragment used to control screen zoom.
*/
@@ -121,18 +115,8 @@
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
- public List<SearchIndexableRaw> getRawDataToIndex(Context context,
- boolean enabled) {
- final Resources res = context.getResources();
- final SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = res.getString(R.string.screen_zoom_title);
- data.key = "screen_zoom_settings";
- data.screenTitle = res.getString(R.string.screen_zoom_title);
- data.keywords = res.getString(R.string.screen_zoom_keywords);
-
- final List<SearchIndexableRaw> result = new ArrayList<>(1);
- result.add(data);
- return result;
+ protected boolean isPageSearchEnabled(Context context) {
+ return false;
}
};
}
diff --git a/src/com/android/settings/display/ToggleFontSizePreferenceFragment.java b/src/com/android/settings/display/ToggleFontSizePreferenceFragment.java
index d024685..db4d899 100644
--- a/src/com/android/settings/display/ToggleFontSizePreferenceFragment.java
+++ b/src/com/android/settings/display/ToggleFontSizePreferenceFragment.java
@@ -27,13 +27,8 @@
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.Indexable;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.search.SearchIndexable;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Preference fragment used to control font size.
*/
@@ -118,16 +113,8 @@
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
- public List<SearchIndexableRaw> getRawDataToIndex(Context context,
- boolean enabled) {
- final ArrayList<SearchIndexableRaw> result = new ArrayList<>();
- final SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = context.getString(R.string.title_font_size);
- data.screenTitle = context.getString(R.string.title_font_size);
- data.key = "font_size_setting_screen";
- data.keywords = context.getString(R.string.keywords_display_font_size);
- result.add(data);
- return result;
+ protected boolean isPageSearchEnabled(Context context) {
+ return false;
}
};
diff --git a/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceController.java b/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceController.java
index 1b88e38..00d17f1 100644
--- a/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceController.java
+++ b/src/com/android/settings/enterprise/ManageDeviceAdminPreferenceController.java
@@ -43,8 +43,7 @@
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_manage_device_admin)
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
}
diff --git a/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java b/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
index 0266689..99510a2 100644
--- a/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
+++ b/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
@@ -102,7 +102,7 @@
if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
final String batteryLevel = Utils.getBatteryPercentage(intent);
final String batteryStatus = Utils.getBatteryStatus(
- mContext.getResources(), intent);
+ mContext, intent);
if (forceUpdate) {
mBatteryListener.onBatteryChanged(BatteryUpdateType.MANUAL);
} else if(!batteryLevel.equals(mBatteryLevel)) {
diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java
index ab03b65..1935c35 100644
--- a/src/com/android/settings/fuelgauge/BatteryInfo.java
+++ b/src/com/android/settings/fuelgauge/BatteryInfo.java
@@ -133,7 +133,7 @@
remaining = context.getString(R.string.remaining_length_format,
Formatter.formatShortElapsedTime(context, remainingTimeUs / 1000));
}
- view.setBottomLabels(new CharSequence[] {timeString, remaining});
+ view.setBottomLabels(new CharSequence[]{timeString, remaining});
}
public static void getBatteryInfo(final Context context, final Callback callback) {
@@ -232,9 +232,8 @@
info.batteryPercentString = Utils.formatPercentage(info.batteryLevel);
info.mCharging = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0;
info.averageTimeToDischarge = estimate.getAverageDischargeTime();
- final Resources resources = context.getResources();
- info.statusLabel = Utils.getBatteryStatus(resources, batteryBroadcast);
+ info.statusLabel = Utils.getBatteryStatus(context, batteryBroadcast);
if (!info.mCharging) {
updateBatteryInfoDischarging(context, shortString, estimate, info);
} else {
@@ -261,12 +260,11 @@
R.string.power_remaining_charging_duration_only, timeString);
info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString);
} else {
- final String chargeStatusLabel = resources.getString(
- R.string.battery_info_status_charging_lower);
+ final String chargeStatusLabel = Utils.getBatteryStatus(context, batteryBroadcast);
info.remainingLabel = null;
info.chargeLabel = info.batteryLevel == 100 ? info.batteryPercentString :
resources.getString(R.string.power_charging, info.batteryPercentString,
- chargeStatusLabel);
+ chargeStatusLabel.toLowerCase());
}
}
diff --git a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
index f6182f6..88fd1ce 100644
--- a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
@@ -48,8 +48,7 @@
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_top_level_battery)
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/gestures/GestureSettings.java b/src/com/android/settings/gestures/GestureSettings.java
index 763efaf..76964e5 100644
--- a/src/com/android/settings/gestures/GestureSettings.java
+++ b/src/com/android/settings/gestures/GestureSettings.java
@@ -19,16 +19,12 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.hardware.display.AmbientDisplayConfiguration;
-import android.provider.SearchIndexableResource;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
-import java.util.Arrays;
-import java.util.List;
-
@SearchIndexable
public class GestureSettings extends DashboardFragment {
@@ -67,20 +63,5 @@
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.gestures;
- return Arrays.asList(sir);
- }
-
- @Override
- protected boolean isPageSearchEnabled(Context context) {
- // All rows in this screen can lead to a different page, so suppress everything
- // from this page to remove duplicates.
- return false;
- }
- };
+ new BaseSearchIndexProvider(R.xml.gestures);
}
diff --git a/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java b/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
index afb3431..7c7be09 100644
--- a/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
@@ -38,7 +38,7 @@
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_volumeHushGestureEnabled)
- ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
+ ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/homepage/TopLevelSettings.java b/src/com/android/settings/homepage/TopLevelSettings.java
index 8a7f4bd..e27e288 100644
--- a/src/com/android/settings/homepage/TopLevelSettings.java
+++ b/src/com/android/settings/homepage/TopLevelSettings.java
@@ -100,12 +100,5 @@
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.top_level_settings) {
-
- @Override
- protected boolean isPageSearchEnabled(Context context) {
- // Never searchable, all entries in this page are already indexed elsewhere.
- return false;
- }
- };
+ new BaseSearchIndexProvider(R.xml.top_level_settings);
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java b/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
index c4765c3..3c88eb2 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
@@ -162,11 +162,10 @@
@VisibleForTesting
boolean isAvailable(Context context) {
- // checking dark theme mode.
- if (isDarkThemeMode(context)) {
+ // check if dark theme mode is enabled or if dark theme scheduling is on.
+ if (isDarkThemeMode(context) || isNightModeScheduled()) {
return false;
}
-
// checking the current battery level
final BatteryManager batteryManager = context.getSystemService(BatteryManager.class);
final int level = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
@@ -186,6 +185,18 @@
sSliceClicked = clicked;
}
+ private boolean isNightModeScheduled() {
+ final int mode = mUiModeManager.getNightMode();
+ if (DEBUG) {
+ Log.d(TAG, "night mode : " + mode);
+ }
+ // Turn on from sunset to sunrise or turn on at custom time
+ if (mode == UiModeManager.MODE_NIGHT_AUTO || mode == UiModeManager.MODE_NIGHT_CUSTOM) {
+ return true;
+ }
+ return false;
+ }
+
public static class DarkThemeWorker extends SliceBackgroundWorker<Void> {
private final Context mContext;
private final ContentObserver mContentObserver =
diff --git a/src/com/android/settings/inputmethod/InputMethodPreferenceController.java b/src/com/android/settings/inputmethod/InputMethodPreferenceController.java
index 5c5d0fb..1b11038 100644
--- a/src/com/android/settings/inputmethod/InputMethodPreferenceController.java
+++ b/src/com/android/settings/inputmethod/InputMethodPreferenceController.java
@@ -30,10 +30,11 @@
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.inputmethod.InputMethodPreference;
+import com.google.common.annotations.VisibleForTesting;
+
import java.text.Collator;
import java.util.ArrayList;
import java.util.List;
-import com.google.common.annotations.VisibleForTesting;
public class InputMethodPreferenceController extends BasePreferenceController implements
LifecycleObserver, OnStart {
@@ -52,7 +53,7 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE_UNSEARCHABLE;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/language/TtsPreferenceController.java b/src/com/android/settings/language/TtsPreferenceController.java
index 7e34175..6507785 100644
--- a/src/com/android/settings/language/TtsPreferenceController.java
+++ b/src/com/android/settings/language/TtsPreferenceController.java
@@ -38,7 +38,6 @@
public int getAvailabilityStatus() {
return !mTtsEngines.getEngines().isEmpty() &&
mContext.getResources().getBoolean(R.bool.config_show_tts_settings_summary)
- ? AVAILABLE_UNSEARCHABLE
- : CONDITIONALLY_UNAVAILABLE;
+ ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
}
diff --git a/src/com/android/settings/language/UserDictionaryPreferenceController.java b/src/com/android/settings/language/UserDictionaryPreferenceController.java
index d7829c6..27c47ed 100644
--- a/src/com/android/settings/language/UserDictionaryPreferenceController.java
+++ b/src/com/android/settings/language/UserDictionaryPreferenceController.java
@@ -37,7 +37,7 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE_UNSEARCHABLE;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/media/MediaOutputIndicatorSlice.java b/src/com/android/settings/media/MediaOutputIndicatorSlice.java
index d66ee8b..17d7cee 100644
--- a/src/com/android/settings/media/MediaOutputIndicatorSlice.java
+++ b/src/com/android/settings/media/MediaOutputIndicatorSlice.java
@@ -23,6 +23,7 @@
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
+import android.graphics.Bitmap;
import android.net.Uri;
import android.util.Log;
@@ -77,18 +78,24 @@
final SliceAction primarySliceAction = SliceAction.createDeeplink(
primaryActionIntent, icon, ListBuilder.ICON_IMAGE, title);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
-
+ // To set an empty icon to indent the row
final ListBuilder listBuilder = new ListBuilder(mContext,
MEDIA_OUTPUT_INDICATOR_SLICE_URI,
ListBuilder.INFINITY)
.setAccentColor(color)
.addRow(new ListBuilder.RowBuilder()
.setTitle(title)
+ .setTitleItem(createEmptyIcon(), ListBuilder.ICON_IMAGE)
.setSubtitle(findActiveDeviceName())
.setPrimaryAction(primarySliceAction));
return listBuilder.build();
}
+ private IconCompat createEmptyIcon() {
+ final Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
+ return IconCompat.createWithBitmap(bitmap);
+ }
+
private Intent getMediaOutputSliceIntent() {
final Intent intent = new Intent()
.setAction(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT)
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/network/BluetoothTetherPreferenceController.java b/src/com/android/settings/network/BluetoothTetherPreferenceController.java
index 327b6ac..d41c5af 100644
--- a/src/com/android/settings/network/BluetoothTetherPreferenceController.java
+++ b/src/com/android/settings/network/BluetoothTetherPreferenceController.java
@@ -33,34 +33,29 @@
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
-import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settings.core.BasePreferenceController;
import com.google.common.annotations.VisibleForTesting;
/**
* This controller helps to manage the switch state and visibility of bluetooth tether switch
* preference. It stores preference value when preference changed.
- * TODO(b/147272749): Extend BasePreferenceController.java instead.
*/
-public final class BluetoothTetherPreferenceController extends AbstractPreferenceController
+public final class BluetoothTetherPreferenceController extends BasePreferenceController
implements LifecycleObserver, Preference.OnPreferenceChangeListener {
private static final String TAG = "BluetoothTetherPreferenceController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- public static final String PREF_KEY = "enable_bluetooth_tethering";
private final ConnectivityManager mCm;
private int mBluetoothState;
private Preference mPreference;
private final SharedPreferences mSharedPreferences;
- public BluetoothTetherPreferenceController(Context context, Lifecycle lifecycle) {
- super(context);
+ public BluetoothTetherPreferenceController(Context context, String prefKey) {
+ super(context, prefKey);
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
mSharedPreferences =
context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE);
- if (lifecycle != null) {
- lifecycle.addObserver(this);
- }
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
@@ -76,18 +71,12 @@
}
@Override
- public boolean isAvailable() {
- final String[] bluetoothRegexs = mCm.getTetherableBluetoothRegexs();
- return bluetoothRegexs != null && bluetoothRegexs.length > 0;
- }
-
- @Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = screen.findPreference(PREF_KEY);
+ mPreference = screen.findPreference(mPreferenceKey);
if (mPreference != null && mPreference instanceof SwitchPreference) {
((SwitchPreference) mPreference)
- .setChecked(mSharedPreferences.getBoolean(PREF_KEY, false));
+ .setChecked(mSharedPreferences.getBoolean(mPreferenceKey, false));
}
}
@@ -110,8 +99,13 @@
}
@Override
- public String getPreferenceKey() {
- return PREF_KEY;
+ public int getAvailabilityStatus() {
+ final String[] bluetoothRegexs = mCm.getTetherableBluetoothRegexs();
+ if (bluetoothRegexs == null || bluetoothRegexs.length == 0) {
+ return CONDITIONALLY_UNAVAILABLE;
+ } else {
+ return AVAILABLE;
+ }
}
@VisibleForTesting
@@ -133,7 +127,7 @@
Log.d(TAG, "preference changing to " + o);
}
final SharedPreferences.Editor editor = mSharedPreferences.edit();
- editor.putBoolean(PREF_KEY, (Boolean) o);
+ editor.putBoolean(mPreferenceKey, (Boolean) o);
editor.apply();
return true;
}
diff --git a/src/com/android/settings/network/TetherEnabler.java b/src/com/android/settings/network/TetherEnabler.java
index e2b4c68..2ea3c04 100644
--- a/src/com/android/settings/network/TetherEnabler.java
+++ b/src/com/android/settings/network/TetherEnabler.java
@@ -61,13 +61,14 @@
public static final String SHARED_PREF = "tether_options";
+ // This KEY is used for a shared preference value, not for any displayed preferences.
+ public static final String KEY_ENABLE_WIFI_TETHERING = "enable_wifi_tethering";
@VisibleForTesting
- static final String WIFI_TETHER_KEY =
- WifiTetherDisablePreferenceController.KEY_ENABLE_WIFI_TETHERING;
+ static final String WIFI_TETHER_DISABLE_KEY = "disable_wifi_tethering";
@VisibleForTesting
- static final String USB_TETHER_KEY = UsbTetherPreferenceController.PREF_KEY;
+ static final String USB_TETHER_KEY = "enable_usb_tethering";
@VisibleForTesting
- static final String BLUETOOTH_TETHER_KEY = BluetoothTetherPreferenceController.PREF_KEY;
+ static final String BLUETOOTH_TETHER_KEY = "enable_bluetooth_tethering";
private final SwitchWidgetController mSwitchWidgetController;
private final WifiManager mWifiManager;
@@ -176,7 +177,7 @@
private void stopTether() {
// Wi-Fi tether is selected by default.
- if (mSharedPreferences.getBoolean(WIFI_TETHER_KEY, true)) {
+ if (mSharedPreferences.getBoolean(KEY_ENABLE_WIFI_TETHERING, true)) {
stopTethering(TETHERING_WIFI);
}
@@ -202,7 +203,7 @@
void startTether() {
// Wi-Fi tether is selected by default.
- if (mSharedPreferences.getBoolean(WIFI_TETHER_KEY, true)) {
+ if (mSharedPreferences.getBoolean(KEY_ENABLE_WIFI_TETHERING, true)) {
startTethering(TETHERING_WIFI);
}
@@ -328,7 +329,7 @@
if (!mSwitchWidgetController.isChecked()) {
return;
}
- if (TextUtils.equals(WIFI_TETHER_KEY, key)) {
+ if (TextUtils.equals(KEY_ENABLE_WIFI_TETHERING, key)) {
if (sharedPreferences.getBoolean(key, true)) {
startTethering(TETHERING_WIFI);
} else {
diff --git a/src/com/android/settings/network/TopLevelNetworkEntryPreferenceController.java b/src/com/android/settings/network/TopLevelNetworkEntryPreferenceController.java
index 1136736..f2e1312 100644
--- a/src/com/android/settings/network/TopLevelNetworkEntryPreferenceController.java
+++ b/src/com/android/settings/network/TopLevelNetworkEntryPreferenceController.java
@@ -46,7 +46,7 @@
@Override
public int getAvailabilityStatus() {
- return Utils.isDemoUser(mContext) ? UNSUPPORTED_ON_DEVICE : AVAILABLE_UNSEARCHABLE;
+ return Utils.isDemoUser(mContext) ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/network/UsbTetherPreferenceController.java b/src/com/android/settings/network/UsbTetherPreferenceController.java
index 5722480..c1d3be2 100644
--- a/src/com/android/settings/network/UsbTetherPreferenceController.java
+++ b/src/com/android/settings/network/UsbTetherPreferenceController.java
@@ -36,20 +36,18 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.Utils;
-import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settings.core.BasePreferenceController;
/**
* This controller helps to manage the switch state and visibility of USB tether switch
* preference. It stores preference values when preference changed.
- * TODO(b/147272749): Extend BasePreferenceController.java instead.
*
*/
-public final class UsbTetherPreferenceController extends AbstractPreferenceController implements
+public final class UsbTetherPreferenceController extends BasePreferenceController implements
LifecycleObserver, Preference.OnPreferenceChangeListener {
private static final String TAG = "UsbTetherPrefController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- public static final String PREF_KEY = "enable_usb_tethering";
private final ConnectivityManager mCm;
private boolean mUsbConnected;
@@ -57,14 +55,11 @@
private Preference mPreference;
private final SharedPreferences mSharedPreferences;
- public UsbTetherPreferenceController(Context context, Lifecycle lifecycle) {
- super(context);
+ public UsbTetherPreferenceController(Context context, String prefKey) {
+ super(context, prefKey);
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
mSharedPreferences =
context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE);
- if (lifecycle != null) {
- lifecycle.addObserver(this);
- }
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
@@ -82,23 +77,22 @@
}
@Override
- public boolean isAvailable() {
+ public int getAvailabilityStatus() {
String[] usbRegexs = mCm.getTetherableUsbRegexs();
- return usbRegexs != null && usbRegexs.length > 0 && !Utils.isMonkeyRunning();
- }
-
- @Override
- public String getPreferenceKey() {
- return PREF_KEY;
+ if (usbRegexs == null || usbRegexs.length == 0 || Utils.isMonkeyRunning()) {
+ return CONDITIONALLY_UNAVAILABLE;
+ } else {
+ return AVAILABLE;
+ }
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mPreference = screen.findPreference(PREF_KEY);
+ mPreference = screen.findPreference(mPreferenceKey);
if (mPreference != null && mPreference instanceof SwitchPreference) {
((SwitchPreference) mPreference)
- .setChecked(mSharedPreferences.getBoolean(PREF_KEY, false));
+ .setChecked(mSharedPreferences.getBoolean(mPreferenceKey, false));
}
}
@@ -136,7 +130,7 @@
Log.d(TAG, "preference changing to " + o);
}
final SharedPreferences.Editor editor = mSharedPreferences.edit();
- editor.putBoolean(PREF_KEY, (Boolean) o);
+ editor.putBoolean(mPreferenceKey, (Boolean) o);
editor.apply();
return true;
}
diff --git a/src/com/android/settings/network/WifiTetherDisablePreferenceController.java b/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
index 99fcfcd..ddc2bf7 100644
--- a/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
+++ b/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
@@ -30,7 +30,7 @@
import androidx.preference.SwitchPreference;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settings.core.BasePreferenceController;
/**
* This controller helps to manage the switch state and visibility of wifi tether disable switch
@@ -40,19 +40,13 @@
*
* @see BluetoothTetherPreferenceController
* @see UsbTetherPreferenceController
- * TODO(b/147272749): Extend BasePreferenceController.java instead.
- *
*/
-public final class WifiTetherDisablePreferenceController extends AbstractPreferenceController
+public final class WifiTetherDisablePreferenceController extends BasePreferenceController
implements LifecycleObserver, Preference.OnPreferenceChangeListener,
SharedPreferences.OnSharedPreferenceChangeListener {
private static final String TAG = "WifiTetherDisablePreferenceController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- public static final String PREF_KEY = "disable_wifi_tethering";
-
- // This KEY is used for a shared preference value, not for any displayed preferences.
- public static final String KEY_ENABLE_WIFI_TETHERING = "enable_wifi_tethering";
private final ConnectivityManager mCm;
private boolean mBluetoothTetherEnabled;
@@ -61,8 +55,8 @@
private Preference mPreference;
private final SharedPreferences mSharedPreferences;
- public WifiTetherDisablePreferenceController(Context context, Lifecycle lifecycle) {
- super(context);
+ public WifiTetherDisablePreferenceController(Context context, String prefKey) {
+ super(context, prefKey);
mSharedPreferences =
context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE);
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
@@ -70,9 +64,6 @@
TetherEnabler.USB_TETHER_KEY, false);
mBluetoothTetherEnabled = mSharedPreferences.getBoolean(
TetherEnabler.BLUETOOTH_TETHER_KEY, false);
- if (lifecycle != null) {
- lifecycle.addObserver(this);
- }
}
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
@@ -85,20 +76,19 @@
mSharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
}
- @Override
- public boolean isAvailable() {
- final String[] wifiRegexs = mCm.getTetherableWifiRegexs();
- return wifiRegexs != null && wifiRegexs.length > 0 && shouldShow();
- }
-
@VisibleForTesting
boolean shouldShow() {
return mBluetoothTetherEnabled || mUSBTetherEnabled;
}
@Override
- public String getPreferenceKey() {
- return PREF_KEY;
+ public int getAvailabilityStatus() {
+ final String[] wifiRegexs = mCm.getTetherableWifiRegexs();
+ if (wifiRegexs == null || wifiRegexs.length == 0 || !shouldShow()) {
+ return CONDITIONALLY_UNAVAILABLE;
+ } else {
+ return AVAILABLE;
+ }
}
@Override
@@ -111,10 +101,11 @@
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mScreen = screen;
- mPreference = screen.findPreference(PREF_KEY);
+ mPreference = screen.findPreference(mPreferenceKey);
if (mPreference != null && mPreference instanceof SwitchPreference) {
((SwitchPreference) mPreference)
- .setChecked(!mSharedPreferences.getBoolean(KEY_ENABLE_WIFI_TETHERING, true));
+ .setChecked(!mSharedPreferences.getBoolean(
+ TetherEnabler.KEY_ENABLE_WIFI_TETHERING, true));
mPreference.setOnPreferenceChangeListener(this);
}
updateState(mPreference);
@@ -123,7 +114,7 @@
@Override
public void updateState(Preference preference) {
super.updateState(preference);
- setVisible(mScreen, PREF_KEY, shouldShow());
+ setVisible(mScreen, mPreferenceKey, shouldShow());
}
@Override
@@ -162,7 +153,7 @@
Log.d(TAG, "check state changing to " + o);
}
final SharedPreferences.Editor editor = mSharedPreferences.edit();
- editor.putBoolean(KEY_ENABLE_WIFI_TETHERING, enableWifi);
+ editor.putBoolean(TetherEnabler.KEY_ENABLE_WIFI_TETHERING, enableWifi);
editor.apply();
return true;
}
diff --git a/src/com/android/settings/network/ims/ImsQueryController.java b/src/com/android/settings/network/ims/ImsQueryController.java
index 83d6578..f48fc6a 100644
--- a/src/com/android/settings/network/ims/ImsQueryController.java
+++ b/src/com/android/settings/network/ims/ImsQueryController.java
@@ -16,6 +16,10 @@
package com.android.settings.network.ims;
+import android.telephony.AccessNetworkConstants;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
+
import androidx.annotation.VisibleForTesting;
/**
@@ -23,8 +27,33 @@
*/
abstract class ImsQueryController {
+ private volatile int mCapability;
+ private volatile int mTech;
+ private volatile int mTransportType;
+
+ /**
+ * Constructor for query IMS status
+ *
+ * @param capability {@link MmTelFeature.MmTelCapabilities#MmTelCapability}
+ * @param tech {@link ImsRegistrationImplBase#ImsRegistrationTech}
+ * @param transportType {@link AccessNetworkConstants#TransportType}
+ */
+ ImsQueryController(
+ @MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
+ @ImsRegistrationImplBase.ImsRegistrationTech int tech,
+ @AccessNetworkConstants.TransportType int transportType) {
+ mCapability = capability;
+ mTech = tech;
+ mTransportType = transportType;
+ }
+
@VisibleForTesting
ImsQuery isTtyOnVolteEnabled(int subId) {
return new ImsQueryTtyOnVolteStat(subId);
}
+
+ @VisibleForTesting
+ ImsQuery isProvisionedOnDevice(int subId) {
+ return new ImsQueryProvisioningStat(subId, mCapability, mTech);
+ }
}
diff --git a/src/com/android/settings/network/ims/ImsQueryEnhanced4gLteModeUserSetting.java b/src/com/android/settings/network/ims/ImsQueryEnhanced4gLteModeUserSetting.java
new file mode 100644
index 0000000..c00f1df
--- /dev/null
+++ b/src/com/android/settings/network/ims/ImsQueryEnhanced4gLteModeUserSetting.java
@@ -0,0 +1,47 @@
+/*
+ * 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.network.ims;
+
+import android.telephony.ims.ImsMmTelManager;
+
+
+/**
+ * An {@link ImsQuery} for accessing IMS user setting for enhanced 4G LTE
+ */
+public class ImsQueryEnhanced4gLteModeUserSetting implements ImsQuery {
+
+ /**
+ * Constructor
+ * @param subId subscription id
+ */
+ public ImsQueryEnhanced4gLteModeUserSetting(int subId) {
+ mSubId = subId;
+ }
+
+ private volatile int mSubId;
+
+ /**
+ * Implementation of interface {@link ImsQuery#query()}
+ *
+ * @return result of query
+ */
+ public boolean query() {
+ final ImsMmTelManager imsMmTelManager =
+ ImsMmTelManager.createForSubscriptionId(mSubId);
+ return imsMmTelManager.isAdvancedCallingSettingEnabled();
+ }
+}
diff --git a/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java b/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java
new file mode 100644
index 0000000..5c050b5
--- /dev/null
+++ b/src/com/android/settings/network/ims/ImsQueryProvisioningStat.java
@@ -0,0 +1,57 @@
+/*
+ * 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.network.ims;
+
+import android.telephony.ims.ProvisioningManager;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
+
+
+/**
+ * An {@link ImsQuery} for accessing IMS provision stat
+ */
+public class ImsQueryProvisioningStat implements ImsQuery {
+
+ private volatile int mSubId;
+ private volatile int mCapability;
+ private volatile int mTech;
+
+ /**
+ * Constructor
+ * @param subId subscription id
+ * @param capability {@link MmTelFeature.MmTelCapabilities#MmTelCapability}
+ * @param tech {@link ImsRegistrationImplBase#ImsRegistrationTech}
+ */
+ public ImsQueryProvisioningStat(int subId,
+ @MmTelFeature.MmTelCapabilities.MmTelCapability int capability,
+ @ImsRegistrationImplBase.ImsRegistrationTech int tech) {
+ mSubId = subId;
+ mCapability = capability;
+ mTech = tech;
+ }
+
+ /**
+ * Implementation of interface {@link ImsQuery#query()}
+ *
+ * @return result of query
+ */
+ public boolean query() {
+ final ProvisioningManager privisionManager =
+ ProvisioningManager.createForSubscriptionId(mSubId);
+ return privisionManager.getProvisioningStatusForCapability(mCapability, mTech);
+ }
+}
diff --git a/src/com/android/settings/network/ims/VolteQueryImsState.java b/src/com/android/settings/network/ims/VolteQueryImsState.java
index 320aa26..608768a 100644
--- a/src/com/android/settings/network/ims/VolteQueryImsState.java
+++ b/src/com/android/settings/network/ims/VolteQueryImsState.java
@@ -18,13 +18,16 @@
import android.content.Context;
import android.telecom.TelecomManager;
+import android.telephony.AccessNetworkConstants;
import android.telephony.SubscriptionManager;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
import androidx.annotation.VisibleForTesting;
import com.android.ims.ImsManager;
import com.android.settings.network.SubscriptionUtil;
-
+import com.android.settings.network.telephony.MobileNetworkUtils;
/**
* Controller class for querying Volte status
@@ -41,11 +44,53 @@
* @param subId subscription's id
*/
public VolteQueryImsState(Context context, int subId) {
+ super(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
+ ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
+ AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
mContext = context;
mSubId = subId;
}
/**
+ * Implementation of ImsQueryController#isEnabledByUser(int subId)
+ */
+ @VisibleForTesting
+ ImsQuery isEnabledByUser(int subId) {
+ return new ImsQueryEnhanced4gLteModeUserSetting(subId);
+ }
+
+ @VisibleForTesting
+ ImsManager getImsManager(int subId) {
+ return ImsManager.getInstance(mContext,
+ SubscriptionUtil.getPhoneId(mContext, subId));
+ }
+
+ /**
+ * Check whether VoLTE has been provisioned or not on this subscription
+ *
+ * @return true when VoLTE has been enabled, otherwise false
+ */
+ public boolean isVoLteProvisioned() {
+ final ImsManager imsManager = getImsManager(mSubId);
+ if (imsManager == null) {
+ return false;
+ }
+
+ return imsManager.isVolteEnabledByPlatform()
+ && isProvisionedOnDevice(mSubId).query();
+ }
+
+ /**
+ * Check whether VoLTE can be perform or not on this subscription
+ *
+ * @return true when VoLTE can be performed, otherwise false
+ */
+ public boolean isReadyToVoLte() {
+ return isVoLteProvisioned()
+ && MobileNetworkUtils.isImsServiceStateReady(getImsManager(mSubId));
+ }
+
+ /**
* Get allowance status for user to alter configuration
*
* @return true when changing configuration by user is allowed.
@@ -74,8 +119,6 @@
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
- ImsManager imsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(
- mContext, mSubId));
- return imsManager.isEnhanced4gLteModeSettingEnabledByUser();
+ return isEnabledByUser(mSubId).query();
}
}
diff --git a/src/com/android/settings/network/ims/VtQueryImsState.java b/src/com/android/settings/network/ims/VtQueryImsState.java
index 5ac07a3..a9003b1 100644
--- a/src/com/android/settings/network/ims/VtQueryImsState.java
+++ b/src/com/android/settings/network/ims/VtQueryImsState.java
@@ -18,10 +18,17 @@
import android.content.Context;
import android.telecom.TelecomManager;
+import android.telephony.AccessNetworkConstants;
import android.telephony.SubscriptionManager;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
import androidx.annotation.VisibleForTesting;
+import com.android.ims.ImsManager;
+import com.android.settings.network.SubscriptionUtil;
+import com.android.settings.network.telephony.MobileNetworkUtils;
+
/**
* Controller class for querying VT status
*/
@@ -37,6 +44,9 @@
* @param subId subscription's id
*/
public VtQueryImsState(Context context, int subId) {
+ super(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
+ ImsRegistrationImplBase.REGISTRATION_TECH_LTE,
+ AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
mContext = context;
mSubId = subId;
}
@@ -49,6 +59,28 @@
return new ImsQueryVtUserSetting(subId);
}
+ @VisibleForTesting
+ ImsManager getImsManager(int subId) {
+ return ImsManager.getInstance(mContext,
+ SubscriptionUtil.getPhoneId(mContext, subId));
+ }
+
+ /**
+ * Check whether Video Call can be perform or not on this subscription
+ *
+ * @return true when Video Call can be performed, otherwise false
+ */
+ public boolean isReadyToVideoCall() {
+ final ImsManager imsManager = getImsManager(mSubId);
+ if (imsManager == null) {
+ return false;
+ }
+
+ return imsManager.isVtEnabledByPlatform()
+ && isProvisionedOnDevice(mSubId).query()
+ && MobileNetworkUtils.isImsServiceStateReady(imsManager);
+ }
+
/**
* Get allowance status for user to alter configuration
*
diff --git a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
index e1b3bbf..ab0bc8c 100644
--- a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
+++ b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
@@ -18,10 +18,17 @@
import android.content.Context;
import android.telecom.TelecomManager;
+import android.telephony.AccessNetworkConstants;
import android.telephony.SubscriptionManager;
+import android.telephony.ims.feature.MmTelFeature;
+import android.telephony.ims.stub.ImsRegistrationImplBase;
import androidx.annotation.VisibleForTesting;
+import com.android.ims.ImsManager;
+import com.android.settings.network.SubscriptionUtil;
+import com.android.settings.network.telephony.MobileNetworkUtils;
+
/**
* Controller class for querying Wifi calling status
*/
@@ -37,6 +44,9 @@
* @param subId subscription's id
*/
public WifiCallingQueryImsState(Context context, int subId) {
+ super(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
+ ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN,
+ AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
mContext = context;
mSubId = subId;
}
@@ -49,6 +59,37 @@
return new ImsQueryWfcUserSetting(subId);
}
+ @VisibleForTesting
+ ImsManager getImsManager(int subId) {
+ return ImsManager.getInstance(mContext,
+ SubscriptionUtil.getPhoneId(mContext, subId));
+ }
+
+ /**
+ * Check whether Wifi Calling has been provisioned or not on this subscription
+ *
+ * @return true when Wifi Calling has been enabled, otherwise false
+ */
+ public boolean isWifiCallingProvisioned() {
+ final ImsManager imsManager = getImsManager(mSubId);
+ if (imsManager == null) {
+ return false;
+ }
+
+ return imsManager.isWfcEnabledByPlatform()
+ && isProvisionedOnDevice(mSubId).query();
+ }
+
+ /**
+ * Check whether Wifi Calling can be perform or not on this subscription
+ *
+ * @return true when Wifi Calling can be performed, otherwise false
+ */
+ public boolean isReadyToWifiCalling() {
+ return isWifiCallingProvisioned()
+ && MobileNetworkUtils.isImsServiceStateReady(getImsManager(mSubId));
+ }
+
/**
* Get allowance status for user to alter configuration
*
diff --git a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
index 123e100..efbbbf8 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java
@@ -23,9 +23,6 @@
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -33,8 +30,6 @@
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
-import com.android.ims.ImsManager;
-import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.VolteQueryImsState;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
@@ -55,8 +50,6 @@
Preference mPreference;
private CarrierConfigManager mCarrierConfigManager;
private PersistableBundle mCarrierConfig;
- @VisibleForTesting
- ImsManager mImsManager;
private PhoneCallStateListener mPhoneStateListener;
@VisibleForTesting
Integer mCallState;
@@ -81,10 +74,6 @@
}
mSubId = subId;
mCarrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
- if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
- mImsManager = ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(
- mContext, mSubId));
- }
final boolean show4GForLTE = mCarrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
@@ -96,29 +85,26 @@
return this;
}
- @VisibleForTesting
- ProvisioningManager getProvisioningManager(int subId) {
- return ProvisioningManager.createForSubscriptionId(subId);
- }
-
@Override
public int getAvailabilityStatus(int subId) {
init(subId);
if (!isModeMatched()) {
return CONDITIONALLY_UNAVAILABLE;
}
+ if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+ if ((carrierConfig == null)
+ || carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL)) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
final VolteQueryImsState queryState = queryImsState(subId);
- final boolean isVisible = SubscriptionManager.isValidSubscriptionId(subId)
- && mImsManager != null && carrierConfig != null
- && mImsManager.isVolteEnabledByPlatform()
- && isVolteProvisionedOnDevice(mSubId)
- && MobileNetworkUtils.isImsServiceStateReady(mImsManager)
- && !carrierConfig.getBoolean(CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL);
- return isVisible
- ? (isUserControlAllowed() && queryState.isAllowUserControl()
- ? AVAILABLE : AVAILABLE_UNSEARCHABLE)
- : CONDITIONALLY_UNAVAILABLE;
+ if (!queryState.isReadyToVoLte()) {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ return (isUserControlAllowed() && queryState.isAllowUserControl())
+ ? AVAILABLE : AVAILABLE_UNSEARCHABLE;
}
@Override
@@ -200,19 +186,6 @@
CarrierConfigManager.KEY_EDITABLE_ENHANCED_4G_LTE_BOOL);
}
- private boolean isVolteProvisionedOnDevice(int subId) {
- if (!SubscriptionManager.isValidSubscriptionId(subId)) {
- return true;
- }
- final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
- if (provisioningMgr == null) {
- return true;
- }
- return provisioningMgr.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
- }
-
private class PhoneCallStateListener extends PhoneStateListener {
PhoneCallStateListener() {
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
index 3cad316..31e8239 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
@@ -28,9 +28,6 @@
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -40,10 +37,8 @@
import androidx.slice.builders.ListBuilder.RowBuilder;
import androidx.slice.builders.SliceAction;
-import com.android.ims.ImsManager;
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.VolteQueryImsState;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SliceBroadcastReceiver;
@@ -112,14 +107,6 @@
return null;
}
- final ImsManager imsManager = getImsManager(subId);
-
- if (!imsManager.isVolteEnabledByPlatform()
- || !isVolteProvisionedOnDevice(subId)) {
- Log.d(TAG, "Setting is either not provisioned or not enabled by Platform");
- return null;
- }
-
if (isCarrierConfigManagerKeyEnabled(
CarrierConfigManager.KEY_HIDE_ENHANCED_4G_LTE_BOOL, subId, false)
|| !isCarrierConfigManagerKeyEnabled(
@@ -130,6 +117,11 @@
}
final VolteQueryImsState queryState = queryImsState(subId);
+ if (!queryState.isVoLteProvisioned()) {
+ Log.d(TAG, "Setting is either not provisioned or not enabled by Platform");
+ return null;
+ }
+
try {
return getEnhanced4gLteSlice(sliceUri,
queryState.isEnabledByUser(), subId);
@@ -164,15 +156,6 @@
.build();
}
- protected ImsManager getImsManager(int subId) {
- return ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(mContext, subId));
- }
-
- @VisibleForTesting
- ProvisioningManager getProvisioningManager(int subId) {
- return ProvisioningManager.createForSubscriptionId(subId);
- }
-
/**
* Handles Enhanced 4G LTE mode setting change from Enhanced 4G LTE slice and posts
* notification. Should be called when intent action is ACTION_ENHANCED_4G_LTE_CHANGED
@@ -183,9 +166,8 @@
final int subId = getDefaultVoiceSubId();
if (SubscriptionManager.isValidSubscriptionId(subId)) {
- final ImsManager imsManager = getImsManager(subId);
- if (imsManager.isVolteEnabledByPlatform() && isVolteProvisionedOnDevice(subId)) {
- final VolteQueryImsState queryState = queryImsState(subId);
+ final VolteQueryImsState queryState = queryImsState(subId);
+ if (queryState.isVoLteProvisioned()) {
final boolean currentValue = queryState.isEnabledByUser()
&& queryState.isAllowUserControl();
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
@@ -285,16 +267,6 @@
return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
}
- private boolean isVolteProvisionedOnDevice(int subId) {
- final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
- if (provisioningMgr == null) {
- return true;
- }
- return provisioningMgr.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
- }
-
@VisibleForTesting
VolteQueryImsState queryImsState(int subId) {
return new VolteQueryImsState(mContext, subId);
diff --git a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
index e0ecccc..cdfbff8 100644
--- a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
@@ -85,6 +85,8 @@
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + mSubId,
newPreferredNetworkMode);
+ final ListPreference listPreference = (ListPreference) preference;
+ listPreference.setSummary(getPreferredNetworkModeSummaryResId(newPreferredNetworkMode));
return true;
}
diff --git a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
index 6fba161..eed4046 100644
--- a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
@@ -23,9 +23,6 @@
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsMmTelManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -33,9 +30,7 @@
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
-import com.android.ims.ImsManager;
import com.android.settings.network.MobileDataEnabledListener;
-import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.VolteQueryImsState;
import com.android.settings.network.ims.VtQueryImsState;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -54,8 +49,6 @@
private Preference mPreference;
private CarrierConfigManager mCarrierConfigManager;
- @VisibleForTesting
- ImsManager mImsManager;
private PhoneCallStateListener mPhoneStateListener;
@VisibleForTesting
Integer mCallState;
@@ -101,7 +94,7 @@
return;
}
final SwitchPreference switchPreference = (SwitchPreference) preference;
- final boolean videoCallEnabled = isVideoCallEnabled(mSubId, mImsManager);
+ final boolean videoCallEnabled = isVideoCallEnabled(mSubId);
switchPreference.setVisible(videoCallEnabled);
if (videoCallEnabled) {
final boolean videoCallEditable = queryVoLteState(mSubId).isEnabledByUser()
@@ -138,53 +131,29 @@
public VideoCallingPreferenceController init(int subId) {
mSubId = subId;
- if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
- mImsManager = ImsManager.getInstance(mContext,
- SubscriptionUtil.getPhoneId(mContext, mSubId));
- }
return this;
}
- private boolean isVideoCallEnabled(int subId) {
- final ImsManager imsManager = SubscriptionManager.isValidSubscriptionId(subId)
- ? ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(mContext, subId))
- : null;
- return isVideoCallEnabled(subId, imsManager);
- }
-
@VisibleForTesting
- ProvisioningManager getProvisioningManager(int subId) {
- return ProvisioningManager.createForSubscriptionId(subId);
- }
-
- private boolean isVtProvisionedOnDevice(int subId) {
- if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- return true;
+ boolean isVideoCallEnabled(int subId) {
+ if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+ return false;
}
- final ProvisioningManager provisioningMgr = getProvisioningManager(subId);
- if (provisioningMgr == null) {
- return true;
- }
- return provisioningMgr.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE);
- }
- @VisibleForTesting
- boolean isVideoCallEnabled(int subId, ImsManager imsManager) {
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
- TelephonyManager telephonyManager = mContext.getSystemService(TelephonyManager.class);
- if (SubscriptionManager.isValidSubscriptionId(subId)) {
- telephonyManager = telephonyManager.createForSubscriptionId(subId);
+ if (carrierConfig == null) {
+ return false;
}
- return carrierConfig != null && imsManager != null
- && imsManager.isVtEnabledByPlatform()
- && isVtProvisionedOnDevice(subId)
- && MobileNetworkUtils.isImsServiceStateReady(imsManager)
- && (carrierConfig.getBoolean(
+
+ if (!carrierConfig.getBoolean(
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
- || telephonyManager.isDataEnabled());
+ && (!mContext.getSystemService(TelephonyManager.class)
+ .createForSubscriptionId(subId).isDataEnabled())) {
+ return false;
+ }
+
+ return queryImsState(subId).isReadyToVideoCall();
}
@Override
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index ec23465..e928dba 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -34,9 +34,7 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
-import com.android.ims.ImsManager;
import com.android.settings.R;
-import com.android.settings.network.SubscriptionUtil;
import com.android.settings.network.ims.WifiCallingQueryImsState;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
@@ -56,8 +54,6 @@
Integer mCallState;
@VisibleForTesting
CarrierConfigManager mCarrierConfigManager;
- @VisibleForTesting
- ImsManager mImsManager;
private ImsMmTelManager mImsMmTelManager;
@VisibleForTesting
PhoneAccountHandle mSimCallManager;
@@ -73,7 +69,7 @@
@Override
public int getAvailabilityStatus(int subId) {
return SubscriptionManager.isValidSubscriptionId(subId)
- && MobileNetworkUtils.isWifiCallingEnabled(mContext, subId)
+ && isWifiCallingEnabled(mContext, subId)
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
@@ -164,8 +160,6 @@
public WifiCallingPreferenceController init(int subId) {
mSubId = subId;
- mImsManager = ImsManager.getInstance(mContext,
- SubscriptionUtil.getPhoneId(mContext, mSubId));
mImsMmTelManager = getImsMmTelManager(mSubId);
mSimCallManager = mContext.getSystemService(TelecomManager.class)
.getSimCallManagerForSubscription(mSubId);
@@ -221,4 +215,23 @@
mTelephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
}
}
+
+ private boolean isWifiCallingEnabled(Context context, int subId) {
+ final PhoneAccountHandle simCallManager =
+ context.getSystemService(TelecomManager.class)
+ .getSimCallManagerForSubscription(subId);
+ final int phoneId = SubscriptionManager.getSlotIndex(subId);
+
+ boolean isWifiCallingEnabled;
+ if (simCallManager != null) {
+ final Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(
+ context, simCallManager);
+
+ isWifiCallingEnabled = intent != null;
+ } else {
+ isWifiCallingEnabled = queryImsState(subId).isReadyToWifiCalling();
+ }
+
+ return isWifiCallingEnabled;
+ }
}
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/VibrateWhenRingPreferenceController.java b/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
deleted file mode 100644
index 503b5bc..0000000
--- a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2016 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 android.provider.Settings.System.VIBRATE_WHEN_RINGING;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.Handler;
-import android.provider.DeviceConfig;
-import android.provider.Settings;
-import android.text.TextUtils;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.Utils;
-import com.android.settings.core.TogglePreferenceController;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
-import com.android.settingslib.core.lifecycle.events.OnResume;
-
-public class VibrateWhenRingPreferenceController extends TogglePreferenceController
- implements LifecycleObserver, OnResume, OnPause {
-
- /** Flag for whether or not to apply ramping ringer on incoming phone calls. */
- private static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
- private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
- private final int DEFAULT_VALUE = 0;
- private final int NOTIFICATION_VIBRATE_WHEN_RINGING = 1;
- private SettingObserver mSettingObserver;
-
- public VibrateWhenRingPreferenceController(Context context, String key) {
- super(context, key);
- }
-
- @Override
- public boolean isChecked() {
- return Settings.System.getInt(mContext.getContentResolver(),
- VIBRATE_WHEN_RINGING, DEFAULT_VALUE) != DEFAULT_VALUE;
- }
-
- @Override
- public boolean setChecked(boolean isChecked) {
- return Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
- isChecked ? NOTIFICATION_VIBRATE_WHEN_RINGING : DEFAULT_VALUE);
- }
-
- @Override
- @AvailabilityStatus
- public int getAvailabilityStatus() {
- // If ramping ringer is enabled then this setting will be injected
- // with additional options.
- return Utils.isVoiceCapable(mContext) && !isRampingRingerEnabled()
- ? AVAILABLE
- : UNSUPPORTED_ON_DEVICE;
- }
-
- @Override
- public boolean isSliceable() {
- return TextUtils.equals(getPreferenceKey(), "vibrate_when_ringing");
- }
-
- @Override
- public boolean isPublicSlice() {
- return true;
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- super.displayPreference(screen);
- Preference preference = screen.findPreference(KEY_VIBRATE_WHEN_RINGING);
- if (preference != null) {
- mSettingObserver = new SettingObserver(preference);
- preference.setPersistent(false);
- }
- }
-
- @Override
- public void onResume() {
- if (mSettingObserver != null) {
- mSettingObserver.register(true /* register */);
- }
- }
-
- @Override
- public void onPause() {
- if (mSettingObserver != null) {
- mSettingObserver.register(false /* register */);
- }
- }
-
- private final class SettingObserver extends ContentObserver {
-
- private final Uri VIBRATE_WHEN_RINGING_URI =
- Settings.System.getUriFor(VIBRATE_WHEN_RINGING);
-
- private final Preference mPreference;
-
- public SettingObserver(Preference preference) {
- super(new Handler());
- mPreference = preference;
- }
-
- public void register(boolean register) {
- final ContentResolver cr = mContext.getContentResolver();
- if (register) {
- cr.registerContentObserver(VIBRATE_WHEN_RINGING_URI, false, this);
- } else {
- cr.unregisterContentObserver(this);
- }
- }
-
- @Override
- public void onChange(boolean selfChange, Uri uri) {
- super.onChange(selfChange, uri);
- if (VIBRATE_WHEN_RINGING_URI.equals(uri)) {
- updateState(mPreference);
- }
- }
- }
-
- private boolean isRampingRingerEnabled() {
- return DeviceConfig.getBoolean(
- DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false);
- }
-
-}
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/ZenModeAllBypassingConversationsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeAllBypassingConversationsPreferenceController.java
deleted file mode 100644
index 309cd42..0000000
--- a/src/com/android/settings/notification/zen/ZenModeAllBypassingConversationsPreferenceController.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * 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.zen;
-
-import android.app.Application;
-import android.app.NotificationChannel;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.text.TextUtils;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.core.text.BidiFormatter;
-import androidx.fragment.app.Fragment;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
-import com.android.settings.applications.AppInfoBase;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.app.ChannelNotificationSettings;
-import com.android.settingslib.applications.ApplicationsState;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.widget.apppreference.AppPreference;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Adds a preference to the PreferenceScreen for each conversation notification channel that can
- * bypass DND.
- */
-public class ZenModeAllBypassingConversationsPreferenceController extends
- AbstractPreferenceController implements PreferenceControllerMixin {
-
- private final String KEY = "zen_mode_settings_category_conversations";
-
- @VisibleForTesting ApplicationsState mApplicationsState;
- @VisibleForTesting PreferenceCategory mCategory;
- @VisibleForTesting Context mPrefContext;
-
- private ApplicationsState.Session mAppSession;
- private NotificationBackend mNotificationBackend = new NotificationBackend();
- private Fragment mHostFragment;
-
- public ZenModeAllBypassingConversationsPreferenceController(Context context, Application app,
- Fragment host) {
-
- this(context, app == null ? null : ApplicationsState.getInstance(app), host);
- }
-
- private ZenModeAllBypassingConversationsPreferenceController(Context context,
- ApplicationsState appState, Fragment host) {
- super(context);
- mApplicationsState = appState;
- mHostFragment = host;
-
- if (mApplicationsState != null && host != null) {
- mAppSession = mApplicationsState.newSession(mAppSessionCallbacks, host.getLifecycle());
- }
- }
-
- @Override
- public void displayPreference(PreferenceScreen screen) {
- mCategory = screen.findPreference(KEY);
- mPrefContext = screen.getContext();
- updateNotificationChannelList();
- super.displayPreference(screen);
- }
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY;
- }
-
- /**
- * Call this method to trigger the notification channels list to refresh.
- */
- public void updateNotificationChannelList() {
- if (mAppSession == null) {
- return;
- }
-
- ApplicationsState.AppFilter filter = ApplicationsState.FILTER_ALL_ENABLED;
- List<ApplicationsState.AppEntry> apps = mAppSession.rebuild(filter,
- ApplicationsState.ALPHA_COMPARATOR);
- if (apps != null) {
- updateNotificationChannelList(apps);
- }
- }
-
- @VisibleForTesting
- void updateNotificationChannelList(List<ApplicationsState.AppEntry> apps) {
- if (mCategory == null || apps == null) {
- return;
- }
-
- List<Preference> channelsBypassingDnd = new ArrayList<>();
- for (ApplicationsState.AppEntry entry : apps) {
- String pkg = entry.info.packageName;
- mApplicationsState.ensureIcon(entry);
- for (NotificationChannel channel : mNotificationBackend
- .getNotificationChannelsBypassingDnd(pkg, entry.info.uid).getList()) {
- if (TextUtils.isEmpty(channel.getConversationId())) {
- // only conversation channels
- continue;
- }
- Preference pref = new AppPreference(mPrefContext);
- pref.setKey(pkg + "|" + channel.getId());
- pref.setTitle(BidiFormatter.getInstance().unicodeWrap(entry.label));
- // TODO: use badged shortcut icon instead of app icon
- pref.setIcon(entry.icon);
- pref.setSummary(BidiFormatter.getInstance().unicodeWrap(channel.getName()));
-
- pref.setOnPreferenceClickListener(preference -> {
- Bundle args = new Bundle();
- args.putString(AppInfoBase.ARG_PACKAGE_NAME, entry.info.packageName);
- args.putInt(AppInfoBase.ARG_PACKAGE_UID, entry.info.uid);
- args.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
- new SubSettingLauncher(mContext)
- .setDestination(ChannelNotificationSettings.class.getName())
- .setArguments(args)
- .setTitleRes(R.string.notification_channel_title)
- .setResultListener(mHostFragment, 0)
- .setSourceMetricsCategory(
- SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APP)
- .launch();
- return true;
- });
- channelsBypassingDnd.add(pref);
- }
-
- mCategory.removeAll();
- if (channelsBypassingDnd.size() > 0) {
- mCategory.setVisible(true);
- for (Preference prefToAdd : channelsBypassingDnd) {
- mCategory.addPreference(prefToAdd);
- }
- } else {
- mCategory.setVisible(false);
- }
- }
- }
-
- private final ApplicationsState.Callbacks mAppSessionCallbacks =
- new ApplicationsState.Callbacks() {
-
- @Override
- public void onRunningStateChanged(boolean running) {
- updateNotificationChannelList();
- }
-
- @Override
- public void onPackageListChanged() {
- updateNotificationChannelList();
- }
-
- @Override
- public void onRebuildComplete(ArrayList<ApplicationsState.AppEntry> apps) {
- updateNotificationChannelList(apps);
- }
-
- @Override
- public void onPackageIconChanged() {
- updateNotificationChannelList();
- }
-
- @Override
- public void onPackageSizeChanged(String packageName) {
- updateNotificationChannelList();
- }
-
- @Override
- public void onAllSizesComputed() { }
-
- @Override
- public void onLauncherInfoChanged() {
- updateNotificationChannelList();
- }
-
- @Override
- public void onLoadEntriesCompleted() {
- // Add shortcut info
- updateNotificationChannelList();
- }
- };
-}
diff --git a/src/com/android/settings/notification/zen/ZenModeBackend.java b/src/com/android/settings/notification/zen/ZenModeBackend.java
index ac49466..836f435 100644
--- a/src/com/android/settings/notification/zen/ZenModeBackend.java
+++ b/src/com/android/settings/notification/zen/ZenModeBackend.java
@@ -16,8 +16,12 @@
package com.android.settings.notification.zen;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF;
import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON;
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_NONE;
import android.app.ActivityManager;
import android.app.AutomaticZenRule;
@@ -147,25 +151,35 @@
return SOURCE_NONE;
}
+ protected int getPriorityConversationSenders() {
+ if (isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)) {
+ return mPolicy.priorityConversationSenders;
+ }
+ return CONVERSATION_SENDERS_NONE;
+ }
+
protected void saveVisualEffectsPolicy(int category, boolean suppress) {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ZEN_SETTINGS_UPDATED, 1);
int suppressedEffects = getNewSuppressedEffects(suppress, category);
savePolicy(mPolicy.priorityCategories, mPolicy.priorityCallSenders,
- mPolicy.priorityMessageSenders, suppressedEffects);
+ mPolicy.priorityMessageSenders, suppressedEffects,
+ mPolicy.priorityConversationSenders);
}
protected void saveSoundPolicy(int category, boolean allow) {
int priorityCategories = getNewDefaultPriorityCategories(allow, category);
savePolicy(priorityCategories, mPolicy.priorityCallSenders,
- mPolicy.priorityMessageSenders, mPolicy.suppressedVisualEffects);
+ mPolicy.priorityMessageSenders, mPolicy.suppressedVisualEffects,
+ mPolicy.priorityConversationSenders);
}
protected void savePolicy(int priorityCategories, int priorityCallSenders,
- int priorityMessageSenders, int suppressedVisualEffects) {
+ int priorityMessageSenders, int suppressedVisualEffects,
+ int priorityConversationSenders) {
mPolicy = new NotificationManager.Policy(priorityCategories, priorityCallSenders,
- priorityMessageSenders, suppressedVisualEffects);
+ priorityMessageSenders, suppressedVisualEffects, priorityConversationSenders);
mNotificationManager.setNotificationPolicy(mPolicy);
}
@@ -210,23 +224,21 @@
}
savePolicy(getNewDefaultPriorityCategories(allowSenders, category),
- priorityCallSenders, priorityMessagesSenders, mPolicy.suppressedVisualEffects);
+ priorityCallSenders, priorityMessagesSenders, mPolicy.suppressedVisualEffects,
+ mPolicy.priorityConversationSenders);
if (ZenModeSettingsBase.DEBUG) Log.d(TAG, "onPrefChange allow" +
stringCategory + "=" + allowSenders + " allow" + stringCategory + "From="
+ ZenModeConfig.sourceToString(allowSendersFrom));
}
- protected String getSendersKey(int category) {
- switch (getZenMode()) {
- case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
- case Settings.Global.ZEN_MODE_ALARMS:
- return getKeyFromSetting(SOURCE_NONE);
- default:
- int prioritySenders = getPrioritySenders(category);
- return getKeyFromSetting(isPriorityCategoryEnabled(category)
- ? prioritySenders : SOURCE_NONE);
- }
+ protected void saveConversationSenders(int val) {
+ final boolean allowSenders = val != CONVERSATION_SENDERS_NONE;
+
+ savePolicy(getNewDefaultPriorityCategories(allowSenders, PRIORITY_CATEGORY_CONVERSATIONS),
+ mPolicy.priorityCallSenders, mPolicy.priorityMessageSenders,
+ mPolicy.suppressedVisualEffects, val);
+
}
private int getPrioritySenders(int category) {
@@ -240,6 +252,10 @@
return getPriorityMessageSenders();
}
+ if (category == NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS) {
+ return getPriorityConversationSenders();
+ }
+
return categorySenders;
}
@@ -271,11 +287,13 @@
}
}
- protected int getAlarmsTotalSilenceCallsMessagesSummary(int category) {
+ protected int getAlarmsTotalSilencePeopleSummary(int category) {
if (category == NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES) {
return R.string.zen_mode_from_none_messages;
} else if (category == NotificationManager.Policy.PRIORITY_CATEGORY_CALLS){
return R.string.zen_mode_from_none_calls;
+ } else if (category == NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS) {
+ return R.string.zen_mode_from_no_conversations;
}
return R.string.zen_mode_from_none;
}
@@ -309,6 +327,21 @@
}
}
+ protected int getConversationSummary() {
+ int conversationType = getPriorityConversationSenders();
+
+ switch (conversationType) {
+ case NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE:
+ return R.string.zen_mode_from_all_conversations;
+ case NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT:
+ return R.string.zen_mode_from_important_conversations;
+ case NotificationManager.Policy.CONVERSATION_SENDERS_NONE:
+ return R.string.zen_mode_from_no_conversations;
+ default:
+ return R.string.zen_mode_from_no_conversations;
+ }
+ }
+
protected int getContactsCallsSummary(ZenPolicy policy) {
int peopleType = policy.getPriorityCallSenders();
switch (peopleType) {
@@ -398,12 +431,21 @@
messages = ZenPolicy.PEOPLE_TYPE_NONE;
}
+ int conversations;
+ if (mPolicy.allowConversations()) {
+ // unlike the above, no mapping is needed because the values are the same
+ conversations = mPolicy.allowConversationsFrom();
+ } else {
+ conversations = CONVERSATION_SENDERS_NONE;
+ }
+
return new ZenPolicy.Builder(zenPolicy)
.allowAlarms(mPolicy.allowAlarms())
.allowCalls(calls)
.allowEvents(mPolicy.allowEvents())
.allowMedia(mPolicy.allowMedia())
.allowMessages(messages)
+ .allowConversations(conversations)
.allowReminders(mPolicy.allowReminders())
.allowRepeatCallers(mPolicy.allowRepeatCallers())
.allowSystem(mPolicy.allowSystem())
diff --git a/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java
index 7b97fb1..0930db2 100644
--- a/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModeCallsPreferenceController.java
@@ -56,7 +56,7 @@
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
- preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ preference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java
index ba91f56..de169ed 100644
--- a/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModeMessagesPreferenceController.java
@@ -55,7 +55,7 @@
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
- preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ preference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java b/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java
index a06f023..a48c93d 100644
--- a/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModePeoplePreferenceController.java
@@ -55,7 +55,7 @@
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
case Settings.Global.ZEN_MODE_ALARMS:
preference.setEnabled(false);
- preference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ preference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModePeopleSettings.java b/src/com/android/settings/notification/zen/ZenModePeopleSettings.java
index af3c26b..ff768db 100644
--- a/src/com/android/settings/notification/zen/ZenModePeopleSettings.java
+++ b/src/com/android/settings/notification/zen/ZenModePeopleSettings.java
@@ -65,8 +65,7 @@
controllers.add(new ZenModeRepeatCallersPreferenceController(context, lifecycle,
context.getResources().getInteger(com.android.internal.R.integer
.config_zen_repeat_callers_threshold)));
- controllers.add(
- new ZenModeAllBypassingConversationsPreferenceController(context, app, host));
+ controllers.add(new ZenModePriorityConversationsPreferenceController(context, lifecycle));
controllers.add(new ZenModeSettingsFooterPreferenceController(context, lifecycle,
fragmentManager));
return controllers;
diff --git a/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java
index 780cf84..6b538dc 100644
--- a/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceController.java
@@ -80,7 +80,7 @@
case Settings.Global.ZEN_MODE_ALARMS:
mPreference.setEnabled(false);
mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
- mPreference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ mPreference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
break;
default:
diff --git a/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceController.java b/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceController.java
new file mode 100644
index 0000000..afd17ad
--- /dev/null
+++ b/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceController.java
@@ -0,0 +1,104 @@
+/*
+ * 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.zen;
+
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_ANYONE;
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.service.notification.ZenPolicy.CONVERSATION_SENDERS_NONE;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+public class ZenModePriorityConversationsPreferenceController
+ extends AbstractZenModePreferenceController
+ implements Preference.OnPreferenceChangeListener {
+
+ protected static final String KEY = "zen_mode_conversations";
+ private final ZenModeBackend mBackend;
+ private ListPreference mPreference;
+
+ public ZenModePriorityConversationsPreferenceController(Context context, Lifecycle lifecycle) {
+ super(context, KEY, lifecycle);
+ mBackend = ZenModeBackend.getInstance(context);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(KEY);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ updateValue(preference);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object selectedContactsFrom) {
+ mBackend.saveConversationSenders(Integer.parseInt(selectedContactsFrom.toString()));
+ updateValue(preference);
+ return true;
+ }
+
+ private void updateValue(Preference preference) {
+ mPreference = (ListPreference) preference;
+ switch (getZenMode()) {
+ case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
+ case Settings.Global.ZEN_MODE_ALARMS:
+ mPreference.setEnabled(false);
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_NONE));
+ mPreference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
+ NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS));
+ break;
+ default:
+ preference.setEnabled(true);
+ preference.setSummary(mBackend.getConversationSummary());
+ int senders = mBackend.getPriorityConversationSenders();
+
+ switch (senders) {
+ case CONVERSATION_SENDERS_NONE:
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_NONE));
+ break;
+ case CONVERSATION_SENDERS_IMPORTANT:
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_IMPORTANT));
+ break;
+ default:
+ mPreference.setValue(String.valueOf(CONVERSATION_SENDERS_ANYONE));
+ break;
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java b/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java
index f54179e..6476c63 100644
--- a/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceController.java
@@ -80,7 +80,7 @@
case Settings.Global.ZEN_MODE_ALARMS:
mPreference.setEnabled(false);
mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
- mPreference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ mPreference.setSummary(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
break;
default:
diff --git a/src/com/android/settings/panel/MediaOutputPanel.java b/src/com/android/settings/panel/MediaOutputPanel.java
index c42906d..d6030cc 100644
--- a/src/com/android/settings/panel/MediaOutputPanel.java
+++ b/src/com/android/settings/panel/MediaOutputPanel.java
@@ -22,9 +22,22 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.media.MediaMetadata;
+import android.media.session.MediaController;
+import android.media.session.MediaSessionManager;
import android.net.Uri;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.core.graphics.drawable.IconCompat;
import com.android.settings.R;
+import com.android.settings.Utils;
import java.util.ArrayList;
import java.util.List;
@@ -38,9 +51,14 @@
*/
public class MediaOutputPanel implements PanelContent {
+ private static final String TAG = "MediaOutputPanel";
+
private final Context mContext;
private final String mPackageName;
+ private MediaSessionManager mMediaSessionManager;
+ private MediaController mMediaController;
+
public static MediaOutputPanel create(Context context, String packageName) {
return new MediaOutputPanel(context, packageName);
}
@@ -48,14 +66,79 @@
private MediaOutputPanel(Context context, String packageName) {
mContext = context.getApplicationContext();
mPackageName = packageName;
+ if (mPackageName != null) {
+ mMediaSessionManager = mContext.getSystemService(MediaSessionManager.class);
+ for (MediaController controller : mMediaSessionManager.getActiveSessions(null)) {
+ if (TextUtils.equals(controller.getPackageName(), mPackageName)) {
+ mMediaController = controller;
+ break;
+ }
+ }
+ }
+ if (mMediaController == null) {
+ Log.e(TAG, "Unable to find " + mPackageName + " media controller");
+ }
}
@Override
public CharSequence getTitle() {
+ if (mMediaController != null) {
+ final MediaMetadata metadata = mMediaController.getMetadata();
+ if (metadata != null) {
+ return metadata.getString(MediaMetadata.METADATA_KEY_ARTIST);
+ }
+ }
+ return mContext.getText(R.string.media_volume_title);
+ }
+
+ @Override
+ public CharSequence getSubTitle() {
+ if (mMediaController != null) {
+ final MediaMetadata metadata = mMediaController.getMetadata();
+ if (metadata != null) {
+ return metadata.getString(MediaMetadata.METADATA_KEY_ALBUM);
+ }
+ }
return mContext.getText(R.string.media_output_panel_title);
}
@Override
+ public IconCompat getIcon() {
+ if (mMediaController == null) {
+ return IconCompat.createWithResource(mContext, R.drawable.ic_media_stream).setTint(
+ Utils.getColorAccentDefaultColor(mContext));
+ }
+ final MediaMetadata metadata = mMediaController.getMetadata();
+ if (metadata != null) {
+ final Bitmap bitmap = metadata.getDescription().getIconBitmap();
+ if (bitmap != null) {
+ return IconCompat.createWithBitmap(bitmap);
+ }
+ }
+ Log.d(TAG, "Media meta data does not contain icon information");
+ return getPackageIcon();
+ }
+
+ private IconCompat getPackageIcon() {
+ try {
+ final Drawable drawable = mContext.getPackageManager().getApplicationIcon(mPackageName);
+ if (drawable instanceof BitmapDrawable) {
+ return IconCompat.createWithBitmap(((BitmapDrawable) drawable).getBitmap());
+ }
+ final Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
+ drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
+ final Canvas canvas = new Canvas(bitmap);
+ drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
+ drawable.draw(canvas);
+
+ return IconCompat.createWithBitmap(bitmap);
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "Package is not found. Unable to get package icon.");
+ }
+ return null;
+ }
+
+ @Override
public List<Uri> getSlices() {
final List<Uri> uris = new ArrayList<>();
MEDIA_OUTPUT_SLICE_URI =
diff --git a/src/com/android/settings/panel/PanelContent.java b/src/com/android/settings/panel/PanelContent.java
index badaeb1..5670469 100644
--- a/src/com/android/settings/panel/PanelContent.java
+++ b/src/com/android/settings/panel/PanelContent.java
@@ -19,6 +19,8 @@
import android.content.Intent;
import android.net.Uri;
+import androidx.core.graphics.drawable.IconCompat;
+
import com.android.settingslib.core.instrumentation.Instrumentable;
import java.util.List;
@@ -28,13 +30,11 @@
*/
public interface PanelContent extends Instrumentable {
- int ICON_UNAVAILABLE = -1;
-
/**
- * @return a icon resource for the title of the Panel.
+ * @return a icon for the title of the Panel.
*/
- default int getIcon() {
- return ICON_UNAVAILABLE;
+ default IconCompat getIcon() {
+ return null;
}
/**
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index 40706fe..8fda894 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -38,6 +38,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.core.graphics.drawable.IconCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.LiveData;
@@ -185,20 +186,19 @@
mMetricsProvider = FeatureFactory.getFactory(activity).getMetricsFeatureProvider();
mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
-
// Add predraw listener to remove the animation and while we wait for Slices to load.
mLayoutView.getViewTreeObserver().addOnPreDrawListener(mOnPreDrawListener);
// Start loading Slices. When finished, the Panel will animate in.
loadAllSlices();
- final int iconRes = mPanel.getIcon();
- if (iconRes == PanelContent.ICON_UNAVAILABLE) {
+ final IconCompat icon = mPanel.getIcon();
+ if (icon == null) {
mTitleView.setText(mPanel.getTitle());
} else {
mTitleView.setVisibility(View.GONE);
mPanelHeader.setVisibility(View.VISIBLE);
- mTitleIcon.setImageResource(iconRes);
+ mTitleIcon.setImageIcon(icon.toIcon(getContext()));
mHeaderTitle.setText(mPanel.getTitle());
mHeaderSubtitle.setText(mPanel.getSubTitle());
}
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 8947f8f..6f505bd 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -182,6 +182,15 @@
if ((mTitle == null) && isManagedProfile) {
mTitle = getTitleFromOrganizationName(mUserId);
}
+ final @LockPatternUtils.CredentialType int credentialType = Utils.getCredentialType(
+ mContext, effectiveUserId);
+ if (mTitle == null) {
+ mTitle = getTitleFromCredentialType(credentialType, isManagedProfile);
+ }
+ if (mDetails == null) {
+ mDetails = getDetailsFromCredentialType(credentialType, isManagedProfile);
+ }
+
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
final LockPatternUtils lockPatternUtils = new LockPatternUtils(this);
@@ -233,6 +242,44 @@
}
}
+ private String getTitleFromCredentialType(@LockPatternUtils.CredentialType int credentialType,
+ boolean isManagedProfile) {
+ switch (credentialType) {
+ case LockPatternUtils.CREDENTIAL_TYPE_PIN:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_work_pin_header)
+ : getString(R.string.lockpassword_confirm_your_pin_header);
+ case LockPatternUtils.CREDENTIAL_TYPE_PATTERN:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_work_pattern_header)
+ : getString(R.string.lockpassword_confirm_your_pattern_header);
+ case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_work_password_header)
+ : getString(R.string.lockpassword_confirm_your_password_header);
+ }
+ return null;
+ }
+
+ private String getDetailsFromCredentialType(@LockPatternUtils.CredentialType int credentialType,
+ boolean isManagedProfile) {
+ switch (credentialType) {
+ case LockPatternUtils.CREDENTIAL_TYPE_PIN:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_pin_generic_profile)
+ : getString(R.string.lockpassword_confirm_your_pin_generic);
+ case LockPatternUtils.CREDENTIAL_TYPE_PATTERN:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_pattern_generic_profile)
+ : getString(R.string.lockpassword_confirm_your_pattern_generic);
+ case LockPatternUtils.CREDENTIAL_TYPE_PASSWORD:
+ return isManagedProfile
+ ? getString(R.string.lockpassword_confirm_your_password_generic_profile)
+ : getString(R.string.lockpassword_confirm_your_password_generic);
+ }
+ return null;
+ }
+
@Override
protected void onStart() {
super.onStart();
diff --git a/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java b/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java
index 4b00424..4a4d345 100644
--- a/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java
+++ b/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java
@@ -32,7 +32,7 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE_UNSEARCHABLE;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/security/screenlock/LockScreenPreferenceController.java b/src/com/android/settings/security/screenlock/LockScreenPreferenceController.java
index 8cf0825..8585493 100644
--- a/src/com/android/settings/security/screenlock/LockScreenPreferenceController.java
+++ b/src/com/android/settings/security/screenlock/LockScreenPreferenceController.java
@@ -50,7 +50,7 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE_UNSEARCHABLE;
+ return AVAILABLE;
}
@Override
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index 1785199..34c0f1b 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -286,7 +286,7 @@
final PendingIntent actionIntent = getSliderAction(context, sliceData);
final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
final IconCompat icon = getSafeIcon(context, sliceData);
- @ColorInt final int color = Utils.getColorAccentDefaultColor(context);
+ @ColorInt int color = Utils.getColorAccentDefaultColor(context);
final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
final SliceAction primaryAction = SliceAction.createDeeplink(contentIntent, icon,
ListBuilder.ICON_IMAGE, sliceData.getTitle());
@@ -299,17 +299,22 @@
if (cur > sliderController.getMax()) {
cur = sliderController.getMax();
}
+ final InputRangeBuilder inputRangeBuilder = new InputRangeBuilder()
+ .setTitle(sliceData.getTitle())
+ .setSubtitle(subtitleText)
+ .setPrimaryAction(primaryAction)
+ .setMax(sliderController.getMax())
+ .setMin(sliderController.getMin())
+ .setValue(cur)
+ .setInputAction(actionIntent);
+ if (sliceData.getIconResource() != 0) {
+ inputRangeBuilder.setTitleItem(icon, ListBuilder.ICON_IMAGE);
+ color = CustomSliceable.COLOR_NOT_TINTED;
+ }
return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY)
.setAccentColor(color)
- .addInputRange(new InputRangeBuilder()
- .setTitle(sliceData.getTitle())
- .setSubtitle(subtitleText)
- .setPrimaryAction(primaryAction)
- .setMax(sliderController.getMax())
- .setMin(sliderController.getMin())
- .setValue(cur)
- .setInputAction(actionIntent))
+ .addInputRange(inputRangeBuilder)
.setKeywords(keywords)
.build();
}
diff --git a/src/com/android/settings/sound/VibrateForCallsPreferenceController.java b/src/com/android/settings/sound/VibrateForCallsPreferenceController.java
new file mode 100644
index 0000000..31abd8a
--- /dev/null
+++ b/src/com/android/settings/sound/VibrateForCallsPreferenceController.java
@@ -0,0 +1,66 @@
+/*
+ * 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.sound;
+
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.core.BasePreferenceController;
+
+/**
+ * Controller for vibrate for calls settings.
+ */
+public class VibrateForCallsPreferenceController extends BasePreferenceController {
+
+ private static final int ON = 1;
+ private static final int OFF = 0;
+ @VisibleForTesting
+ static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
+
+ public VibrateForCallsPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ @AvailabilityStatus
+ public int getAvailabilityStatus() {
+ return Utils.isVoiceCapable(mContext) && !DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false)
+ ? AVAILABLE
+ : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ if (Settings.Global.getInt(
+ mContext.getContentResolver(),
+ Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) {
+ return mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer);
+ } else if (Settings.System.getInt(
+ mContext.getContentResolver(),
+ Settings.System.VIBRATE_WHEN_RINGING, OFF) == ON) {
+ return mContext.getText(R.string.vibrate_when_ringing_option_always_vibrate);
+ } else {
+ return mContext.getText(R.string.vibrate_when_ringing_option_never_vibrate);
+ }
+ }
+}
diff --git a/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java b/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java
new file mode 100644
index 0000000..73b9f2f
--- /dev/null
+++ b/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2019 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.sound;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.util.ArrayMap;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.R;
+import com.android.settings.widget.RadioButtonPickerFragment;
+import com.android.settingslib.widget.CandidateInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Fragment for changing vibrate for calls options.
+ */
+public class VibrateForCallsPreferenceFragment extends RadioButtonPickerFragment {
+ private static final String TAG = "VibrateForCallsPreferenceFragment";
+
+ @VisibleForTesting
+ static final String KEY_NEVER_VIBRATE = "never_vibrate";
+ @VisibleForTesting
+ static final String KEY_ALWAYS_VIBRATE = "always_vibrate";
+ @VisibleForTesting
+ static final String KEY_RAMPING_RINGER = "ramping_ringer";
+
+ private static final int ON = 1;
+ private static final int OFF = 0;
+
+ private final Map<String, VibrateForCallsCandidateInfo> mCandidates;
+
+ public VibrateForCallsPreferenceFragment() {
+ mCandidates = new ArrayMap<>();
+ }
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+ loadCandidates(context);
+ }
+
+ private void loadCandidates(Context context) {
+ mCandidates.put(KEY_NEVER_VIBRATE,
+ new VibrateForCallsCandidateInfo(
+ KEY_NEVER_VIBRATE, R.string.vibrate_when_ringing_option_never_vibrate));
+ mCandidates.put(KEY_ALWAYS_VIBRATE,
+ new VibrateForCallsCandidateInfo(
+ KEY_ALWAYS_VIBRATE, R.string.vibrate_when_ringing_option_always_vibrate));
+ mCandidates.put(KEY_RAMPING_RINGER,
+ new VibrateForCallsCandidateInfo(
+ KEY_RAMPING_RINGER, R.string.vibrate_when_ringing_option_ramping_ringer));
+ }
+
+ private void updateSettings(VibrateForCallsCandidateInfo candidate) {
+ final String key = candidate.getKey();
+ if (TextUtils.equals(key, KEY_ALWAYS_VIBRATE)) {
+ Settings.System.putInt(
+ getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, ON);
+ Settings.Global.putInt(
+ getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
+ } else if (TextUtils.equals(key, KEY_RAMPING_RINGER)) {
+ Settings.System.putInt(
+ getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(
+ getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, ON);
+ } else {
+ Settings.System.putInt(
+ getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(
+ getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
+ }
+ }
+
+ @Override
+ protected List<? extends CandidateInfo> getCandidates() {
+ final List<VibrateForCallsCandidateInfo> candidates = new ArrayList<>();
+ candidates.add(mCandidates.get(KEY_NEVER_VIBRATE));
+ candidates.add(mCandidates.get(KEY_ALWAYS_VIBRATE));
+ candidates.add(mCandidates.get(KEY_RAMPING_RINGER));
+ return candidates;
+ }
+
+ @Override
+ protected String getDefaultKey() {
+ if (Settings.Global.getInt(
+ getContext().getContentResolver(),
+ Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) {
+ return KEY_RAMPING_RINGER;
+ } else if (Settings.System.getInt(
+ getContext().getContentResolver(),
+ Settings.System.VIBRATE_WHEN_RINGING, OFF) == ON) {
+ return KEY_ALWAYS_VIBRATE;
+ } else {
+ return KEY_NEVER_VIBRATE;
+ }
+ }
+
+ @Override
+ protected boolean setDefaultKey(String key) {
+ final VibrateForCallsCandidateInfo candidate = mCandidates.get(key);
+ if (candidate == null) {
+ Log.e(TAG, "Unknown vibrate for calls candidate (key = " + key + ")!");
+ return false;
+ }
+ updateSettings(candidate);
+ return true;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.vibrate_for_calls_settings;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.VIBRATE_FOR_CALLS;
+ }
+
+ @VisibleForTesting
+ class VibrateForCallsCandidateInfo extends CandidateInfo {
+ private final String mKey;
+ private final int mLabelId;
+
+ VibrateForCallsCandidateInfo(String key, int labelId) {
+ super(true /* enabled */);
+ mKey = key;
+ mLabelId = labelId;
+ }
+
+ @Override
+ public CharSequence loadLabel() {
+ return getContext().getString(mLabelId);
+ }
+
+ @Override
+ public Drawable loadIcon() {
+ return null;
+ }
+
+ @Override
+ public String getKey() {
+ return mKey;
+ }
+ }
+}
diff --git a/src/com/android/settings/system/ResetPreferenceController.java b/src/com/android/settings/system/ResetPreferenceController.java
index bbb5323..09db32f 100644
--- a/src/com/android/settings/system/ResetPreferenceController.java
+++ b/src/com/android/settings/system/ResetPreferenceController.java
@@ -38,8 +38,7 @@
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_reset_dashboard)
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/utils/AnnotationSpan.java b/src/com/android/settings/utils/AnnotationSpan.java
index e6457da..1b8179d 100644
--- a/src/com/android/settings/utils/AnnotationSpan.java
+++ b/src/com/android/settings/utils/AnnotationSpan.java
@@ -50,7 +50,7 @@
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
- ds.setUnderlineText(false);
+ ds.setUnderlineText(true);
}
public static CharSequence linkify(CharSequence rawText, LinkInfo... linkInfos) {
diff --git a/src/com/android/settings/vpn2/AppDialogFragment.java b/src/com/android/settings/vpn2/AppDialogFragment.java
index 2f9cd7a..ea9e546 100644
--- a/src/com/android/settings/vpn2/AppDialogFragment.java
+++ b/src/com/android/settings/vpn2/AppDialogFragment.java
@@ -22,6 +22,7 @@
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.net.IConnectivityManager;
+import android.net.VpnManager;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -145,7 +146,8 @@
}
final int userId = getUserId();
try {
- mService.setVpnPackageAuthorization(mPackageInfo.packageName, userId, false);
+ mService.setVpnPackageAuthorization(
+ mPackageInfo.packageName, userId, VpnManager.TYPE_VPN_NONE);
onDisconnect(dialog);
} catch (RemoteException e) {
Log.e(TAG, "Failed to forget authorization of " + mPackageInfo.packageName +
diff --git a/src/com/android/settings/vpn2/AppManagementFragment.java b/src/com/android/settings/vpn2/AppManagementFragment.java
index 5f46446..8e3d9bb 100644
--- a/src/com/android/settings/vpn2/AppManagementFragment.java
+++ b/src/com/android/settings/vpn2/AppManagementFragment.java
@@ -15,6 +15,7 @@
*/
package com.android.settings.vpn2;
+import static android.app.AppOpsManager.OP_ACTIVATE_PLATFORM_VPN;
import static android.app.AppOpsManager.OP_ACTIVATE_VPN;
import android.annotation.NonNull;
@@ -312,7 +313,7 @@
final AppOpsManager service =
(AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
final List<AppOpsManager.PackageOps> ops = service.getOpsForPackage(application.uid,
- application.packageName, new int[]{OP_ACTIVATE_VPN});
+ application.packageName, new int[]{OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
return !ArrayUtils.isEmpty(ops);
}
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 83cdf71..8a2b465 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -16,6 +16,7 @@
package com.android.settings.vpn2;
+import static android.app.AppOpsManager.OP_ACTIVATE_PLATFORM_VPN;
import static android.app.AppOpsManager.OP_ACTIVATE_VPN;
import android.annotation.UiThread;
@@ -522,7 +523,8 @@
// Fetch VPN-enabled apps from AppOps.
AppOpsManager aom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
- List<AppOpsManager.PackageOps> apps = aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN});
+ List<AppOpsManager.PackageOps> apps =
+ aom.getPackagesForOps(new int[] {OP_ACTIVATE_VPN, OP_ACTIVATE_PLATFORM_VPN});
if (apps != null) {
for (AppOpsManager.PackageOps pkg : apps) {
int userId = UserHandle.getUserId(pkg.getUid());
@@ -533,8 +535,8 @@
// Look for a MODE_ALLOWED permission to activate VPN.
boolean allowed = false;
for (AppOpsManager.OpEntry op : pkg.getOps()) {
- if (op.getOp() == OP_ACTIVATE_VPN &&
- op.getMode() == AppOpsManager.MODE_ALLOWED) {
+ if ((op.getOp() == OP_ACTIVATE_VPN || op.getOp() == OP_ACTIVATE_PLATFORM_VPN)
+ && op.getMode() == AppOpsManager.MODE_ALLOWED) {
allowed = true;
}
}
diff --git a/src/com/android/settings/wfd/WifiDisplayPreferenceController.java b/src/com/android/settings/wfd/WifiDisplayPreferenceController.java
index 3227387..a83a56b 100644
--- a/src/com/android/settings/wfd/WifiDisplayPreferenceController.java
+++ b/src/com/android/settings/wfd/WifiDisplayPreferenceController.java
@@ -69,8 +69,7 @@
@Override
public int getAvailabilityStatus() {
- return WifiDisplaySettings.isAvailable(mContext) ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
+ return WifiDisplaySettings.isAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
@@ -104,4 +103,4 @@
public void onStop() {
mRouter.removeCallback(mRouterCallback);
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/wfd/WifiDisplaySettings.java b/src/com/android/settings/wfd/WifiDisplaySettings.java
index 4022809..21352b7 100755
--- a/src/com/android/settings/wfd/WifiDisplaySettings.java
+++ b/src/com/android/settings/wfd/WifiDisplaySettings.java
@@ -520,7 +520,7 @@
if (DEBUG) {
Slog.d(TAG, "Setting listen mode to: " + enable);
}
- mWifiP2pManager.listen(mWifiP2pChannel, enable, new ActionListener() {
+ final ActionListener listener = new ActionListener() {
@Override
public void onSuccess() {
if (DEBUG) {
@@ -534,7 +534,12 @@
Slog.e(TAG, "Failed to " + (enable ? "entered" : "exited")
+ " listen mode with reason " + reason + ".");
}
- });
+ };
+ if (enable) {
+ mWifiP2pManager.startListening(mWifiP2pChannel, listener);
+ } else {
+ mWifiP2pManager.stopListening(mWifiP2pChannel, listener);
+ }
}
private void setWifiP2pChannels(final int lc, final int oc) {
diff --git a/src/com/android/settings/widget/EntityHeaderController.java b/src/com/android/settings/widget/EntityHeaderController.java
index 8e31290..440882f 100644
--- a/src/com/android/settings/widget/EntityHeaderController.java
+++ b/src/com/android/settings/widget/EntityHeaderController.java
@@ -29,7 +29,6 @@
import android.os.Bundle;
import android.os.UserHandle;
import android.text.TextUtils;
-import android.util.IconDrawableFactory;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -147,7 +146,7 @@
* accessibility purposes.
*/
public EntityHeaderController setIcon(ApplicationsState.AppEntry appEntry) {
- mIcon = IconDrawableFactory.newInstance(mAppContext).getBadgedIcon(appEntry.info);
+ mIcon = Utils.getBadgedIcon(mAppContext, appEntry.info);
return this;
}
diff --git a/src/com/android/settings/widget/MasterSwitchPreference.java b/src/com/android/settings/widget/MasterSwitchPreference.java
index b34b162..9fe077e 100644
--- a/src/com/android/settings/widget/MasterSwitchPreference.java
+++ b/src/com/android/settings/widget/MasterSwitchPreference.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.util.AttributeSet;
+import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Switch;
@@ -81,6 +82,11 @@
}
}
});
+
+ // Consumes move events to ignore drag actions.
+ switchWidget.setOnTouchListener((v, event) -> {
+ return event.getActionMasked() == MotionEvent.ACTION_MOVE;
+ });
}
mSwitch = (Switch) holder.findViewById(R.id.switchWidget);
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 488aadb..64814fa 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -17,6 +17,7 @@
package com.android.settings.wifi;
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
+import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED;
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
import android.annotation.NonNull;
@@ -27,7 +28,6 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
@@ -73,7 +73,6 @@
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPoint.AccessPointListener;
import com.android.settingslib.wifi.AccessPointPreference;
@@ -81,7 +80,6 @@
import com.android.settingslib.wifi.WifiTracker;
import com.android.settingslib.wifi.WifiTrackerFactory;
-import java.util.ArrayList;
import java.util.List;
/**
@@ -193,9 +191,6 @@
DataUsagePreference mDataUsagePreference;
private LinkablePreference mStatusMessagePreference;
- // For Search
- public static final String DATA_KEY_REFERENCE = "main_toggle_wifi";
-
/**
* Tracks whether the user initiated a connection via clicking in order to autoscroll to the
* network once connected.
@@ -730,7 +725,8 @@
}
WifiConfiguration.NetworkSelectionStatus networkStatus =
config.getNetworkSelectionStatus();
- if (networkStatus == null || networkStatus.isNetworkEnabled()) {
+ if (networkStatus == null
+ || networkStatus.getNetworkSelectionStatus() == NETWORK_SELECTION_ENABLED) {
return false;
}
int reason = networkStatus.getNetworkSelectionDisableReason();
@@ -1244,24 +1240,6 @@
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.wifi_settings) {
@Override
- public List<SearchIndexableRaw> getRawDataToIndex(Context context,
- boolean enabled) {
- final List<SearchIndexableRaw> result = new ArrayList<>();
- final Resources res = context.getResources();
-
- // Add fragment title if we are showing this fragment
- if (res.getBoolean(R.bool.config_show_wifi_settings)) {
- SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = res.getString(R.string.wifi_settings);
- data.screenTitle = res.getString(R.string.wifi_settings);
- data.keywords = res.getString(R.string.keywords_wifi);
- data.key = DATA_KEY_REFERENCE;
- result.add(data);
- }
- return result;
- }
-
- @Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
diff --git a/src/com/android/settings/wifi/WifiSettings2.java b/src/com/android/settings/wifi/WifiSettings2.java
index 932f5d9..1a7d572 100644
--- a/src/com/android/settings/wifi/WifiSettings2.java
+++ b/src/com/android/settings/wifi/WifiSettings2.java
@@ -16,6 +16,7 @@
package com.android.settings.wifi;
+import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED;
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
import android.app.Activity;
@@ -25,7 +26,6 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkScoreManager;
import android.net.NetworkTemplate;
@@ -73,7 +73,6 @@
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.wifi.LongPressWifiEntryPreference;
import com.android.wifitrackerlib.WifiEntry;
import com.android.wifitrackerlib.WifiEntry.ConnectCallback;
@@ -81,7 +80,6 @@
import java.time.Clock;
import java.time.ZoneOffset;
-import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -198,9 +196,6 @@
DataUsagePreference mDataUsagePreference;
private LinkablePreference mStatusMessagePreference;
- // For Search
- public static final String DATA_KEY_REFERENCE = "main_toggle_wifi";
-
/**
* Tracks whether the user initiated a connection via clicking in order to autoscroll to the
* network once connected.
@@ -1019,26 +1014,7 @@
};
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableRaw> getRawDataToIndex(Context context,
- boolean enabled) {
- final List<SearchIndexableRaw> result = new ArrayList<>();
- final Resources res = context.getResources();
-
- // Add fragment title if we are showing this fragment
- if (res.getBoolean(R.bool.config_show_wifi_settings)) {
- SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = res.getString(R.string.wifi_settings);
- data.screenTitle = res.getString(R.string.wifi_settings);
- data.keywords = res.getString(R.string.keywords_wifi);
- data.key = DATA_KEY_REFERENCE;
- result.add(data);
- }
-
- return result;
- }
- };
+ new BaseSearchIndexProvider(R.xml.wifi_settings2);
private class WifiEntryConnectCallback implements ConnectCallback {
final WifiEntry mConnectWifiEntry;
@@ -1100,7 +1076,8 @@
}
WifiConfiguration.NetworkSelectionStatus networkStatus =
config.getNetworkSelectionStatus();
- if (networkStatus == null || networkStatus.isNetworkEnabled()) {
+ if (networkStatus == null
+ || networkStatus.getNetworkSelectionStatus() == NETWORK_SELECTION_ENABLED) {
return false;
}
int reason = networkStatus.getNetworkSelectionDisableReason();
diff --git a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
index b584ea1..05c7b4e 100644
--- a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
+++ b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
@@ -715,7 +715,7 @@
}
@VisibleForTesting
- void updateScanResults(List<AccessPoint> allAccessPoints) {
+ void updateScanResultsToUi(List<AccessPoint> allAccessPoints) {
if (mUiToRequestedList == null) {
// Nothing need to be updated.
return;
@@ -723,13 +723,16 @@
// Update the signal level of the UI networks.
for (UiConfigurationItem uiConfigurationItem : mUiToRequestedList) {
- final Optional<AccessPoint> matchedAccessPoint = allAccessPoints
- .stream()
- .filter(accesspoint -> accesspoint.matches(
- uiConfigurationItem.mWifiNetworkSuggestion.getWifiConfiguration()))
- .findFirst();
- uiConfigurationItem.mLevel =
- matchedAccessPoint.isPresent() ? matchedAccessPoint.get().getLevel() : 0;
+ uiConfigurationItem.mLevel = 0;
+ if (allAccessPoints != null) {
+ final Optional<AccessPoint> matchedAccessPoint = allAccessPoints
+ .stream()
+ .filter(accesspoint -> accesspoint.matches(
+ uiConfigurationItem.mWifiNetworkSuggestion.getWifiConfiguration()))
+ .findFirst();
+ uiConfigurationItem.mLevel =
+ matchedAccessPoint.isPresent() ? matchedAccessPoint.get().getLevel() : 0;
+ }
}
if (mIsSingleNetwork) {
@@ -742,7 +745,17 @@
}
@Override
+ public void onResume() {
+ super.onResume();
+ onAccessPointsChanged();
+ }
+
+ /**
+ * Update the results when data changes
+ */
+ @Override
public void onAccessPointsChanged() {
- updateScanResults(mWifiTracker.getAccessPoints());
+ updateScanResultsToUi(
+ mWifiTracker.getManager().isWifiEnabled() ? mWifiTracker.getAccessPoints() : null);
}
}
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettings.java b/src/com/android/settings/wifi/calling/WifiCallingSettings.java
index 72e1df2..5c0ee9b 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettings.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettings.java
@@ -22,9 +22,6 @@
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -35,11 +32,11 @@
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
-import com.android.ims.ImsManager;
import com.android.internal.util.CollectionUtils;
import com.android.settings.R;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.network.SubscriptionUtil;
+import com.android.settings.network.ims.WifiCallingQueryImsState;
import com.android.settings.search.actionbar.SearchMenuController;
import com.android.settings.support.actionbar.HelpMenuController;
import com.android.settings.support.actionbar.HelpResourceProvider;
@@ -196,25 +193,6 @@
}
}
- @VisibleForTesting
- boolean isWfcEnabledByPlatform(SubscriptionInfo info) {
- final ImsManager imsManager = ImsManager.getInstance(getActivity(),
- info.getSimSlotIndex());
- return imsManager.isWfcEnabledByPlatform();
- }
-
- @VisibleForTesting
- boolean isWfcProvisionedOnDevice(SubscriptionInfo info) {
- final ProvisioningManager provisioningMgr =
- ProvisioningManager.createForSubscriptionId(info.getSubscriptionId());
- if (provisioningMgr == null) {
- return true;
- }
- return provisioningMgr.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN);
- }
-
private void updateSubList() {
mSil = SubscriptionUtil.getActiveSubscriptions(
getContext().getSystemService(SubscriptionManager.class));
@@ -225,7 +203,7 @@
}
for (int i = 0; i < mSil.size(); ) {
final SubscriptionInfo info = mSil.get(i);
- if (!isWfcEnabledByPlatform(info) || !isWfcProvisionedOnDevice(info)) {
+ if (!queryImsState(info.getSubscriptionId()).isWifiCallingProvisioned()) {
mSil.remove(i);
} else {
i++;
@@ -241,4 +219,9 @@
getActivity().getActionBar().setTitle(title);
}
}
+
+ @VisibleForTesting
+ WifiCallingQueryImsState queryImsState(int subId) {
+ return new WifiCallingQueryImsState(getContext(), subId);
+ }
}
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/AutoclickPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AutoclickPreferenceControllerTest.java
index b8be23e..d670ee8 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AutoclickPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AutoclickPreferenceControllerTest.java
@@ -46,7 +46,7 @@
@Test
public void getAvailabilityStatus_shouldReturnAvailableUnsearchable() {
assertThat(mController.getAvailabilityStatus())
- .isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
+ .isEqualTo(BasePreferenceController.AVAILABLE);
}
@Test
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/accessibility/TopLevelAccessibilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceControllerTest.java
index 809d8b4..3acc02c 100644
--- a/tests/robotests/src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/TopLevelAccessibilityPreferenceControllerTest.java
@@ -16,23 +16,19 @@
package com.android.settings.accessibility;
-import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
-import com.android.settings.R;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
@RunWith(RobolectricTestRunner.class)
public class TopLevelAccessibilityPreferenceControllerTest {
@@ -48,7 +44,7 @@
@Test
public void getAvailibilityStatus_availableByDefault() {
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
index 1f63c9c4..a161f84 100644
--- a/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppInfoWithHeaderTest.java
@@ -39,6 +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.ShadowSettingsLibUtils;
import com.android.settings.widget.EntityHeaderController;
import com.android.settingslib.applications.AppUtils;
import com.android.settingslib.applications.ApplicationsState;
@@ -58,7 +59,7 @@
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowEntityHeaderController.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/SpecialAppAccessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java
index 75302d8..00d3cb1 100644
--- a/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/SpecialAppAccessPreferenceControllerTest.java
@@ -16,7 +16,7 @@
package com.android.settings.applications;
-import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.google.common.truth.Truth.assertThat;
@@ -83,7 +83,7 @@
@Test
public void getAvailabilityState_unsearchable() {
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
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 c82cbe5..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,6 +42,7 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+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;
@@ -54,8 +55,10 @@
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowSettingsLibUtils.class)
public class AppHeaderViewPreferenceControllerTest {
@Mock
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index 3d864cc..074df76 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -366,6 +366,7 @@
appEntry.extraInfo = mock(AppFilterItem.class);
appList.add(appEntry);
ReflectionHelpers.setField(adapter, "mEntries", appList);
+ ReflectionHelpers.setField(adapter, "mContext", mContext);
adapter.onBindViewHolder(holder, 0);
// no crash? yay!
@@ -387,6 +388,7 @@
appEntry.info = mock(ApplicationInfo.class);
appList.add(appEntry);
ReflectionHelpers.setField(adapter, "mEntries", appList);
+ ReflectionHelpers.setField(adapter, "mContext", mContext);
adapter.onBindViewHolder(holder, 0);
verify(holder).updateSwitch(any(), anyBoolean(), anyBoolean());
@@ -406,6 +408,7 @@
appEntry.info = mock(ApplicationInfo.class);
appList.add(appEntry);
ReflectionHelpers.setField(adapter, "mEntries", appList);
+ ReflectionHelpers.setField(adapter, "mContext", mContext);
adapter.onBindViewHolder(holder, 0);
verify(holder, never()).updateSwitch(any(), anyBoolean(), anyBoolean());
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceControllerTest.java
index a287ea6..cc960d7 100644
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/DefaultPaymentSettingsPreferenceControllerTest.java
@@ -76,4 +76,14 @@
assertThat(mController.isAvailable()).isFalse();
}
+
+ @Test
+ public void getAvailabilityStatus_NfcIsDisabled_shouldReturnDisabled() {
+ when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
+ when(mUserManager.isAdminUser()).thenReturn(true);
+ when(mNfcAdapter.isEnabled()).thenReturn(false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ DefaultPaymentSettingsPreferenceController.DISABLED_DEPENDENT_SETTING);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/PaymentSettingsEnablerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/PaymentSettingsEnablerTest.java
new file mode 100644
index 0000000..f1d8952
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/PaymentSettingsEnablerTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.applications.specialaccess;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+
+import android.content.Context;
+import android.nfc.NfcAdapter;
+
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class PaymentSettingsEnablerTest {
+ private Context mContext;
+ private Preference mPreference;
+ private PaymentSettingsEnabler mEnabler;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mPreference = new Preference(mContext);
+ mEnabler = spy(new PaymentSettingsEnabler(mContext, mPreference));
+ }
+
+ @Test
+ public void handleNfcStateChanged_stateOff_shouldChangeSummaryAndDisablePreference() {
+ mEnabler.handleNfcStateChanged(NfcAdapter.STATE_OFF);
+
+ assertThat(mPreference.getSummary().toString()).contains(
+ mContext.getString(R.string.nfc_and_payment_settings_payment_off_nfc_off_summary));
+ assertThat(mPreference.isEnabled()).isFalse();
+ }
+
+ @Test
+ public void handleNfcStateChanged_stateOn_shouldClearSummaryAndEnablePreference() {
+ mEnabler.handleNfcStateChanged(NfcAdapter.STATE_ON);
+
+ assertThat(mPreference.getSummary()).isNull();
+ assertThat(mPreference.isEnabled()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesControllerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesControllerTest.java
new file mode 100644
index 0000000..730a3cc
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesControllerTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.applications.specialaccess.interactacrossprofiles;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.robolectric.Shadows.shadowOf;
+
+import android.content.Context;
+import android.content.pm.UserInfo;
+import android.os.UserManager;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class InteractAcrossProfilesControllerTest {
+ private static final int PERSONAL_PROFILE_ID = 0;
+ private static final int WORK_PROFILE_ID = 10;
+
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ private final UserManager mUserManager = mContext.getSystemService(UserManager.class);
+ private final InteractAcrossProfilesController mController =
+ new InteractAcrossProfilesController(mContext, "test_key");
+
+ @Test
+ public void getAvailabilityStatus_multipleProfiles_returnsAvailable() {
+ shadowOf(mUserManager).addUser(
+ PERSONAL_PROFILE_ID, "personal-profile"/* name */, 0/* flags */);
+ shadowOf(mUserManager).addProfile(
+ PERSONAL_PROFILE_ID,
+ WORK_PROFILE_ID,
+ "work-profile"/* profileName */,
+ UserInfo.FLAG_MANAGED_PROFILE);
+
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_oneProfile_returnsDisabled() {
+ shadowOf(mUserManager).addUser(
+ PERSONAL_PROFILE_ID, "personal-profile"/* name */, 0/* flags */);
+
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetailsTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetailsTest.java
new file mode 100644
index 0000000..9e48b9e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetailsTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.applications.specialaccess.interactacrossprofiles;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.robolectric.Shadows.shadowOf;
+
+import android.app.AppOpsManager;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.pm.PermissionInfo;
+import android.os.Process;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class InteractAcrossProfilesDetailsTest {
+
+ private static final String CROSS_PROFILE_PACKAGE_NAME = "crossProfilePackage";
+ public static final String INTERACT_ACROSS_PROFILES_PERMISSION =
+ "android.permission.INTERACT_ACROSS_PROFILES";
+
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ private final AppOpsManager mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
+ private final PackageManager mPackageManager = mContext.getPackageManager();
+ private final InteractAcrossProfilesDetails mFragment = new InteractAcrossProfilesDetails();
+
+ @Test
+ public void getPreferenceSummary_appOpAllowed_returnsAllowed() {
+ String appOp = AppOpsManager.permissionToOp(INTERACT_ACROSS_PROFILES_PERMISSION);
+ shadowOf(mAppOpsManager).setMode(
+ appOp, Process.myUid(), CROSS_PROFILE_PACKAGE_NAME, AppOpsManager.MODE_ALLOWED);
+ shadowOf(mPackageManager).addPermissionInfo(createCrossProfilesPermissionInfo());
+
+ assertThat(mFragment.getPreferenceSummary(
+ mContext, CROSS_PROFILE_PACKAGE_NAME, Process.myUid()))
+ .isEqualTo(mContext.getString(R.string.app_permission_summary_allowed));
+ }
+
+ @Test
+ public void getPreferenceSummary_appOpNotAllowed_returnsNotAllowed() {
+ String appOp = AppOpsManager.permissionToOp(INTERACT_ACROSS_PROFILES_PERMISSION);
+ shadowOf(mAppOpsManager).setMode(
+ appOp, Process.myUid(), CROSS_PROFILE_PACKAGE_NAME, AppOpsManager.MODE_IGNORED);
+ shadowOf(mPackageManager).addPermissionInfo(createCrossProfilesPermissionInfo());
+
+ assertThat(mFragment.getPreferenceSummary(
+ mContext, CROSS_PROFILE_PACKAGE_NAME, Process.myUid()))
+ .isEqualTo(mContext.getString(R.string.app_permission_summary_not_allowed));
+ }
+
+ private PermissionInfo createCrossProfilesPermissionInfo() {
+ PermissionInfo permissionInfo = new PermissionInfo();
+ permissionInfo.name = INTERACT_ACROSS_PROFILES_PERMISSION;
+ permissionInfo.protectionLevel = PermissionInfo.PROTECTION_FLAG_APPOP;
+ return permissionInfo;
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesPreferenceControllerTest.java
new file mode 100644
index 0000000..bac7437
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesPreferenceControllerTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.applications.specialaccess.interactacrossprofiles;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.robolectric.Shadows.shadowOf;
+
+import android.content.Context;
+import android.content.pm.CrossProfileApps;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class InteractAcrossProfilesPreferenceControllerTest {
+
+ private static final String CROSS_PROFILE_PACKAGE_NAME = "crossProfilePackage";
+ private static final String NOT_CROSS_PROFILE_PACKAGE_NAME = "notCrossProfilePackage";
+
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ private final CrossProfileApps mCrossProfileApps =
+ mContext.getSystemService(CrossProfileApps.class);
+ private final InteractAcrossProfilesDetailsPreferenceController mController =
+ new InteractAcrossProfilesDetailsPreferenceController(mContext, "test_key");
+
+ @Test
+ public void getAvailabilityStatus_crossProfilePackage_returnsAvailable() {
+ mController.setPackageName(CROSS_PROFILE_PACKAGE_NAME);
+ shadowOf(mCrossProfileApps).addCrossProfilePackage(CROSS_PROFILE_PACKAGE_NAME);
+
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_notCrossProfilePackage_returnsDisabled() {
+ mController.setPackageName(NOT_CROSS_PROFILE_PACKAGE_NAME);
+
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(BasePreferenceController.DISABLED_FOR_USER);
+ }
+
+ @Test
+ public void getDetailFragmentClass_shouldReturnInteractAcrossProfilesDetails() {
+ assertThat(mController.getDetailFragmentClass())
+ .isEqualTo(InteractAcrossProfilesDetails.class);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettingsTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettingsTest.java
new file mode 100644
index 0000000..9a4c56b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettingsTest.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.applications.specialaccess.interactacrossprofiles;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.robolectric.Shadows.shadowOf;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.CrossProfileApps;
+import android.content.pm.PackageManager;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.util.Pair;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import com.google.common.collect.ImmutableList;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.shadows.ShadowProcess;
+import org.robolectric.util.ReflectionHelpers;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class InteractAcrossProfilesSettingsTest {
+
+ private static final int PERSONAL_PROFILE_ID = 0;
+ private static final int WORK_PROFILE_ID = 10;
+ private static final int WORK_UID = UserHandle.PER_USER_RANGE * WORK_PROFILE_ID;
+
+ private static final String PERSONAL_CROSS_PROFILE_PACKAGE = "personalCrossProfilePackage";
+ private static final String PERSONAL_NON_CROSS_PROFILE_PACKAGE =
+ "personalNonCrossProfilePackage";
+ private static final String WORK_CROSS_PROFILE_PACKAGE = "workCrossProfilePackage";
+ private static final String WORK_NON_CROSS_PROFILE_PACKAGE =
+ "workNonCrossProfilePackage";
+ private static final List<String> PERSONAL_PROFILE_INSTALLED_PACKAGES =
+ ImmutableList.of(PERSONAL_CROSS_PROFILE_PACKAGE, PERSONAL_NON_CROSS_PROFILE_PACKAGE);
+ private static final List<String> WORK_PROFILE_INSTALLED_PACKAGES =
+ ImmutableList.of(WORK_CROSS_PROFILE_PACKAGE, WORK_NON_CROSS_PROFILE_PACKAGE);
+
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ private final PackageManager mPackageManager = mContext.getPackageManager();
+ private final UserManager mUserManager = mContext.getSystemService(UserManager.class);
+ private final CrossProfileApps mCrossProfileApps =
+ mContext.getSystemService(CrossProfileApps.class);
+ private final InteractAcrossProfilesSettings mFragment = new InteractAcrossProfilesSettings();
+
+ @Before
+ public void setup() {
+ ReflectionHelpers.setField(mFragment, "mPackageManager", mPackageManager);
+ ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
+ ReflectionHelpers.setField(mFragment, "mCrossProfileApps", mCrossProfileApps);
+ }
+
+ @Test
+ public void collectConfigurableApps_fromPersonal_returnsPersonalPackages() {
+ shadowOf(mUserManager).addUser(
+ PERSONAL_PROFILE_ID, "personal-profile"/* name */, 0/* flags */);
+ shadowOf(mUserManager).addProfile(
+ PERSONAL_PROFILE_ID, WORK_PROFILE_ID,
+ "work-profile"/* profileName */, 0/* profileFlags */);
+ shadowOf(mPackageManager).setInstalledPackagesForUserId(
+ PERSONAL_PROFILE_ID, PERSONAL_PROFILE_INSTALLED_PACKAGES);
+ shadowOf(mPackageManager).setInstalledPackagesForUserId(
+ WORK_PROFILE_ID, WORK_PROFILE_INSTALLED_PACKAGES);
+ shadowOf(mCrossProfileApps).addCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
+ shadowOf(mCrossProfileApps).addCrossProfilePackage(WORK_CROSS_PROFILE_PACKAGE);
+
+ List<Pair<ApplicationInfo, UserHandle>> apps = mFragment.collectConfigurableApps();
+
+ assertThat(apps.size()).isEqualTo(1);
+ assertThat(apps.get(0).first.packageName).isEqualTo(PERSONAL_CROSS_PROFILE_PACKAGE);
+ }
+
+ @Test
+ public void collectConfigurableApps_fromWork_returnsPersonalPackages() {
+ shadowOf(mUserManager).addUser(
+ PERSONAL_PROFILE_ID, "personal-profile"/* name */, 0/* flags */);
+ shadowOf(mUserManager).addProfile(
+ PERSONAL_PROFILE_ID, WORK_PROFILE_ID,
+ "work-profile"/* profileName */, 0/* profileFlags */);
+ ShadowProcess.setUid(WORK_UID);
+ shadowOf(mPackageManager).setInstalledPackagesForUserId(
+ PERSONAL_PROFILE_ID, PERSONAL_PROFILE_INSTALLED_PACKAGES);
+ shadowOf(mPackageManager).setInstalledPackagesForUserId(
+ WORK_PROFILE_ID, WORK_PROFILE_INSTALLED_PACKAGES);
+ shadowOf(mCrossProfileApps).addCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
+ shadowOf(mCrossProfileApps).addCrossProfilePackage(WORK_CROSS_PROFILE_PACKAGE);
+
+ List<Pair<ApplicationInfo, UserHandle>> apps = mFragment.collectConfigurableApps();
+
+ assertThat(apps.size()).isEqualTo(1);
+ assertThat(apps.get(0).first.packageName).isEqualTo(PERSONAL_CROSS_PROFILE_PACKAGE);
+ }
+
+ @Test
+ public void collectConfigurableApps_onlyOneProfile_returnsEmpty() {
+ shadowOf(mUserManager).addUser(
+ PERSONAL_PROFILE_ID, "personal-profile"/* name */, 0/* flags */);
+ shadowOf(mPackageManager).setInstalledPackagesForUserId(
+ PERSONAL_PROFILE_ID, PERSONAL_PROFILE_INSTALLED_PACKAGES);
+ shadowOf(mCrossProfileApps).addCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
+
+ List<Pair<ApplicationInfo, UserHandle>> apps = mFragment.collectConfigurableApps();
+
+ assertThat(apps).isEmpty();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsControllerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsControllerTest.java
index 0607e58..4c4acc7 100644
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsControllerTest.java
@@ -16,7 +16,7 @@
package com.android.settings.applications.specialaccess.premiumsms;
-import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.google.common.truth.Truth.assertThat;
@@ -47,7 +47,7 @@
@Test
public void getAvailability_byDefault_shouldBeShown() {
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/applications/specialaccess/vrlistener/EnabledVrListenersControllerTest.java b/tests/robotests/src/com/android/settings/applications/specialaccess/vrlistener/EnabledVrListenersControllerTest.java
index 32b18ef..5f102a0 100644
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/vrlistener/EnabledVrListenersControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/vrlistener/EnabledVrListenersControllerTest.java
@@ -16,7 +16,7 @@
package com.android.settings.applications.specialaccess.vrlistener;
-import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
@@ -48,7 +48,7 @@
@Test
public void getAvailability_byDefault_unsearchable() {
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
index 9637884..5fc45a6 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
@@ -115,18 +115,6 @@
}
@Override
- public boolean connect(BluetoothDevice device) {
- mConnectedDevices.add(device);
- return true;
- }
-
- @Override
- public boolean disconnect(BluetoothDevice device) {
- mConnectedDevices.remove(device);
- return false;
- }
-
- @Override
public int getConnectionStatus(BluetoothDevice device) {
if (mConnectedDevices.contains(device)) {
return BluetoothProfile.STATE_CONNECTED;
@@ -136,20 +124,21 @@
}
@Override
- public boolean isPreferred(BluetoothDevice device) {
+ public boolean isEnabled(BluetoothDevice device) {
return mPreferred.getOrDefault(device, false);
}
@Override
- public int getPreferred(BluetoothDevice device) {
- return isPreferred(device) ?
- BluetoothProfile.CONNECTION_POLICY_ALLOWED
+ public int getConnectionPolicy(BluetoothDevice device) {
+ return isEnabled(device)
+ ? BluetoothProfile.CONNECTION_POLICY_ALLOWED
: BluetoothProfile.CONNECTION_POLICY_FORBIDDEN;
}
@Override
- public void setPreferred(BluetoothDevice device, boolean preferred) {
- mPreferred.put(device, preferred);
+ public boolean setEnabled(BluetoothDevice device, boolean enabled) {
+ mPreferred.put(device, enabled);
+ return true;
}
@Override
@@ -192,7 +181,7 @@
private LocalBluetoothProfile addFakeProfile(int profileNameResId,
boolean deviceIsPreferred) {
LocalBluetoothProfile profile = new FakeBluetoothProfile(mContext, profileNameResId);
- profile.setPreferred(mDevice, deviceIsPreferred);
+ profile.setEnabled(mDevice, deviceIsPreferred);
mConnectableProfiles.add(profile);
when(mProfileManager.getProfileByName(eq(profile.toString()))).thenReturn(profile);
return profile;
@@ -266,7 +255,7 @@
assertThat(pref.isChecked()).isTrue();
pref.performClick();
assertThat(pref.isChecked()).isFalse();
- assertThat(mConnectableProfiles.get(0).isPreferred(mDevice)).isFalse();
+ assertThat(mConnectableProfiles.get(0).isEnabled(mDevice)).isFalse();
// Make sure no new preferences were added.
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
@@ -274,7 +263,7 @@
// Clicking the pref again should make the profile once again preferred.
pref.performClick();
assertThat(pref.isChecked()).isTrue();
- assertThat(mConnectableProfiles.get(0).isPreferred(mDevice)).isTrue();
+ assertThat(mConnectableProfiles.get(0).isEnabled(mDevice)).isTrue();
// Make sure we still haven't gotten any new preferences added.
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
@@ -364,7 +353,7 @@
mContext.getString(R.string.bluetooth_profile_a2dp_high_quality_unknown_codec));
when(profile.supportsHighQualityAudio(mDevice)).thenReturn(supportsHighQualityAudio);
when(profile.isHighQualityAudioEnabled(mDevice)).thenReturn(highQualityAudioEnabled);
- when(profile.isPreferred(mDevice)).thenReturn(preferred);
+ when(profile.isEnabled(mDevice)).thenReturn(preferred);
when(profile.isProfileReady()).thenReturn(true);
mConnectableProfiles.add(profile);
return profile;
@@ -426,8 +415,8 @@
SwitchPreference audioPref =
(SwitchPreference) mScreen.findPreference(audioProfile.toString());
audioPref.performClick();
- verify(audioProfile).setPreferred(mDevice, false);
- when(audioProfile.isPreferred(mDevice)).thenReturn(false);
+ verify(audioProfile).setEnabled(mDevice, false);
+ when(audioProfile.isEnabled(mDevice)).thenReturn(false);
mController.onDeviceAttributesChanged();
assertThat(audioPref.isVisible()).isTrue();
SwitchPreference highQualityAudioPref = getHighQualityAudioPref();
@@ -435,8 +424,8 @@
// And re-enabling media audio should make high quality switch to reappear.
audioPref.performClick();
- verify(audioProfile).setPreferred(mDevice, true);
- when(audioProfile.isPreferred(mDevice)).thenReturn(true);
+ verify(audioProfile).setEnabled(mDevice, true);
+ when(audioProfile.isEnabled(mDevice)).thenReturn(true);
mController.onDeviceAttributesChanged();
highQualityAudioPref = getHighQualityAudioPref();
assertThat(highQualityAudioPref.isVisible()).isTrue();
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/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
index 3fa0e4d..d6bcb12 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
@@ -16,6 +16,7 @@
package com.android.settings.connecteddevice;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -23,6 +24,7 @@
import android.nfc.NfcAdapter;
import android.provider.SearchIndexableResource;
+import com.android.settings.nfc.AndroidBeamPreferenceController;
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.drawer.CategoryKey;
@@ -85,6 +87,6 @@
AdvancedConnectedDeviceDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
.getNonIndexableKeys(context);
- assertThat(niks).contains(AdvancedConnectedDeviceDashboardFragment.KEY_BLUETOOTH);
+ assertThat(niks).contains(AndroidBeamPreferenceController.KEY_ANDROID_BEAM_SETTINGS);
}
}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/BluetoothDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/BluetoothDashboardFragmentTest.java
deleted file mode 100644
index ed944cf..0000000
--- a/tests/robotests/src/com/android/settings/connecteddevice/BluetoothDashboardFragmentTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.settings.connecteddevice;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.text.TextUtils;
-
-import com.android.settings.R;
-import com.android.settingslib.search.SearchIndexableRaw;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-public class BluetoothDashboardFragmentTest {
-
- private Context mContext;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- }
-
- @Test
- public void rawData_includesFragmentResult() {
- final List<SearchIndexableRaw> rawList =
- BluetoothDashboardFragment.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext,
- true /* enabled */);
-
- final SearchIndexableRaw fragmentResult = rawList.stream().filter(
- raw -> TextUtils.equals(raw.title,
- mContext.getString(R.string.bluetooth_settings))).findFirst().get();
-
- assertThat(fragmentResult).isNotNull();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
index 778bb79..c4f1587 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
@@ -52,6 +52,7 @@
public class ConnectedDeviceDashboardFragmentTest {
private static final String KEY_NEARBY_DEVICES = "bt_nearby_slice";
private static final String KEY_DISCOVERABLE_FOOTER = "discoverable_footer";
+ private static final String KEY_SEE_ALL = "previously_connected_devices_see_all";
@Mock
private PackageManager mPackageManager;
@@ -82,7 +83,7 @@
.getNonIndexableKeys(mContext);
assertThat(niks).containsExactly(KEY_CONNECTED_DEVICES, KEY_AVAILABLE_DEVICES,
- KEY_NEARBY_DEVICES, KEY_DISCOVERABLE_FOOTER);
+ KEY_NEARBY_DEVICES, KEY_DISCOVERABLE_FOOTER, KEY_SEE_ALL);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentControllerTest.java
new file mode 100644
index 0000000..fdedc88
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentControllerTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.connecteddevice;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.nfc.NfcAdapter;
+import android.nfc.NfcManager;
+import android.os.UserManager;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(RobolectricTestRunner.class)
+public class NfcAndPaymentFragmentControllerTest {
+ private NfcAndPaymentFragmentController mController;
+ private Context mContext;
+
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private UserManager mUserManager;
+ @Mock
+ private NfcManager mNfcManager;
+ @Mock
+ private NfcAdapter mNfcAdapter;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+
+ when(mContext.getApplicationContext()).thenReturn(mContext);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+ when(mContext.getSystemService(Context.NFC_SERVICE)).thenReturn(mNfcManager);
+ when(NfcAdapter.getDefaultAdapter(mContext)).thenReturn(mNfcAdapter);
+
+ mController = new NfcAndPaymentFragmentController(mContext, "fakeKey");
+ ReflectionHelpers.setField(mController, "mNfcAdapter", mNfcAdapter);
+ }
+
+ @Test
+ public void getAvailabilityStatus_hasNfc_shouldReturnAvailable() {
+ when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
+ when(mUserManager.isAdminUser()).thenReturn(true);
+ when(mNfcAdapter.isEnabled()).thenReturn(true);
+
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(NfcAndPaymentFragmentController.AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_noNfcAdapter_shouldReturnUnsupported() {
+ ReflectionHelpers.setField(mController, "mNfcAdapter", null);
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(NfcAndPaymentFragmentController.UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_notAdminUser_shouldReturnDisabled() {
+ when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
+ when(mUserManager.isAdminUser()).thenReturn(false);
+ when(mNfcAdapter.isEnabled()).thenReturn(true);
+
+ assertThat(mController.getAvailabilityStatus())
+ .isEqualTo(NfcAndPaymentFragmentController.DISABLED_FOR_USER);
+ }
+
+ @Test
+ public void getSummary_nfcOn_shouldProvideOnSummary() {
+ when(mNfcAdapter.isEnabled()).thenReturn(true);
+ assertThat(mController.getSummary().toString()).contains(
+ mContext.getString(R.string.switch_on_text));
+ }
+
+ @Test
+ public void getSummary_nfcOff_shouldProvideOffSummary() {
+ when(mNfcAdapter.isEnabled()).thenReturn(false);
+ assertThat(mController.getSummary().toString()).contains(
+ mContext.getString(R.string.switch_off_text));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentTest.java
new file mode 100644
index 0000000..af68784
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/connecteddevice/NfcAndPaymentFragmentTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.connecteddevice;
+
+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.nfc.NfcAdapter;
+import android.provider.SearchIndexableResource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class NfcAndPaymentFragmentTest {
+ private NfcAndPaymentFragment mFragment;
+ private Context mContext;
+
+ @Mock
+ private NfcAdapter mNfcAdapter;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mFragment = new NfcAndPaymentFragment();
+ mContext = spy(RuntimeEnvironment.application);
+ }
+
+ @Test
+ public void searchIndexProvider_shouldIndexResource() {
+ final List<SearchIndexableResource> indexRes =
+ NfcAndPaymentFragment.SEARCH_INDEX_DATA_PROVIDER
+ .getXmlResourcesToIndex(mContext, true /* enabled */);
+
+ assertThat(indexRes).isNotNull();
+ assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId());
+ }
+
+ @Test
+ public void searchIndexProvider_shouldIndexAllItems() {
+ when(mContext.getApplicationContext()).thenReturn(mContext);
+ when(NfcAdapter.getDefaultAdapter(mContext)).thenReturn(mNfcAdapter);
+ when(mNfcAdapter.isSecureNfcSupported()).thenReturn(true);
+
+ final List<String> niks = NfcAndPaymentFragment.SEARCH_INDEX_DATA_PROVIDER
+ .getNonIndexableKeys(mContext);
+
+ assertThat(niks).isNotNull();
+ assertThat(niks).isEmpty();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java
index ab73370..14fe4bd 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java
@@ -16,7 +16,7 @@
package com.android.settings.connecteddevice;
-import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
@@ -48,7 +48,7 @@
@Test
public void getAvailibilityStatus_availableByDefault() {
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilsTest.java b/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilsTest.java
index 9ad6a7b..41e1ab1 100644
--- a/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/core/PreferenceXmlParserUtilsTest.java
@@ -76,10 +76,11 @@
@Test
public void testDataKeywordsValid_ReturnsPreferenceKeywords() {
- XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
+ XmlResourceParser parser = getChildByType(R.xml.display_settings,
+ "com.android.settings.display.TimeoutListPreference");
final AttributeSet attrs = Xml.asAttributeSet(parser);
String keywords = PreferenceXmlParserUtils.getDataKeywords(mContext, attrs);
- String expKeywords = mContext.getString(R.string.keywords_display);
+ String expKeywords = mContext.getString(R.string.keywords_screen_timeout);
assertThat(keywords).isEqualTo(expKeywords);
}
diff --git a/tests/robotests/src/com/android/settings/development/WifiScanThrottlingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/WifiScanThrottlingPreferenceControllerTest.java
index 605bd0d..787bd1d 100644
--- a/tests/robotests/src/com/android/settings/development/WifiScanThrottlingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/WifiScanThrottlingPreferenceControllerTest.java
@@ -16,16 +16,11 @@
package com.android.settings.development;
-import static com.android.settings.development.WifiScanThrottlingPreferenceController.SETTING_THROTTLING_ENABLE_VALUE_OFF;
-import static com.android.settings.development.WifiScanThrottlingPreferenceController.SETTING_THROTTLING_ENABLE_VALUE_ON;
-
-import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
-import android.provider.Settings;
+import android.net.wifi.WifiManager;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
@@ -36,7 +31,6 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class WifiScanThrottlingPreferenceControllerTest {
@@ -45,14 +39,16 @@
private SwitchPreference mPreference;
@Mock
private PreferenceScreen mPreferenceScreen;
-
+ @Mock
private Context mContext;
+ @Mock
+ private WifiManager mWifiManager;
private WifiScanThrottlingPreferenceController mController;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
+ when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
mController = new WifiScanThrottlingPreferenceController(mContext);
when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
.thenReturn(mPreference);
@@ -63,27 +59,19 @@
public void onPreferenceChanged_turnOnScanThrottling() {
mController.onPreferenceChange(mPreference, true /* new value */);
- final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_SCAN_THROTTLE_ENABLED, 1 /* default */);
-
- assertThat(mode).isEqualTo(SETTING_THROTTLING_ENABLE_VALUE_ON);
+ verify(mWifiManager).setScanThrottleEnabled(true);
}
@Test
public void onPreferenceChanged_turnOffScanThrottling() {
mController.onPreferenceChange(mPreference, false /* new value */);
- final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_SCAN_THROTTLE_ENABLED, 1 /* default */);
-
- assertThat(mode).isEqualTo(SETTING_THROTTLING_ENABLE_VALUE_OFF);
+ verify(mWifiManager).setScanThrottleEnabled(false);
}
@Test
public void updateState_preferenceShouldBeChecked() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_SCAN_THROTTLE_ENABLED,
- SETTING_THROTTLING_ENABLE_VALUE_ON);
+ when(mWifiManager.isScanThrottleEnabled()).thenReturn(true);
mController.updateState(mPreference);
verify(mPreference).setChecked(true);
@@ -91,9 +79,7 @@
@Test
public void updateState_preferenceShouldNotBeChecked() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_SCAN_THROTTLE_ENABLED,
- SETTING_THROTTLING_ENABLE_VALUE_OFF);
+ when(mWifiManager.isScanThrottleEnabled()).thenReturn(false);
mController.updateState(mPreference);
verify(mPreference).setChecked(false);
@@ -102,10 +88,7 @@
@Test
public void onDeveloperOptionsDisabled_shouldDisablePreference() {
mController.onDeveloperOptionsDisabled();
- final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_SCAN_THROTTLE_ENABLED, 1 /* default */);
-
- assertThat(mode).isEqualTo(SETTING_THROTTLING_ENABLE_VALUE_ON);
+ verify(mWifiManager).setScanThrottleEnabled(true);
verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(true);
}
diff --git a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
index dd5af2b..de4be1d 100644
--- a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceControllerTest.java
@@ -21,6 +21,7 @@
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
@@ -41,8 +42,6 @@
import com.android.settings.R;
-import java.util.Arrays;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -51,6 +50,8 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.Arrays;
+
@RunWith(RobolectricTestRunner.class)
public class GameDriverAppPreferenceControllerTest {
@@ -87,10 +88,13 @@
mContext = spy(RuntimeEnvironment.application);
mResolver = mContext.getContentResolver();
mValueList =
- mContext.getResources().getStringArray(R.array.game_driver_app_preference_values);
- mDialogTitle = mContext.getResources().getString(R.string.game_driver_app_preference_title);
+ mContext.getResources().getStringArray(
+ R.array.graphics_driver_app_preference_values);
+ mDialogTitle = mContext.getResources().getString(
+ R.string.graphics_driver_app_preference_title);
mPreferencePrereleaseDriver =
- mContext.getResources().getString(R.string.game_driver_app_preference_prerelease_driver);
+ mContext.getResources().getString(
+ R.string.graphics_driver_app_preference_prerelease_driver);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverDashboardTest.java b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverDashboardTest.java
index f8f8add..eb5c3b3 100644
--- a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverDashboardTest.java
+++ b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverDashboardTest.java
@@ -50,6 +50,6 @@
@Test
public void getPreferenceScreen_shouldReturnGameDriverSettings() {
- assertThat(mDashboard.getPreferenceScreenResId()).isEqualTo(R.xml.game_driver_settings);
+ assertThat(mDashboard.getPreferenceScreenResId()).isEqualTo(R.xml.graphics_driver_settings);
}
}
diff --git a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceControllerTest.java
index df59971..8495f60 100644
--- a/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/gamedriver/GameDriverEnableForAllAppsPreferenceControllerTest.java
@@ -71,11 +71,11 @@
mResolver = mContext.getContentResolver();
final Resources resources = mContext.getResources();
- mPreferenceDefault = resources.getString(R.string.game_driver_app_preference_default);
+ mPreferenceDefault = resources.getString(R.string.graphics_driver_app_preference_default);
mPreferenceGameDriver =
- resources.getString(R.string.game_driver_app_preference_game_driver);
+ resources.getString(R.string.graphics_driver_app_preference_game_driver);
mPreferencePrereleaseDriver =
- resources.getString(R.string.game_driver_app_preference_prerelease_driver);
+ resources.getString(R.string.graphics_driver_app_preference_prerelease_driver);
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
Settings.Global.putInt(
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 4306955..903b88b 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java
@@ -58,7 +58,7 @@
@Test
public void firmwareVersion_shouldAlwaysBeShown() {
assertThat(mController.getAvailabilityStatus())
- .isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
+ .isEqualTo(BasePreferenceController.AVAILABLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java
index 950d962..59f24dd 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/MainlineModuleVersionPreferenceControllerTest.java
@@ -111,6 +111,20 @@
}
@Test
+ public void updateStates_canHandleIntent_preferenceShouldBeSelectable() throws Exception {
+ setupModulePackage("test version 123");
+ when(mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0))
+ .thenReturn(new ResolveInfo());
+
+ final MainlineModuleVersionPreferenceController controller =
+ new MainlineModuleVersionPreferenceController(mContext, "key");
+
+ controller.updateState(mPreference);
+
+ assertThat(mPreference.isSelectable()).isTrue();
+ }
+
+ @Test
public void updateStates_cannotHandleIntent_setNullToPreference() throws Exception {
setupModulePackage("test version 123");
when(mPackageManager.resolveActivity(MODULE_UPDATE_INTENT, 0))
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/HardwareInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/HardwareInfoPreferenceControllerTest.java
index 413c492..291f6e2 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/HardwareInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/hardwareinfo/HardwareInfoPreferenceControllerTest.java
@@ -61,7 +61,7 @@
@Test
public void isAvailable_returnTrueIfVisible() {
assertThat(mController.getAvailabilityStatus()).isEqualTo(
- BasePreferenceController.AVAILABLE_UNSEARCHABLE);
+ BasePreferenceController.AVAILABLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/display/FontSizePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/FontSizePreferenceControllerTest.java
index 888b711..58e7ccd 100644
--- a/tests/robotests/src/com/android/settings/display/FontSizePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/FontSizePreferenceControllerTest.java
@@ -49,7 +49,7 @@
@Test
public void isAlwaysAvailable() {
assertThat(mController.getAvailabilityStatus())
- .isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
+ .isEqualTo(BasePreferenceController.AVAILABLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
index cdbbf7e..4d5f1a0 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java
@@ -42,7 +42,6 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-
import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@@ -73,7 +72,7 @@
mChargingIntent.putExtra(BatteryManager.EXTRA_LEVEL, BATTERY_INTENT_LEVEL);
mChargingIntent.putExtra(BatteryManager.EXTRA_SCALE, BATTERY_INTENT_SCALE);
mChargingIntent
- .putExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_CHARGING);
+ .putExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_CHARGING);
}
@Test
@@ -85,9 +84,9 @@
mBatteryBroadcastReceiver.onReceive(mContext, mChargingIntent);
assertThat(mBatteryBroadcastReceiver.mBatteryLevel)
- .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
+ .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
assertThat(mBatteryBroadcastReceiver.mBatteryStatus)
- .isEqualTo(Utils.getBatteryStatus(mContext.getResources(), mChargingIntent));
+ .isEqualTo(Utils.getBatteryStatus(mContext, mChargingIntent));
verify(mBatteryListener).onBatteryChanged(BatteryUpdateType.BATTERY_LEVEL);
}
@@ -111,7 +110,7 @@
public void testOnReceive_batteryDataNotChanged_listenerNotInvoked() {
final String batteryLevel = Utils.getBatteryPercentage(mChargingIntent);
final String batteryStatus =
- Utils.getBatteryStatus(mContext.getResources(), mChargingIntent);
+ Utils.getBatteryStatus(mContext, mChargingIntent);
mBatteryBroadcastReceiver.mBatteryLevel = batteryLevel;
mBatteryBroadcastReceiver.mBatteryStatus = batteryStatus;
@@ -134,9 +133,9 @@
mBatteryBroadcastReceiver.register();
assertThat(mBatteryBroadcastReceiver.mBatteryLevel)
- .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
+ .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
assertThat(mBatteryBroadcastReceiver.mBatteryStatus)
- .isEqualTo(Utils.getBatteryStatus(mContext.getResources(), mChargingIntent));
+ .isEqualTo(Utils.getBatteryStatus(mContext, mChargingIntent));
// 2 times because register will force update the battery
verify(mBatteryListener, times(2)).onBatteryChanged(BatteryUpdateType.MANUAL);
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
index 58ed6b4..3775802 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
@@ -16,7 +16,7 @@
package com.android.settings.fuelgauge;
-import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.android.settings.fuelgauge.TopLevelBatteryPreferenceController.getDashboardLabel;
@@ -27,9 +27,9 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
public class TopLevelBatteryPreferenceControllerTest {
@@ -44,7 +44,7 @@
@Test
public void getAvailibilityStatus_availableByDefault() {
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java
index d6c6a1f..17db208 100644
--- a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsTest.java
@@ -72,6 +72,6 @@
assertThat(AssistGestureSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
RuntimeEnvironment.application))
- .contains("gesture_assist_settings_page");
+ .isNotEmpty();
}
}
diff --git a/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
index 0771685..c752eb9 100644
--- a/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
@@ -21,7 +21,7 @@
import static android.provider.Settings.Secure.VOLUME_HUSH_OFF;
import static android.provider.Settings.Secure.VOLUME_HUSH_VIBRATE;
-import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.google.common.truth.Truth.assertThat;
@@ -64,7 +64,7 @@
when(mResources.getBoolean(
com.android.internal.R.bool.config_volumeHushGestureEnabled)).thenReturn(true);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
index 06f9b98..ad2930d 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
@@ -23,8 +23,11 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
import android.content.Context;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import com.android.settings.homepage.contextualcards.ContextualCard;
import com.android.settings.homepage.contextualcards.ContextualCard.CardType;
@@ -37,6 +40,8 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowSubscriptionManager;
+import org.robolectric.shadows.ShadowTelephonyManager;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
@@ -45,6 +50,7 @@
@RunWith(RobolectricTestRunner.class)
public class ConditionContextualCardControllerTest {
+ private static final int SUB_ID = 2;
@Mock
private ConditionManager mConditionManager;
@@ -57,6 +63,17 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+
+ // parameters required by CellularDataConditionController
+ final ShadowSubscriptionManager shadowSubscriptionMgr = shadowOf(
+ mContext.getSystemService(SubscriptionManager.class));
+ shadowSubscriptionMgr.setDefaultDataSubscriptionId(SUB_ID);
+
+ final TelephonyManager telephonyManager =
+ spy(mContext.getSystemService(TelephonyManager.class));
+ final ShadowTelephonyManager shadowTelephonyMgr = shadowOf(telephonyManager);
+ shadowTelephonyMgr.setTelephonyManagerForSubscriptionId(SUB_ID, telephonyManager);
+
mController = spy(new ConditionContextualCardController(mContext));
ReflectionHelpers.setField(mController, "mConditionManager", mConditionManager);
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java
index 7170bdd..3be65dc 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSliceTest.java
@@ -25,6 +25,7 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
+import android.app.UiModeManager;
import android.content.Context;
import android.net.Uri;
import android.os.BatteryManager;
@@ -54,6 +55,8 @@
private BatteryManager mBatteryManager;
@Mock
private PowerManager mPowerManager;
+ @Mock
+ private UiModeManager mUiModeManager;
private Context mContext;
private DarkThemeSlice mDarkThemeSlice;
@@ -68,6 +71,7 @@
mFeatureFactory.slicesFeatureProvider.newUiSession();
doReturn(mPowerManager).when(mContext).getSystemService(PowerManager.class);
when(mPowerManager.isPowerSaveMode()).thenReturn(false);
+ doReturn(mUiModeManager).when(mContext).getSystemService(UiModeManager.class);
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
@@ -90,8 +94,25 @@
}
@Test
+ public void isAvailable_nonDarkTheme_autoNightMode_returnFalse() {
+ mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
+ setNightMode(UiModeManager.MODE_NIGHT_AUTO);
+
+ assertThat(mDarkThemeSlice.isAvailable(mContext)).isFalse();
+ }
+
+ @Test
+ public void isAvailable_nonDarkTheme_customNightMode_returnFalse() {
+ mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
+ setNightMode(UiModeManager.MODE_NIGHT_CUSTOM);
+
+ assertThat(mDarkThemeSlice.isAvailable(mContext)).isFalse();
+ }
+
+ @Test
public void isAvailable_nonDarkThemeBatteryCapacityEq100_returnFalse() {
setBatteryCapacityLevel(100);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
assertThat(mDarkThemeSlice.isAvailable(mContext)).isFalse();
}
@@ -99,6 +120,7 @@
@Test
public void isAvailable_nonDarkThemeBatteryCapacityLt50_returnTrue() {
setBatteryCapacityLevel(40);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
assertThat(mDarkThemeSlice.isAvailable(mContext)).isTrue();
}
@@ -142,6 +164,7 @@
mFeatureFactory.slicesFeatureProvider.getUiSessionToken();
mDarkThemeSlice.sKeepSliceShow = true;
setBatteryCapacityLevel(40);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
assertThat(mDarkThemeSlice.getSlice()).isNotNull();
}
@@ -162,6 +185,7 @@
mDarkThemeSlice.sSliceClicked = true;
setBatteryCapacityLevel(40);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
assertThat(mDarkThemeSlice.getSlice()).isNotNull();
}
@@ -169,6 +193,7 @@
@Test
public void getSlice_isAvailable_returnSlice() {
setBatteryCapacityLevel(40);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
assertThat(mDarkThemeSlice.getSlice()).isNotNull();
}
@@ -176,6 +201,7 @@
@Test
public void getSlice_isAvailable_showTitleSubtitle() {
setBatteryCapacityLevel(40);
+ setNightMode(UiModeManager.MODE_NIGHT_NO);
final Slice slice = mDarkThemeSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
@@ -191,4 +217,8 @@
when(mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY))
.thenReturn(power_level);
}
+
+ private void setNightMode(int mode) {
+ when(mUiModeManager.getNightMode()).thenReturn(mode);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
index 4b0df98..b4bda14 100644
--- a/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationForWorkPreferenceControllerTest.java
@@ -38,7 +38,6 @@
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -114,7 +113,6 @@
}
@Test
- @Ignore
public void onLocationModeChanged_disabledByAdmin_shouldDisablePreference() {
mController.displayPreference(mScreen);
final EnforcedAdmin admin = mock(EnforcedAdmin.class);
@@ -124,11 +122,9 @@
mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
verify(mPreference).setDisabledByAdmin(any());
- verify(mPreference).setChecked(false);
}
@Test
- @Ignore
public void onLocationModeChanged_locationOff_shouldDisablePreference() {
mController.displayPreference(mScreen);
doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
@@ -138,7 +134,7 @@
verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false);
- verify(mPreference).setSummary(R.string.switch_off_text);
+ verify(mPreference).setSummary(R.string.location_app_permission_summary_location_off);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
index c76e234..ec4087a 100644
--- a/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/BluetoothTetherPreferenceControllerTest.java
@@ -16,11 +16,12 @@
package com.android.settings.network;
+import static com.android.settings.network.TetherEnabler.BLUETOOTH_TETHER_KEY;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
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;
@@ -28,7 +29,6 @@
import android.content.Context;
import android.net.ConnectivityManager;
-import androidx.lifecycle.Lifecycle;
import androidx.test.core.app.ApplicationProvider;
import org.junit.Before;
@@ -55,7 +55,7 @@
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
mConnectivityManager);
when(mConnectivityManager.getTetherableBluetoothRegexs()).thenReturn(new String[] {""});
- mController = new BluetoothTetherPreferenceController(mContext, mock(Lifecycle.class));
+ mController = new BluetoothTetherPreferenceController(mContext, BLUETOOTH_TETHER_KEY);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
index a18e49d..4ae829f 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -16,9 +16,6 @@
package com.android.settings.network;
-import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_ABSENT;
-import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT;
-
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
@@ -29,10 +26,8 @@
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
-import android.telephony.UiccSlotInfo;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -88,43 +83,6 @@
}
@Test
- @Ignore
- public void getAvailableSubscriptions_oneSelectableTwoDisabledPSimsOneAbsent_twoResults() {
- final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
- final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
- final SubscriptionInfo info3 = mock(SubscriptionInfo.class);
-
- when(info1.getSubscriptionId()).thenReturn(111);
- when(info1.getSimSlotIndex()).thenReturn(-1);
-
- when(info2.getSubscriptionId()).thenReturn(222);
- when(info2.getSimSlotIndex()).thenReturn(-1);
-
- when(info3.getSubscriptionId()).thenReturn(333);
- when(info3.getSimSlotIndex()).thenReturn(0);
-
- when(mSubMgr.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info1));
- when(mSubMgr.getAllSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2, info3));
-
- final UiccSlotInfo info2slot = mock(UiccSlotInfo.class);
- final UiccSlotInfo info3slot = mock(UiccSlotInfo.class);
-
- when(info2slot.getLogicalSlotIdx()).thenReturn(-1);
- when(info2slot.getCardStateInfo()).thenReturn(CARD_STATE_INFO_ABSENT);
-
- when(info3slot.getLogicalSlotIdx()).thenReturn(0);
- when(info3slot.getCardStateInfo()).thenReturn(CARD_STATE_INFO_PRESENT);
-
- final UiccSlotInfo[] slotInfos = {info2slot, info3slot};
- when(mTelMgr.getUiccSlotsInfo()).thenReturn(slotInfos);
-
- final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mContext);
- assertThat(subs).hasSize(2);
- assertThat(subs.get(0).getSubscriptionId()).isEqualTo(111);
- assertThat(subs.get(1).getSubscriptionId()).isEqualTo(333);
- }
-
- @Test
public void getActiveSubscriptions_nullInfoFromSubscriptionManager_nonNullResult() {
when(mSubMgr.getActiveSubscriptionInfoList()).thenReturn(null);
final List<SubscriptionInfo> subs = SubscriptionUtil.getActiveSubscriptions(mSubMgr);
diff --git a/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java b/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
index a2d55dc..6fa2251 100644
--- a/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/network/TetherEnablerTest.java
@@ -136,7 +136,8 @@
@Test
public void onSwitchToggled_onlyStartsWifiTetherWhenNeeded() {
- when(mSharedPreferences.getBoolean(TetherEnabler.WIFI_TETHER_KEY, true)).thenReturn(true);
+ when(mSharedPreferences.getBoolean(TetherEnabler.KEY_ENABLE_WIFI_TETHERING, true))
+ .thenReturn(true);
when(mWifiManager.isWifiApEnabled()).thenReturn(true);
mEnabler.onSwitchToggled(true);
verify(mConnectivityManager, never()).startTethering(anyInt(), anyBoolean(), any(), any());
@@ -150,7 +151,8 @@
public void onSwitchToggled_shouldStartUSBTetherWhenSelected() {
SharedPreferences preference = mock(SharedPreferences.class);
ReflectionHelpers.setField(mEnabler, "mSharedPreferences", preference);
- when(preference.getBoolean(TetherEnabler.WIFI_TETHER_KEY, true)).thenReturn(false);
+ when(preference.getBoolean(TetherEnabler.KEY_ENABLE_WIFI_TETHERING, true))
+ .thenReturn(false);
when(preference.getBoolean(TetherEnabler.USB_TETHER_KEY, false)).thenReturn(true);
when(preference.getBoolean(TetherEnabler.BLUETOOTH_TETHER_KEY, true)).thenReturn(false);
diff --git a/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
index 9127e4b..c150222 100644
--- a/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/UsbTetherPreferenceControllerTest.java
@@ -16,11 +16,12 @@
package com.android.settings.network;
+import static com.android.settings.network.TetherEnabler.USB_TETHER_KEY;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
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;
@@ -28,7 +29,6 @@
import android.content.Context;
import android.net.ConnectivityManager;
-import androidx.lifecycle.Lifecycle;
import androidx.test.core.app.ApplicationProvider;
import org.junit.Before;
@@ -54,8 +54,8 @@
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(
mConnectivityManager);
- when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[] {""});
- mController = new UsbTetherPreferenceController(mContext, mock(Lifecycle.class));
+ when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
+ mController = new UsbTetherPreferenceController(mContext, USB_TETHER_KEY);
}
@Test
@@ -75,7 +75,7 @@
@Test
public void display_availableChangedCorrectly() {
- when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[] {""});
+ when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[]{""});
assertThat(mController.isAvailable()).isTrue();
when(mConnectivityManager.getTetherableUsbRegexs()).thenReturn(new String[0]);
diff --git a/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
index e42c477..ebb9902 100644
--- a/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/WifiTetherDisablePreferenceControllerTest.java
@@ -16,7 +16,9 @@
package com.android.settings.network;
-import static com.android.settings.network.WifiTetherDisablePreferenceController.PREF_KEY;
+import static com.android.settings.network.TetherEnabler.BLUETOOTH_TETHER_KEY;
+import static com.android.settings.network.TetherEnabler.USB_TETHER_KEY;
+import static com.android.settings.network.TetherEnabler.WIFI_TETHER_DISABLE_KEY;
import static com.google.common.truth.Truth.assertThat;
@@ -30,7 +32,6 @@
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
-import androidx.lifecycle.Lifecycle;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import androidx.test.core.app.ApplicationProvider;
@@ -68,10 +69,10 @@
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[]{""});
when(mContext.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE))
.thenReturn(mSharedPreferences);
- mController = new WifiTetherDisablePreferenceController(mContext, mock(Lifecycle.class));
+ mController = new WifiTetherDisablePreferenceController(mContext, WIFI_TETHER_DISABLE_KEY);
ReflectionHelpers.setField(mController, "mScreen", mPreferenceScreen);
ReflectionHelpers.setField(mController, "mPreference", mPreference);
- when(mPreferenceScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
+ when(mPreferenceScreen.findPreference(WIFI_TETHER_DISABLE_KEY)).thenReturn(mPreference);
}
@Test
@@ -103,30 +104,22 @@
@Test
public void switch_shouldListenToUsbAndBluetooth() {
- when(mSharedPreferences.getBoolean(
- BluetoothTetherPreferenceController.PREF_KEY, false)).thenReturn(true);
- mController.onSharedPreferenceChanged(mSharedPreferences,
- BluetoothTetherPreferenceController.PREF_KEY);
+ when(mSharedPreferences.getBoolean(BLUETOOTH_TETHER_KEY, false)).thenReturn(true);
+ mController.onSharedPreferenceChanged(mSharedPreferences, BLUETOOTH_TETHER_KEY);
verify(mPreference).setVisible(eq(true));
- when(mSharedPreferences.getBoolean(
- UsbTetherPreferenceController.PREF_KEY, false)).thenReturn(true);
- mController.onSharedPreferenceChanged(mSharedPreferences,
- UsbTetherPreferenceController.PREF_KEY);
+ when(mSharedPreferences.getBoolean(USB_TETHER_KEY, false)).thenReturn(true);
+ mController.onSharedPreferenceChanged(mSharedPreferences, USB_TETHER_KEY);
assertThat(mController.shouldShow()).isTrue();
- when(mSharedPreferences.getBoolean(
- UsbTetherPreferenceController.PREF_KEY, false)).thenReturn(false);
- mController.onSharedPreferenceChanged(mSharedPreferences,
- UsbTetherPreferenceController.PREF_KEY);
+ when(mSharedPreferences.getBoolean(USB_TETHER_KEY, false)).thenReturn(false);
+ mController.onSharedPreferenceChanged(mSharedPreferences, USB_TETHER_KEY);
assertThat(mController.shouldShow()).isTrue();
- when(mSharedPreferences.getBoolean(
- BluetoothTetherPreferenceController.PREF_KEY, false)).thenReturn(false);
+ when(mSharedPreferences.getBoolean(BLUETOOTH_TETHER_KEY, false)).thenReturn(false);
when(mSharedPreferences.edit()).thenReturn(mock(SharedPreferences.Editor.class));
when(mPreference.isChecked()).thenReturn(true);
- mController.onSharedPreferenceChanged(mSharedPreferences,
- BluetoothTetherPreferenceController.PREF_KEY);
+ mController.onSharedPreferenceChanged(mSharedPreferences, BLUETOOTH_TETHER_KEY);
verify(mPreference).setChecked(eq(false));
verify(mPreference).setVisible(eq(false));
}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java b/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java
new file mode 100644
index 0000000..d2a7129
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java
@@ -0,0 +1,38 @@
+/*
+ * 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.network.ims;
+
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class MockImsQueryResult {
+
+ public static class BooleanResult implements ImsQuery {
+ private boolean mResult;
+
+ public BooleanResult(boolean result) {
+ super();
+ mResult = result;
+ }
+
+ public boolean query() {
+ return mResult;
+ }
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java
new file mode 100644
index 0000000..42ddd70
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java
@@ -0,0 +1,84 @@
+/*
+ * 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.network.ims;
+
+import android.content.Context;
+
+import com.android.ims.ImsManager;
+
+
+
+/**
+ * Controller class for mock VoLte status
+ */
+public class MockVolteQueryImsState extends VolteQueryImsState {
+
+ private ImsQuery mIsTtyOnVolteEnabled;
+ private ImsQuery mIsProvisionedOnDevice;
+ private ImsQuery mIsEnabledByUser;
+
+ /**
+ * Constructor
+ *
+ * @param context {@link Context}
+ * @param subId subscription's id
+ */
+ public MockVolteQueryImsState(Context context, int subId) {
+ super(context, subId);
+ }
+
+ public ImsManager getImsManager(int subId) {
+ return super.getImsManager(subId);
+ }
+
+ public void setIsTtyOnVolteEnabled(boolean enabled) {
+ mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isTtyOnVolteEnabled(int subId) {
+ if (mIsTtyOnVolteEnabled != null) {
+ return mIsTtyOnVolteEnabled;
+ }
+ return super.isTtyOnVolteEnabled(subId);
+ }
+
+ public void setIsProvisionedOnDevice(boolean isProvisioned) {
+ mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
+ }
+
+ @Override
+ ImsQuery isProvisionedOnDevice(int subId) {
+ if (mIsProvisionedOnDevice != null) {
+ return mIsProvisionedOnDevice;
+ }
+ return super.isProvisionedOnDevice(subId);
+ }
+
+ public void setIsEnabledByUser(boolean enabled) {
+ mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isEnabledByUser(int subId) {
+ if (mIsEnabledByUser != null) {
+ return mIsEnabledByUser;
+ }
+ return super.isEnabledByUser(subId);
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
new file mode 100644
index 0000000..b5971e9
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
@@ -0,0 +1,82 @@
+/*
+ * 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.network.ims;
+
+import android.content.Context;
+
+import com.android.ims.ImsManager;
+
+
+/**
+ * Controller class for mock VT status
+ */
+public class MockVtQueryImsState extends VtQueryImsState {
+
+ private ImsQuery mIsTtyOnVolteEnabled;
+ private ImsQuery mIsProvisionedOnDevice;
+ private ImsQuery mIsEnabledByUser;
+
+ /**
+ * Constructor
+ *
+ * @param context {@link Context}
+ * @param subId subscription's id
+ */
+ public MockVtQueryImsState(Context context, int subId) {
+ super(context, subId);
+ }
+
+ public ImsManager getImsManager(int subId) {
+ return super.getImsManager(subId);
+ }
+
+ public void setIsTtyOnVolteEnabled(boolean enabled) {
+ mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isTtyOnVolteEnabled(int subId) {
+ if (mIsTtyOnVolteEnabled != null) {
+ return mIsTtyOnVolteEnabled;
+ }
+ return super.isTtyOnVolteEnabled(subId);
+ }
+
+ public void setIsProvisionedOnDevice(boolean isProvisioned) {
+ mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
+ }
+
+ @Override
+ ImsQuery isProvisionedOnDevice(int subId) {
+ if (mIsProvisionedOnDevice != null) {
+ return mIsProvisionedOnDevice;
+ }
+ return super.isProvisionedOnDevice(subId);
+ }
+
+ public void setIsEnabledByUser(boolean enabled) {
+ mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isEnabledByUser(int subId) {
+ if (mIsEnabledByUser != null) {
+ return mIsEnabledByUser;
+ }
+ return super.isEnabledByUser(subId);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockWifiCallingQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockWifiCallingQueryImsState.java
new file mode 100644
index 0000000..aa30aa0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/ims/MockWifiCallingQueryImsState.java
@@ -0,0 +1,83 @@
+/*
+ * 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.network.ims;
+
+import android.content.Context;
+
+import com.android.ims.ImsManager;
+
+
+/**
+ * Controller class for mock Wifi calling status
+ */
+public class MockWifiCallingQueryImsState extends WifiCallingQueryImsState {
+
+ private ImsQuery mIsTtyOnVolteEnabled;
+ private ImsQuery mIsProvisionedOnDevice;
+ private ImsQuery mIsEnabledByUser;
+
+ /**
+ * Constructor
+ *
+ * @param context {@code Context}
+ * @param subId subscription's id
+ */
+ public MockWifiCallingQueryImsState(Context context, int subId) {
+ super(context, subId);
+ }
+
+ public ImsManager getImsManager(int subId) {
+ return super.getImsManager(subId);
+ }
+
+ public void setIsTtyOnVolteEnabled(boolean enabled) {
+ mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isTtyOnVolteEnabled(int subId) {
+ if (mIsTtyOnVolteEnabled != null) {
+ return mIsTtyOnVolteEnabled;
+ }
+ return super.isTtyOnVolteEnabled(subId);
+ }
+
+ public void setIsProvisionedOnDevice(boolean isProvisioned) {
+ mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
+ }
+
+ @Override
+ ImsQuery isProvisionedOnDevice(int subId) {
+ if (mIsProvisionedOnDevice != null) {
+ return mIsProvisionedOnDevice;
+ }
+ return super.isProvisionedOnDevice(subId);
+ }
+
+ public void setIsEnabledByUser(boolean enabled) {
+ mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
+ }
+
+ @Override
+ ImsQuery isEnabledByUser(int subId) {
+ if (mIsEnabledByUser != null) {
+ return mIsEnabledByUser;
+ }
+ return super.isEnabledByUser(subId);
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
index 3e0bfa3..d7db984 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceControllerTest.java
@@ -35,7 +35,7 @@
import com.android.ims.ImsManager;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.network.ims.VolteQueryImsState;
+import com.android.settings.network.ims.MockVolteQueryImsState;
import com.android.settingslib.RestrictedSwitchPreference;
import org.junit.Before;
@@ -63,7 +63,7 @@
@Mock
private ProvisioningManager mProvisioningManager;
- private VolteQueryImsState mQueryImsState;
+ private MockVolteQueryImsState mQueryImsState;
private Enhanced4gLtePreferenceController mController;
private SwitchPreference mPreference;
@@ -85,17 +85,13 @@
mCarrierConfig = new PersistableBundle();
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
- mQueryImsState = spy(new VolteQueryImsState(mContext, SUB_ID));
+ mQueryImsState = spy(new MockVolteQueryImsState(mContext, SUB_ID));
+ doReturn(mImsManager).when(mQueryImsState).getImsManager(anyInt());
+ mQueryImsState.setIsProvisionedOnDevice(true);
mPreference = new RestrictedSwitchPreference(mContext);
- mController = spy(new Enhanced4gLtePreferenceController(mContext, "roaming") {
- @Override
- ProvisioningManager getProvisioningManager(int subId) {
- return mProvisioningManager;
- }
- });
+ mController = spy(new Enhanced4gLtePreferenceController(mContext, "VoLTE"));
mController.init(SUB_ID);
- mController.mImsManager = mImsManager;
doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
mPreference.setKey(mController.getPreferenceKey());
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
index c9abe23..a89a7aa 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
@@ -34,8 +34,6 @@
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.ims.ProvisioningManager;
-import android.telephony.ims.feature.MmTelFeature;
-import android.telephony.ims.stub.ImsRegistrationImplBase;
import androidx.slice.Slice;
import androidx.slice.SliceItem;
@@ -47,7 +45,7 @@
import com.android.ims.ImsManager;
import com.android.settings.R;
-import com.android.settings.network.ims.VolteQueryImsState;
+import com.android.settings.network.ims.MockVolteQueryImsState;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.SettingsSliceProvider;
import com.android.settings.slices.SliceBroadcastReceiver;
@@ -81,7 +79,7 @@
private ProvisioningManager mProvisioningManager;
private ShadowSubscriptionManager mShadowSubscriptionManager;
- private VolteQueryImsState mQueryImsState;
+ private MockVolteQueryImsState mQueryImsState;
private Context mContext;
private FakeEnhanced4gLteSliceHelper mEnhanced4gLteSliceHelper;
@@ -110,7 +108,9 @@
//setup for SliceBroadcastReceiver test
mReceiver = spy(new SliceBroadcastReceiver());
- mQueryImsState = spy(new VolteQueryImsState(mContext, SUB_ID));
+ mQueryImsState = spy(new MockVolteQueryImsState(mContext, SUB_ID));
+ doReturn(mMockImsManager).when(mQueryImsState).getImsManager(anyInt());
+ mQueryImsState.setIsProvisionedOnDevice(true);
mEnhanced4gLteSliceHelper = spy(new FakeEnhanced4gLteSliceHelper(mContext));
doReturn(mQueryImsState).when(mEnhanced4gLteSliceHelper).queryImsState(anyInt());
@@ -143,9 +143,7 @@
@Test
public void test_CreateEnhanced4gLteSlice_success() {
when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
- when(mProvisioningManager.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+ mQueryImsState.setIsProvisionedOnDevice(true);
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -160,9 +158,7 @@
@Test
public void test_SettingSliceProvider_getsRightSliceEnhanced4gLte() {
when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
- when(mProvisioningManager.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+ mQueryImsState.setIsProvisionedOnDevice(true);
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -179,9 +175,7 @@
@Ignore
public void test_SliceBroadcastReceiver_toggleOffEnhanced4gLte() {
when(mMockImsManager.isVolteEnabledByPlatform()).thenReturn(true);
- when(mProvisioningManager.getProvisioningStatusForCapability(
- MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE,
- ImsRegistrationImplBase.REGISTRATION_TECH_LTE)).thenReturn(true);
+ mQueryImsState.setIsProvisionedOnDevice(true);
doReturn(false).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mSlicesFeatureProvider.getNewEnhanced4gLteSliceHelper(mContext))
@@ -278,7 +272,7 @@
}
private class FakeEnhanced4gLteSliceHelper extends Enhanced4gLteSliceHelper {
- int mSubId = 1;
+ int mSubId = SUB_ID;
FakeEnhanced4gLteSliceHelper(Context context) {
super(context);
@@ -289,16 +283,6 @@
return mMockCarrierConfigManager;
}
- @Override
- protected ImsManager getImsManager(int subId) {
- return mMockImsManager;
- }
-
- @Override
- ProvisioningManager getProvisioningManager(int subId) {
- return mProvisioningManager;
- }
-
protected int getDefaultVoiceSubId() {
return mSubId;
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
index a69ab53..2d5f47b 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
@@ -92,6 +92,7 @@
}
@Test
+ @Ignore
public void dialog_subscriptionMissing_noCrash() {
final AlertDialog dialog = startDialog();
final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
index e68a0f4..c766289 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
@@ -20,7 +20,6 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.spy;
import android.content.Context;
@@ -29,14 +28,13 @@
import android.telephony.TelephonyManager;
import android.telephony.ims.ProvisioningManager;
import android.telephony.ims.feature.ImsFeature;
-import android.telephony.ims.feature.MmTelFeature;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import com.android.ims.ImsManager;
+import com.android.settings.network.ims.MockVtQueryImsState;
import com.android.settings.network.ims.VolteQueryImsState;
-import com.android.settings.network.ims.VtQueryImsState;
import org.junit.Before;
import org.junit.Test;
@@ -61,7 +59,7 @@
@Mock
private PreferenceScreen mPreferenceScreen;
- private VtQueryImsState mQueryImsState;
+ private MockVtQueryImsState mQueryImsState;
private VolteQueryImsState mQueryVoLteState;
private VideoCallingPreferenceController mController;
@@ -74,7 +72,6 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
doReturn(mCarrierConfigManager).when(mContext)
.getSystemService(CarrierConfigManager.class);
@@ -85,29 +82,22 @@
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, true);
doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
- mQueryImsState = spy(new VtQueryImsState(mContext, SUB_ID));
+ mQueryImsState = spy(new MockVtQueryImsState(mContext, SUB_ID));
doReturn(true).when(mQueryImsState).isEnabledByUser();
+ doReturn(mImsManager).when(mQueryImsState).getImsManager(anyInt());
mQueryVoLteState = spy(new VolteQueryImsState(mContext, SUB_ID));
doReturn(true).when(mQueryVoLteState).isEnabledByUser();
mPreference = new SwitchPreference(mContext);
- mController = spy(new VideoCallingPreferenceController(mContext, "wifi_calling") {
- @Override
- ProvisioningManager getProvisioningManager(int subId) {
- return mProvisioningManager;
- }
- });
+ mController = spy(new VideoCallingPreferenceController(mContext, "wifi_calling"));
mController.init(SUB_ID);
- mController.mImsManager = mImsManager;
doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
doReturn(mQueryVoLteState).when(mController).queryVoLteState(anyInt());
mPreference.setKey(mController.getPreferenceKey());
doReturn(true).when(mImsManager).isVtEnabledByPlatform();
- doReturn(true).when(mProvisioningManager)
- .getProvisioningStatusForCapability(
- eq(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VIDEO), anyInt());
+ mQueryImsState.setIsProvisionedOnDevice(true);
doReturn(ImsFeature.STATE_READY).when(mImsManager).getImsServiceState();
doReturn(true).when(mTelephonyManager).isDataEnabled();
@@ -116,14 +106,15 @@
@Test
public void isVideoCallEnabled_allFlagsOn_returnTrue() {
- assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isTrue();
+ assertThat(mController.isVideoCallEnabled(SUB_ID)).isTrue();
}
@Test
public void isVideoCallEnabled_disabledByPlatform_returnFalse() {
+ mQueryImsState.setIsProvisionedOnDevice(false);
doReturn(false).when(mImsManager).isVtEnabledByPlatform();
- assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
+ assertThat(mController.isVideoCallEnabled(SUB_ID)).isFalse();
}
@Test
@@ -132,7 +123,7 @@
CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, false);
doReturn(false).when(mTelephonyManager).isDataEnabled();
- assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
+ assertThat(mController.isVideoCallEnabled(SUB_ID)).isFalse();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
index 961f8cb..b91f718 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import com.android.ims.ImsManager;
import com.android.internal.R;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.network.ims.WifiCallingQueryImsState;
+import com.android.settings.network.ims.MockWifiCallingQueryImsState;
import org.junit.Before;
import org.junit.Ignore;
@@ -66,7 +66,7 @@
@Mock
private PreferenceScreen mPreferenceScreen;
- private WifiCallingQueryImsState mQueryImsState;
+ private MockWifiCallingQueryImsState mQueryImsState;
private WifiCallingPreferenceController mController;
private Preference mPreference;
@@ -79,8 +79,10 @@
mContext = spy(RuntimeEnvironment.application);
- mQueryImsState = spy(new WifiCallingQueryImsState(mContext, SUB_ID));
+ mQueryImsState = spy(new MockWifiCallingQueryImsState(mContext, SUB_ID));
doReturn(true).when(mQueryImsState).isEnabledByUser();
+ doReturn(mImsManager).when(mQueryImsState).getImsManager(anyInt());
+ mQueryImsState.setIsProvisionedOnDevice(true);
mPreference = new Preference(mContext);
mController = spy(new WifiCallingPreferenceController(mContext, "wifi_calling") {
@@ -91,7 +93,6 @@
});
mController.mCarrierConfigManager = mCarrierConfigManager;
mController.init(SUB_ID);
- mController.mImsManager = mImsManager;
mController.mCallState = TelephonyManager.CALL_STATE_IDLE;
doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
mPreference.setKey(mController.getPreferenceKey());
@@ -143,7 +144,6 @@
mCarrierConfig.putBoolean(
CarrierConfigManager.KEY_USE_WFC_HOME_NETWORK_MODE_IN_ROAMING_NETWORK_BOOL, true);
mController.init(SUB_ID);
- mController.mImsManager = mImsManager;
when(mImsMmTelManager.getVoWiFiRoamingModeSetting()).thenReturn(
ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED);
diff --git a/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java b/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
index 513da65..525f3ef 100644
--- a/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
@@ -53,7 +53,6 @@
static final String PAYMENT_KEY = "nfc_payment";
static final String FOREGROUND_KEY = "nfc_foreground";
- static final String PAYMENT_SCREEN_KEY = "nfc_payment_settings_screen";
private Context mContext;
@@ -107,14 +106,14 @@
}
@Test
- public void getNonIndexabkeKey_guestUser_returnsFalse() {
+ public void getNonIndexableKey_guestUser_returnsFalse() {
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC)).thenReturn(true);
when(mUserInfo.isGuest()).thenReturn(true);
final List<String> niks =
PaymentSettings.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
- assertThat(niks).containsAllOf(FOREGROUND_KEY, PAYMENT_KEY, PAYMENT_SCREEN_KEY);
+ assertThat(niks).containsAllOf(FOREGROUND_KEY, PAYMENT_KEY);
}
@Test
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/VibrateWhenRingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
deleted file mode 100644
index ec275c1..0000000
--- a/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (C) 2016 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 android.provider.Settings.System.VIBRATE_WHEN_RINGING;
-
-import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.provider.DeviceConfig;
-import android.provider.Settings;
-import android.telephony.TelephonyManager;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-import androidx.preference.TwoStatePreference;
-
-import com.android.settings.testutils.shadow.ShadowDeviceConfig;
-
-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 org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowContentResolver;
-
-@RunWith(RobolectricTestRunner.class)
-@Config(shadows={ShadowDeviceConfig.class})
-public class VibrateWhenRingPreferenceControllerTest {
-
- private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
- private final int DEFAULT_VALUE = 0;
- private final int NOTIFICATION_VIBRATE_WHEN_RINGING = 1;
- private Context mContext;
- private ContentResolver mContentResolver;
- @Mock
- private PreferenceScreen mScreen;
- @Mock
- private TelephonyManager mTelephonyManager;
- private VibrateWhenRingPreferenceController mController;
- private Preference mPreference;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
- mContentResolver = mContext.getContentResolver();
- when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
- mController = new VibrateWhenRingPreferenceController(mContext, KEY_VIBRATE_WHEN_RINGING);
- mPreference = new Preference(mContext);
- mPreference.setKey(mController.getPreferenceKey());
- when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
- }
-
- @Test
- public void display_shouldDisplay() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
- mController.displayPreference(mScreen);
- assertThat(mPreference.isVisible()).isTrue();
- }
-
- @Test
- public void display_shouldNotDisplay_notVoiceCapable() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
- mController.displayPreference(mScreen);
- assertThat(mPreference.isVisible()).isFalse();
- }
-
- @Test
- public void display_shouldNotDisplay_RampingRingerEnabled() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "true", false);
- mController.displayPreference(mScreen);
- assertThat(mPreference.isVisible()).isFalse();
- }
-
- @Test
- public void display_shouldNotDisplay_VoiceEnabled_RampingRingerEnabled() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "true", false);
- mController.displayPreference(mScreen);
- assertThat(mPreference.isVisible()).isFalse();
- }
-
- @Test
- public void display_shouldNotDisplay_VoiceDisabled_RampingRingerEnabled() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "true", false);
- mController.displayPreference(mScreen);
- assertThat(mPreference.isVisible()).isFalse();
- }
-
- @Test
- public void testOnPreferenceChange_turnOn_returnOn() {
- mController.onPreferenceChange(null, true);
- final int mode = Settings.System.getInt(mContext.getContentResolver(),
- VIBRATE_WHEN_RINGING, DEFAULT_VALUE);
-
- assertThat(mode).isEqualTo(NOTIFICATION_VIBRATE_WHEN_RINGING);
- }
-
- @Test
- public void testOnPreferenceChange_turnOff_returnOff() {
- mController.onPreferenceChange(null, false);
- final int mode = Settings.System.getInt(mContext.getContentResolver(),
- VIBRATE_WHEN_RINGING, DEFAULT_VALUE);
-
- assertThat(mode).isEqualTo(DEFAULT_VALUE);
- }
-
- @Test
- public void voiceCapable_availabled() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- }
-
- @Test
- public void voiceCapable_notAvailabled() {
- when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
- DeviceConfig.setProperty("telephony", "ramping_ringer_enabled", "false", false);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
- }
-
- @Test
- public void updateState_settingIsOn_preferenceShouldBeChecked() {
- final TwoStatePreference preference = mock(TwoStatePreference.class);
- Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING, 1);
-
- mController.updateState(preference);
-
- assertThat(mController.isChecked()).isTrue();
- }
-
- @Test
- public void updateState_settingIsOff_preferenceShouldNotBeChecked() {
- final TwoStatePreference preference = mock(TwoStatePreference.class);
- Settings.System.putInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING, 0);
-
- mController.updateState(preference);
-
- assertThat(mController.isChecked()).isFalse();
- }
-
- @Test
- public void setChecked_settingsIsOn() {
- mController.setChecked(true);
- final int mode = Settings.System.getInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
- -1);
-
- assertThat(mode).isEqualTo(NOTIFICATION_VIBRATE_WHEN_RINGING);
- }
-
- @Test
- public void setChecked_settingsIsOff() {
- mController.setChecked(false);
- final int mode = Settings.System.getInt(mContext.getContentResolver(), VIBRATE_WHEN_RINGING,
- -1);
-
- assertThat(mode).isEqualTo(DEFAULT_VALUE);
- }
-
- @Test
- public void testObserver_onResume_shouldRegisterObserver() {
- final ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
- mController.displayPreference(mScreen);
-
- mController.onResume();
-
- assertThat(shadowContentResolver.getContentObservers(
- Settings.System.getUriFor(VIBRATE_WHEN_RINGING))).isNotEmpty();
- }
-
- @Test
- public void testObserver_onPause_shouldUnregisterObserver() {
- final ShadowContentResolver shadowContentResolver = Shadow.extract(mContentResolver);
- mController.displayPreference(mScreen);
-
- mController.onResume();
- mController.onPause();
-
- assertThat(shadowContentResolver.getContentObservers(
- Settings.System.getUriFor(VIBRATE_WHEN_RINGING))).isEmpty();
- }
-
- @Test
- public void isSliceableCorrectKey_returnsTrue() {
- final VibrateWhenRingPreferenceController controller =
- new VibrateWhenRingPreferenceController(mContext, "vibrate_when_ringing");
- assertThat(controller.isSliceable()).isTrue();
- }
-
- @Test
- public void isSliceableIncorrectKey_returnsFalse() {
- final VibrateWhenRingPreferenceController controller =
- new VibrateWhenRingPreferenceController(mContext, "bad_key");
- assertThat(controller.isSliceable()).isFalse();
- }
-
- @Test
- public void isPublicSlice_returnTrue() {
- assertThat(mController.isPublicSlice()).isTrue();
- }
-}
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/notification/zen/ZenModeBackendTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
index c4ece5a..247d68e 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
@@ -1,25 +1,41 @@
package com.android.settings.notification.zen;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_NONE;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CALLS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES;
+import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_ANY;
+import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS;
+import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_STARRED;
+import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT;
+
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.app.AutomaticZenRule;
import android.app.NotificationManager;
+import android.app.NotificationManager.Policy;
import android.content.Context;
import android.database.Cursor;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
-import com.android.settings.notification.zen.ZenModeBackend;
+import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
@@ -55,60 +71,6 @@
mBackend = new ZenModeBackend(mContext);
}
- @Test
- public void updateState_checkRuleOrderingDescending() {
- final int NUM_RULES = 4;
- Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(
- NUM_RULES, false);
- Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
-
- // check ordering, most recent should be at the end
- for (int i = 0; i < NUM_RULES; i++) {
- assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i].getKey());
- }
- }
-
- @Test
- public void updateState_checkRuleOrderingAscending() {
- final int NUM_RULES = 4;
- Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesAscendingCreationTime(
- NUM_RULES, false);
- Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
-
- // check ordering, most recent should be at the end
- for (int i = 0; i < NUM_RULES; i++) {
- assertEquals(GENERIC_RULE_NAME + i, rules[i].getKey());
- }
- }
-
- @Test
- public void updateState_checkRuleOrderingDescending_withDefaultRules() {
- final int NUM_RULES = 4;
-
- Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(NUM_RULES,
- true);
- Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
-
- assertEquals(rules[0].getKey(), DEFAULT_ID_1);
- assertEquals(rules[1].getKey(), DEFAULT_ID_2);
- // NON-DEFAULT RULES check ordering, most recent at the bottom/end
- for (int i = 0; i < NUM_RULES; i++) {
- assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i + 2].getKey());
- }
- }
-
- @Test
- public void updateSummary_nullCursorValues() {
- Cursor testCursorWithNullValues = createMockCursor(3);
- when(testCursorWithNullValues.getString(0)).thenReturn(null);
-
- // expected - no null values
- List<String> contacts = mBackend.getStarredContacts(testCursorWithNullValues);
- for (String contact : contacts) {
- assertThat(contact).isNotNull();
- }
- }
-
private Cursor createMockCursor(int size) {
Cursor mockCursor = mock(Cursor.class);
when(mockCursor.moveToFirst()).thenReturn(true);
@@ -173,4 +135,133 @@
ruleMap.entrySet().toArray(toReturn);
return toReturn;
}
+
+ @Test
+ public void updateState_checkRuleOrderingDescending() {
+ final int NUM_RULES = 4;
+ Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(
+ NUM_RULES, false);
+ Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
+
+ // check ordering, most recent should be at the end
+ for (int i = 0; i < NUM_RULES; i++) {
+ assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i].getKey());
+ }
+ }
+
+ @Test
+ public void updateState_checkRuleOrderingAscending() {
+ final int NUM_RULES = 4;
+ Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesAscendingCreationTime(
+ NUM_RULES, false);
+ Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
+
+ // check ordering, most recent should be at the end
+ for (int i = 0; i < NUM_RULES; i++) {
+ assertEquals(GENERIC_RULE_NAME + i, rules[i].getKey());
+ }
+ }
+
+ @Test
+ public void updateState_checkRuleOrderingDescending_withDefaultRules() {
+ final int NUM_RULES = 4;
+
+ Map.Entry<String, AutomaticZenRule>[] rules = populateAutoZenRulesDescendingCreationTime(NUM_RULES,
+ true);
+ Arrays.sort(rules, ZenModeBackend.RULE_COMPARATOR);
+
+ assertEquals(rules[0].getKey(), DEFAULT_ID_1);
+ assertEquals(rules[1].getKey(), DEFAULT_ID_2);
+ // NON-DEFAULT RULES check ordering, most recent at the bottom/end
+ for (int i = 0; i < NUM_RULES; i++) {
+ assertEquals(GENERIC_RULE_NAME + (NUM_RULES - 1 - i), rules[i + 2].getKey());
+ }
+ }
+
+ @Test
+ public void updateSummary_nullCursorValues() {
+ Cursor testCursorWithNullValues = createMockCursor(3);
+ when(testCursorWithNullValues.getString(0)).thenReturn(null);
+
+ // expected - no null values
+ List<String> contacts = mBackend.getStarredContacts(testCursorWithNullValues);
+ for (String contact : contacts) {
+ assertThat(contact).isNotNull();
+ }
+ }
+
+ @Test
+ public void saveConversationSenders_importantToNone() {
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(
+ new Policy(PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_IMPORTANT));
+ mBackend = new ZenModeBackend(mContext);
+
+ mBackend.saveConversationSenders(CONVERSATION_SENDERS_NONE);
+
+ ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
+ verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
+
+ Policy expected = new Policy(
+ PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_NONE);
+ assertEquals(expected, captor.getValue());
+ }
+
+ @Test
+ public void saveConversationSenders_noneToAll() {
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(new Policy(
+ PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_NONE));
+ mBackend = new ZenModeBackend(mContext);
+
+ mBackend.saveConversationSenders(CONVERSATION_SENDERS_ANYONE);
+
+ ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
+ verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
+
+ Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_ANYONE);
+ assertEquals(expected, captor.getValue());
+ }
+
+ @Test
+ public void saveSenders_doesNotChangeConversations() {
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(
+ new Policy(PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_CONTACTS,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_ANYONE));
+ mBackend = new ZenModeBackend(mContext);
+
+ mBackend.saveSenders(PRIORITY_CATEGORY_CALLS, PRIORITY_SENDERS_ANY);
+
+ ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
+ verify(mNotificationManager, times(1)).setNotificationPolicy(captor.capture());
+
+ Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
+ | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
+ PRIORITY_SENDERS_ANY,
+ PRIORITY_SENDERS_STARRED,
+ SUPPRESSED_EFFECT_AMBIENT,
+ CONVERSATION_SENDERS_ANYONE);
+ assertEquals(expected, captor.getValue());
+ }
+
}
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java
index e4490d5..d1f80b8 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityCallsPreferenceControllerTest.java
@@ -34,8 +34,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.notification.zen.ZenModeBackend;
-import com.android.settings.notification.zen.ZenModePriorityCallsPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -88,7 +86,7 @@
when(mBackend.getPriorityCallSenders())
.thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
- when(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ when(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_CALLS)).thenCallRealMethod();
when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_CALLS))
.thenCallRealMethod();
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceControllerTest.java
new file mode 100644
index 0000000..1583b91
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityConversationsPreferenceControllerTest.java
@@ -0,0 +1,191 @@
+/*
+ * 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.zen;
+
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT;
+import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_NONE;
+import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_CONVERSATIONS;
+import static android.provider.Settings.Global.ZEN_MODE;
+import static android.provider.Settings.Global.ZEN_MODE_ALARMS;
+import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
+import static android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.NotificationManager;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(RobolectricTestRunner.class)
+public class ZenModePriorityConversationsPreferenceControllerTest {
+
+ private ZenModePriorityConversationsPreferenceController mController;
+
+ @Mock
+ private ZenModeBackend mBackend;
+ @Mock
+ private NotificationManager mNotificationManager;
+ @Mock
+ private ListPreference mockPref;
+ @Mock
+ private NotificationManager.Policy mPolicy;
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+ private ContentResolver mContentResolver;
+ private Context mContext;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowApplication = ShadowApplication.getInstance();
+ shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNotificationManager);
+
+ mContext = RuntimeEnvironment.application;
+ mContentResolver = RuntimeEnvironment.application.getContentResolver();
+ when(mNotificationManager.getNotificationPolicy()).thenReturn(mPolicy);
+
+ when(mBackend.getPriorityConversationSenders())
+ .thenReturn(CONVERSATION_SENDERS_IMPORTANT);
+ when(mBackend.getAlarmsTotalSilencePeopleSummary(PRIORITY_CATEGORY_CONVERSATIONS))
+ .thenCallRealMethod();
+ when(mBackend.getConversationSummary()).thenCallRealMethod();
+
+ mController = new ZenModePriorityConversationsPreferenceController(
+ mContext, mock(Lifecycle.class));
+ ReflectionHelpers.setField(mController, "mBackend", mBackend);
+
+ when(mPreferenceScreen.findPreference(mController.getPreferenceKey())).thenReturn(mockPref);
+ mController.displayPreference(mPreferenceScreen);
+ }
+
+ @Test
+ public void updateState_TotalSilence() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_NO_INTERRUPTIONS);
+
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+ final ListPreference mockPref = mock(ListPreference.class);
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(false);
+ verify(mockPref).setSummary(R.string.zen_mode_from_no_conversations);
+ }
+
+ @Test
+ public void updateState_AlarmsOnly() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_ALARMS);
+
+ final ListPreference mockPref = mock(ListPreference.class);
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(false);
+ verify(mockPref).setSummary(R.string.zen_mode_from_no_conversations);
+ }
+
+ @Test
+ public void updateState_Priority_important() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(true);
+ verify(mockPref).setSummary(R.string.zen_mode_from_important_conversations);
+ verify(mockPref).setValue(String.valueOf(CONVERSATION_SENDERS_IMPORTANT));
+ }
+
+ @Test
+ public void updateState_Priority_all() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_ANYONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+
+
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(true);
+ verify(mockPref).setSummary(R.string.zen_mode_from_all_conversations);
+ verify(mockPref).setValue(String.valueOf(CONVERSATION_SENDERS_ANYONE));
+ }
+
+ @Test
+ public void updateState_Priority_none() {
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_NONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(false);
+
+ mController.updateState(mockPref);
+
+ verify(mockPref).setEnabled(true);
+ verify(mockPref).setSummary(R.string.zen_mode_from_no_conversations);
+ verify(mockPref).setValue(String.valueOf(CONVERSATION_SENDERS_NONE));
+ }
+
+ @Test
+ public void onPreferenceChange_noneToImportant() {
+ // start with none
+
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_NONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(false);
+
+ mController.updateState(mockPref);
+ reset(mBackend);
+
+ mController.onPreferenceChange(mockPref, String.valueOf(CONVERSATION_SENDERS_IMPORTANT));
+
+ verify(mBackend).saveConversationSenders(CONVERSATION_SENDERS_IMPORTANT);
+ verify(mBackend).getPriorityConversationSenders();
+ }
+
+ @Test
+ public void onPreferenceChange_allToNone() {
+ // start with none
+
+ Settings.Global.putInt(mContentResolver, ZEN_MODE, ZEN_MODE_IMPORTANT_INTERRUPTIONS);
+ when(mBackend.getPriorityConversationSenders()).thenReturn(CONVERSATION_SENDERS_ANYONE);
+ when(mBackend.isPriorityCategoryEnabled(PRIORITY_CATEGORY_CONVERSATIONS)).thenReturn(true);
+
+ mController.updateState(mockPref);
+ reset(mBackend);
+
+ mController.onPreferenceChange(mockPref, String.valueOf(CONVERSATION_SENDERS_NONE));
+
+ verify(mBackend).saveConversationSenders(CONVERSATION_SENDERS_NONE);
+ verify(mBackend).getPriorityConversationSenders();
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java
index 3ecd22a..7af2211 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModePriorityMessagesPreferenceControllerTest.java
@@ -34,8 +34,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.notification.zen.ZenModeBackend;
-import com.android.settings.notification.zen.ZenModePriorityMessagesPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -88,7 +86,7 @@
when(mBackend.getPriorityMessageSenders())
.thenReturn(NotificationManager.Policy.PRIORITY_SENDERS_STARRED);
- when(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
+ when(mBackend.getAlarmsTotalSilencePeopleSummary(
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES)).thenCallRealMethod();
when(mBackend.getContactsSummary(NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES))
.thenCallRealMethod();
diff --git a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
index 3b4d2c4..8888093 100644
--- a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
+++ b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
@@ -22,6 +22,8 @@
import android.content.Intent;
import android.net.Uri;
+import androidx.core.graphics.drawable.IconCompat;
+
import java.util.Arrays;
import java.util.List;
@@ -41,11 +43,11 @@
public static final Intent INTENT = new Intent();
private CharSequence mSubTitle;
- private int mIconRes = -1;
+ private IconCompat mIcon;
@Override
- public int getIcon() {
- return mIconRes;
+ public IconCompat getIcon() {
+ return mIcon;
}
@Override
@@ -53,8 +55,8 @@
return mSubTitle;
}
- public void setIcon(int iconRes) {
- mIconRes = iconRes;
+ public void setIcon(IconCompat icon) {
+ mIcon = icon;
}
public void setSubTitle(CharSequence subTitle) {
diff --git a/tests/robotests/src/com/android/settings/panel/MediaOutputPanelTest.java b/tests/robotests/src/com/android/settings/panel/MediaOutputPanelTest.java
index b411037..fb7f0ae 100644
--- a/tests/robotests/src/com/android/settings/panel/MediaOutputPanelTest.java
+++ b/tests/robotests/src/com/android/settings/panel/MediaOutputPanelTest.java
@@ -20,28 +20,59 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.media.MediaMetadata;
+import android.media.session.MediaController;
+import android.media.session.MediaSessionManager;
import android.net.Uri;
+import com.android.settings.R;
import com.android.settings.slices.CustomSliceRegistry;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.ArrayList;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class MediaOutputPanelTest {
private static final String TEST_PACKAGENAME = "com.test.packagename";
+ private static final String TEST_ARTIST = "test_artist";
+ private static final String TEST_ALBUM = "test_album";
+
+ @Mock
+ private MediaSessionManager mMediaSessionManager;
+ @Mock
+ private MediaController mMediaController;
+ @Mock
+ private MediaMetadata mMediaMetadata;
private MediaOutputPanel mPanel;
+ private Context mContext;
+ private List<MediaController> mMediaControllers = new ArrayList<>();
@Before
public void setUp() {
- mPanel = MediaOutputPanel.create(RuntimeEnvironment.application, TEST_PACKAGENAME);
+ MockitoAnnotations.initMocks(this);
+
+ mContext = spy(RuntimeEnvironment.application);
+ mMediaControllers.add(mMediaController);
+ when(mMediaController.getPackageName()).thenReturn(TEST_PACKAGENAME);
+ when(mMediaSessionManager.getActiveSessions(any())).thenReturn(mMediaControllers);
+ when(mContext.getApplicationContext()).thenReturn(mContext);
+ when(mContext.getSystemService(MediaSessionManager.class)).thenReturn(mMediaSessionManager);
+ mPanel = MediaOutputPanel.create(mContext, TEST_PACKAGENAME);
}
@Test
@@ -62,4 +93,76 @@
public void getSeeMoreIntent_isNull() {
assertThat(mPanel.getSeeMoreIntent()).isNull();
}
+
+ @Test
+ public void getTitle_withMetadata_returnArtistName() {
+ when(mMediaMetadata.getString(MediaMetadata.METADATA_KEY_ARTIST)).thenReturn(TEST_ARTIST);
+ when(mMediaController.getMetadata()).thenReturn(mMediaMetadata);
+
+ assertThat(mPanel.getTitle()).isEqualTo(TEST_ARTIST);
+ }
+
+ @Test
+ public void getTitle_noMetadata_returnDefaultString() {
+ when(mMediaController.getMetadata()).thenReturn(null);
+
+ assertThat(mPanel.getTitle()).isEqualTo(mContext.getText(R.string.media_volume_title));
+ }
+
+ @Test
+ public void getTitle_noPackageName_returnDefaultString() {
+ mPanel = MediaOutputPanel.create(mContext, null);
+ when(mMediaMetadata.getString(MediaMetadata.METADATA_KEY_ARTIST)).thenReturn(TEST_ARTIST);
+ when(mMediaController.getMetadata()).thenReturn(mMediaMetadata);
+
+ assertThat(mPanel.getTitle()).isEqualTo(mContext.getText(R.string.media_volume_title));
+ }
+
+ @Test
+ public void getTitle_noController_defaultString() {
+ mMediaControllers.clear();
+ when(mMediaMetadata.getString(MediaMetadata.METADATA_KEY_ARTIST)).thenReturn(TEST_ARTIST);
+ when(mMediaController.getMetadata()).thenReturn(mMediaMetadata);
+ mPanel = MediaOutputPanel.create(mContext, TEST_PACKAGENAME);
+
+ assertThat(mPanel.getTitle()).isEqualTo(mContext.getText(R.string.media_volume_title));
+ }
+
+ @Test
+ public void getSubTitle_withMetadata_returnAlbumName() {
+ when(mMediaMetadata.getString(MediaMetadata.METADATA_KEY_ALBUM)).thenReturn(TEST_ALBUM);
+ when(mMediaController.getMetadata()).thenReturn(mMediaMetadata);
+
+ assertThat(mPanel.getSubTitle()).isEqualTo(TEST_ALBUM);
+ }
+
+ @Test
+ public void getSubTitle_noMetadata_returnDefaultString() {
+ when(mMediaController.getPackageName()).thenReturn(TEST_PACKAGENAME);
+ when(mMediaController.getMetadata()).thenReturn(null);
+
+ assertThat(mPanel.getSubTitle()).isEqualTo(mContext.getText(
+ R.string.media_output_panel_title));
+ }
+
+ @Test
+ public void getSubTitle_noPackageName_returnDefaultString() {
+ mPanel = MediaOutputPanel.create(mContext, null);
+ when(mMediaMetadata.getString(MediaMetadata.METADATA_KEY_ARTIST)).thenReturn(TEST_ARTIST);
+ when(mMediaController.getMetadata()).thenReturn(mMediaMetadata);
+
+ assertThat(mPanel.getSubTitle()).isEqualTo(mContext.getText(
+ R.string.media_output_panel_title));
+ }
+
+ @Test
+ public void getSubTitle_noController_returnDefaultString() {
+ mMediaControllers.clear();
+ mPanel = MediaOutputPanel.create(mContext, TEST_PACKAGENAME);
+ when(mMediaMetadata.getString(MediaMetadata.METADATA_KEY_ALBUM)).thenReturn(TEST_ALBUM);
+ when(mMediaController.getMetadata()).thenReturn(mMediaMetadata);
+
+ assertThat(mPanel.getSubTitle()).isEqualTo(mContext.getText(
+ R.string.media_output_panel_title));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
index ee4131e..1976557 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
@@ -33,6 +33,8 @@
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.core.graphics.drawable.IconCompat;
+
import com.android.settings.R;
import com.android.settings.testutils.FakeFeatureFactory;
@@ -150,7 +152,8 @@
@Test
public void supportIcon_displayIconHeaderLayout() {
- mFakePanelContent.setIcon(R.drawable.ic_android);
+ final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_android);
+ mFakePanelContent.setIcon(icon);
mFakePanelContent.setSubTitle(SUBTITLE);
final ActivityController<FakeSettingsPanelActivity> activityController =
Robolectric.buildActivity(FakeSettingsPanelActivity.class);
diff --git a/tests/robotests/src/com/android/settings/security/InstallCertificateFromStorageTest.java b/tests/robotests/src/com/android/settings/security/InstallCertificateFromStorageTest.java
index 03bdb08..8484ebf 100644
--- a/tests/robotests/src/com/android/settings/security/InstallCertificateFromStorageTest.java
+++ b/tests/robotests/src/com/android/settings/security/InstallCertificateFromStorageTest.java
@@ -62,7 +62,6 @@
private void setUpTestKeys() {
mTestKeys = new ArrayList<>();
- mTestKeys.add("install_certificate_from_storage");
mTestKeys.add("certificate_types");
mTestKeys.add("install_ca_certificate");
mTestKeys.add("install_user_certificate");
diff --git a/tests/robotests/src/com/android/settings/security/screenlock/LockScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/screenlock/LockScreenPreferenceControllerTest.java
index 36eadba..17bef3c 100644
--- a/tests/robotests/src/com/android/settings/security/screenlock/LockScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/screenlock/LockScreenPreferenceControllerTest.java
@@ -21,7 +21,7 @@
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
-import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.google.common.truth.Truth.assertThat;
@@ -90,7 +90,7 @@
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
when(mLockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(true);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
@@ -98,7 +98,7 @@
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
when(mLockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(false);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
@@ -107,7 +107,7 @@
when(mLockPatternUtils.getKeyguardStoredPasswordQuality(anyInt()))
.thenReturn(PASSWORD_QUALITY_ALPHABETIC);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
@@ -116,7 +116,7 @@
when(mLockPatternUtils.getKeyguardStoredPasswordQuality(anyInt()))
.thenReturn(PASSWORD_QUALITY_UNSPECIFIED);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java
new file mode 100644
index 0000000..bf2b0f3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.sound;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.provider.Settings;
+import android.telephony.TelephonyManager;
+
+import com.android.settings.R;
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+
+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;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowDeviceConfig.class})
+public class VibrateForCallsPreferenceControllerTest {
+
+ private static final int OFF = 0;
+ private static final int ON = 1;
+ private Context mContext;
+ private ContentResolver mContentResolver;
+ @Mock
+ private TelephonyManager mTelephonyManager;
+ private VibrateForCallsPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mContentResolver = mContext.getContentResolver();
+ when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
+ mController = new VibrateForCallsPreferenceController(
+ mContext, VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED);
+ }
+
+ @Test
+ public void getAvailabilityStatus_notVoiceCapable_returnUnsupportedOnDevice() {
+ when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED, "false", false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_rampingRingerEnabled_returnUnsupportedOnDevice() {
+ when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED, "true", false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_voiceCapableAndRampingRingerDisabled_returnAvailable() {
+ when(mTelephonyManager.isVoiceCapable()).thenReturn(true);
+ DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
+ VibrateForCallsPreferenceController.RAMPING_RINGER_ENABLED, "false", false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getSummary_applyRampingRinger_rampingRingerSummary() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON);
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer));
+ }
+
+ @Test
+ public void getSummary_enableVibrateWhenRinging_alwaysVibrateSummary() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getText(R.string.vibrate_when_ringing_option_always_vibrate));
+ }
+
+ @Test
+ public void getSummary_notApplyRampingRingerDisableVibrateWhenRinging_neverVibrateSummary() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getText(R.string.vibrate_when_ringing_option_never_vibrate));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java
new file mode 100644
index 0000000..0a766d6
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.sound;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class VibrateForCallsPreferenceFragmentTest {
+
+ private static final int OFF = 0;
+ private static final int ON = 1;
+ private Context mContext;
+ private ContentResolver mContentResolver;
+ private VibrateForCallsPreferenceFragment mFragment;
+
+ @Before
+ public void setUp() {
+ mContext = spy(RuntimeEnvironment.application);
+ mContentResolver = mContext.getContentResolver();
+ mFragment = spy(new VibrateForCallsPreferenceFragment());
+ doReturn(mContext).when(mFragment).getContext();
+ mFragment.onAttach(mContext);
+ }
+
+ @Test
+ public void getDefaultKey_applyRampingRinger_keyRampingRinger() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON);
+
+ assertThat(mFragment.getDefaultKey()).isEqualTo(
+ VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
+ }
+
+ @Test
+ public void getDefaultKey_enableVibrateWhenRinging_keyAlwaysVibrate() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+ assertThat(mFragment.getDefaultKey()).isEqualTo(
+ VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
+ }
+
+ @Test
+ public void getDefaultKey_notApplyRampingRingerDisableVibrateWhenRinging_keyNeverVibrate() {
+ Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
+ Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
+
+ assertThat(mFragment.getDefaultKey()).isEqualTo(
+ VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
+ }
+
+ @Test
+ public void setDefaultKey_keyRampingRinger_applyRampingRingerDisableVibrateWhenRinging() {
+ mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
+
+ assertThat(Settings.Global.getInt(
+ mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(ON);
+ assertThat(Settings.System.getInt(
+ mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
+ }
+
+ @Test
+ public void setDefaultKey_keyAlwaysVibrate_notApplyRampingRingerEnableVibrateWhenRinging() {
+ mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
+
+ assertThat(Settings.Global.getInt(
+ mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
+ assertThat(Settings.System.getInt(
+ mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(ON);
+ }
+
+ @Test
+ public void setDefaultKey_keyNeverVibrate_notApplyRampingRingerDisableVibrateWhenRinging() {
+ mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
+
+ assertThat(Settings.Global.getInt(
+ mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
+ assertThat(Settings.System.getInt(
+ mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
+ }
+}
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/testutils/shadow/ShadowUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
index c1f33c6..eadd33a 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
@@ -18,7 +18,10 @@
import android.content.ComponentName;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
import android.hardware.fingerprint.FingerprintManager;
import android.os.UserHandle;
import android.os.UserManager;
@@ -144,6 +147,11 @@
return sResultLinks;
}
+ @Implementation
+ protected static Drawable getBadgedIcon(Context context, ApplicationInfo appInfo) {
+ return new ColorDrawable(0);
+ }
+
public static void setHandledDomains(ArraySet<String> links) {
sResultLinks = links;
}
diff --git a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
index 1d600a4..df9a2c1 100644
--- a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
@@ -30,7 +30,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
-import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.ColorDrawable;
@@ -38,7 +37,6 @@
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
-import android.widget.ImageView;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
@@ -46,7 +44,6 @@
import androidx.preference.Preference;
import com.android.settings.R;
-import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.widget.LayoutPreference;
import org.junit.Before;
@@ -258,20 +255,6 @@
}
@Test
- public void setIcon_usingAppEntry_shouldLoadIconFromDrawableFactory() {
- final View view = mLayoutInflater
- .inflate(R.layout.settings_entity_header, null /* root */);
- final ApplicationsState.AppEntry entry = mock(ApplicationsState.AppEntry.class);
- entry.info = new ApplicationInfo();
- mController = EntityHeaderController.newInstance(mActivity, mFragment, view);
- mController.setIcon(entry).done(mActivity);
- final ImageView iconView = view.findViewById(R.id.entity_header_icon);
-
- // ... entry.icon is still empty. This means the icon didn't come from cache.
- assertThat(entry.icon).isNull();
- }
-
- @Test
public void bindButton_hasAppNotifIntent_shouldShowButton() {
final View appLinks = mLayoutInflater
.inflate(R.layout.settings_entity_header, null /* root */);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
index eb4f326..320d767 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
@@ -49,7 +49,6 @@
import com.android.settings.datausage.DataUsagePreference;
import com.android.settings.testutils.shadow.ShadowDataUsageUtils;
import com.android.settings.testutils.shadow.ShadowFragment;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.wifi.LongPressWifiEntryPreference;
import com.android.wifitrackerlib.WifiEntry;
import com.android.wifitrackerlib.WifiPickerTracker;
@@ -64,8 +63,6 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import java.util.List;
-
@RunWith(RobolectricTestRunner.class)
public class WifiSettings2Test {
@@ -95,26 +92,6 @@
}
@Test
- public void testSearchIndexProvider_shouldIndexFragmentTitle() {
- final List<SearchIndexableRaw> indexRes =
- WifiSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext,
- true /* enabled */);
-
- assertThat(indexRes).isNotNull();
- assertThat(indexRes.get(0).key).isEqualTo(WifiSettings.DATA_KEY_REFERENCE);
- }
-
- @Test
- @Config(qualifiers = "mcc999")
- public void testSearchIndexProvider_ifWifiSettingsNotVisible_shouldNotIndexFragmentTitle() {
- final List<SearchIndexableRaw> indexRes =
- WifiSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext,
- true /* enabled */);
-
- assertThat(indexRes).isEmpty();
- }
-
- @Test
public void addNetworkFragmentSendResult_onActivityResult_shouldHandleEvent() {
final WifiSettings wifiSettings = spy(new WifiSettings());
final Intent intent = new Intent();
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
index 2fe7c5c..4ed85c6 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;
@@ -52,7 +54,6 @@
import com.android.settings.datausage.DataUsagePreference;
import com.android.settings.testutils.shadow.ShadowDataUsageUtils;
import com.android.settings.testutils.shadow.ShadowFragment;
-import com.android.settingslib.search.SearchIndexableRaw;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.WifiTracker;
@@ -100,26 +101,6 @@
}
@Test
- public void testSearchIndexProvider_shouldIndexFragmentTitle() {
- final List<SearchIndexableRaw> indexRes =
- WifiSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext,
- true /* enabled */);
-
- assertThat(indexRes).isNotNull();
- assertThat(indexRes.get(0).key).isEqualTo(WifiSettings.DATA_KEY_REFERENCE);
- }
-
- @Test
- @Config(qualifiers = "mcc999")
- public void testSearchIndexProvider_ifWifiSettingsNotVisible_shouldNotIndexFragmentTitle() {
- final List<SearchIndexableRaw> indexRes =
- WifiSettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext,
- true /* enabled */);
-
- assertThat(indexRes).isEmpty();
- }
-
- @Test
public void addNetworkFragmentSendResult_onActivityResult_shouldHandleEvent() {
final WifiSettings wifiSettings = spy(new WifiSettings());
final Intent intent = new Intent();
@@ -145,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;
diff --git a/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
index ae236bf..955b721 100644
--- a/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
@@ -26,6 +26,7 @@
import android.app.settings.SettingsEnums;
import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
import android.net.wifi.WifiNetworkSuggestion;
import android.os.Bundle;
import android.os.Parcelable;
@@ -59,7 +60,8 @@
private static final String FAKE_NEW_SAVED_WPA_SSID = "\"fake_new_wpa_ssid\"";
private static final String KEY_SSID = "key_ssid";
private static final String KEY_SECURITY = "key_security";
- private static final int SCANED_LEVEL = 4;
+ private static final int SCANED_LEVEL0 = 0;
+ private static final int SCANED_LEVEL4 = 4;
private AddAppNetworksFragment mAddAppNetworksFragment;
private List<WifiNetworkSuggestion> mFakedSpecifiedNetworksList;
@@ -76,6 +78,9 @@
@Mock
private WifiTracker mMockWifiTracker;
+ @Mock
+ private WifiManager mMockWifiManager;
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
@@ -86,10 +91,13 @@
WifiConfiguration.KeyMgmt.NONE, null);
mSavedWpaConfigurationEntry = generateRegularWifiConfiguration(FAKE_NEW_SAVED_WPA_SSID,
WifiConfiguration.KeyMgmt.WPA_PSK, "\"1234567890\"");
+ when(mMockWifiTracker.getManager()).thenReturn(mMockWifiManager);
+ when(mMockWifiManager.isWifiEnabled()).thenReturn(true);
+
mAddAppNetworksFragment.mWifiTracker = mMockWifiTracker;
WifiTrackerFactory.setTestingWifiTracker(mMockWifiTracker);
- setUpOneScannedNetworkWithScanedLevel();
+ setUpOneScannedNetworkWithScanedLevel4();
}
@Test
@@ -208,6 +216,7 @@
@Test
public void withOneSuggestion_whenScanResultChanged_uiListShouldHaveNewLevel() {
// Arrange
+ when(mAddAppNetworksFragment.mWifiTracker.getManager().isWifiEnabled()).thenReturn(true);
// Setup a fake saved network list and assign to fragment.
addOneSavedNetworkConfiguration(mSavedWpaConfigurationEntry);
// Setup one specified networks and its results and assign to fragment.
@@ -221,16 +230,36 @@
// Assert
assertThat(mAddAppNetworksFragment.mUiToRequestedList.get(0).mLevel).isEqualTo(
- SCANED_LEVEL);
+ SCANED_LEVEL4);
}
- private void setUpOneScannedNetworkWithScanedLevel() {
+ @Test
+ public void withOneSuggestion_whenScanResultChangedButWifiOff_uiListShouldHaveZeroLevel() {
+ // Arrange
+ when(mAddAppNetworksFragment.mWifiTracker.getManager().isWifiEnabled()).thenReturn(false);
+ // Setup a fake saved network list and assign to fragment.
+ addOneSavedNetworkConfiguration(mSavedWpaConfigurationEntry);
+ // Setup one specified networks and its results and assign to fragment.
+ addOneSpecifiedRegularNetworkSuggestion(mNewOpenSuggestionEntry);
+ mAddAppNetworksFragment.mAllSpecifiedNetworksList = mFakedSpecifiedNetworksList;
+ // Call filterSavedNetworks to generate necessary objects.
+ mAddAppNetworksFragment.filterSavedNetworks(mFakeSavedNetworksList);
+
+ // Act
+ mAddAppNetworksFragment.onAccessPointsChanged();
+
+ // Assert
+ assertThat(mAddAppNetworksFragment.mUiToRequestedList.get(0).mLevel).isEqualTo(
+ SCANED_LEVEL0);
+ }
+
+ private void setUpOneScannedNetworkWithScanedLevel4() {
final ArrayList list = new ArrayList<>();
list.add(mMockAccessPoint);
when(mMockWifiTracker.getAccessPoints()).thenReturn(list);
when(mMockAccessPoint.getSsidStr()).thenReturn(FAKE_NEW_OPEN_SSID);
when(mMockAccessPoint.matches(any(WifiConfiguration.class))).thenReturn(true);
- when(mMockAccessPoint.getLevel()).thenReturn(SCANED_LEVEL);
+ when(mMockAccessPoint.getLevel()).thenReturn(SCANED_LEVEL4);
}
private void addOneSavedNetworkConfiguration(@NonNull WifiConfiguration wifiConfiguration) {
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
index b4ad167..e864ce3 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/ListWithEntrySummaryPreferenceTest.java
@@ -28,14 +28,13 @@
import com.android.settings.R;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowLooper;
@RunWith(RobolectricTestRunner.class)
-@Ignore
public class ListWithEntrySummaryPreferenceTest {
private Context mContext;
@@ -55,6 +54,7 @@
public void setUp() {
mContext = RuntimeEnvironment.application;
mContext.setTheme(R.style.Theme_Settings_Home);
+ ShadowLooper.pauseMainLooper();
mPreference = new ListWithEntrySummaryPreference(mContext, null);
mPreference.setEntries(mDefaultEntries);
mPreference.setEntryValues(mDefaultEntryValues);
@@ -62,7 +62,7 @@
}
@Test
- public void initialize_defaultEntries_shouldDisplayDefalutEntries() {
+ public void initialize_defaultEntries_shouldDisplayDefaultEntries() {
AlertDialog dialog = showDialog(mPreference);
ListAdapter adapter = dialog.getListView().getAdapter();
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsTest.java
index 7957ae0..dc3b2b0 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsTest.java
@@ -18,13 +18,13 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
+import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
@@ -32,14 +32,19 @@
import androidx.fragment.app.FragmentActivity;
+import com.android.ims.ImsManager;
import com.android.settings.R;
import com.android.settings.network.SubscriptionUtil;
+import com.android.settings.network.ims.MockWifiCallingQueryImsState;
import com.android.settings.widget.RtlCompatibleViewPager;
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.androidx.fragment.FragmentController;
import java.util.ArrayList;
@@ -48,12 +53,38 @@
@RunWith(RobolectricTestRunner.class)
public class WifiCallingSettingsTest {
+ private static final int SUB_ID1 = 111;
+ private static final int SUB_ID2 = 222;
+
+ private Context mContext;
+
+ @Mock
+ private ImsManager mImsManager;
private WifiCallingSettings mFragment;
+ private MockWifiCallingQueryImsState mQueryImsState1;
+ private MockWifiCallingQueryImsState mQueryImsState2;
+
@Before
public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = spy(RuntimeEnvironment.application);
+
+ mQueryImsState1 = spy(new MockWifiCallingQueryImsState(mContext, SUB_ID1));
+ mQueryImsState2 = spy(new MockWifiCallingQueryImsState(mContext, SUB_ID2));
+ doReturn(true).when(mQueryImsState1).isEnabledByUser();
+ doReturn(true).when(mQueryImsState2).isEnabledByUser();
+ doReturn(mImsManager).when(mQueryImsState1).getImsManager(anyInt());
+ doReturn(mImsManager).when(mQueryImsState2).getImsManager(anyInt());
+ doReturn(true).when(mImsManager).isWfcEnabledByPlatform();
+ mQueryImsState1.setIsProvisionedOnDevice(true);
+ mQueryImsState2.setIsProvisionedOnDevice(true);
+
mFragment = spy(new WifiCallingSettings());
+ doReturn(mQueryImsState1).when(mFragment).queryImsState(SUB_ID1);
+ doReturn(mQueryImsState2).when(mFragment).queryImsState(SUB_ID2);
}
@Test
@@ -65,12 +96,12 @@
@Test
public void setupFragment_oneSubscription_noCrash() {
final SubscriptionInfo info = mock(SubscriptionInfo.class);
- when(info.getSubscriptionId()).thenReturn(111);
+ when(info.getSubscriptionId()).thenReturn(SUB_ID1);
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
Collections.singletonList(info)));
- doReturn(true).when(mFragment).isWfcEnabledByPlatform(any(SubscriptionInfo.class));
- doReturn(true).when(mFragment).isWfcProvisionedOnDevice(any(SubscriptionInfo.class));
+ doReturn(true).when(mImsManager).isWfcEnabledByPlatform();
+ mQueryImsState1.setIsProvisionedOnDevice(true);
final Intent intent = new Intent();
intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
@@ -88,13 +119,11 @@
public void setupFragment_twoSubscriptions_correctSelection() {
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
- when(info1.getSubscriptionId()).thenReturn(111);
- when(info2.getSubscriptionId()).thenReturn(222);
+ when(info1.getSubscriptionId()).thenReturn(SUB_ID1);
+ when(info2.getSubscriptionId()).thenReturn(SUB_ID2);
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
Arrays.asList(info1, info2)));
- doReturn(true).when(mFragment).isWfcEnabledByPlatform(any(SubscriptionInfo.class));
- doReturn(true).when(mFragment).isWfcProvisionedOnDevice(any(SubscriptionInfo.class));
final Intent intent = new Intent();
intent.putExtra(Settings.EXTRA_SUB_ID, info2.getSubscriptionId());
@@ -114,14 +143,12 @@
public void setupFragment_twoSubscriptionsOneNotProvisionedOnDevice_oneResult() {
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
- when(info1.getSubscriptionId()).thenReturn(111);
- when(info2.getSubscriptionId()).thenReturn(222);
+ when(info1.getSubscriptionId()).thenReturn(SUB_ID1);
+ when(info2.getSubscriptionId()).thenReturn(SUB_ID2);
SubscriptionUtil.setActiveSubscriptionsForTesting(new ArrayList<>(
Arrays.asList(info1, info2)));
- doReturn(true).when(mFragment).isWfcEnabledByPlatform(any(SubscriptionInfo.class));
- doReturn(true).when(mFragment).isWfcProvisionedOnDevice(eq(info1));
- doReturn(false).when(mFragment).isWfcProvisionedOnDevice(eq(info2));
+ mQueryImsState2.setIsProvisionedOnDevice(false);
final Intent intent = new Intent();
intent.putExtra(Settings.EXTRA_SUB_ID, info1.getSubscriptionId());
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);
diff --git a/tests/uitests/assets/search_results_list b/tests/uitests/assets/search_results_list
index f2536ef..a6dafe2 100644
--- a/tests/uitests/assets/search_results_list
+++ b/tests/uitests/assets/search_results_list
@@ -224,7 +224,7 @@
Enable Bluetooth HCI snoop log;bt_hci_snoop_log
Enable GPU debug layers;enable_gpu_debug_layers
Enable Wi-Fi Verbose Logging;wifi_verbose_logging
-Enable for all apps;game_driver_all_apps_preference
+Enable for all apps;graphics_driver_all_apps_preference
Enable freeform windows;enable_freeform_support
Enable view attribute inspection;debug_view_attributes
Encrypt phone;encryption_and_credentials_encryption_status
@@ -256,7 +256,7 @@
Force desktop mode;force_desktop_mode_on_external_displays
Force full GNSS measurements;enable_gnss_raw_meas_full_tracking
Free up space;storage_settings_free_space
-Game Driver Preferences;game_driver_settings
+Graphics Driver Preferences;graphics_driver_settings
Games;pref_games
Gestures;gesture_settings
Gestures;gesture_settings_screen
@@ -612,7 +612,7 @@
Wallpaper;wallpaper
Wallpapers;wallpaper_attributions
WebView implementation;select_webview_provider
-When Game Driver is turned on, you can pick to use the updated graphics driver for Apps installed on the device.;game_driver_footer
+When there are multiple graphics drivers, you can pick to use the updated graphics driver for Apps installed on the device.;graphics_driver_footer
When device is in VR;vr_display_pref
When to start;when_to_start
Wi-Fi;main_toggle_wifi
diff --git a/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java b/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
index 4ebfef7..bc8a52a 100644
--- a/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
+++ b/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java
@@ -316,7 +316,8 @@
assertThat(accessPoint.getConfig()).isNotNull();
NetworkSelectionStatus networkStatus = accessPoint.getConfig().getNetworkSelectionStatus();
assertThat(networkStatus).isNotNull();
- assertThat(networkStatus.isNetworkEnabled()).isFalse();
+ assertThat(networkStatus.getNetworkSelectionStatus())
+ .isEqualTo(NetworkSelectionStatus.NETWORK_SELECTION_TEMPORARY_DISABLED);
assertThat(networkStatus.getNetworkSelectionDisableReason()).isEqualTo(
NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);