Merge "Add listener for panel header icon"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d2bdc9f..4996aeb 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -384,12 +384,10 @@
android:value="true" />
</activity>
- <!-- Runs in the phone process since it needs access to UiccController -->
<activity android:name="Settings$ApnSettingsActivity"
android:label="@string/apn_settings"
android:launchMode="singleTask"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:process="com.android.phone">
+ android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter android:priority="1">
<action android:name="android.settings.APN_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1199,6 +1197,10 @@
<activity
android:name=".notification.history.NotificationHistoryActivity"
android:label="@string/notification_history_title">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.NOTIFICATION_HISTORY" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1418,8 +1420,7 @@
</activity>
<activity android:name="Settings$IccLockSettingsActivity"
- android:label="@string/sim_lock_settings"
- android:process="com.android.phone">
+ android:label="@string/sim_lock_settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/protos/contextual_card_list.proto b/protos/contextual_card_list.proto
index 69c3741..54e5654 100644
--- a/protos/contextual_card_list.proto
+++ b/protos/contextual_card_list.proto
@@ -19,6 +19,7 @@
POSSIBLE = 2;
IMPORTANT = 3;
DEFERRED_SETUP = 5;
+ STICKY = 6;
}
/** Slice uri of the contextual card */
diff --git a/res/drawable/ic_analytics_grey.xml b/res/drawable/ic_analytics_grey.xml
new file mode 100644
index 0000000..f0bbdb9
--- /dev/null
+++ b/res/drawable/ic_analytics_grey.xml
@@ -0,0 +1,21 @@
+<!--
+ ~ 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 android:autoMirrored="true" android:height="24dp"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#757575" android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM9,17L7,17v-5h2v5zM13,17h-2v-3h2v3zM13,12h-2v-2h2v2zM17,17h-2L15,7h2v10z"/>
+</vector>
diff --git a/res/drawable/ic_storage_grey.xml b/res/drawable/ic_storage_grey.xml
new file mode 100644
index 0000000..420aba8
--- /dev/null
+++ b/res/drawable/ic_storage_grey.xml
@@ -0,0 +1,21 @@
+<!--
+ ~ 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 android:autoMirrored="true" android:height="24dp"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#757575" android:pathData="M2,20h20v-4L2,16v4zM4,17h2v2L4,19v-2zM2,4v4h20L22,4L2,4zM6,7L4,7L4,5h2v2zM2,14h20v-4L2,10v4zM4,11h2v2L4,13v-2z"/>
+</vector>
diff --git a/res/layout/accessibility_autoclick_custom_seekbar.xml b/res/layout/accessibility_autoclick_custom_seekbar.xml
index 0a60cff..283530b 100644
--- a/res/layout/accessibility_autoclick_custom_seekbar.xml
+++ b/res/layout/accessibility_autoclick_custom_seekbar.xml
@@ -31,12 +31,12 @@
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.TextView" />
<LinearLayout
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<ImageView
- android:id="@+id/smaller"
+ android:id="@+id/shorter"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
@@ -49,12 +49,13 @@
<SeekBar
android:id="@+id/autoclick_delay"
- android:layout_width="260dp"
+ android:layout_width="0dp"
android:layout_height="48dp"
+ android:layout_weight="1"
android:contentDescription="@string/accessibility_autoclick_seekbar_desc" />
<ImageView
- android:id="@+id/larger"
+ android:id="@+id/longer"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
diff --git a/res/layout/contextual_slice_full_tile.xml b/res/layout/contextual_slice_full_tile.xml
index 1438cfb..4b1155e 100644
--- a/res/layout/contextual_slice_full_tile.xml
+++ b/res/layout/contextual_slice_full_tile.xml
@@ -21,23 +21,17 @@
android:layout_height="wrap_content"
style="@style/ContextualCardStyle">
- <FrameLayout
+ <include layout="@layout/dismissal_swipe_background"/>
+
+ <androidx.slice.widget.SliceView
+ android:id="@+id/slice_view"
+ android:theme="@style/Theme.Settings.ContextualCard"
+ style="@style/ContextualCardSliceViewStyle"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="wrap_content"
+ android:importantForAccessibility="no"/>
- <include layout="@layout/dismissal_swipe_background"/>
+ <!--dismissal view-->
+ <include layout="@layout/contextual_card_dismissal_view"/>
- <androidx.slice.widget.SliceView
- android:id="@+id/slice_view"
- android:theme="@style/Theme.Settings.ContextualCard"
- style="@style/ContextualCardSliceViewStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:importantForAccessibility="no"/>
-
- <!--dismissal view-->
- <include layout="@layout/contextual_card_dismissal_view"/>
-
- </FrameLayout>
</com.google.android.material.card.MaterialCardView>
\ No newline at end of file
diff --git a/res/layout/contextual_slice_sticky_tile.xml b/res/layout/contextual_slice_sticky_tile.xml
index 117732d..734697f 100644
--- a/res/layout/contextual_slice_sticky_tile.xml
+++ b/res/layout/contextual_slice_sticky_tile.xml
@@ -15,11 +15,12 @@
limitations under the License.
-->
-<com.google.android.material.card.MaterialCardView
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/ContextualCardStyle">
+ android:orientation="vertical"
+ style="@style/StickyCardStyle">
<androidx.slice.widget.SliceView
android:id="@+id/slice_view"
@@ -27,7 +28,9 @@
style="@style/ContextualCardSliceViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
+ android:layout_marginBottom="@dimen/contextual_card_vertical_margin"
android:importantForAccessibility="no"/>
-</com.google.android.material.card.MaterialCardView>
\ No newline at end of file
+ <include layout="@layout/horizontal_divider"/>
+
+</LinearLayout>
diff --git a/res/layout/interact_across_profiles_consent_dialog.xml b/res/layout/interact_across_profiles_consent_dialog.xml
new file mode 100644
index 0000000..6052508
--- /dev/null
+++ b/res/layout/interact_across_profiles_consent_dialog.xml
@@ -0,0 +1,114 @@
+<?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.
+ -->
+
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/interact_across_profiles_dialog_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="24dp"
+ android:paddingEnd="24dp"
+ android:orientation="horizontal">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <LinearLayout
+ android:id="@+id/interact_across_profiles_dialog"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:gravity="start"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/interact_across_profiles_consent_dialog_title"
+ android:text="@string/interact_across_profiles_consent_dialog_title"
+ style="@style/CrossProfileConsentDialogTitle"/>
+
+ <TextView
+ android:id="@+id/interact_across_profiles_consent_dialog_summary"
+ android:text="@string/interact_across_profiles_consent_dialog_summary"
+ style="@style/CrossProfileConsentDialogDescription"/>
+
+ <LinearLayout
+ android:id="@+id/app_data_content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="16pt"
+ android:gravity="start"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/app_data_icon"
+ android:src="@drawable/ic_analytics_grey"
+ style="@style/CrossProfileConsentDialogIcon"/>
+
+ <LinearLayout
+ android:id="@+id/app_data_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingStart="16dp"
+ android:gravity="start"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/app_data_title"
+ android:text="@string/interact_across_profiles_consent_dialog_app_data_title"
+ style="@style/CrossProfileConsentDialogSubTitle"/>
+
+ <TextView
+ android:id="@+id/app_data_summary"
+ android:text="@string/interact_across_profiles_consent_dialog_app_data_summary"
+ style="@style/CrossProfileConsentDialogSubDescription"/>
+ </LinearLayout>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/permissions_content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="start"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/permissions_icon"
+ android:src="@drawable/ic_storage_grey"
+ style="@style/CrossProfileConsentDialogIcon"/>
+
+ <LinearLayout
+ android:id="@+id/permissions_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="start"
+ android:paddingStart="16dp"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/permissions_title"
+ android:text="@string/interact_across_profiles_consent_dialog_permissions_title"
+ style="@style/CrossProfileConsentDialogSubTitle"/>
+
+ <TextView
+ android:id="@+id/permissions_summary"
+ android:text="@string/interact_across_profiles_consent_dialog_permissions_summary"
+ style="@style/CrossProfileConsentDialogSubDescription"/>
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+ </ScrollView>
+</RelativeLayout>
diff --git a/res/layout/notification_history.xml b/res/layout/notification_history.xml
index a97afb6..b3308c5 100644
--- a/res/layout/notification_history.xml
+++ b/res/layout/notification_history.xml
@@ -19,8 +19,7 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:id="@+id/scroll"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@*android:color/material_grey_50">
+ android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
@@ -100,17 +99,13 @@
android:layout_height="wrap_content"
android:clipChildren="true"
android:elevation="3dp"
- android:background="@drawable/rounded_bg"
- settings:layout_constraintHeight_max="200dp"
- settings:layout_constrainedHeight="true">
+ android:background="@drawable/rounded_bg">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/notification_list"
android:layout_width="match_parent"
- android:layout_height="0dp"
+ android:layout_height="wrap_content"
android:clipChildren="true"
- settings:layout_constraintHeight_max="300dp"
- settings:layout_constrainedHeight="true"
settings:fastScrollEnabled="true"
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
@@ -144,10 +139,8 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/notification_list"
android:layout_width="match_parent"
- android:layout_height="0dp"
+ android:layout_height="wrap_content"
android:clipChildren="true"
- settings:layout_constraintHeight_max="300dp"
- settings:layout_constrainedHeight="true"
settings:fastScrollEnabled="true"
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
diff --git a/res/layout/notification_history_app_layout.xml b/res/layout/notification_history_app_layout.xml
index 84fe91b..4c899e6 100644
--- a/res/layout/notification_history_app_layout.xml
+++ b/res/layout/notification_history_app_layout.xml
@@ -47,7 +47,7 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
android:paddingStart="8dp" />
</LinearLayout>
<TextView
@@ -56,9 +56,8 @@
android:layout_width="wrap_content"
android:paddingStart="6dp"
android:layout_gravity="center_vertical"
- android:fontFamily="sans-serif-medium"
android:paddingTop="8dp"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"/>
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"/>
</LinearLayout>
<ImageButton
android:id="@+id/expand"
diff --git a/res/layout/notification_history_log_row.xml b/res/layout/notification_history_log_row.xml
index 748e134..136af38 100644
--- a/res/layout/notification_history_log_row.xml
+++ b/res/layout/notification_history_log_row.xml
@@ -40,8 +40,7 @@
android:layout_centerVertical="true"
android:ellipsize="end"
android:singleLine="true"
- android:fontFamily="sans-serif-medium"
- android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textAlignment="viewStart"/>
<ImageView
@@ -65,8 +64,7 @@
android:layout_centerVertical="true"
android:ellipsize="end"
android:singleLine="true"
- android:textColor="?android:attr/textColorPrimary"
- android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
android:textAlignment="viewEnd"
/>
</RelativeLayout>
@@ -79,8 +77,7 @@
android:ellipsize="end"
android:singleLine="true"
android:paddingTop="3dp"
- android:textColor="?android:attr/textColorPrimary"
- android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
android:textAlignment="viewStart" />
</LinearLayout>
diff --git a/res/layout/notification_sbn_log_row.xml b/res/layout/notification_sbn_log_row.xml
index 39b918d..e94150d 100644
--- a/res/layout/notification_sbn_log_row.xml
+++ b/res/layout/notification_sbn_log_row.xml
@@ -95,8 +95,7 @@
android:layout_centerVertical="true"
android:ellipsize="end"
android:singleLine="true"
- android:textColor="?android:attr/textColorPrimary"
- android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
android:textAlignment="viewEnd"
/>
</RelativeLayout>
@@ -116,7 +115,7 @@
android:layout_gravity="left|center_vertical"
android:ellipsize="end"
android:singleLine="true"
- android:textColor="?android:attr/textColorPrimary"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
android:textAlignment="viewStart"
/>
@@ -127,8 +126,7 @@
android:layout_gravity="left|center_vertical"
android:ellipsize="end"
android:singleLine="true"
- android:textColor="?android:attr/textColorPrimary"
- android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
android:textAlignment="viewStart"
/>
diff --git a/res/layout/palette_listview_item.xml b/res/layout/palette_listview_item.xml
index e8cc940..3342ef1 100644
--- a/res/layout/palette_listview_item.xml
+++ b/res/layout/palette_listview_item.xml
@@ -22,10 +22,12 @@
<TextView
android:id="@+id/item_textview"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingLeft="10dp"
- android:textSize="20dp"
+ android:layout_height="42dp"
+ android:fontFamily="roboto-bold"
+ android:gravity="center_vertical"
android:maxLength="20"
- android:singleLine="true"/>
+ android:paddingLeft="@dimen/accessibility_layout_margin_start_end"
+ android:singleLine="true"
+ android:textSize="14dp" />
</FrameLayout>
diff --git a/res/layout/zen_mode_settings_button.xml b/res/layout/zen_mode_settings_button.xml
index 14fe644..49aa287 100644
--- a/res/layout/zen_mode_settings_button.xml
+++ b/res/layout/zen_mode_settings_button.xml
@@ -23,13 +23,6 @@
android:paddingVertical="@dimen/zen_mode_button_padding_vertical">
<TextView
- android:text="@string/zen_mode_settings_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="@dimen/screen_margin_sides"
- android:textAppearance="@android:style/TextAppearance.DeviceDefault.Large"/>
-
- <TextView
android:text="@string/zen_mode_settings_summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index f79874c..024569b 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -82,6 +82,7 @@
<dimen name="notification_importance_button_padding">14dp</dimen>
<dimen name="notification_history_header_drawable_start">26dp</dimen>
+ <dimen name="conversation_icon_size">48dp</dimen>
<dimen name="zen_mode_button_padding_vertical">16dp</dimen>
<dimen name="zen_schedule_rule_checkbox_padding">7dp</dimen>
@@ -266,7 +267,7 @@
<dimen name="message_metadata_top_padding">4dp</dimen>
<!-- Accessibility Settings -->
- <dimen name="accessibility_layout_margin_start_end">24dp</dimen>
+ <dimen name="accessibility_layout_margin_start_end">16dp</dimen>
<dimen name="accessibility_button_preference_padding_top_bottom">18dp</dimen>
<!-- Accessibility, Screen magnification. These values are meant to be relative values and the actual layout value will be set programmatically. -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3effe22..adf414f2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3750,6 +3750,31 @@
<!-- Tethering controls, footer note displayed when tethering is disabled because Data Saver mode is on [CHAR LIMIT=none]-->
<string name="tether_settings_disabled_on_data_saver">"Can\u2019t tether or use portable hotspots while Data Saver is on"</string>
+ <!-- Tethering setting summary when only Wi-Fi hotspot is on [CHAR LIMIT=NONE]-->
+ <string name="tether_settings_summary_hotspot_only">Hotspot only</string>
+ <!-- Tethering setting summary when only USB tethering is on [CHAR LIMIT=NONE]-->
+ <string name="tether_settings_summary_usb_tethering_only">USB only</string>
+ <!-- Tethering setting summary when only Bluetooth tethering is on [CHAR LIMIT=NONE]-->
+ <string name="tether_settings_summary_bluetooth_tethering_only">Bluetooth only</string>
+ <!-- Tethering setting summary when Wi-Fi hotspot and USB tethering are on [CHAR LIMIT=NONE]-->
+ <string name="tether_settings_summary_hotspot_and_usb">Hotspot, USB</string>
+ <!-- Tethering setting summary when Wi-Fi hotspot and Bluetooth tethering are on [CHAR LIMIT=NONE]-->
+ <string name="tether_settings_summary_hotspot_and_bluetooth">Hotspot, Bluetooth</string>
+ <!-- Tethering setting summary when USB and Bluetooth tethering are on [CHAR LIMIT=NONE]-->
+ <string name="tether_settings_summary_usb_and_bluetooth">USB, Bluetooth</string>
+ <!-- Tethering setting summary when Wi-Fi hotspot and USB and Bluetooth tethering are on [CHAR LIMIT=NONE]-->
+ <string name="tether_settings_summary_hotspot_and_usb_and_bluetooth">Hotspot, USB, Bluetooth</string>
+ <!-- Tethering setting summary when hotspot and tethering are off [CHAR LIMIT=NONE]-->
+ <string name="tether_settings_summary_off">Not sharing internet with other devices</string>
+
+ <!-- Disable Wifi Hotspot option-->
+ <!-- Don't use Wi-Fi hotspot summary when USB tethering is chosen [CHAR LIMIT=NONE]-->
+ <string name="disable_wifi_hotspot_when_usb_on">Only share internet via USB</string>
+ <!-- Don't use Wi-Fi hotspot summary when Bluetooth tethering is chosen [CHAR LIMIT=NONE]-->
+ <string name="disable_wifi_hotspot_when_bluetooth_on">Only share internet via Bluetooth</string>
+ <!-- Don't use Wi-Fi hotspot summary when USB tethering and Bluetooth tethering are chosen [CHAR LIMIT=NONE]-->
+ <string name="disable_wifi_hotspot_when_usb_and_bluetooth_on">Only share internet via USB and Bluetooth</string>
+
<!-- USB Tethering options -->
<string name="usb_title">USB</string>
<string name="usb_tethering_button_text">USB tethering</string>
@@ -4822,7 +4847,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">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>
+ <string name="accessibility_screen_magnification_summary"><![CDATA[Quickly zoom in on the screen to see content more clearly.<br/><br/><b>To zoom in:</b><br/>\t1. Use shortcut to start magnification<br/>\t2. Tap the screen<br/>\t3. Drag 2 fingers to move around screen<br/>\t4. Pinch with 2 fingers to adjust zoom<br/>\t5. Use shortcut to stop magnification<br/><br/><b>To zoom in temporarily:</b><br/>\t1. Use shortcut to start magnification<br/>\t2. Touch & hold anywhere on the screen<br/>\t3. Drag finger to move around screen<br/>\t4. Lift finger 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] -->
@@ -4932,12 +4957,12 @@
<!-- 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">Use color inversion</string>
<!-- Subtitle for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
- <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>
+ <string name="accessibility_display_inversion_preference_subtitle"><![CDATA[Color inversion turns light screens dark. This helps people who are sensitive to bright light see the screen more easily.<br/><br/>Note: 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] -->
+ <!-- Option heading to leave the auto click requirement for accessibility users at its default level. [CHAR LIMIT=50] -->
<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>
@@ -4958,7 +4983,7 @@
<!-- Description for the button that longer auto click time. [CHAR_LIMIT=NONE] -->
<string name="accessibility_autoclick_longer_desc">Longer</string>
<!-- Description for the seekbar that adjust auto click time. [CHAR_LIMIT=NONE] -->
- <string name="accessibility_autoclick_seekbar_desc">auto click time</string>
+ <string name="accessibility_autoclick_seekbar_desc">Auto click time</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. -->
@@ -8057,6 +8082,9 @@
<!-- Notification history screen; summary when history is off [CHAR LIMIT=200] -->
<string name="notification_history_off_title_extended">Notification history is turned off</string>
+ <!-- Notification history screen; content description describing what happens when you tap on a notification history entry [CHAR LIMIT=NONE] -->
+ <string name="notification_history_view_settings">view notification settings</string>
+
<!-- Configure Notifications: setting title, whether the snooze menu is shown on notifications [CHAR LIMIT=80] -->
<string name="snooze_options_title">Allow notification snoozing</string>
@@ -8445,33 +8473,55 @@
<!-- 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>
+ <string name="interact_across_profiles_title" translatable="false">Connected personal and work apps</string>
- <!-- Special access > Connected work and personal apps > Text to display when the list is empty. [CHAR LIMIT=NONE] -->
+ <!-- Special access > Connected personal and work 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] -->
+ <!-- Special access > Connected personal and work 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>
+ <string name="interact_across_profiles_app_detail_title" translatable="false">Connected personal and work 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 personal and work apps > Switch title. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_switch_enabled" translatable="false">Connected</string>
- <!-- Apps > App Details > Connected work and personal apps > Description. [CHAR LIMIT=NONE] -->
+ <!-- Apps > App Details > Connected personal and work apps > Switch title. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_switch_disabled" translatable="false">Connect these apps</string>
+
+ <!-- Apps > App Details > Connected personal and work 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] -->
+ <!-- Apps > App Details > Connected personal and work 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>
+ <!-- Apps > App Details > Connected personal and work apps > Consent dialog title. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_title" translatable="false">Trust work %1$s 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>
+ <!-- Apps > App Details > Connected personal and work apps > Consent dialog description. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_summary" translatable="false">%1$s may expose your personal data to your IT admin.</string>
+
+ <!-- Apps > App Details > Connected personal and work apps > Consent dialog App data title. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_app_data_title" translatable="false">App data</string>
+
+ <!-- Apps > App Details > Connected personal and work apps > Consent dialog App data description. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_app_data_summary" translatable="false">It can access data in your personal %1$s app.</string>
+
+ <!-- Apps > App Details > Connected personal and work apps > Consent dialog Permissions title. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_permissions_title" translatable="false">Permissions</string>
+
+ <!-- Apps > App Details > Connected personal and work apps > Consent dialog Permissions description. [CHAR LIMIT=NONE] -->
+ <string name="interact_across_profiles_consent_dialog_permissions_summary" translatable="false">It can use your personal %1$s app\u2019s permissions, like access to location, storage, or contacts.</string>
+
+ <!-- Summary of preference to manage connected personal and work apps, informing the user that currently no apps are connected -->
+ <string name="interact_across_profiles_number_of_connected_apps_none" translatable="false">No apps connected</string>
+
+ <!-- Summary of preference to manage connected personal and work apps, informing the user how many apps are connected -->
+ <plurals name="interact_across_profiles_number_of_connected_apps" translatable="false">
+ <item quantity="one"><xliff:g id="count">%d</xliff:g> app connected</item>
+ <item quantity="other"><xliff:g id="count">%d</xliff:g> apps connected</item>
+ </plurals>
<!-- 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>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 02998ae..c42fab2 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -423,6 +423,12 @@
<item name="rippleColor">?android:attr/colorControlHighlight</item>
</style>
+ <style name="StickyCardStyle">
+ <item name="android:layout_marginBottom">@dimen/contextual_card_vertical_margin</item>
+ <item name="android:layout_marginStart">@dimen/contextual_card_side_margin</item>
+ <item name="android:layout_marginEnd">@dimen/contextual_card_side_margin</item>
+ </style>
+
<style name="SearchBarStyle">
<item name="android:layout_margin">@dimen/search_bar_margin</item>
<item name="cardCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
@@ -637,4 +643,49 @@
<item name="android:clipChildren">true</item>
</style>
+ <style name="CrossProfileConsentDialogTitle">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:gravity">center</item>
+ <item name="android:textSize">20sp</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:fontFamily">google-sans-medium</item>
+ <item name="android:paddingTop">36dp</item>
+ <item name="android:paddingBottom">16dp</item>
+ </style>
+
+ <style name="CrossProfileConsentDialogDescription">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_marginBottom">36dp</item>
+ <item name="android:textSize">16sp</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:fontFamily">sans-serif</item>
+ <item name="android:gravity">start</item>
+ </style>
+
+ <style name="CrossProfileConsentDialogIcon">
+ <item name="android:layout_width">24dp</item>
+ <item name="android:layout_height">24dp</item>
+ <item name="android:antialias">true</item>
+ <item name="android:gravity">start</item>
+ </style>
+
+ <style name="CrossProfileConsentDialogSubTitle">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textSize">16sp</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:fontFamily">sans-serif</item>
+ <item name="android:gravity">start</item>
+ </style>
+
+ <style name="CrossProfileConsentDialogSubDescription">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:textColor">?android:attr/textColorSecondary</item>
+ <item name="android:fontFamily">sans-serif</item>
+ <item name="android:gravity">start</item>
+ </style>
</resources>
diff --git a/res/xml/accessibility_autoclick_settings.xml b/res/xml/accessibility_autoclick_settings.xml
index ad588f6..f126113 100644
--- a/res/xml/accessibility_autoclick_settings.xml
+++ b/res/xml/accessibility_autoclick_settings.xml
@@ -47,6 +47,7 @@
android:key="autoclick_custom_seekbar"
android:layout="@layout/accessibility_autoclick_custom_seekbar"
android:selectable="false"
+ android:visibility="gone"
settings:allowDividerBelow="true"
settings:controller="com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController" />
diff --git a/res/xml/accessibility_color_inversion_settings.xml b/res/xml/accessibility_color_inversion_settings.xml
index 9681001..ba0d6fd 100644
--- a/res/xml/accessibility_color_inversion_settings.xml
+++ b/res/xml/accessibility_color_inversion_settings.xml
@@ -31,17 +31,4 @@
settings:allowDividerBelow="true"
settings:searchable="false" />
- <PreferenceCategory
- android:key="color_inversion_footer_category">
-
- <com.android.settingslib.widget.FooterPreference
- android:key="color_inversion_footer"
- android:persistent="false"
- android:selectable="false"
- settings:allowDividerAbove="false"
- android:title="@string/accessibility_display_inversion_preference_subtitle"
- settings:searchable="false" />
-
- </PreferenceCategory>
-
</PreferenceScreen>
diff --git a/res/xml/accessibility_daltonizer_settings.xml b/res/xml/accessibility_daltonizer_settings.xml
index b2ab5ef..c98736b 100644
--- a/res/xml/accessibility_daltonizer_settings.xml
+++ b/res/xml/accessibility_daltonizer_settings.xml
@@ -52,16 +52,4 @@
</PreferenceCategory>
- <PreferenceCategory
- android:key="daltonizer_footer_category">
-
- <com.android.settingslib.widget.FooterPreference
- android:key="daltonizer_footer"
- android:persistent="false"
- android:selectable="false"
- settings:allowDividerAbove="false"
- android:title="@string/accessibility_display_daltonizer_preference_subtitle"
- settings:searchable="false" />
-
- </PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index b7b88ed..7ff68aa 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -17,16 +17,10 @@
<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">
- <Preference
- android:fragment="com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment"
- android:key="accessibility_shortcut_preference"
- android:persistent="false"
- android:title="@string/accessibility_global_gesture_preference_title"
- settings:controller="com.android.settings.accessibility.AccessibilityShortcutPreferenceController"/>
-
<PreferenceCategory
android:key="user_installed_services_category"
android:persistent="false"
@@ -198,7 +192,8 @@
<PreferenceCategory
android:key="experimental_category"
android:persistent="false"
- android:title="@string/experimental_category_title">
+ android:title="@string/experimental_category_title"
+ settings:initialExpandedChildrenCount="1">
<SwitchPreference
android:key="toggle_high_text_contrast_preference"
@@ -221,5 +216,14 @@
android:persistent="false"
android:title="@string/accessibility_display_inversion_preference_title"
settings:controller="com.android.settings.accessibility.ColorInversionPreferenceController"/>
+
+ <SwitchPreference
+ android:key="accessibility_shortcut_preference"
+ android:persistent="false"
+ android:title="@string/accessibility_shortcut_service_on_lock_screen_title"
+ android:summary="@string/accessibility_shortcut_description"
+ settings:controller="com.android.settings.accessibility.AccessibilityShortcutPreferenceController"/>
+
</PreferenceCategory>
+
</PreferenceScreen>
diff --git a/res/xml/accessibility_shortcut_settings.xml b/res/xml/accessibility_shortcut_settings.xml
deleted file mode 100644
index 0bfd6b6..0000000
--- a/res/xml/accessibility_shortcut_settings.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<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">
-
- <Preference
- 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" />
-
- <com.android.settingslib.widget.FooterPreference
- android:key="accessibility_shortcut_footer"
- android:selectable="false"
- android:title="@string/accessibility_shortcut_description"
- settings:searchable="false" />
-
-</PreferenceScreen>
diff --git a/res/xml/accounts_dashboard_settings.xml b/res/xml/accounts_dashboard_settings.xml
index c42e1c7..d2affc7 100644
--- a/res/xml/accounts_dashboard_settings.xml
+++ b/res/xml/accounts_dashboard_settings.xml
@@ -17,7 +17,9 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/account_dashboard_title">
+ android:key="user_and_account_settings_screen"
+ android:title="@string/account_dashboard_title"
+ settings:keywords="@string/keywords_accounts">
<PreferenceCategory
android:key="dashboard_tile_placeholder"
diff --git a/res/xml/all_tether_prefs.xml b/res/xml/all_tether_prefs.xml
index bc3471b..d16adc5 100644
--- a/res/xml/all_tether_prefs.xml
+++ b/res/xml/all_tether_prefs.xml
@@ -74,6 +74,7 @@
<SwitchPreference
android:key="disable_wifi_tethering"
android:title="Don't use Wi-Fi hotspot"
+ android:summary="@string/summary_placeholder"
settings:controller="com.android.settings.network.WifiTetherDisablePreferenceController"
settings:keywords="@string/keywords_hotspot_tethering" />
</PreferenceCategory>
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index aa1a6ee..f75bd86 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -18,6 +18,7 @@
<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/connected_devices.xml b/res/xml/connected_devices.xml
index 444b35c..a1736b2 100644
--- a/res/xml/connected_devices.xml
+++ b/res/xml/connected_devices.xml
@@ -17,6 +17,7 @@
<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
diff --git a/res/xml/connected_devices_advanced.xml b/res/xml/connected_devices_advanced.xml
index ba62380..bd8f1dd 100644
--- a/res/xml/connected_devices_advanced.xml
+++ b/res/xml/connected_devices_advanced.xml
@@ -21,7 +21,7 @@
<Preference
android:fragment="com.android.settings.connecteddevice.BluetoothDashboardFragment"
- android:key="bluetooth_settings"
+ android:key="bluetooth_switchbar_screen"
android:title="@string/bluetooth_settings_title"
android:icon="@*android:drawable/ic_settings_bluetooth"
android:order="-9"/>
diff --git a/res/xml/development_tile_settings.xml b/res/xml/development_tile_settings.xml
index e5bfbbf..558535fe 100644
--- a/res/xml/development_tile_settings.xml
+++ b/res/xml/development_tile_settings.xml
@@ -18,5 +18,7 @@
<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:searchable="false"
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 9a48761..6fbc139 100644
--- a/res/xml/device_admin_settings.xml
+++ b/res/xml/device_admin_settings.xml
@@ -19,6 +19,8 @@
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:searchable="false"
settings:controller="com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminListPreferenceController">
<com.android.settingslib.widget.FooterPreference
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 4bf0c82..35b7b4d 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -17,7 +17,9 @@
<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
diff --git a/res/xml/interact_across_profiles_permissions_details.xml b/res/xml/interact_across_profiles_permissions_details.xml
index e9a4803..8b1e043 100644
--- a/res/xml/interact_across_profiles_permissions_details.xml
+++ b/res/xml/interact_across_profiles_permissions_details.xml
@@ -24,15 +24,13 @@
android:selectable="false"/>
<SwitchPreference
- android:key="interact_across_profiles_settings_switch"
- android:title="@string/interact_across_profiles_app_detail_switch"/>
+ android:key="interact_across_profiles_settings_switch" />
<Preference
android:summary="@string/interact_across_profiles_summary_1"
- android:selectable="false"/>
+ android:selectable="false" />
<Preference
android:summary="@string/interact_across_profiles_summary_2"
- android:selectable="false"/>
-
+ android:selectable="false" />
</PreferenceScreen>
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index 6662c2f..fb03f4c 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -17,7 +17,9 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/location_settings_title">
+ android:key="location_settings"
+ android:title="@string/location_settings_title"
+ settings:keywords="@string/keywords_location">
<PreferenceCategory
android:key="recent_location_requests"
diff --git a/res/xml/manage_external_storage_permission_details.xml b/res/xml/manage_external_storage_permission_details.xml
index b540ff6..29ff297 100644
--- a/res/xml/manage_external_storage_permission_details.xml
+++ b/res/xml/manage_external_storage_permission_details.xml
@@ -14,7 +14,9 @@
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="manage_external_storage_permission_details"
android:title="@string/manage_external_storage_title">
@@ -22,8 +24,9 @@
android:key="app_ops_settings_switch"
android:title="@string/permit_manage_external_storage"/>
- <Preference
- android:summary="@string/allow_manage_external_storage_description"
- android:selectable="false"/>
+ <com.android.settingslib.widget.FooterPreference
+ android:title="@string/allow_manage_external_storage_description"
+ android:selectable="false"
+ settings:searchable="false"/>
</PreferenceScreen>
diff --git a/res/xml/my_device_info.xml b/res/xml/my_device_info.xml
index dbf1623..5e5fab3 100644
--- a/res/xml/my_device_info.xml
+++ b/res/xml/my_device_info.xml
@@ -18,6 +18,7 @@
<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
diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml
index c57c5b0..eaa7808 100644
--- a/res/xml/network_and_internet.xml
+++ b/res/xml/network_and_internet.xml
@@ -17,6 +17,7 @@
<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">
@@ -30,7 +31,7 @@
<com.android.settings.widget.MasterSwitchPreference
android:fragment="com.android.settings.wifi.WifiSettings"
- android:key="toggle_wifi"
+ android:key="main_toggle_wifi"
android:title="@string/wifi_settings"
android:summary="@string/summary_placeholder"
android:icon="@drawable/ic_settings_wireless"
@@ -79,6 +80,18 @@
settings:userRestriction="no_config_tethering"
settings:useAdminDisabledSummary="true" />
+ <com.android.settings.widget.MasterSwitchPreference
+ android:fragment="com.android.settings.AllInOneTetherSettings"
+ android:key="all_tether_settings"
+ android:title="@string/tether_settings_title_all"
+ android:icon="@drawable/ic_wifi_tethering"
+ android:order="6"
+ android:summary="@string/summary_placeholder"
+ settings:controller="com.android.settings.network.AllInOneTetherPreferenceController"
+ settings:keywords="@string/keywords_hotspot_tethering"
+ settings:userRestriction="no_config_tethering"
+ settings:useAdminDisabledSummary="true" />
+
<com.android.settings.datausage.DataSaverPreference
android:key="restrict_background_parent_entry"
android:title="@string/data_saver_title"
diff --git a/res/xml/notification_access_settings.xml b/res/xml/notification_access_settings.xml
index ca84f1b..43f7c49 100644
--- a/res/xml/notification_access_settings.xml
+++ b/res/xml/notification_access_settings.xml
@@ -18,5 +18,7 @@
<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:searchable="false"
settings:controller="com.android.settings.applications.specialaccess.notificationaccess.NotificationAccessScreenPreferenceController" />
diff --git a/res/xml/picture_in_picture_settings.xml b/res/xml/picture_in_picture_settings.xml
index 1f08246..c9e3a3f 100644
--- a/res/xml/picture_in_picture_settings.xml
+++ b/res/xml/picture_in_picture_settings.xml
@@ -18,5 +18,7 @@
<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:searchable="false"
settings:controller="com.android.settings.applications.specialaccess.pictureinpicture.PictureInPictureScreenPreferenceController" />
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index 869bb94..005ce17 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -17,7 +17,9 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/power_usage_summary_title">
+ android:key="power_usage_summary_screen"
+ android:title="@string/power_usage_summary_title"
+ settings:keywords="@string/keywords_battery">
<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 82aece3..ede6057 100644
--- a/res/xml/premium_sms_settings.xml
+++ b/res/xml/premium_sms_settings.xml
@@ -18,5 +18,7 @@
<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:searchable="false"
settings:controller="com.android.settings.applications.specialaccess.premiumsms.PremiumSmsScreenPreferenceController" />
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index abedc53..623460c 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -18,6 +18,7 @@
<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/security_dashboard_settings.xml b/res/xml/security_dashboard_settings.xml
index cf56d67..d417bb2 100644
--- a/res/xml/security_dashboard_settings.xml
+++ b/res/xml/security_dashboard_settings.xml
@@ -18,6 +18,7 @@
<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">
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index c525ccd..a24a95f 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -18,6 +18,7 @@
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">
diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml
index 132d50e..b0498f8 100644
--- a/res/xml/special_access.xml
+++ b/res/xml/special_access.xml
@@ -40,6 +40,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="device_administrators"
android:title="@string/manage_device_admin"
android:fragment="com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminSettings"
@@ -147,13 +154,6 @@
</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/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index 5d0fbcd..88b8d2f 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -17,6 +17,7 @@
<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">
@@ -75,4 +76,4 @@
android:targetClass="@string/additional_system_update_menu"/>
</Preference>
-</PreferenceScreen>
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/top_level_settings.xml b/res/xml/top_level_settings.xml
index 8f8d3d1..367f426 100644
--- a/res/xml/top_level_settings.xml
+++ b/res/xml/top_level_settings.xml
@@ -53,7 +53,6 @@
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
@@ -80,7 +79,6 @@
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
@@ -98,7 +96,6 @@
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
@@ -117,7 +114,6 @@
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 88837b8..25b3139 100644
--- a/res/xml/trust_agent_settings.xml
+++ b/res/xml/trust_agent_settings.xml
@@ -17,6 +17,8 @@
<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:searchable="false"
settings:controller="com.android.settings.security.trustagent.TrustAgentsPreferenceController">
</PreferenceScreen>
diff --git a/res/xml/user_dictionary_list_fragment.xml b/res/xml/user_dictionary_list_fragment.xml
index 2f921a0..2565a1a 100644
--- a/res/xml/user_dictionary_list_fragment.xml
+++ b/res/xml/user_dictionary_list_fragment.xml
@@ -17,7 +17,9 @@
<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:searchable="false"
settings:controller="com.android.settings.inputmethod.UserDictionaryListPreferenceController">
</PreferenceScreen>
diff --git a/res/xml/vr_listeners_settings.xml b/res/xml/vr_listeners_settings.xml
index a35b987..d9b364c 100644
--- a/res/xml/vr_listeners_settings.xml
+++ b/res/xml/vr_listeners_settings.xml
@@ -18,5 +18,7 @@
<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:searchable="false"
settings:controller="com.android.settings.applications.specialaccess.vrlistener.VrListenerScreenPreferenceController" />
diff --git a/res/xml/zen_mode_event_rule_settings.xml b/res/xml/zen_mode_event_rule_settings.xml
index 841fc06..46b95e1 100644
--- a/res/xml/zen_mode_event_rule_settings.xml
+++ b/res/xml/zen_mode_event_rule_settings.xml
@@ -24,6 +24,7 @@
<com.android.settingslib.widget.LayoutPreference
android:key="pref_app_header"
android:layout="@layout/settings_entity_header"
+ android:selectable="false"
settings:allowDividerBelow="true" />
<com.android.settingslib.widget.ActionButtonsPreference
diff --git a/res/xml/zen_mode_schedule_rule_settings.xml b/res/xml/zen_mode_schedule_rule_settings.xml
index 8484854..cab8731 100644
--- a/res/xml/zen_mode_schedule_rule_settings.xml
+++ b/res/xml/zen_mode_schedule_rule_settings.xml
@@ -24,6 +24,7 @@
<com.android.settingslib.widget.LayoutPreference
android:key="pref_app_header"
android:layout="@layout/settings_entity_header"
+ android:selectable="false"
settings:allowDividerBelow="true"/>
<com.android.settingslib.widget.ActionButtonsPreference
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index a55c6be..ce2d132 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -18,7 +18,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title=" ">
+ android:title="@string/zen_mode_settings_title">
<!-- Turn on DND button -->
<com.android.settingslib.widget.LayoutPreference
diff --git a/src/com/android/settings/AllInOneTetherSettings.java b/src/com/android/settings/AllInOneTetherSettings.java
index f2a0f52..a15ad1f 100644
--- a/src/com/android/settings/AllInOneTetherSettings.java
+++ b/src/com/android/settings/AllInOneTetherSettings.java
@@ -46,7 +46,10 @@
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.RestrictedDashboardFragment;
import com.android.settings.datausage.DataSaverBackend;
+import com.android.settings.network.BluetoothTetherPreferenceController;
import com.android.settings.network.TetherEnabler;
+import com.android.settings.network.UsbTetherPreferenceController;
+import com.android.settings.network.WifiTetherDisablePreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar;
import com.android.settings.widget.SwitchBarController;
@@ -66,7 +69,6 @@
/**
* Displays preferences for all Tethering options.
- * TODO(b/147323306): Add tether option preferences into this fragment after controllers created.
*/
@SearchIndexable
public final class AllInOneTetherSettings extends RestrictedDashboardFragment
@@ -172,6 +174,9 @@
mSecurityPreferenceController = use(WifiTetherSecurityPreferenceController.class);
mPasswordPreferenceController = use(WifiTetherPasswordPreferenceController.class);
mApBandPreferenceController = use(WifiTetherApBandPreferenceController.class);
+ getSettingsLifecycle().addObserver(use(UsbTetherPreferenceController.class));
+ getSettingsLifecycle().addObserver(use(BluetoothTetherPreferenceController.class));
+ getSettingsLifecycle().addObserver(use(WifiTetherDisablePreferenceController.class));
}
@Override
@@ -196,8 +201,6 @@
// Set initial state based on SharedPreferences value.
onSharedPreferenceChanged(mSharedPreferences, KEY_ENABLE_WIFI_TETHERING);
-
- // TODO(b/147325229): Hide advanced settings like security and ap band.
}
@Override
@@ -316,12 +319,6 @@
}
@Override
- public void onExpandButtonClick() {
- super.onExpandButtonClick();
- // TODO(b/147325229): Display hidden advanced settings like security and ap band.
- }
-
- @Override
public int getHelpResource() {
return R.string.help_url_tether;
}
diff --git a/src/com/android/settings/IccLockSettings.java b/src/com/android/settings/IccLockSettings.java
index 2dbfd62..de89e3c 100644
--- a/src/com/android/settings/IccLockSettings.java
+++ b/src/com/android/settings/IccLockSettings.java
@@ -51,7 +51,6 @@
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
-import com.android.internal.telephony.TelephonyIntents;
import com.android.settings.network.ProxySubscriptionManager;
import java.util.List;
@@ -143,7 +142,7 @@
private final BroadcastReceiver mSimStateReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
- if (TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(action)) {
+ if (Intent.ACTION_SIM_STATE_CHANGED.equals(action)) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_SIM_STATE_CHANGED));
}
}
@@ -293,7 +292,7 @@
// ACTION_SIM_STATE_CHANGED is sticky, so we'll receive current state after this call,
// which will call updatePreferences().
- final IntentFilter filter = new IntentFilter(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
+ final IntentFilter filter = new IntentFilter(Intent.ACTION_SIM_STATE_CHANGED);
getContext().registerReceiver(mSimStateReceiver, filter);
if (mDialogState != OFF_MODE) {
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index 07ba28f..80e5706 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -258,6 +258,18 @@
return 0;
}
+ /**
+ * Whether preference is allowing to be displayed to the user.
+ *
+ * @param preference to check if it can be displayed to the user (not hidding in expand area).
+ * @return {@code true} when preference is allowing to be displayed to the user.
+ * {@code false} when preference is hidden in expand area and not been displayed to the user.
+ */
+ protected boolean isPreferenceExpanded(Preference preference) {
+ return ((mAdapter == null)
+ || (mAdapter.getPreferenceAdapterPosition(preference) != RecyclerView.NO_POSITION));
+ }
+
protected void onDataSetChanged() {
highlightPreferenceIfNeeded();
updateEmptyView();
diff --git a/src/com/android/settings/TestingSettingsBroadcastReceiver.java b/src/com/android/settings/TestingSettingsBroadcastReceiver.java
index 2172cd0..aa28a18 100644
--- a/src/com/android/settings/TestingSettingsBroadcastReceiver.java
+++ b/src/com/android/settings/TestingSettingsBroadcastReceiver.java
@@ -10,10 +10,10 @@
public class TestingSettingsBroadcastReceiver extends BroadcastReceiver {
-
+
public TestingSettingsBroadcastReceiver() {
}
-
+
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(SECRET_CODE_ACTION)) {
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 1722c99..94e73fa 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -31,7 +31,6 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
-import android.provider.DeviceConfig;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -75,6 +74,8 @@
// Index of the first preference in a preference category.
private static final int FIRST_PREFERENCE_IN_CATEGORY_INDEX = -1;
+ private static final String EMPTY_STRING = "";
+
// Preference categories
private static final String CATEGORY_SCREEN_READER = "screen_reader_category";
private static final String CATEGORY_AUDIO_AND_CAPTIONS = "audio_and_captions_category";
@@ -121,8 +122,6 @@
// presentation.
private static final long DELAY_UPDATE_SERVICES_MILLIS = 1000;
- static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
-
private final Handler mHandler = new Handler();
private final Runnable mUpdateRunnable = new Runnable() {
@@ -258,26 +257,28 @@
public static CharSequence getServiceSummary(Context context, AccessibilityServiceInfo info,
boolean serviceEnabled) {
+ final CharSequence serviceSummary = info.loadSummary(context.getPackageManager());
+ final int fragmentType = AccessibilityUtil.getAccessibilityServiceFragmentType(info);
+
+ if (fragmentType == AccessibilityServiceFragmentType.INVISIBLE) {
+ return TextUtils.isEmpty(serviceSummary) ? EMPTY_STRING : serviceSummary;
+ }
+
final String serviceState = serviceEnabled
? context.getString(R.string.accessibility_summary_state_enabled)
: context.getString(R.string.accessibility_summary_state_disabled);
- final CharSequence serviceSummary = info.loadSummary(context.getPackageManager());
final String stateSummaryCombo = context.getString(
R.string.preference_summary_default_combination,
serviceState, serviceSummary);
- return (TextUtils.isEmpty(serviceSummary))
- ? serviceState
- : stateSummaryCombo;
+ return (TextUtils.isEmpty(serviceSummary)) ? serviceState : stateSummaryCombo;
+
}
@VisibleForTesting
static boolean isRampingRingerEnabled(final Context context) {
- return (Settings.Global.getInt(
- context.getContentResolver(),
- Settings.Global.APPLY_RAMPING_RINGER, 0) == 1)
- && DeviceConfig.getBoolean(
- DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false);
+ return Settings.Global.getInt(
+ context.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0) == 1;
}
private void initializeAllPreferences() {
@@ -403,7 +404,8 @@
preference.setEnabled(true);
}
- switch (AccessibilityUtil.getAccessibilityServiceFragmentType(info)) {
+ final int fragmentType = AccessibilityUtil.getAccessibilityServiceFragmentType(info);
+ switch (fragmentType) {
case AccessibilityServiceFragmentType.LEGACY:
preference.setFragment(
LegacyAccessibilityServicePreferenceFragment.class.getName());
@@ -514,6 +516,8 @@
experimentalCategory.removePreference(mDisplayDaltonizerPreferenceScreen);
mDisplayDaltonizerPreferenceScreen.setOrder(
mDisplayMagnificationPreferenceScreen.getOrder() + 1);
+ mDisplayDaltonizerPreferenceScreen.setSummary(AccessibilityUtil.getSummary(
+ getContext(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED));
mToggleInversionPreference.setOrder(
mDisplayDaltonizerPreferenceScreen.getOrder() + 1);
mToggleLargePointerIconPreference.setOrder(
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceController.java
index af0a99f..ce3d294 100644
--- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 The Android Open Source Project
+ * 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.
@@ -13,40 +13,48 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.android.settings.accessibility;
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
+
+import android.content.ContentResolver;
import android.content.Context;
import android.os.UserHandle;
-import android.view.accessibility.AccessibilityManager;
+import android.provider.Settings;
-import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
-import com.android.settingslib.accessibility.AccessibilityUtils;
+import com.android.settings.core.TogglePreferenceController;
-public class AccessibilityShortcutPreferenceController extends BasePreferenceController {
+/**
+ * Settings page for accessibility shortcut
+ */
+public class AccessibilityShortcutPreferenceController extends TogglePreferenceController {
+
public AccessibilityShortcutPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@Override
- public int getAvailabilityStatus() {
- return AccessibilityManager
- .getInstance(mContext).getInstalledAccessibilityServiceList().isEmpty()
- ? DISABLED_DEPENDENT_SETTING : AVAILABLE;
+ public boolean isChecked() {
+ final ContentResolver cr = mContext.getContentResolver();
+ // 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, OFF);
+ final boolean enabledFromLockScreen = Settings.Secure.getInt(
+ cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, dialogShown) == ON;
+ return enabledFromLockScreen;
}
@Override
- public CharSequence getSummary() {
- if (AccessibilityManager.getInstance(mContext)
- .getInstalledAccessibilityServiceList().isEmpty()) {
- return mContext.getString(R.string.accessibility_no_services_installed);
- } else {
- final boolean shortcutEnabled =
- AccessibilityUtils.isShortcutEnabled(mContext, UserHandle.myUserId());
- return shortcutEnabled
- ? AccessibilityShortcutPreferenceFragment.getServiceName(mContext)
- : mContext.getString(R.string.accessibility_feature_state_off);
- }
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Secure.putIntForUser(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, isChecked ? ON : OFF,
+ UserHandle.USER_CURRENT);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
}
}
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
deleted file mode 100644
index 659eaca..0000000
--- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * 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.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;
-import android.content.ComponentName;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.database.ContentObserver;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.UserHandle;
-import android.provider.Settings;
-import android.view.View;
-import android.view.accessibility.AccessibilityManager;
-
-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.settingslib.accessibility.AccessibilityUtils;
-import com.android.settingslib.search.Indexable;
-import com.android.settingslib.search.SearchIndexable;
-
-/**
- * Settings page for accessibility shortcut
- */
-@SearchIndexable
-public class AccessibilityShortcutPreferenceFragment extends ToggleFeaturePreferenceFragment
- implements Indexable {
-
- public static final String SHORTCUT_SERVICE_KEY = "accessibility_shortcut_service";
- public static final String ON_LOCK_SCREEN_KEY = "accessibility_shortcut_on_lock_screen";
-
- private Preference mServicePreference;
- private SwitchPreference mOnLockScreenSwitchPreference;
- private final ContentObserver mContentObserver = new ContentObserver(new Handler()) {
- @Override
- public void onChange(boolean selfChange) {
- updatePreferences();
- }
- };
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.ACCESSIBILITY_TOGGLE_GLOBAL_GESTURE;
- }
-
- @Override
- public int getHelpResource() {
- return R.string.help_url_accessibility_shortcut;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- mServicePreference = findPreference(SHORTCUT_SERVICE_KEY);
- mOnLockScreenSwitchPreference = (SwitchPreference) findPreference(ON_LOCK_SCREEN_KEY);
- mOnLockScreenSwitchPreference.setOnPreferenceChangeListener((Preference p, Object o) -> {
- Settings.Secure.putInt(getContentResolver(),
- Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN,
- ((Boolean) o) ? ON : OFF);
- return true;
- });
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- final PreferenceScreen preferenceScreen = getPreferenceScreen();
- preferenceScreen.findPreference(KEY_GENERAL_CATEGORY).setVisible(false);
-
- preferenceScreen.setOrderingAsAdded(false);
- mToggleServiceDividerSwitchPreference.setOrder(mServicePreference.getOrder() - 1);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- updatePreferences();
- getContentResolver().registerContentObserver(
- Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN),
- false, mContentObserver);
- }
-
- @Override
- public void onPause() {
- getContentResolver().unregisterContentObserver(mContentObserver);
- super.onPause();
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.accessibility_shortcut_settings;
- }
-
- @Override
- 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, 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 ? ON : OFF);
- updatePreferences();
- }
-
- @Override
- protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
- final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
- getString(R.string.accessibility_global_gesture_preference_title));
- switchPreference.setTitle(switchBarText);
- }
-
- private void updatePreferences() {
- ContentResolver cr = getContentResolver();
- Context context = getContext();
- mServicePreference.setSummary(getServiceName(context));
- 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, OFF);
- }
- boolean isEnabled = Settings.Secure
- .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, OFF);
- final boolean enabledFromLockScreen = Settings.Secure.getInt(
- 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(mToggleServiceDividerSwitchPreference.isChecked());
- mOnLockScreenSwitchPreference.setEnabled(mToggleServiceDividerSwitchPreference.isChecked());
- }
-
- /**
- * Get the user-visible name of the service currently selected for the shortcut.
- *
- * @param context The current context
- * @return The name of the service or a string saying that none is selected.
- */
- public static CharSequence getServiceName(Context context) {
- if (!shortcutFeatureAvailable(context)) {
- return context.getString(R.string.accessibility_no_service_selected);
- }
- AccessibilityServiceInfo shortcutServiceInfo = getServiceInfo(context);
- if (shortcutServiceInfo != null) {
- return shortcutServiceInfo.getResolveInfo().loadLabel(context.getPackageManager());
- }
- return AccessibilityShortcutController.getFrameworkShortcutFeaturesMap()
- .get(getShortcutComponent(context)).getLabel(context);
- }
-
- private static AccessibilityServiceInfo getServiceInfo(Context context) {
- return AccessibilityManager.getInstance(context)
- .getInstalledServiceInfoWithComponentName(getShortcutComponent(context));
- }
-
- private static boolean shortcutFeatureAvailable(Context context) {
- ComponentName shortcutFeature = getShortcutComponent(context);
- if (shortcutFeature == null) return false;
-
- if (AccessibilityShortcutController.getFrameworkShortcutFeaturesMap()
- .containsKey(shortcutFeature)) {
- return true;
- }
- return getServiceInfo(context) != null;
- }
-
- private static @Nullable
- ComponentName getShortcutComponent(Context context) {
- String componentNameString = AccessibilityUtils.getShortcutTargetServiceComponentNameString(
- context, UserHandle.myUserId());
- if (componentNameString == null) return null;
- return ComponentName.unflattenFromString(componentNameString);
- }
-
- public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- // This fragment is for details of the shortcut. Only the shortcut itself needs
- // to be indexed.
- protected boolean isPageSearchEnabled(Context context) {
- return false;
- }
- };
-}
diff --git a/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java b/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
index e53afeb..ca3befa 100644
--- a/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
@@ -16,6 +16,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.content.ComponentName;
import android.content.ContentResolver;
@@ -39,8 +42,7 @@
private final ComponentName mComponentName;
- private final int ON = 1;
- private final int OFF = 0;
+ private static final String EMPTY_STRING = "";
public AccessibilitySlicePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
@@ -55,8 +57,9 @@
@Override
public CharSequence getSummary() {
final AccessibilityServiceInfo serviceInfo = getAccessibilityServiceInfo();
- return serviceInfo == null
- ? "" : AccessibilitySettings.getServiceSummary(mContext, serviceInfo, isChecked());
+
+ return serviceInfo == null ? EMPTY_STRING : AccessibilitySettings.getServiceSummary(
+ mContext, serviceInfo, isChecked());
}
@Override
diff --git a/src/com/android/settings/accessibility/CaptionAppearanceFragment.java b/src/com/android/settings/accessibility/CaptionAppearanceFragment.java
index 0fd3d06..d31465e 100644
--- a/src/com/android/settings/accessibility/CaptionAppearanceFragment.java
+++ b/src/com/android/settings/accessibility/CaptionAppearanceFragment.java
@@ -122,10 +122,6 @@
refreshPreviewText();
}
- private void refreshPreferenceViewEnabled(boolean enabled) {
- mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
- }
-
private void refreshPreviewText() {
final Context context = getActivity();
if (context == null) {
@@ -217,8 +213,6 @@
mPreferenceList.add(mFontSize);
mPreferenceList.add(mPreset);
- refreshPreferenceViewEnabled(mCaptioningManager.isEnabled());
-
mCustom = (PreferenceCategory) findPreference(PREF_CUSTOM);
mShowingCustom = true;
diff --git a/src/com/android/settings/accessibility/DaltonizerPreferenceController.java b/src/com/android/settings/accessibility/DaltonizerPreferenceController.java
index 2922b76..c859d8c 100644
--- a/src/com/android/settings/accessibility/DaltonizerPreferenceController.java
+++ b/src/com/android/settings/accessibility/DaltonizerPreferenceController.java
@@ -19,15 +19,10 @@
import android.content.Context;
import android.provider.Settings;
-import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
-import com.google.common.primitives.Ints;
-
/** Controller that shows and updates the color correction summary. */
public class DaltonizerPreferenceController extends BasePreferenceController {
-
- private static final String DALTONIZER_TYPE = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER;
private static final String DALTONIZER_ENABLED =
Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
@@ -42,21 +37,6 @@
@Override
public CharSequence getSummary() {
- final String[] daltonizerSummaries = mContext.getResources().getStringArray(
- R.array.daltonizer_mode_summaries);
- final int[] daltonizerValues = mContext.getResources().getIntArray(
- R.array.daltonizer_type_values);
- final int timeoutValue =
- DaltonizerRadioButtonPreferenceController.getSecureAccessibilityDaltonizerValue(
- mContext.getContentResolver(), DALTONIZER_TYPE);
- final int idx = Ints.indexOf(daltonizerValues, timeoutValue);
- final String serviceSummary = daltonizerSummaries[idx == -1 ? 0 : idx];
-
- final CharSequence serviceState = AccessibilityUtil.getSummary(mContext,
- DALTONIZER_ENABLED);
-
- return mContext.getString(
- R.string.preference_summary_default_combination,
- serviceState, serviceSummary);
+ return AccessibilityUtil.getSummary(mContext, DALTONIZER_ENABLED);
}
}
diff --git a/src/com/android/settings/accessibility/DaltonizerRadioButtonPreferenceController.java b/src/com/android/settings/accessibility/DaltonizerRadioButtonPreferenceController.java
index dd5eb10..f6f554e 100644
--- a/src/com/android/settings/accessibility/DaltonizerRadioButtonPreferenceController.java
+++ b/src/com/android/settings/accessibility/DaltonizerRadioButtonPreferenceController.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.content.res.Resources;
import android.provider.Settings;
+import android.view.View;
import android.view.accessibility.AccessibilityManager;
import androidx.lifecycle.LifecycleObserver;
@@ -122,6 +123,7 @@
mPreference = (RadioButtonPreference)
screen.findPreference(getPreferenceKey());
mPreference.setOnClickListener(this);
+ mPreference.setAppendixVisibility(View.GONE);
updateState(mPreference);
}
diff --git a/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java b/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java
index 31a8c19..f73ca01 100644
--- a/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java
+++ b/src/com/android/settings/accessibility/MagnificationGesturesPreferenceController.java
@@ -92,8 +92,8 @@
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED);
extras.putInt(AccessibilitySettings.EXTRA_TITLE_RES,
R.string.accessibility_screen_magnification_gestures_title);
- extras.putInt(AccessibilitySettings.EXTRA_SUMMARY_RES,
- R.string.accessibility_screen_magnification_summary);
+ extras.putCharSequence(AccessibilitySettings.EXTRA_HTML_DESCRIPTION,
+ context.getText(R.string.accessibility_screen_magnification_summary));
extras.putInt(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID,
R.raw.accessibility_screen_magnification);
}
diff --git a/src/com/android/settings/accessibility/MagnificationNavbarPreferenceController.java b/src/com/android/settings/accessibility/MagnificationNavbarPreferenceController.java
index 1b8d854d..952f820 100644
--- a/src/com/android/settings/accessibility/MagnificationNavbarPreferenceController.java
+++ b/src/com/android/settings/accessibility/MagnificationNavbarPreferenceController.java
@@ -55,8 +55,8 @@
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED);
extras.putInt(AccessibilitySettings.EXTRA_TITLE_RES,
R.string.accessibility_screen_magnification_navbar_title);
- extras.putInt(AccessibilitySettings.EXTRA_SUMMARY_RES,
- R.string.accessibility_screen_magnification_navbar_summary);
+ extras.putCharSequence(AccessibilitySettings.EXTRA_HTML_DESCRIPTION,
+ mContext.getText(R.string.accessibility_screen_magnification_navbar_summary));
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED, isChecked());
extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mIsFromSUW);
}
diff --git a/src/com/android/settings/accessibility/MagnificationPreferenceController.java b/src/com/android/settings/accessibility/MagnificationPreferenceController.java
index 8b214a2..7ac7bef 100644
--- a/src/com/android/settings/accessibility/MagnificationPreferenceController.java
+++ b/src/com/android/settings/accessibility/MagnificationPreferenceController.java
@@ -18,7 +18,6 @@
import android.content.Context;
import android.os.Bundle;
-import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -41,22 +40,8 @@
@Override
public CharSequence getSummary() {
- final boolean tripleTapEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1;
- final boolean buttonEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 1;
-
- int summaryResId = 0;
- if (!tripleTapEnabled && !buttonEnabled) {
- summaryResId = R.string.accessibility_feature_state_off;
- } else if (!tripleTapEnabled && buttonEnabled) {
- summaryResId = R.string.accessibility_screen_magnification_navbar_title;
- } else if (tripleTapEnabled && !buttonEnabled) {
- summaryResId = R.string.accessibility_screen_magnification_gestures_title;
- } else {
- summaryResId = R.string.accessibility_screen_magnification_state_navbar_gesture;
- }
- return mContext.getResources().getText(summaryResId);
+ return mContext.getResources().getText(
+ R.string.accessibility_screen_magnification_navbar_title);
}
@Override
diff --git a/src/com/android/settings/accessibility/PaletteListPreference.java b/src/com/android/settings/accessibility/PaletteListPreference.java
index de35112..c5c4205 100644
--- a/src/com/android/settings/accessibility/PaletteListPreference.java
+++ b/src/com/android/settings/accessibility/PaletteListPreference.java
@@ -26,7 +26,7 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
-import com.android.settingslib.widget.R;
+import com.android.settings.R;
/** Preference that easier preview by matching name to color. */
public class PaletteListPreference extends Preference {
diff --git a/src/com/android/settings/accessibility/PaletteListView.java b/src/com/android/settings/accessibility/PaletteListView.java
index 0030817..ef010e2 100644
--- a/src/com/android/settings/accessibility/PaletteListView.java
+++ b/src/com/android/settings/accessibility/PaletteListView.java
@@ -35,7 +35,7 @@
import androidx.annotation.VisibleForTesting;
-import com.android.settingslib.widget.R;
+import com.android.settings.R;
import com.google.common.collect.Iterables;
@@ -55,13 +55,13 @@
* display also the view background shows the color beside the text variable end point.
*/
public class PaletteListView extends ListView {
- private static final float VIEW_PITCH = 0.05f;
private final Context mContext;
private final DisplayAdapter mDisplayAdapter;
private final LayoutInflater mLayoutInflater;
private final String mDefaultGradientColorCodeString;
private final int mDefaultGradientColor;
private float mTextBound;
+ private static final float LANDSCAPE_MAX_WIDTH_PERCENTAGE = 100f;
public PaletteListView(Context context) {
this(context, null);
@@ -206,8 +206,17 @@
final float textWidth = textView.getPaint().measureText(textView.getText().toString());
// Computes rate of text width compare to screen width, and measures the round the double
// to two decimal places manually.
- final float textBound = Math.round(textWidth / getScreenWidth(windowManager) * 100) / 100f;
- mTextBound = textBound + VIEW_PITCH;
+ final float textBound = Math.round(
+ textWidth / getScreenWidth(windowManager) * LANDSCAPE_MAX_WIDTH_PERCENTAGE)
+ / LANDSCAPE_MAX_WIDTH_PERCENTAGE;
+
+ // Left padding and right padding with color preview.
+ final float paddingPixel = getResources().getDimension(
+ R.dimen.accessibility_layout_margin_start_end);
+ final float paddingWidth =
+ Math.round(paddingPixel / getScreenWidth(windowManager)
+ * LANDSCAPE_MAX_WIDTH_PERCENTAGE) / LANDSCAPE_MAX_WIDTH_PERCENTAGE;
+ mTextBound = textBound + paddingWidth + paddingWidth;
}
private static class ViewHolder {
diff --git a/src/com/android/settings/accessibility/ShortcutPreference.java b/src/com/android/settings/accessibility/ShortcutPreference.java
index 84ced68..2a62439 100644
--- a/src/com/android/settings/accessibility/ShortcutPreference.java
+++ b/src/com/android/settings/accessibility/ShortcutPreference.java
@@ -53,7 +53,7 @@
}
private OnClickListener mListener = null;
- private static final float DISABLED_ALPHA = 0.5f;
+ private static final float DISABLED_ALPHA = 0.77f;
private static final float ENABLED_ALPHA = 1.0f;
private int mSettingsVisibility = View.VISIBLE;
private boolean mAutoEnabledSettings;
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index a75c536..17ca939 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -330,9 +330,6 @@
.appendPath(String.valueOf(animatedImageRes))
.build();
- // Settings html description.
- mHtmlDescription = arguments.getCharSequence(AccessibilitySettings.EXTRA_HTML_DESCRIPTION);
-
// Get Accessibility service name.
mPackageName = getAccessibilityServiceInfo().getResolveInfo().loadLabel(
getPackageManager());
diff --git a/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java b/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java
index 301d8dc..b98a503 100644
--- a/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java
+++ b/src/com/android/settings/accessibility/ToggleAutoclickCustomSeekbarController.java
@@ -138,12 +138,12 @@
mDelayLabel = preference.findViewById(R.id.current_label);
mDelayLabel.setText(delayTimeToString(delayMillis));
- mShorter = preference.findViewById(R.id.smaller);
+ mShorter = preference.findViewById(R.id.shorter);
mShorter.setOnClickListener(v -> {
minusDelayByImageView();
});
- mLonger = preference.findViewById(R.id.larger);
+ mLonger = preference.findViewById(R.id.longer);
mLonger.setOnClickListener(v -> {
plusDelayByImageView();
});
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index ffde1e3..ec5784e 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -29,8 +29,6 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import com.android.settings.R;
@@ -45,7 +43,6 @@
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";
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
private final Handler mHandler = new Handler();
private SettingsContentObserver mSettingsContentObserver;
@@ -91,7 +88,8 @@
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mComponentName = COLOR_INVERSION_COMPONENT_NAME;
- mPackageName = getString(R.string.accessibility_display_inversion_preference_title);
+ mPackageName = getText(R.string.accessibility_display_inversion_preference_title);
+ mHtmlDescription = getText(R.string.accessibility_display_inversion_preference_subtitle);
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
enableServiceFeatureKeys.add(ENABLED);
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
@@ -104,17 +102,6 @@
}
@Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- final PreferenceScreen preferenceScreen = getPreferenceScreen();
- preferenceScreen.setOrderingAsAdded(false);
- final PreferenceCategory footerCategory = preferenceScreen.findPreference(
- CATEGORY_FOOTER_KEY);
- footerCategory.setOrder(Integer.MAX_VALUE);
- }
-
- @Override
public void onResume() {
super.onResume();
updateSwitchBarToggleSwitch();
diff --git a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
index f2b84e5..9b8b117 100644
--- a/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleDaltonizerPreferenceFragment.java
@@ -32,7 +32,6 @@
import android.view.ViewGroup;
import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
@@ -50,8 +49,8 @@
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 String KEY_PREVIEW = "daltonizer_preview";
+ private static final String KEY_CATEGORY_MODE = "daltonizer_mode_category";
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
private final Handler mHandler = new Handler();
private SettingsContentObserver mSettingsContentObserver;
@@ -82,7 +81,8 @@
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mComponentName = DALTONIZER_COMPONENT_NAME;
- mPackageName = getString(R.string.accessibility_display_daltonizer_preference_title);
+ mPackageName = getText(R.string.accessibility_display_daltonizer_preference_title);
+ mHtmlDescription = getText(R.string.accessibility_display_daltonizer_preference_subtitle);
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
enableServiceFeatureKeys.add(ENABLED);
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
@@ -97,16 +97,32 @@
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
+ updatePreferenceOrder();
+ }
+
+ /** Customizes the order by preference key. */
+ private List<String> getPreferenceOrderList() {
+ List<String> lists = new ArrayList<>();
+ lists.add(KEY_PREVIEW);
+ lists.add(KEY_USE_SERVICE_PREFERENCE);
+ lists.add(KEY_CATEGORY_MODE);
+ lists.add(KEY_GENERAL_CATEGORY);
+ lists.add(KEY_INTRODUCTION_CATEGORY);
+ return lists;
+ }
+
+ private void updatePreferenceOrder() {
+ List<String> lists = getPreferenceOrderList();
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);
+ final int size = lists.size();
+ for (int i = 0; i < size; i++) {
+ final Preference preference = preferenceScreen.findPreference(lists.get(i));
+ if (preference != null) {
+ preference.setOrder(i);
+ }
+ }
}
@Override
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 5571591..19a0f2b 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -27,6 +27,8 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.os.UserHandle;
+import android.provider.Settings;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
@@ -47,6 +49,7 @@
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.widget.SwitchBar;
+import com.android.settingslib.accessibility.AccessibilityUtils;
import com.android.settingslib.widget.FooterPreference;
import java.lang.annotation.Retention;
@@ -79,7 +82,9 @@
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";
+ protected static final String KEY_USE_SERVICE_PREFERENCE = "use_service";
+ protected static final String KEY_GENERAL_CATEGORY = "general_categories";
+ protected static final String KEY_INTRODUCTION_CATEGORY = "introduction_categories";
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
@@ -110,6 +115,7 @@
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setupDefaultShortcutIfNecessary(getPrefContext());
final int resId = getPreferenceScreenResId();
if (resId <= 0) {
PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(
@@ -136,6 +142,9 @@
final SwitchBar switchBar = activity.getSwitchBar();
switchBar.hide();
+ // Need to be called as early as possible. Protected variables will be assigned here.
+ onProcessArguments(getArguments());
+
PreferenceScreen preferenceScreen = getPreferenceScreen();
if (mImageUri != null) {
final AnimatedImagePreference animatedImagePreference = new AnimatedImagePreference(
@@ -146,9 +155,14 @@
}
mToggleServiceDividerSwitchPreference = new DividerSwitchPreference(getPrefContext());
+ mToggleServiceDividerSwitchPreference.setKey(KEY_USE_SERVICE_PREFERENCE);
+ if (getArguments().containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
+ final boolean enabled = getArguments().getBoolean(AccessibilitySettings.EXTRA_CHECKED);
+ mToggleServiceDividerSwitchPreference.setChecked(enabled);
+ }
+
preferenceScreen.addPreference(mToggleServiceDividerSwitchPreference);
- onProcessArguments(getArguments());
updateToggleServiceTitle(mToggleServiceDividerSwitchPreference);
final PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
@@ -177,6 +191,7 @@
getPrefContext());
final CharSequence title = getString(R.string.accessibility_introduction_title,
mPackageName);
+ introductionCategory.setKey(KEY_INTRODUCTION_CATEGORY);
introductionCategory.setTitle(title);
preferenceScreen.addPreference(introductionCategory);
@@ -335,12 +350,6 @@
// Key.
mPreferenceKey = arguments.getString(AccessibilitySettings.EXTRA_PREFERENCE_KEY);
- // Enabled.
- if (arguments.containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
- final boolean enabled = arguments.getBoolean(AccessibilitySettings.EXTRA_CHECKED);
- mToggleServiceDividerSwitchPreference.setChecked(enabled);
- }
-
// Title.
if (arguments.containsKey(AccessibilitySettings.EXTRA_RESOLVE_INFO)) {
ResolveInfo info = arguments.getParcelable(AccessibilitySettings.EXTRA_RESOLVE_INFO);
@@ -358,6 +367,12 @@
AccessibilitySettings.EXTRA_SUMMARY);
createFooterPreference(summary);
}
+
+ // Settings html description.
+ if (arguments.containsKey(AccessibilitySettings.EXTRA_HTML_DESCRIPTION)) {
+ mHtmlDescription = arguments.getCharSequence(
+ AccessibilitySettings.EXTRA_HTML_DESCRIPTION);
+ }
}
private Drawable getDrawableFromUri(Uri imageUri) {
@@ -631,4 +646,32 @@
preferenceScreen.addPreference(new FooterPreference.Builder(getActivity()).setTitle(
title).build());
}
+
+ /**
+ * Setups a configurable default if the setting has never been set.
+ */
+ private static void setupDefaultShortcutIfNecessary(Context context) {
+ final String targetKey = Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE;
+ String targetString = Settings.Secure.getString(context.getContentResolver(), targetKey);
+ if (!TextUtils.isEmpty(targetString)) {
+ // The shortcut setting has been set
+ return;
+ }
+
+ // AccessibilityManager#getAccessibilityShortcutTargets may not return correct shortcut
+ // targets during boot. Needs to read settings directly here.
+ targetString = AccessibilityUtils.getShortcutTargetServiceComponentNameString(context,
+ UserHandle.myUserId());
+ if (TextUtils.isEmpty(targetString)) {
+ // No configurable default accessibility service
+ return;
+ }
+
+ // Only fallback to default accessibility service when setting is never updated.
+ final ComponentName shortcutName = ComponentName.unflattenFromString(targetString);
+ if (shortcutName != null) {
+ Settings.Secure.putString(context.getContentResolver(), targetKey,
+ shortcutName.flattenToString());
+ }
+ }
}
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 7ca2abf..e31feaa 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -83,8 +83,6 @@
private static final char COMPONENT_NAME_SEPARATOR = ':';
private static final TextUtils.SimpleStringSplitter sStringColonSplitter =
new TextUtils.SimpleStringSplitter(COMPONENT_NAME_SEPARATOR);
-
- protected Preference mConfigWarningPreference;
protected VideoPreference mVideoPreference;
protected class VideoPreference extends Preference {
@@ -192,12 +190,6 @@
initShortcutPreference();
super.onViewCreated(view, savedInstanceState);
-
- mConfigWarningPreference = new Preference(getPrefContext());
- mConfigWarningPreference.setSelectable(false);
- mConfigWarningPreference.setPersistent(false);
- mConfigWarningPreference.setVisible(false);
- preferenceScreen.addPreference(mConfigWarningPreference);
}
@Override
@@ -219,7 +211,6 @@
videoView.start();
}
- updateConfigurationWarningIfNeeded();
updateShortcutPreferenceData();
updateShortcutPreference();
}
@@ -428,7 +419,6 @@
: DialogEnums.ACCESSIBILITY_BUTTON_TUTORIAL);
}
MagnificationPreferenceFragment.setChecked(getContentResolver(), preferenceKey, enabled);
- updateConfigurationWarningIfNeeded();
}
@Override
@@ -496,16 +486,6 @@
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
}
- private void updateConfigurationWarningIfNeeded() {
- final CharSequence warningMessage =
- MagnificationPreferenceFragment.getConfigurationWarningStringForSecureSettingsKey(
- mPreferenceKey, getPrefContext());
- if (warningMessage != null) {
- mConfigWarningPreference.setSummary(warningMessage);
- }
- mConfigWarningPreference.setVisible(warningMessage != null);
- }
-
@VisibleForTesting
static void optInAllMagnificationValuesToSettings(Context context, int shortcutTypes) {
if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
diff --git a/src/com/android/settings/applications/AppStateAppOpsBridge.java b/src/com/android/settings/applications/AppStateAppOpsBridge.java
index 8c001d8..b4f6e48 100755
--- a/src/com/android/settings/applications/AppStateAppOpsBridge.java
+++ b/src/com/android/settings/applications/AppStateAppOpsBridge.java
@@ -61,6 +61,7 @@
this(context, appState, callback, appOpsOpCode, permissions,
AppGlobals.getPackageManager());
}
+
AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
int[] appOpsOpCodes, String[] permissions) {
this(context, appState, callback, appOpsOpCodes, permissions,
@@ -70,9 +71,10 @@
@VisibleForTesting
AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
int appOpsOpCode, String[] permissions, IPackageManager packageManager) {
- this(context, appState, callback, new int[] {appOpsOpCode}, permissions,
+ this(context, appState, callback, new int[]{appOpsOpCode}, permissions,
packageManager);
}
+
AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
int[] appOpsOpCodes, String[] permissions, IPackageManager packageManager) {
super(appState, callback);
@@ -155,8 +157,12 @@
for (int i = 0; i < N; i++) {
AppEntry app = apps.get(i);
int userId = UserHandle.getUserId(app.info.uid);
- ArrayMap<String, PermissionState> userMap = entries.get(userId);
- app.extraInfo = userMap != null ? userMap.get(app.info.packageName) : null;
+ if (entries != null) {
+ ArrayMap<String, PermissionState> userMap = entries.get(userId);
+ app.extraInfo = userMap != null ? userMap.get(app.info.packageName) : null;
+ } else {
+ app.extraInfo = null;
+ }
}
}
@@ -247,6 +253,10 @@
* a particular package.
*/
private void loadAppOpsStates(SparseArray<ArrayMap<String, PermissionState>> entries) {
+ if (entries == null) {
+ return;
+ }
+
// Find out which packages have been granted permission from AppOps.
final List<AppOpsManager.PackageOps> packageOps = mAppOpsManager.getPackagesForOps(
mAppOpsOpCodes);
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 0f7a8c2..54af16f 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -43,6 +43,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageItemInfo;
import android.net.Uri;
+import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
@@ -143,7 +144,7 @@
implements View.OnClickListener, OnItemSelectedListener, SearchView.OnQueryTextListener {
static final String TAG = "ManageApplications";
- static final boolean DEBUG = false;
+ static final boolean DEBUG = Build.IS_DEBUGGABLE;
// Intent extras.
public static final String EXTRA_CLASSNAME = "classname";
@@ -178,8 +179,6 @@
public static final int STORAGE_TYPE_LEGACY = 2; // Show apps even if they can be categorized.
public static final int STORAGE_TYPE_PHOTOS_VIDEOS = 3;
- private static final int NO_USER_SPECIFIED = -1;
-
/**
* Intents with action {@code android.settings.MANAGE_APP_OVERLAY_PERMISSION}
* and data URI scheme {@code package} don't go to the app-specific screen for managing the
@@ -410,7 +409,7 @@
mApplications.mHasReceivedBridgeCallback =
savedInstanceState.getBoolean(EXTRA_HAS_BRIDGE, false);
}
- int userId = mIsWorkOnly ? mWorkUserId : UserHandle.getUserId(mCurrentUid);
+ int userId = mIsWorkOnly ? mWorkUserId : UserHandle.myUserId();
if (mStorageType == STORAGE_TYPE_MUSIC) {
Context context = getContext();
mApplications.setExtraViewController(
@@ -461,19 +460,8 @@
pinnedHeader.addView(mSpinnerHeader, 0);
final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
- mFilterAdapter.enableFilter(appFilterRegistry.getDefaultFilterType(mListType));
-
- AppFilter compositeFilter = getCompositeFilter(mListType, mStorageType, mVolumeUuid);
- if (mIsWorkOnly) {
- compositeFilter = new CompoundFilter(compositeFilter, ApplicationsState.FILTER_WORK);
- }
- if (mIsPersonalOnly) {
- compositeFilter = new CompoundFilter(compositeFilter,
- ApplicationsState.FILTER_PERSONAL);
- }
- if (compositeFilter != null) {
- mApplications.setCompositeFilter(compositeFilter);
- }
+ final int filterType = appFilterRegistry.getDefaultFilterType(mListType);
+ mFilterAdapter.enableFilter(filterType);
if (mListType == LIST_TYPE_MAIN) {
if (UserManager.get(getActivity()).getUserProfiles().size() > 1 && !mIsWorkOnly
@@ -491,6 +479,8 @@
if (mListType == LIST_TYPE_HIGH_POWER) {
mFilterAdapter.enableFilter(FILTER_APPS_POWER_WHITELIST_ALL);
}
+
+ setCompositeFilter();
}
@VisibleForTesting
@@ -511,11 +501,8 @@
return new CompoundFilter(ApplicationsState.FILTER_MOVIES, filter);
} else if (listType == LIST_TYPE_PHOTOGRAPHY) {
return new CompoundFilter(ApplicationsState.FILTER_PHOTOS, filter);
- } else {
- final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
- return appFilterRegistry.get(
- appFilterRegistry.getDefaultFilterType(listType)).getFilter();
}
+ return null;
}
@Override
@@ -615,6 +602,21 @@
}
}
+ private void setCompositeFilter() {
+ AppFilter compositeFilter = getCompositeFilter(mListType, mStorageType, mVolumeUuid);
+ if (compositeFilter == null) {
+ compositeFilter = mFilter.getFilter();
+ }
+ if (mIsWorkOnly) {
+ compositeFilter = new CompoundFilter(compositeFilter, ApplicationsState.FILTER_WORK);
+ }
+ if (mIsPersonalOnly) {
+ compositeFilter = new CompoundFilter(compositeFilter,
+ ApplicationsState.FILTER_PERSONAL);
+ }
+ mApplications.setCompositeFilter(compositeFilter);
+ }
+
// utility method used to start sub activity
private void startApplicationDetailsActivity() {
switch (mListType) {
@@ -823,6 +825,7 @@
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mFilter = mFilterAdapter.getFilter(position);
+ setCompositeFilter();
mApplications.setFilter(mFilter);
if (DEBUG) {
@@ -1227,14 +1230,10 @@
comparatorObj = ApplicationsState.ALPHA_COMPARATOR;
}
- filterObj = new CompoundFilter(filterObj, ApplicationsState.FILTER_NOT_HIDE);
- AppFilter finalFilterObj = filterObj;
+ final AppFilter finalFilterObj = new CompoundFilter(filterObj,
+ ApplicationsState.FILTER_NOT_HIDE);
ThreadUtils.postOnBackgroundThread(() -> {
- final ArrayList<AppEntry> entries = mSession.rebuild(finalFilterObj,
- comparatorObj, false);
- if (entries != null) {
- ThreadUtils.postOnMainThread(() -> onRebuildComplete(entries));
- }
+ mSession.rebuild(finalFilterObj, comparatorObj, false);
});
}
@@ -1284,7 +1283,7 @@
@Override
public void onRebuildComplete(ArrayList<AppEntry> entries) {
if (DEBUG) {
- Log.d(TAG, "onRebuildComplete");
+ Log.d(TAG, "onRebuildComplete size=" + entries.size());
}
final int filterType = mAppFilter.getFilterType();
if (filterType == FILTER_APPS_POWER_WHITELIST ||
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesController.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesController.java
index 0f7c057..bc8542e 100644
--- a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesController.java
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesController.java
@@ -17,10 +17,13 @@
package com.android.settings.applications.specialaccess.interactacrossprofiles;
import android.content.Context;
+import android.content.pm.CrossProfileApps;
+import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.os.UserHandle;
import android.os.UserManager;
+import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import java.util.List;
@@ -33,12 +36,16 @@
private final Context mContext;
private final UserManager mUserManager;
+ private final PackageManager mPackageManager;
+ private final CrossProfileApps mCrossProfileApps;
public InteractAcrossProfilesController(Context context, String preferenceKey) {
super(context, preferenceKey);
mContext = context;
mUserManager = mContext.getSystemService(UserManager.class);
+ mCrossProfileApps = mContext.getSystemService(CrossProfileApps.class);
+ mPackageManager = mContext.getPackageManager();
}
@Override
@@ -51,4 +58,17 @@
}
return DISABLED_FOR_USER;
}
+
+ @Override
+ public CharSequence getSummary() {
+ final int connectedApps = InteractAcrossProfilesSettings.getNumberOfEnabledApps(
+ mContext, mPackageManager, mUserManager, mCrossProfileApps);
+ return connectedApps == 0
+ ? mContext.getResources().getString(
+ R.string.interact_across_profiles_number_of_connected_apps_none)
+ : mContext.getResources().getQuantityString(
+ R.plurals.interact_across_profiles_number_of_connected_apps,
+ connectedApps,
+ connectedApps);
+ }
}
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
index ad40d70..ff61626 100644
--- a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
@@ -22,13 +22,15 @@
import android.content.DialogInterface;
import android.content.PermissionChecker;
import android.content.pm.CrossProfileApps;
+import android.content.pm.PackageManager;
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.view.View;
import android.widget.ImageView;
+import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
@@ -51,6 +53,7 @@
private UserManager mUserManager;
private SwitchPreference mSwitchPref;
private LayoutPreference mHeader;
+ private PackageManager mPackageManager;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -59,6 +62,7 @@
mContext = getContext();
mCrossProfileApps = mContext.getSystemService(CrossProfileApps.class);
mUserManager = mContext.getSystemService(UserManager.class);
+ mPackageManager = mContext.getPackageManager();
addPreferencesFromResource(R.xml.interact_across_profiles_permissions_details);
mSwitchPref = findPreference(INTERACT_ACROSS_PROFILES_SETTINGS_SWITCH);
@@ -72,10 +76,17 @@
}
final UserHandle workProfile = getWorkProfile();
final UserHandle personalProfile = mUserManager.getProfileParent(workProfile);
- addAppIcons(personalProfile, workProfile);
+ addAppTitleAndIcons(personalProfile, workProfile);
}
- private void addAppIcons(UserHandle personalProfile, UserHandle workProfile) {
+ private void addAppTitleAndIcons(UserHandle personalProfile, UserHandle workProfile) {
+ final TextView title = mHeader.findViewById(R.id.entity_header_title);
+ if (title != null) {
+ final String appLabel = mPackageInfo.applicationInfo.loadLabel(
+ mPackageManager).toString();
+ title.setText(appLabel);
+ }
+
final ImageView personalIconView = mHeader.findViewById(R.id.entity_header_icon_personal);
if (personalIconView != null) {
personalIconView.setImageDrawable(IconDrawableFactory.newInstance(mContext)
@@ -114,35 +125,57 @@
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();
+ showConsentDialog();
}
return true;
}
+ private void showConsentDialog() {
+ final String appLabel = mPackageInfo.applicationInfo.loadLabel(mPackageManager).toString();
+
+ final View dialogView = getLayoutInflater().inflate(
+ R.layout.interact_across_profiles_consent_dialog, null);
+
+ final TextView dialogTitle = dialogView.findViewById(
+ R.id.interact_across_profiles_consent_dialog_title);
+ dialogTitle.setText(
+ getString(R.string.interact_across_profiles_consent_dialog_title, appLabel));
+
+ final TextView dialogSummary = dialogView.findViewById(
+ R.id.interact_across_profiles_consent_dialog_summary);
+ dialogSummary.setText(
+ getString(R.string.interact_across_profiles_consent_dialog_summary, appLabel));
+
+ final TextView appDataSummary = dialogView.findViewById(R.id.app_data_summary);
+ appDataSummary.setText(getString(
+ R.string.interact_across_profiles_consent_dialog_app_data_summary, appLabel));
+
+ final TextView permissionsSummary = dialogView.findViewById(R.id.permissions_summary);
+ permissionsSummary.setText(getString(
+ R.string.interact_across_profiles_consent_dialog_permissions_summary, appLabel));
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ builder.setView(dialogView)
+ .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();
+ }
+
private boolean isInteractAcrossProfilesEnabled() {
return isInteractAcrossProfilesEnabled(
mContext, mPackageName, mPackageInfo.applicationInfo.uid);
}
- private static boolean isInteractAcrossProfilesEnabled(Context context, String packageName, int uid) {
+ static boolean isInteractAcrossProfilesEnabled(Context context, String packageName, int uid) {
return PermissionChecker.PERMISSION_GRANTED
== PermissionChecker.checkPermissionForPreflight(
context,
@@ -178,13 +211,21 @@
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);
+ if (isInteractAcrossProfilesEnabled()) {
+ mSwitchPref.setChecked(true);
+ mSwitchPref.setTitle(R.string.interact_across_profiles_switch_enabled);
+ if (horizontalArrowIcon != null) {
+ horizontalArrowIcon.setImageDrawable(
+ mContext.getDrawable(R.drawable.ic_swap_horiz_blue));
+ }
+ } else {
+ mSwitchPref.setChecked(false);
+ mSwitchPref.setTitle(R.string.interact_across_profiles_switch_disabled);
+ if (horizontalArrowIcon != null) {
+ horizontalArrowIcon.setImageDrawable(
+ mContext.getDrawable(R.drawable.ic_swap_horiz_grey));
+ }
}
return true;
}
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettings.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettings.java
index 2fd1e9f..d686978 100644
--- a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettings.java
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettings.java
@@ -73,7 +73,7 @@
screen.removeAll();
final ArrayList<Pair<ApplicationInfo, UserHandle>> crossProfileApps =
- collectConfigurableApps();
+ collectConfigurableApps(mPackageManager, mUserManager, mCrossProfileApps);
final Context prefContext = getPrefContext();
for (final Pair<ApplicationInfo, UserHandle> appData : crossProfileApps) {
@@ -124,21 +124,37 @@
* @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();
+ static ArrayList<Pair<ApplicationInfo, UserHandle>> collectConfigurableApps(
+ PackageManager packageManager, UserManager userManager,
+ CrossProfileApps crossProfileApps) {
+ final UserHandle personalProfile = getPersonalProfileForCallingUser(userManager);
if (personalProfile == null) {
return new ArrayList<>();
}
- final ArrayList<Pair<ApplicationInfo, UserHandle>> crossProfileApps = new ArrayList<>();
- final List<PackageInfo> installedPackages = mPackageManager.getInstalledPackagesAsUser(
+ final ArrayList<Pair<ApplicationInfo, UserHandle>> apps = new ArrayList<>();
+ final List<PackageInfo> installedPackages = packageManager.getInstalledPackagesAsUser(
GET_ACTIVITIES, personalProfile.getIdentifier());
for (PackageInfo packageInfo : installedPackages) {
- if (mCrossProfileApps.canConfigureInteractAcrossProfiles(packageInfo.packageName)) {
- crossProfileApps.add(new Pair<>(packageInfo.applicationInfo, personalProfile));
+ if (crossProfileApps.canConfigureInteractAcrossProfiles(packageInfo.packageName)) {
+ apps.add(new Pair<>(packageInfo.applicationInfo, personalProfile));
}
}
- return crossProfileApps;
+ return apps;
+ }
+
+ /**
+ * @return the number of applications that can interact across profiles.
+ */
+ static int getNumberOfEnabledApps(
+ Context context, PackageManager packageManager, UserManager userManager,
+ CrossProfileApps crossProfileApps) {
+ final ArrayList<Pair<ApplicationInfo, UserHandle>> apps =
+ collectConfigurableApps(packageManager, userManager, crossProfileApps);
+ apps.removeIf(
+ app -> !InteractAcrossProfilesDetails.isInteractAcrossProfilesEnabled(
+ context, app.first.packageName, app.first.uid));
+ return apps.size();
}
/**
@@ -146,12 +162,12 @@
* Returns null if user is not in a profile group.
*/
@Nullable
- private UserHandle getPersonalProfileForCallingUser() {
+ private static UserHandle getPersonalProfileForCallingUser(UserManager userManager) {
final int callingUser = UserHandle.myUserId();
- if (mUserManager.getProfiles(callingUser).isEmpty()) {
+ if (userManager.getProfiles(callingUser).isEmpty()) {
return null;
}
- final UserInfo parentProfile = mUserManager.getProfileParent(callingUser);
+ final UserInfo parentProfile = userManager.getProfileParent(callingUser);
return parentProfile == null
? UserHandle.of(callingUser) : parentProfile.getUserHandle();
}
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index d2ad30d..331e572 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -29,4 +29,5 @@
public static final String CONTROLLER_ENHANCEMENT = "settings_controller_loading_enhancement";
public static final String CONDITIONAL_CARDS = "settings_conditionals";
public static final String TETHER_ALL_IN_ONE = "settings_tether_all_in_one";
+ public static final String CONTEXTUAL_HOME2 = "settings_contextual_home2";
}
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 3a744a9..a2233fc 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -258,7 +258,7 @@
preference.setSummary(summary);
} else if (tile.getMetaData() != null
&& tile.getMetaData().containsKey(META_DATA_PREFERENCE_SUMMARY_URI)) {
- // Set a placeholder summary before starting to fetch real summary, this is necessary
+ // Set a placeholder summary before starting to fetch real summary, this is necessary
// to avoid preference height change.
preference.setSummary(R.string.summary_placeholder);
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index 0d3d5b0..d121195 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -320,6 +320,13 @@
}
/**
+ * Get current PreferenceController(s)
+ */
+ protected Collection<List<AbstractPreferenceController>> getPreferenceControllers() {
+ return mPreferenceControllers.values();
+ }
+
+ /**
* Update state of each preference managed by PreferenceController.
*/
protected void updatePreferenceStates() {
diff --git a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
index 128f4da..0f429c7 100644
--- a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
+++ b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
@@ -83,7 +83,7 @@
final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
synchronized (mBluetoothA2dpConfigStore) {
if (mBluetoothA2dp != null) {
- setCodecConfigPreference(mBluetoothA2dp.getActiveDevice(), codecConfig);
+ setCodecConfigPreference(null, codecConfig); // Use current active device
}
}
// Because the setting is not persisted into permanent storage, we cannot call update state
@@ -102,14 +102,13 @@
@Override
public void updateState(Preference preference) {
- BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
- if (getCodecConfig(activeDevice) == null || mPreference == null) {
+ if (getCodecConfig(null) == null || mPreference == null) { // Use current active device
return;
}
BluetoothCodecConfig codecConfig;
synchronized (mBluetoothA2dpConfigStore) {
- codecConfig = getCodecConfig(activeDevice);
+ codecConfig = getCodecConfig(null); // Use current active device
}
final int index = getCurrentA2dpSettingIndex(codecConfig);
diff --git a/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java b/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
index 6f1eab0..71907b6 100644
--- a/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
@@ -80,7 +80,7 @@
}
writeConfigurationValues(index);
final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
- bluetoothA2dp.setCodecConfigPreference(bluetoothA2dp.getActiveDevice(), codecConfig);
+ bluetoothA2dp.setCodecConfigPreference(null, codecConfig);
mPreference.setSummary(((BaseBluetoothDialogPreference) mPreference).generateSummary(
index));
}
@@ -146,8 +146,7 @@
if (bluetoothA2dp == null) {
return null;
}
- final BluetoothCodecStatus codecStatus =
- bluetoothA2dp.getCodecStatus(bluetoothA2dp.getActiveDevice());
+ final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(null);
if (codecStatus == null) {
Log.d(TAG, "Unable to get current codec config. Codec status is null");
return null;
@@ -178,8 +177,7 @@
* @return {@link BluetoothCodecConfig}.
*/
protected BluetoothCodecConfig getSelectableByCodecType(int codecTypeValue) {
- final BluetoothCodecConfig[] configs = getSelectableConfigs(
- mBluetoothA2dp.getActiveDevice());
+ final BluetoothCodecConfig[] configs = getSelectableConfigs(null);
if (configs == null) {
Log.d(TAG, "Unable to get selectable config. Selectable configs is empty.");
return null;
diff --git a/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java b/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
index 8eecec9..c2977a8 100644
--- a/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
@@ -83,9 +83,9 @@
return index;
}
// Check HD audio is enabled, display the available list.
- if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
+ if (bluetoothA2dp.getOptionalCodecsEnabled(activeDevice)
== BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) {
- BluetoothCodecConfig[] configs = getSelectableConfigs(bluetoothA2dp.getActiveDevice());
+ BluetoothCodecConfig[] configs = getSelectableConfigs(null);
if (configs != null) {
return getIndexFromConfig(configs);
}
@@ -101,8 +101,7 @@
int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
switch (index) {
case 0:
- codecTypeValue = getHighestCodec(getSelectableConfigs(
- mBluetoothA2dp.getActiveDevice()));
+ codecTypeValue = getHighestCodec(getSelectableConfigs(null));
codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
break;
case 1:
diff --git a/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java b/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java
index 714b9ab..8008188 100644
--- a/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java
@@ -58,11 +58,11 @@
mPreference.setEnabled(false);
return;
}
- final boolean supported = (bluetoothA2dp.isOptionalCodecsSupported(activeDevice)
+ final boolean supported = (bluetoothA2dp.supportsOptionalCodecs(activeDevice)
== BluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
mPreference.setEnabled(supported);
if (supported) {
- final boolean isEnabled = bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
+ final boolean isEnabled = bluetoothA2dp.getOptionalCodecsEnabled(activeDevice)
== BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED;
((SwitchPreference) mPreference).setChecked(isEnabled);
}
diff --git a/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceController.java b/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceController.java
index e368aab..4862cfe 100644
--- a/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceController.java
+++ b/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceController.java
@@ -26,6 +26,7 @@
import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.core.BasePreferenceController;
@@ -80,6 +81,12 @@
}
@Override
+ public void updateState(Preference preference) {
+ final FooterPreference footerPref = (FooterPreference) preference;
+ footerPref.setVisible(isAvailable());
+ }
+
+ @Override
public void onGraphicsDriverContentChanged() {
updateState(mPreference);
}
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index aedaa4c..38626ca 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -550,6 +550,13 @@
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/simstatus/SimStatusDialogController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
index 1986965..d7e07d9 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
@@ -27,6 +27,7 @@
import android.os.IBinder;
import android.os.PersistableBundle;
import android.os.RemoteException;
+import android.telephony.AccessNetworkConstants;
import android.telephony.Annotation;
import android.telephony.CarrierConfigManager;
import android.telephony.CellBroadcastIntents;
@@ -42,6 +43,9 @@
import android.telephony.TelephonyManager;
import android.telephony.UiccCardInfo;
import android.telephony.euicc.EuiccManager;
+import android.telephony.ims.ImsException;
+import android.telephony.ims.ImsMmTelManager;
+import android.telephony.ims.ImsReasonInfo;
import android.text.TextUtils;
import android.util.Log;
@@ -107,11 +111,27 @@
new OnSubscriptionsChangedListener() {
@Override
public void onSubscriptionsChanged() {
- mSubscriptionInfo = mSubscriptionManager.getActiveSubscriptionInfo(
- mSubscriptionInfo.getSubscriptionId());
- mTelephonyManager = mTelephonyManager.createForSubscriptionId(
- mSubscriptionInfo.getSubscriptionId());
- updateNetworkProvider();
+ final int prevSubId = (mSubscriptionInfo != null)
+ ? mSubscriptionInfo.getSubscriptionId()
+ : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
+ mSubscriptionInfo = getPhoneSubscriptionInfo(mSlotIndex);
+
+ final int nextSubId = (mSubscriptionInfo != null)
+ ? mSubscriptionInfo.getSubscriptionId()
+ : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
+ if (prevSubId != nextSubId) {
+ if (SubscriptionManager.isValidSubscriptionId(prevSubId)) {
+ unregisterImsRegistrationCallback(prevSubId);
+ }
+ if (SubscriptionManager.isValidSubscriptionId(nextSubId)) {
+ mTelephonyManager =
+ mTelephonyManager.createForSubscriptionId(nextSubId);
+ registerImsRegistrationCallback(nextSubId);
+ }
+ }
+ updateSubscriptionStatus();
}
};
@@ -201,13 +221,17 @@
}
mPhoneStateListener = getPhoneStateListener();
+ updateLatestAreaInfo();
+ updateSubscriptionStatus();
+ }
+
+ private void updateSubscriptionStatus() {
updateNetworkProvider();
final ServiceState serviceState = mTelephonyManager.getServiceState();
final SignalStrength signalStrength = mTelephonyManager.getSignalStrength();
updatePhoneNumber();
- updateLatestAreaInfo();
updateServiceState(serviceState);
updateSignalStrength(signalStrength);
updateNetworkType();
@@ -241,6 +265,7 @@
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
| PhoneStateListener.LISTEN_SERVICE_STATE);
mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
+ registerImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId());
if (mShowLatestAreaInfo) {
updateAreaInfoText();
@@ -255,6 +280,7 @@
return;
}
+ unregisterImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId());
mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
@@ -525,21 +551,68 @@
}
}
- private void updateImsRegistrationState() {
+ private boolean isImsRegistrationStateShowUp() {
final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
final PersistableBundle carrierConfig =
mCarrierConfigManager.getConfigForSubId(subscriptionId);
- final boolean showImsRegState = carrierConfig == null ? false :
+ return carrierConfig == null ? false :
carrierConfig.getBoolean(
CarrierConfigManager.KEY_SHOW_IMS_REGISTRATION_STATUS_BOOL);
- if (showImsRegState) {
- final boolean isImsRegistered = mTelephonyManager.isImsRegistered(subscriptionId);
- mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(isImsRegistered ?
- R.string.ims_reg_status_registered : R.string.ims_reg_status_not_registered));
- } else {
- mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_LABEL_ID);
- mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_VALUE_ID);
+ }
+
+ private void updateImsRegistrationState() {
+ if (isImsRegistrationStateShowUp()) {
+ return;
}
+ mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_LABEL_ID);
+ mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_VALUE_ID);
+ }
+
+ private ImsMmTelManager.RegistrationCallback mImsRegStateCallback =
+ new ImsMmTelManager.RegistrationCallback() {
+ @Override
+ public void onRegistered(@AccessNetworkConstants.TransportType int imsTransportType) {
+ mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
+ R.string.ims_reg_status_registered));
+ }
+ @Override
+ public void onRegistering(@AccessNetworkConstants.TransportType int imsTransportType) {
+ mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
+ R.string.ims_reg_status_not_registered));
+ }
+ @Override
+ public void onUnregistered(@Nullable ImsReasonInfo info) {
+ mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
+ R.string.ims_reg_status_not_registered));
+ }
+ @Override
+ public void onTechnologyChangeFailed(
+ @AccessNetworkConstants.TransportType int imsTransportType,
+ @Nullable ImsReasonInfo info) {
+ mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
+ R.string.ims_reg_status_not_registered));
+ }
+ };
+
+ private void registerImsRegistrationCallback(int subId) {
+ if (!isImsRegistrationStateShowUp()) {
+ return;
+ }
+ try {
+ final ImsMmTelManager imsMmTelMgr = ImsMmTelManager.createForSubscriptionId(subId);
+ imsMmTelMgr.registerImsRegistrationCallback(mDialog.getContext().getMainExecutor(),
+ mImsRegStateCallback);
+ } catch (ImsException exception) {
+ Log.w(TAG, "fail to register IMS status for subId=" + subId, exception);
+ }
+ }
+
+ private void unregisterImsRegistrationCallback(int subId) {
+ if (!isImsRegistrationStateShowUp()) {
+ return;
+ }
+ final ImsMmTelManager imsMmTelMgr = ImsMmTelManager.createForSubscriptionId(subId);
+ imsMmTelMgr.unregisterImsRegistrationCallback(mImsRegStateCallback);
}
private SubscriptionInfo getPhoneSubscriptionInfo(int slotId) {
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index f87ff33..c2a0b62 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -20,7 +20,6 @@
import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.WORK_TAB;
import android.app.settings.SettingsEnums;
-import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
@@ -173,7 +172,7 @@
if (intent != null) {
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
- launchIntent(intent);
+ Utils.launchIntent(mFragment, intent);
return true;
}
@@ -467,24 +466,6 @@
}
}
- private void launchIntent(Intent intent) {
- try {
- final int userId = intent.getIntExtra(Intent.EXTRA_USER_ID, -1);
-
- // b/33117269: Note that launchIntent may launch activity in different task which set
- // different launchMode (e.g. Files), using startActivityForesult to set task as
- // source task, and set requestCode as 0 means don't care about returnCode currently.
- if (userId == -1) {
- mFragment.startActivityForResult(intent, 0 /* requestCode not used */);
- } else {
- mFragment.getActivity().startActivityForResultAsUser(intent,
- 0 /* requestCode not used */, new UserHandle(userId));
- }
- } catch (ActivityNotFoundException e) {
- Log.w(TAG, "No activity found for " + intent);
- }
- }
-
private static long totalValues(StorageMeasurement.MeasurementDetails details, int userId,
String... keys) {
long total = 0;
diff --git a/src/com/android/settings/homepage/TopLevelSettings.java b/src/com/android/settings/homepage/TopLevelSettings.java
index e27e288..8a7f4bd 100644
--- a/src/com/android/settings/homepage/TopLevelSettings.java
+++ b/src/com/android/settings/homepage/TopLevelSettings.java
@@ -100,5 +100,12 @@
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.top_level_settings);
+ 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;
+ }
+ };
}
diff --git a/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java b/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java
index 39c48c1..8c471b0 100644
--- a/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java
@@ -31,7 +31,7 @@
public class CardDatabaseHelper extends SQLiteOpenHelper {
private static final String TAG = "CardDatabaseHelper";
private static final String DATABASE_NAME = "homepage_cards.db";
- private static final int DATABASE_VERSION = 5;
+ private static final int DATABASE_VERSION = 6;
public static final String CARD_TABLE = "cards";
@@ -62,11 +62,6 @@
String CATEGORY = "category";
/**
- * Keep the card last display's locale.
- */
- String LOCALIZED_TO_LOCALE = "localized_to_locale";
-
- /**
* Package name for all card candidates.
*/
String PACKAGE_NAME = "package_name";
@@ -77,51 +72,6 @@
String APP_VERSION = "app_version";
/**
- * Title resource name of the package.
- */
- String TITLE_RES_NAME = "title_res_name";
-
- /**
- * Title of the package to be shown.
- */
- String TITLE_TEXT = "title_text";
-
- /**
- * Summary resource name of the package.
- */
- String SUMMARY_RES_NAME = "summary_res_name";
-
- /**
- * Summary of the package to be shown.
- */
- String SUMMARY_TEXT = "summary_text";
-
- /**
- * Icon resource name of the package.
- */
- String ICON_RES_NAME = "icon_res_name";
-
- /**
- * Icon resource id of the package.
- */
- String ICON_RES_ID = "icon_res_id";
-
- /**
- * Key value mapping to Intent in Settings. Do action when user presses card.
- */
- String CARD_ACTION = "card_action";
-
- /**
- * Expire time of the card. The unit of the value is mini-second.
- */
- String EXPIRE_TIME_MS = "expire_time_ms";
-
- /**
- * Decide the card display full-length width or half-width in screen.
- */
- String SUPPORT_HALF_WIDTH = "support_half_width";
-
- /**
* Decide the card is dismissed or not.
*/
String CARD_DISMISSED = "card_dismissed";
@@ -140,30 +90,10 @@
" TEXT, " +
CardColumns.CATEGORY +
" INTEGER DEFAULT 0, " +
- CardColumns.LOCALIZED_TO_LOCALE +
- " TEXT, " +
CardColumns.PACKAGE_NAME +
" TEXT NOT NULL, " +
CardColumns.APP_VERSION +
" INTEGER NOT NULL, " +
- CardColumns.TITLE_RES_NAME +
- " TEXT, " +
- CardColumns.TITLE_TEXT +
- " TEXT, " +
- CardColumns.SUMMARY_RES_NAME +
- " TEXT, " +
- CardColumns.SUMMARY_TEXT +
- " TEXT, " +
- CardColumns.ICON_RES_NAME +
- " TEXT, " +
- CardColumns.ICON_RES_ID +
- " INTEGER DEFAULT 0, " +
- CardColumns.CARD_ACTION +
- " INTEGER, " +
- CardColumns.EXPIRE_TIME_MS +
- " INTEGER, " +
- CardColumns.SUPPORT_HALF_WIDTH +
- " INTEGER DEFAULT 0, " +
CardColumns.CARD_DISMISSED +
" INTEGER DEFAULT 0 " +
");";
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCard.java b/src/com/android/settings/homepage/contextualcards/ContextualCard.java
index ccfb22d..262cd2f 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCard.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCard.java
@@ -56,17 +56,10 @@
private final double mRankingScore;
private final String mSliceUri;
private final int mCategory;
- private final String mLocalizedToLocale;
private final String mPackageName;
private final long mAppVersion;
- private final String mTitleResName;
private final String mTitleText;
- private final String mSummaryResName;
private final String mSummaryText;
- private final String mIconResName;
- private final int mIconResId;
- private final int mCardAction;
- private final long mExpireTimeMS;
private final boolean mIsLargeCard;
private final Drawable mIconDrawable;
@LayoutRes
@@ -98,10 +91,6 @@
return mCategory;
}
- public String getLocalizedToLocale() {
- return mLocalizedToLocale;
- }
-
public String getPackageName() {
return mPackageName;
}
@@ -110,38 +99,14 @@
return mAppVersion;
}
- public String getTitleResName() {
- return mTitleResName;
- }
-
public String getTitleText() {
return mTitleText;
}
- public String getSummaryResName() {
- return mSummaryResName;
- }
-
public String getSummaryText() {
return mSummaryText;
}
- public String getIconResName() {
- return mIconResName;
- }
-
- public int getIconResId() {
- return mIconResId;
- }
-
- public int getCardAction() {
- return mCardAction;
- }
-
- public long getExpireTimeMS() {
- return mExpireTimeMS;
- }
-
public Drawable getIconDrawable() {
return mIconDrawable;
}
@@ -150,10 +115,6 @@
return mIsLargeCard;
}
- boolean isCustomCard() {
- return TextUtils.isEmpty(mSliceUri);
- }
-
public int getViewType() {
return mViewType;
}
@@ -177,17 +138,10 @@
mRankingScore = builder.mRankingScore;
mSliceUri = builder.mSliceUri;
mCategory = builder.mCategory;
- mLocalizedToLocale = builder.mLocalizedToLocale;
mPackageName = builder.mPackageName;
mAppVersion = builder.mAppVersion;
- mTitleResName = builder.mTitleResName;
mTitleText = builder.mTitleText;
- mSummaryResName = builder.mSummaryResName;
mSummaryText = builder.mSummaryText;
- mIconResName = builder.mIconResName;
- mIconResId = builder.mIconResId;
- mCardAction = builder.mCardAction;
- mExpireTimeMS = builder.mExpireTimeMS;
mIconDrawable = builder.mIconDrawable;
mIsLargeCard = builder.mIsLargeCard;
mViewType = builder.mViewType;
@@ -207,31 +161,14 @@
mBuilder.setSliceUri(Uri.parse(mSliceUri));
mCategory = c.getInt(c.getColumnIndex(CardDatabaseHelper.CardColumns.CATEGORY));
mBuilder.setCategory(mCategory);
- mLocalizedToLocale = c.getString(
- c.getColumnIndex(CardDatabaseHelper.CardColumns.LOCALIZED_TO_LOCALE));
- mBuilder.setLocalizedToLocale(mLocalizedToLocale);
mPackageName = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.PACKAGE_NAME));
mBuilder.setPackageName(mPackageName);
mAppVersion = c.getLong(c.getColumnIndex(CardDatabaseHelper.CardColumns.APP_VERSION));
mBuilder.setAppVersion(mAppVersion);
- mTitleResName = c.getString(
- c.getColumnIndex(CardDatabaseHelper.CardColumns.TITLE_RES_NAME));
- mBuilder.setTitleResName(mTitleResName);
- mTitleText = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.TITLE_TEXT));
+ mTitleText = "";
mBuilder.setTitleText(mTitleText);
- mSummaryResName = c.getString(
- c.getColumnIndex(CardDatabaseHelper.CardColumns.SUMMARY_RES_NAME));
- mBuilder.setSummaryResName(mSummaryResName);
- mSummaryText = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.SUMMARY_TEXT));
- mBuilder.setSummaryText(mSummaryText);
- mIconResName = c.getString(c.getColumnIndex(CardDatabaseHelper.CardColumns.ICON_RES_NAME));
- mBuilder.setIconResName(mIconResName);
- mIconResId = c.getInt(c.getColumnIndex(CardDatabaseHelper.CardColumns.ICON_RES_ID));
- mBuilder.setIconResId(mIconResId);
- mCardAction = c.getInt(c.getColumnIndex(CardDatabaseHelper.CardColumns.CARD_ACTION));
- mBuilder.setCardAction(mCardAction);
- mExpireTimeMS = c.getLong(c.getColumnIndex(CardDatabaseHelper.CardColumns.EXPIRE_TIME_MS));
- mBuilder.setExpireTimeMS(mExpireTimeMS);
+ mSummaryText = "";
+ mBuilder.setTitleText(mSummaryText);
mIsLargeCard = false;
mBuilder.setIsLargeCard(mIsLargeCard);
mIconDrawable = null;
@@ -278,17 +215,10 @@
private double mRankingScore;
private String mSliceUri;
private int mCategory;
- private String mLocalizedToLocale;
private String mPackageName;
private long mAppVersion;
- private String mTitleResName;
private String mTitleText;
- private String mSummaryResName;
private String mSummaryText;
- private String mIconResName;
- private int mIconResId;
- private int mCardAction;
- private long mExpireTimeMS;
private Drawable mIconDrawable;
private boolean mIsLargeCard;
@LayoutRes
@@ -321,11 +251,6 @@
return this;
}
- public Builder setLocalizedToLocale(String localizedToLocale) {
- mLocalizedToLocale = localizedToLocale;
- return this;
- }
-
public Builder setPackageName(String packageName) {
mPackageName = packageName;
return this;
@@ -336,46 +261,16 @@
return this;
}
- public Builder setTitleResName(String titleResName) {
- mTitleResName = titleResName;
- return this;
- }
-
public Builder setTitleText(String titleText) {
mTitleText = titleText;
return this;
}
- public Builder setSummaryResName(String summaryResName) {
- mSummaryResName = summaryResName;
- return this;
- }
-
public Builder setSummaryText(String summaryText) {
mSummaryText = summaryText;
return this;
}
- public Builder setIconResName(String iconResName) {
- mIconResName = iconResName;
- return this;
- }
-
- public Builder setIconResId(int iconResId) {
- mIconResId = iconResId;
- return this;
- }
-
- public Builder setCardAction(int cardAction) {
- mCardAction = cardAction;
- return this;
- }
-
- public Builder setExpireTimeMS(long expireTimeMS) {
- mExpireTimeMS = expireTimeMS;
- return this;
- }
-
public Builder setIconDrawable(Drawable iconDrawable) {
mIconDrawable = iconDrawable;
return this;
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index 17a226d..1c83a10 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -16,6 +16,7 @@
package com.android.settings.homepage.contextualcards;
+import static com.android.settings.intelligence.ContextualCardProto.ContextualCard.Category.STICKY_VALUE;
import static com.android.settings.slices.CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI;
@@ -112,9 +113,7 @@
if (cursor.getCount() > 0) {
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
final ContextualCard card = new ContextualCard(cursor);
- if (card.isCustomCard()) {
- //TODO(b/114688391): Load and generate custom card,then add into list
- } else if (isLargeCard(card)) {
+ if (isLargeCard(card)) {
result.add(card.mutate().setIsLargeCard(true).build());
} else {
result.add(card);
@@ -129,18 +128,34 @@
@VisibleForTesting
List<ContextualCard> getDisplayableCards(List<ContextualCard> candidates) {
final List<ContextualCard> eligibleCards = filterEligibleCards(candidates);
+ final List<ContextualCard> stickyCards = new ArrayList<>();
final List<ContextualCard> visibleCards = new ArrayList<>();
final List<ContextualCard> hiddenCards = new ArrayList<>();
- final int size = eligibleCards.size();
- final int cardCount = getCardCount();
- for (int i = 0; i < size; i++) {
- if (i < cardCount) {
- visibleCards.add(eligibleCards.get(i));
- } else {
- hiddenCards.add(eligibleCards.get(i));
+ final int maxCardCount = getCardCount();
+ eligibleCards.forEach(card -> {
+ if (card.getCategory() != STICKY_VALUE) {
+ return;
}
- }
+ if (stickyCards.size() < maxCardCount) {
+ stickyCards.add(card);
+ } else {
+ hiddenCards.add(card);
+ }
+ });
+
+ final int nonStickyCardCount = maxCardCount - stickyCards.size();
+ eligibleCards.forEach(card -> {
+ if (card.getCategory() == STICKY_VALUE) {
+ return;
+ }
+ if (visibleCards.size() < nonStickyCardCount) {
+ visibleCards.add(card);
+ } else {
+ hiddenCards.add(card);
+ }
+ });
+ visibleCards.addAll(stickyCards);
if (!CardContentProvider.DELETE_CARD_URI.equals(mNotifyUri)) {
final MetricsFeatureProvider metricsFeatureProvider =
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
index 9e9069f..9beb624 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
@@ -17,6 +17,7 @@
package com.android.settings.homepage.contextualcards;
import static com.android.settings.homepage.contextualcards.ContextualCardLoader.CARD_CONTENT_LOADER_ID;
+import static com.android.settings.intelligence.ContextualCardProto.ContextualCard.Category.STICKY_VALUE;
import static com.android.settings.intelligence.ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE;
import static com.android.settings.slices.CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI;
import static com.android.settings.slices.CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI;
@@ -346,16 +347,23 @@
return result;
}
- // TODO(b/143055685):use category to determine whether they are sticky.
private List<ContextualCard> getCardsWithStickyViewType(List<ContextualCard> cards) {
final List<ContextualCard> result = new ArrayList<>(cards);
int replaceCount = 0;
for (int index = 0; index < result.size(); index++) {
+ final ContextualCard card = cards.get(index);
+ if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.CONTEXTUAL_HOME2)) {
+ if (card.getCategory() == STICKY_VALUE) {
+ result.set(index, card.mutate().setViewType(
+ SliceContextualCardRenderer.VIEW_TYPE_STICKY).build());
+ }
+ continue;
+ }
+
if (replaceCount > STICKY_CARDS.size() - 1) {
break;
}
- final ContextualCard card = cards.get(index);
if (card.getCardType() != ContextualCard.CardType.SLICE) {
continue;
}
diff --git a/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java b/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
index 8558ee7..0fcde26 100644
--- a/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
+++ b/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
@@ -88,9 +88,6 @@
if (card.getRankingScore() < 0) {
return false;
}
- if (card.isCustomCard()) {
- return true;
- }
final Uri uri = card.getSliceUri();
if (!ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java
index c5e987a..6fba85e 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionHeaderContextualCardRenderer.java
@@ -59,7 +59,7 @@
final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(
mContext).getMetricsFeatureProvider();
view.icons.removeAllViews();
- headerCard.getConditionalCards().stream().forEach(card -> {
+ headerCard.getConditionalCards().forEach(card -> {
final ImageView icon = (ImageView) LayoutInflater.from(mContext).inflate(
R.layout.conditional_card_header_icon, view.icons, false);
icon.setImageDrawable(card.getIconDrawable());
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
index 6f07d47..05531d6 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
@@ -166,7 +166,7 @@
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void onStop() {
- mFlippedCardSet.stream().forEach(holder -> resetCardView(holder));
+ mFlippedCardSet.forEach(holder -> resetCardView(holder));
mFlippedCardSet.clear();
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
index 3f35fb5..f634d43 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
@@ -16,6 +16,8 @@
package com.android.settings.homepage.contextualcards.slices;
+import static com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer.VIEW_TYPE_STICKY;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.view.View;
@@ -75,7 +77,9 @@
// Customize slice view for Settings
cardHolder.sliceView.setShowTitleItems(true);
if (card.isLargeCard()) {
- cardHolder.sliceView.setShowHeaderDivider(true);
+ if (holder.getItemViewType() != VIEW_TYPE_STICKY) {
+ cardHolder.sliceView.setShowHeaderDivider(true);
+ }
cardHolder.sliceView.setShowActionDividers(true);
}
}
diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java
index 8e6da80..3c9999e 100644
--- a/src/com/android/settings/media/MediaOutputSlice.java
+++ b/src/com/android/settings/media/MediaOutputSlice.java
@@ -104,7 +104,7 @@
}
private void addRow(MediaDevice device, MediaDevice connectedDevice, ListBuilder listBuilder) {
- if (TextUtils.equals(device.getId(), connectedDevice.getId())) {
+ if (connectedDevice != null && TextUtils.equals(device.getId(), connectedDevice.getId())) {
listBuilder.addInputRange(getActiveDeviceHeaderRow(device));
} else {
listBuilder.addRow(getMediaDeviceRow(device));
diff --git a/src/com/android/settings/network/AllInOneTetherPreferenceController.java b/src/com/android/settings/network/AllInOneTetherPreferenceController.java
new file mode 100644
index 0000000..85cfb8b
--- /dev/null
+++ b/src/com/android/settings/network/AllInOneTetherPreferenceController.java
@@ -0,0 +1,212 @@
+/*
+ * 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;
+
+import static android.os.UserManager.DISALLOW_CONFIG_TETHERING;
+
+import static com.android.settings.network.TetherEnabler.BLUETOOTH_TETHER_KEY;
+import static com.android.settings.network.TetherEnabler.KEY_ENABLE_WIFI_TETHERING;
+import static com.android.settings.network.TetherEnabler.USB_TETHER_KEY;
+import static com.android.settingslib.RestrictedLockUtilsInternal.checkIfRestrictionEnforced;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothPan;
+import android.bluetooth.BluetoothProfile;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.UserHandle;
+import android.util.FeatureFlagUtils;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.Lifecycle.Event;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.TetherSettings;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.FeatureFlags;
+import com.android.settings.widget.MasterSwitchController;
+import com.android.settings.widget.MasterSwitchPreference;
+import com.android.settingslib.TetherUtil;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * This controller helps to manage the switch state and visibility of "Hotspot & tethering" switch
+ * preference. It updates the preference summary text based on tethering state.
+ */
+public class AllInOneTetherPreferenceController extends BasePreferenceController implements
+ LifecycleObserver, TetherEnabler.OnTetherStateUpdateListener {
+ private static final String TAG = "AllInOneTetherPreferenceController";
+
+ private static final byte HOTSPOT_ONLY = 1;
+ private static final byte USB_ONLY = 1 << 1;
+ private static final byte BLUETOOTH_ONLY = 1 << 2;
+ private static final byte HOTSPOT_AND_USB = HOTSPOT_ONLY | USB_ONLY;
+ private static final byte HOTSPOT_AND_BLUETOOTH = HOTSPOT_ONLY | BLUETOOTH_ONLY;
+ private static final byte USB_AND_BLUETOOTH = USB_ONLY | BLUETOOTH_ONLY;
+ private static final byte HOTSPOT_AND_USB_AND_BLUETOOTH =
+ HOTSPOT_ONLY | USB_ONLY | BLUETOOTH_ONLY;
+
+ private final boolean mAdminDisallowedTetherConfig;
+ private final AtomicReference<BluetoothPan> mBluetoothPan;
+ private final BluetoothAdapter mBluetoothAdapter;
+ private final SharedPreferences mTetherEnablerSharedPreferences;
+ @VisibleForTesting
+ final BluetoothProfile.ServiceListener mBtProfileServiceListener =
+ new BluetoothProfile.ServiceListener() {
+ @Override
+ public void onServiceConnected(int profile, BluetoothProfile proxy) {
+ mBluetoothPan.set((BluetoothPan) proxy);
+ }
+
+ @Override
+ public void onServiceDisconnected(int profile) {
+ mBluetoothPan.set(null);
+ }
+ };
+
+ private MasterSwitchPreference mPreference;
+ private TetherEnabler mTetherEnabler;
+
+ @VisibleForTesting(otherwise = VisibleForTesting.NONE)
+ AllInOneTetherPreferenceController() {
+ super(null /*context*/, "test");
+ mAdminDisallowedTetherConfig = false;
+ mBluetoothPan = new AtomicReference<>();
+ mBluetoothAdapter = null;
+ mTetherEnablerSharedPreferences = null;
+ }
+
+ public AllInOneTetherPreferenceController(Context context, String key) {
+ super(context, key);
+ mBluetoothPan = new AtomicReference<>();
+ mAdminDisallowedTetherConfig = checkIfRestrictionEnforced(
+ context, DISALLOW_CONFIG_TETHERING, UserHandle.myUserId()) != null;
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+ mTetherEnablerSharedPreferences =
+ context.getSharedPreferences(TetherEnabler.SHARED_PREF, Context.MODE_PRIVATE);
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(mPreferenceKey);
+ if (mPreference != null && !mAdminDisallowedTetherConfig) {
+ // Grey out if provisioning is not available.
+ mPreference.setEnabled(!TetherSettings.isProvisioningNeededButUnavailable(mContext));
+ }
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (!TetherUtil.isTetherAvailable(mContext)
+ || !FeatureFlagUtils.isEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE)) {
+ return CONDITIONALLY_UNAVAILABLE;
+ } else {
+ return AVAILABLE;
+ }
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ if (mPreference != null && mPreference.isChecked()) {
+ int chosenType = 0;
+ chosenType |= mTetherEnablerSharedPreferences
+ .getBoolean(KEY_ENABLE_WIFI_TETHERING, true) ? HOTSPOT_ONLY : 0;
+ chosenType |= mTetherEnablerSharedPreferences.getBoolean(USB_TETHER_KEY, false)
+ ? USB_ONLY : 0;
+ chosenType |= mTetherEnablerSharedPreferences.getBoolean(BLUETOOTH_TETHER_KEY, false)
+ ? BLUETOOTH_ONLY : 0;
+ switch (chosenType) {
+ case HOTSPOT_ONLY:
+ return mContext.getString(R.string.tether_settings_summary_hotspot_only);
+ case USB_ONLY:
+ return mContext.getString(R.string.tether_settings_summary_usb_tethering_only);
+ case BLUETOOTH_ONLY:
+ return mContext.getString(
+ R.string.tether_settings_summary_bluetooth_tethering_only);
+ case HOTSPOT_AND_USB:
+ return mContext.getString(R.string.tether_settings_summary_hotspot_and_usb);
+ case HOTSPOT_AND_BLUETOOTH:
+ return mContext.getString(
+ R.string.tether_settings_summary_hotspot_and_bluetooth);
+ case USB_AND_BLUETOOTH:
+ return mContext.getString(R.string.tether_settings_summary_usb_and_bluetooth);
+ case HOTSPOT_AND_USB_AND_BLUETOOTH:
+ return mContext.getString(
+ R.string.tether_settings_summary_hotspot_and_usb_and_bluetooth);
+ default:
+ Log.e(TAG, "None of the tether interfaces is chosen");
+ return mContext.getString(R.string.summary_placeholder);
+ }
+ }
+
+ return mContext.getString(R.string.tether_settings_summary_off);
+ }
+
+ @OnLifecycleEvent(Event.ON_CREATE)
+ public void onCreate() {
+ if (mBluetoothAdapter != null
+ && mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON) {
+ mBluetoothAdapter.getProfileProxy(mContext, mBtProfileServiceListener,
+ BluetoothProfile.PAN);
+ }
+ }
+
+ @OnLifecycleEvent(Event.ON_RESUME)
+ public void onResume() {
+ if (mTetherEnabler != null) {
+ mTetherEnabler.setListener(this);
+ }
+ }
+
+ @OnLifecycleEvent(Event.ON_PAUSE)
+ public void onPause() {
+ if (mTetherEnabler != null) {
+ mTetherEnabler.setListener(null);
+ }
+ }
+
+ @OnLifecycleEvent(Event.ON_DESTROY)
+ public void onDestroy() {
+ final BluetoothProfile profile = mBluetoothPan.getAndSet(null);
+ if (profile != null && mBluetoothAdapter != null) {
+ mBluetoothAdapter.closeProfileProxy(BluetoothProfile.PAN, profile);
+ }
+ }
+
+ void initEnabler(Lifecycle lifecycle) {
+ if (mPreference != null) {
+ mTetherEnabler = new TetherEnabler(
+ mContext, new MasterSwitchController(mPreference), mBluetoothPan);
+ if (lifecycle != null) {
+ lifecycle.addObserver(mTetherEnabler);
+ }
+ } else {
+ Log.e(TAG, "TetherEnabler is not initialized");
+ }
+ }
+
+ @Override
+ public void onTetherStateUpdated(boolean isTethering) {
+ updateState(mPreference);
+ }
+}
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 2bc97e6..ad3df33 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -20,6 +20,7 @@
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AlertDialog;
@@ -65,6 +66,13 @@
use(MultiNetworkHeaderController.class).init(getSettingsLifecycle());
use(AirplaneModePreferenceController.class).setFragment(this);
+ getSettingsLifecycle().addObserver(use(AllInOneTetherPreferenceController.class));
+ }
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ super.onCreatePreferences(savedInstanceState, rootKey);
+ use(AllInOneTetherPreferenceController.class).initEnabler(getSettingsLifecycle());
}
@Override
@@ -150,13 +158,5 @@
null /* metricsFeatureProvider */, null /* fragment */,
null /* mobilePlanHost */);
}
-
- @Override
- public List<String> getNonIndexableKeys(Context context) {
- List<String> keys = super.getNonIndexableKeys(context);
- // Remove master switch as a result
- keys.add(WifiMasterSwitchPreferenceController.KEY_TOGGLE_WIFI);
- return keys;
- }
};
}
diff --git a/src/com/android/settings/network/TetherEnabler.java b/src/com/android/settings/network/TetherEnabler.java
index ffb0ef2..e17dcd1 100644
--- a/src/com/android/settings/network/TetherEnabler.java
+++ b/src/com/android/settings/network/TetherEnabler.java
@@ -61,6 +61,20 @@
DataSaverBackend.Listener, LifecycleObserver,
SharedPreferences.OnSharedPreferenceChangeListener {
+ private OnTetherStateUpdateListener mListener;
+
+ /**
+ * Interface definition for a callback to be invoked when the tethering has been updated.
+ */
+ public interface OnTetherStateUpdateListener {
+ /**
+ * Called when the tethering state has changed.
+ *
+ * @param isTethering The new tethering state.
+ */
+ void onTetherStateUpdated(boolean isTethering);
+ }
+
private static final String TAG = "TetherEnabler";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -135,6 +149,10 @@
mContext.unregisterReceiver(mTetherChangeReceiver);
}
+ public void setListener(@Nullable OnTetherStateUpdateListener listener) {
+ mListener = listener;
+ }
+
@VisibleForTesting
void updateState(@Nullable String[] tethered) {
boolean isTethering = tethered == null ? isTethering() : isTethering(tethered);
@@ -143,6 +161,9 @@
}
setSwitchCheckedInternal(isTethering);
mSwitchWidgetController.setEnabled(!mDataSaverEnabled);
+ if (mListener != null) {
+ mListener.onTetherStateUpdated(isTethering);
+ }
}
private void setSwitchCheckedInternal(boolean checked) {
diff --git a/src/com/android/settings/network/TetherPreferenceController.java b/src/com/android/settings/network/TetherPreferenceController.java
index 8fc05aa..d18d897 100644
--- a/src/com/android/settings/network/TetherPreferenceController.java
+++ b/src/com/android/settings/network/TetherPreferenceController.java
@@ -39,7 +39,6 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
-import com.android.settings.AllInOneTetherSettings;
import com.android.settings.R;
import com.android.settings.TetherSettings;
import com.android.settings.core.FeatureFlags;
@@ -112,16 +111,13 @@
// Grey out if provisioning is not available.
mPreference.setEnabled(!TetherSettings.isProvisioningNeededButUnavailable(mContext));
-
- if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE)) {
- mPreference.setFragment(AllInOneTetherSettings.class.getName());
- }
}
}
@Override
public boolean isAvailable() {
- return TetherUtil.isTetherAvailable(mContext);
+ return TetherUtil.isTetherAvailable(mContext)
+ && !FeatureFlagUtils.isEnabled(mContext, FeatureFlags.TETHER_ALL_IN_ONE);
}
@Override
diff --git a/src/com/android/settings/network/WifiTetherDisablePreferenceController.java b/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
index a7242cf..32f841d 100644
--- a/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
+++ b/src/com/android/settings/network/WifiTetherDisablePreferenceController.java
@@ -30,6 +30,7 @@
import androidx.preference.SwitchPreference;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.TetherUtil;
@@ -95,8 +96,14 @@
@Override
public CharSequence getSummary() {
- // TODO(b/146818850): Update summary accordingly.
- return super.getSummary();
+ if (mUSBTetherEnabled && mBluetoothTetherEnabled) {
+ return mContext.getString(R.string.disable_wifi_hotspot_when_usb_and_bluetooth_on);
+ } else if (mUSBTetherEnabled) {
+ return mContext.getString(R.string.disable_wifi_hotspot_when_usb_on);
+ } else if (mBluetoothTetherEnabled) {
+ return mContext.getString(R.string.disable_wifi_hotspot_when_bluetooth_on);
+ }
+ return mContext.getString(R.string.summary_placeholder);
}
@Override
diff --git a/src/com/android/settings/network/ims/ImsQueryController.java b/src/com/android/settings/network/ims/ImsQueryController.java
index f48fc6a..fec862b 100644
--- a/src/com/android/settings/network/ims/ImsQueryController.java
+++ b/src/com/android/settings/network/ims/ImsQueryController.java
@@ -47,13 +47,15 @@
mTransportType = transportType;
}
+ abstract boolean isEnabledByUser(int subId);
+
@VisibleForTesting
- ImsQuery isTtyOnVolteEnabled(int subId) {
- return new ImsQueryTtyOnVolteStat(subId);
+ boolean isTtyOnVolteEnabled(int subId) {
+ return (new ImsQueryTtyOnVolteStat(subId)).query();
}
@VisibleForTesting
- ImsQuery isProvisionedOnDevice(int subId) {
- return new ImsQueryProvisioningStat(subId, mCapability, mTech);
+ boolean isProvisionedOnDevice(int subId) {
+ return (new ImsQueryProvisioningStat(subId, mCapability, mTech)).query();
}
}
diff --git a/src/com/android/settings/network/ims/VolteQueryImsState.java b/src/com/android/settings/network/ims/VolteQueryImsState.java
index 608768a..23f8bab 100644
--- a/src/com/android/settings/network/ims/VolteQueryImsState.java
+++ b/src/com/android/settings/network/ims/VolteQueryImsState.java
@@ -55,8 +55,8 @@
* Implementation of ImsQueryController#isEnabledByUser(int subId)
*/
@VisibleForTesting
- ImsQuery isEnabledByUser(int subId) {
- return new ImsQueryEnhanced4gLteModeUserSetting(subId);
+ boolean isEnabledByUser(int subId) {
+ return (new ImsQueryEnhanced4gLteModeUserSetting(subId)).query();
}
@VisibleForTesting
@@ -77,7 +77,7 @@
}
return imsManager.isVolteEnabledByPlatform()
- && isProvisionedOnDevice(mSubId).query();
+ && isProvisionedOnDevice(mSubId);
}
/**
@@ -101,7 +101,7 @@
}
return ((!isTtyEnabled(mContext))
- || (isTtyOnVolteEnabled(mSubId).query()));
+ || (isTtyOnVolteEnabled(mSubId)));
}
@VisibleForTesting
@@ -119,6 +119,6 @@
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
- return isEnabledByUser(mSubId).query();
+ return isEnabledByUser(mSubId);
}
}
diff --git a/src/com/android/settings/network/ims/VtQueryImsState.java b/src/com/android/settings/network/ims/VtQueryImsState.java
index a9003b1..60bd729 100644
--- a/src/com/android/settings/network/ims/VtQueryImsState.java
+++ b/src/com/android/settings/network/ims/VtQueryImsState.java
@@ -55,8 +55,8 @@
* Implementation of ImsQueryController#isEnabledByUser(int subId)
*/
@VisibleForTesting
- ImsQuery isEnabledByUser(int subId) {
- return new ImsQueryVtUserSetting(subId);
+ boolean isEnabledByUser(int subId) {
+ return (new ImsQueryVtUserSetting(subId)).query();
}
@VisibleForTesting
@@ -77,7 +77,7 @@
}
return imsManager.isVtEnabledByPlatform()
- && isProvisionedOnDevice(mSubId).query()
+ && isProvisionedOnDevice(mSubId)
&& MobileNetworkUtils.isImsServiceStateReady(imsManager);
}
@@ -91,7 +91,7 @@
return false;
}
return ((!isTtyEnabled(mContext))
- || (isTtyOnVolteEnabled(mSubId).query()));
+ || (isTtyOnVolteEnabled(mSubId)));
}
@VisibleForTesting
@@ -109,6 +109,6 @@
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
- return isEnabledByUser(mSubId).query();
+ return isEnabledByUser(mSubId);
}
}
diff --git a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
index ab0bc8c..1667b7f 100644
--- a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
+++ b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
@@ -55,8 +55,8 @@
* Implementation of ImsQueryController#isEnabledByUser(int subId)
*/
@VisibleForTesting
- ImsQuery isEnabledByUser(int subId) {
- return new ImsQueryWfcUserSetting(subId);
+ boolean isEnabledByUser(int subId) {
+ return (new ImsQueryWfcUserSetting(subId)).query();
}
@VisibleForTesting
@@ -77,7 +77,7 @@
}
return imsManager.isWfcEnabledByPlatform()
- && isProvisionedOnDevice(mSubId).query();
+ && isProvisionedOnDevice(mSubId);
}
/**
@@ -101,7 +101,7 @@
}
return ((!isTtyEnabled(mContext))
- || (isTtyOnVolteEnabled(mSubId).query()));
+ || (isTtyOnVolteEnabled(mSubId)));
}
@VisibleForTesting
@@ -119,6 +119,6 @@
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
- return isEnabledByUser(mSubId).query();
+ return isEnabledByUser(mSubId);
}
}
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
index 31e8239..52fc99c 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
@@ -163,19 +163,30 @@
* @param intent action performed
*/
public void handleEnhanced4gLteChanged(Intent intent) {
- final int subId = getDefaultVoiceSubId();
+ // skip checking when no toggle state update contained within Intent
+ final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE, false);
+ if (newValue != intent.getBooleanExtra(EXTRA_TOGGLE_STATE, true)) {
+ notifyEnhanced4gLteUpdate();
+ return;
+ }
- if (SubscriptionManager.isValidSubscriptionId(subId)) {
- final VolteQueryImsState queryState = queryImsState(subId);
- if (queryState.isVoLteProvisioned()) {
- final boolean currentValue = queryState.isEnabledByUser()
- && queryState.isAllowUserControl();
- final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
- currentValue);
- if (newValue != currentValue) {
- setEnhanced4gLteModeSetting(subId, newValue);
- }
- }
+ final int subId = getDefaultVoiceSubId();
+ if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+ notifyEnhanced4gLteUpdate();
+ return;
+ }
+
+ final VolteQueryImsState queryState = queryImsState(subId);
+ final boolean currentValue = queryState.isEnabledByUser()
+ && queryState.isAllowUserControl();
+ if (newValue == currentValue) {
+ notifyEnhanced4gLteUpdate();
+ return;
+ }
+
+ // isVoLteProvisioned() is the last item to check since it might block the main thread
+ if (queryState.isVoLteProvisioned()) {
+ setEnhanced4gLteModeSetting(subId, newValue);
}
notifyEnhanced4gLteUpdate();
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index a4b32e6..199564d 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -33,6 +33,7 @@
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.dashboard.RestrictedDashboardFragment;
@@ -47,7 +48,9 @@
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
@@ -72,6 +75,8 @@
private UserManager mUserManager;
private String mClickedPrefKey;
+ private List<AbstractPreferenceController> mHiddenControllerList;
+
public MobileNetworkSettings() {
super(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS);
}
@@ -113,12 +118,12 @@
MobileNetworkUtils.getSearchableSubscriptionId(context));
Log.i(LOG_TAG, "display subId: " + mSubId);
- if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- return Arrays.asList(
- new DataUsageSummaryPreferenceController(getActivity(), getSettingsLifecycle(),
- this, mSubId));
+ if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
+ return Arrays.asList();
}
- return Arrays.asList();
+ return Arrays.asList(
+ new DataUsageSummaryPreferenceController(getActivity(), getSettingsLifecycle(),
+ this, mSubId));
}
@Override
@@ -187,6 +192,50 @@
onRestoreInstance(icicle);
}
+ @Override
+ public void onExpandButtonClick() {
+ final PreferenceScreen screen = getPreferenceScreen();
+ mHiddenControllerList.stream()
+ .filter(controller -> controller.isAvailable())
+ .forEach(controller -> {
+ final String key = controller.getPreferenceKey();
+ final Preference preference = screen.findPreference(key);
+ controller.updateState(preference);
+ });
+ super.onExpandButtonClick();
+ }
+
+ /*
+ * Replace design within {@link DashboardFragment#updatePreferenceStates()}
+ */
+ @Override
+ protected void updatePreferenceStates() {
+ mHiddenControllerList = new ArrayList<AbstractPreferenceController>();
+
+ final PreferenceScreen screen = getPreferenceScreen();
+ final Collection<List<AbstractPreferenceController>> controllerLists =
+ getPreferenceControllers();
+ controllerLists.stream().flatMap(Collection::stream)
+ .forEach(controller -> {
+ final String key = controller.getPreferenceKey();
+ if (TextUtils.isEmpty(key)) {
+ return;
+ }
+ final Preference preference = screen.findPreference(key);
+ if (preference == null) {
+ return;
+ }
+ if (!isPreferenceExpanded(preference)) {
+ mHiddenControllerList.add(controller);
+ return;
+ }
+ if (!controller.isAvailable()) {
+ return;
+ }
+ controller.updateState(preference);
+ });
+ }
+
@VisibleForTesting
void onRestoreInstance(Bundle icicle) {
if (icicle != null) {
@@ -238,7 +287,7 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
final MenuItem item = menu.add(Menu.NONE, R.id.edit_sim_name, Menu.NONE,
R.string.mobile_network_sim_name);
item.setIcon(com.android.internal.R.drawable.ic_mode_edit);
@@ -249,7 +298,7 @@
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
- if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ if (SubscriptionManager.isValidSubscriptionId(mSubId)) {
if (menuItem.getItemId() == R.id.edit_sim_name) {
RenameMobileNetworkDialogFragment.newInstance(mSubId).show(
getFragmentManager(), RenameMobileNetworkDialogFragment.TAG);
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 875a804..4f62f7f 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -18,6 +18,15 @@
import static android.provider.Telephony.Carriers.ENFORCE_MANAGED_URI;
+import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.CDMA;
+import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.EVDO;
+import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.GSM;
+import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.LTE;
+import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.NR;
+import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.RAF_TD_SCDMA;
+import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.RAF_UNKNOWN;
+import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.WCDMA;
+
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -54,6 +63,7 @@
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.network.ims.WifiCallingQueryImsState;
import com.android.settings.network.telephony.TelephonyConstants.TelephonyManagerConstants;
import com.android.settingslib.development.DevelopmentSettingsEnabler;
import com.android.settingslib.graph.SignalDrawable;
@@ -61,15 +71,6 @@
import java.util.Arrays;
import java.util.List;
-import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.CDMA;
-import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.EVDO;
-import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.GSM;
-import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.LTE;
-import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.NR;
-import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.RAF_TD_SCDMA;
-import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.RAF_UNKNOWN;
-import static com.android.settings.network.telephony.TelephonyConstants.RadioAccessFamily.WCDMA;
-
public class MobileNetworkUtils {
private static final String TAG = "MobileNetworkUtils";
@@ -152,10 +153,10 @@
isWifiCallingEnabled = intent != null;
} else {
+ final WifiCallingQueryImsState queryState =
+ new WifiCallingQueryImsState(context, subId);
final ImsManager imsMgr = ImsManager.getInstance(context, phoneId);
- isWifiCallingEnabled = imsMgr != null
- && imsMgr.isWfcEnabledByPlatform()
- && isWfcProvisionedOnDevice(subId)
+ isWifiCallingEnabled = queryState.isWifiCallingProvisioned()
&& isImsServiceStateReady(imsMgr);
}
diff --git a/src/com/android/settings/network/telephony/RoamingPreferenceController.java b/src/com/android/settings/network/telephony/RoamingPreferenceController.java
index 08fe323..2e116d8 100644
--- a/src/com/android/settings/network/telephony/RoamingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/RoamingPreferenceController.java
@@ -22,7 +22,6 @@
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
-import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
@@ -111,20 +110,10 @@
}
@Override
- public boolean handlePreferenceTreeClick(Preference preference) {
- if (TextUtils.equals(preference.getKey(), getPreferenceKey())) {
- if (isDialogNeeded()) {
- showDialog();
- }
- return true;
- }
-
- return false;
- }
-
- @Override
public boolean setChecked(boolean isChecked) {
- if (!isDialogNeeded()) {
+ if (isDialogNeeded()) {
+ showDialog();
+ } else {
// Update data directly if we don't need dialog
mTelephonyManager.setDataRoamingEnabled(isChecked);
return true;
diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java
index c8fb7e3..d6f8986 100644
--- a/src/com/android/settings/notification/NotificationBackend.java
+++ b/src/com/android/settings/notification/NotificationBackend.java
@@ -37,6 +37,8 @@
import android.content.pm.ParceledListSlice;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -51,6 +53,7 @@
import com.android.settingslib.R;
import com.android.settingslib.Utils;
+import com.android.settingslib.notification.ConversationIconFactory;
import com.android.settingslib.utils.StringUtil;
import java.util.ArrayList;
@@ -509,10 +512,15 @@
return null;
}
- public Drawable getConversationDrawable(Context context, ShortcutInfo info) {
- LauncherApps la = context.getSystemService(LauncherApps.class);
- return la.getShortcutBadgedIconDrawable(info,
- context.getResources().getDisplayMetrics().densityDpi);
+ public Drawable getConversationDrawable(Context context, ShortcutInfo info, String pkg,
+ int uid) {
+ ConversationIconFactory iconFactory = new ConversationIconFactory(context,
+ context.getSystemService(LauncherApps.class),
+ context.getPackageManager(), IconDrawableFactory.newInstance(context),
+ context.getResources().getDimensionPixelSize(
+ R.dimen.conversation_icon_size));
+ return new BitmapDrawable(context.getResources(),
+ iconFactory.getConversationBitmap(info, pkg, uid));
}
public void requestPinShortcut(Context context, ShortcutInfo shortcutInfo) {
diff --git a/src/com/android/settings/notification/app/ConversationListPreferenceController.java b/src/com/android/settings/notification/app/ConversationListPreferenceController.java
index fa1b050..dba7086 100644
--- a/src/com/android/settings/notification/app/ConversationListPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationListPreferenceController.java
@@ -127,7 +127,7 @@
conversation.getParentChannelLabel(), conversation.getGroupLabel())
: conversation.getParentChannelLabel());
if (si != null) {
- pref.setIcon(mBackend.getConversationDrawable(mContext, si));
+ pref.setIcon(mBackend.getConversationDrawable(mContext, si, mAppRow.pkg, mAppRow.uid));
}
pref.setKey(conversation.getNotificationChannel().getId());
diff --git a/src/com/android/settings/notification/app/NotificationSettings.java b/src/com/android/settings/notification/app/NotificationSettings.java
index 983ad2b..e30b35c 100644
--- a/src/com/android/settings/notification/app/NotificationSettings.java
+++ b/src/com/android/settings/notification/app/NotificationSettings.java
@@ -33,6 +33,7 @@
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.ShortcutInfo;
+import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.UserHandle;
@@ -203,7 +204,8 @@
mConversationInfo = mBackend.getConversationInfo(
mContext, mPkg, mUid, mChannel.getConversationId());
if (mConversationInfo != null) {
- mConversationDrawable = mBackend.getConversationDrawable(mContext, mConversationInfo);
+ mConversationDrawable = mBackend.getConversationDrawable(
+ mContext, mConversationInfo, mAppRow.pkg, mAppRow.uid);
}
}
diff --git a/src/com/android/settings/notification/history/NotificationHistoryActivity.java b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
index 7bd345f..9b78ae9 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryActivity.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
@@ -77,12 +77,18 @@
final View container = viewForPackage.findViewById(R.id.list_container);
container.setVisibility(View.GONE);
ImageButton expand = viewForPackage.findViewById(R.id.expand);
+ expand.setContentDescription(container.getVisibility() == View.VISIBLE
+ ? getString(R.string.condition_expand_hide)
+ : getString(R.string.condition_expand_show));
expand.setOnClickListener(v -> {
container.setVisibility(container.getVisibility() == View.VISIBLE
? View.GONE : View.VISIBLE);
expand.setImageResource(container.getVisibility() == View.VISIBLE
? R.drawable.ic_expand_less
: com.android.internal.R.drawable.ic_expand_more);
+ expand.setContentDescription(container.getVisibility() == View.VISIBLE
+ ? getString(R.string.condition_expand_hide)
+ : getString(R.string.condition_expand_show));
});
TextView label = viewForPackage.findViewById(R.id.label);
@@ -123,6 +129,7 @@
mPm = getPackageManager();
+ mTodayView.removeAllViews();
mHistoryLoader = new HistoryLoader(this, new NotificationBackend(), mPm);
mHistoryLoader.load(mOnHistoryLoaderListener);
@@ -239,16 +246,18 @@
LinearLayoutManager lm = new LinearLayoutManager(NotificationHistoryActivity.this);
rv.setLayoutManager(lm);
rv.setAdapter(new NotificationSbnAdapter(NotificationHistoryActivity.this, mPm));
- ((NotificationSbnAdapter) rv.getAdapter()).onRebuildComplete(
- Arrays.asList(snoozed));
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(
rv.getContext(), lm.getOrientation());
rv.addItemDecoration(dividerItemDecoration);
+ rv.setNestedScrollingEnabled(false);
+
+ ((NotificationSbnAdapter) rv.getAdapter()).onRebuildComplete(
+ Arrays.asList(snoozed));
}
try {
StatusBarNotification[] dismissed = mNm.getHistoricalNotifications(
- NotificationHistoryActivity.this.getPackageName(), 10, false);
+ NotificationHistoryActivity.this.getPackageName(), 6, false);
RecyclerView rv = mDismissView.findViewById(R.id.notification_list);
LinearLayoutManager lm = new LinearLayoutManager(NotificationHistoryActivity.this);
rv.setLayoutManager(lm);
@@ -256,6 +265,8 @@
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(
rv.getContext(), lm.getOrientation());
rv.addItemDecoration(dividerItemDecoration);
+ rv.setNestedScrollingEnabled(false);
+
((NotificationSbnAdapter) rv.getAdapter()).onRebuildComplete(
Arrays.asList(dismissed));
mDismissView.setVisibility(View.VISIBLE);
diff --git a/src/com/android/settings/notification/history/NotificationHistoryAdapter.java b/src/com/android/settings/notification/history/NotificationHistoryAdapter.java
index 87804d5..4448dee 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryAdapter.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryAdapter.java
@@ -63,7 +63,8 @@
holder.setTitle(hn.getTitle());
holder.setSummary(hn.getText());
holder.setPostedTime(hn.getPostedTimeMs());
- holder.addOnClick(hn.getPackage(), hn.getUserId(), hn.getChannelId());
+ holder.addOnClick(hn.getPackage(), hn.getUserId(), hn.getChannelId(),
+ hn.getConversationId());
}
@Override
diff --git a/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java b/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java
index 35f5615..d1f47af 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryViewHolder.java
@@ -18,6 +18,7 @@
import static android.provider.Settings.EXTRA_APP_PACKAGE;
import static android.provider.Settings.EXTRA_CHANNEL_ID;
+import static android.provider.Settings.EXTRA_CONVERSATION_ID;
import android.content.Intent;
import android.os.UserHandle;
@@ -26,6 +27,9 @@
import android.widget.DateTimeView;
import android.widget.TextView;
+import androidx.core.view.AccessibilityDelegateCompat;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.R;
@@ -58,13 +62,27 @@
mTime.setTime(postedTime);
}
- void addOnClick(String pkg, int userId, String channelId) {
+ void addOnClick(String pkg, int userId, String channelId, String conversationId) {
itemView.setOnClickListener(v -> {
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
.putExtra(EXTRA_APP_PACKAGE, pkg)
- .putExtra(EXTRA_CHANNEL_ID, channelId);
+ .putExtra(EXTRA_CHANNEL_ID, channelId)
+ .putExtra(EXTRA_CONVERSATION_ID, conversationId);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
itemView.getContext().startActivityAsUser(intent, UserHandle.of(userId));
});
+ ViewCompat.setAccessibilityDelegate(itemView, new AccessibilityDelegateCompat() {
+ @Override
+ public void onInitializeAccessibilityNodeInfo(View host,
+ AccessibilityNodeInfoCompat info) {
+ super.onInitializeAccessibilityNodeInfo(host, info);
+ CharSequence description =
+ host.getResources().getText(R.string.notification_history_view_settings);
+ AccessibilityNodeInfoCompat.AccessibilityActionCompat customClick =
+ new AccessibilityNodeInfoCompat.AccessibilityActionCompat(
+ AccessibilityNodeInfoCompat.ACTION_CLICK, description);
+ info.addAction(customClick);
+ }
+ });
}
}
diff --git a/src/com/android/settings/notification/history/NotificationSbnAdapter.java b/src/com/android/settings/notification/history/NotificationSbnAdapter.java
index 80ba278..a35b5d4 100644
--- a/src/com/android/settings/notification/history/NotificationSbnAdapter.java
+++ b/src/com/android/settings/notification/history/NotificationSbnAdapter.java
@@ -28,6 +28,7 @@
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.util.Log;
+import android.util.Slog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -70,17 +71,21 @@
public void onBindViewHolder(final @NonNull NotificationSbnViewHolder holder,
int position) {
final StatusBarNotification sbn = mValues.get(position);
- holder.setIcon(loadIcon(sbn));
- holder.setPackageName(loadPackageName(sbn.getPackageName()).toString());
- holder.setTitle(getTitleString(sbn.getNotification()));
- holder.setSummary(getTextString(mContext, sbn.getNotification()));
- holder.setPostedTime(sbn.getPostTime());
- if (!mUserBadgeCache.containsKey(sbn.getUserId())) {
- Drawable profile = mContext.getPackageManager().getUserBadgeForDensity(
- UserHandle.of(sbn.getUserId()), -1);
- mUserBadgeCache.put(sbn.getUserId(), profile);
+ if (sbn != null) {
+ holder.setIcon(loadIcon(sbn));
+ holder.setPackageName(loadPackageName(sbn.getPackageName()).toString());
+ holder.setTitle(getTitleString(sbn.getNotification()));
+ holder.setSummary(getTextString(mContext, sbn.getNotification()));
+ holder.setPostedTime(sbn.getPostTime());
+ if (!mUserBadgeCache.containsKey(sbn.getUserId())) {
+ Drawable profile = mContext.getPackageManager().getUserBadgeForDensity(
+ UserHandle.of(sbn.getUserId()), -1);
+ mUserBadgeCache.put(sbn.getUserId(), profile);
+ }
+ holder.setProfileBadge(mUserBadgeCache.get(sbn.getUserId()));
+ } else {
+ Slog.w(TAG, "null entry in list at position " + position);
}
- holder.setProfileBadge(mUserBadgeCache.get(sbn.getUserId()));
}
@Override
@@ -89,6 +94,13 @@
}
public void onRebuildComplete(List<StatusBarNotification> notifications) {
+ // summaries are low content; don't bother showing them
+ for (int i = notifications.size() - 1; i >= 0; i--) {
+ StatusBarNotification sbn = notifications.get(i);
+ if (sbn.isGroup() && sbn.getNotification().isGroupSummary()) {
+ notifications.remove(i);
+ }
+ }
mValues = notifications;
notifyDataSetChanged();
}
diff --git a/src/com/android/settings/notification/zen/ZenAutomaticRuleHeaderPreferenceController.java b/src/com/android/settings/notification/zen/ZenAutomaticRuleHeaderPreferenceController.java
index 4f6717b..8139555 100644
--- a/src/com/android/settings/notification/zen/ZenAutomaticRuleHeaderPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenAutomaticRuleHeaderPreferenceController.java
@@ -25,7 +25,6 @@
import android.graphics.drawable.Drawable;
import android.service.notification.ZenModeConfig;
import android.util.Slog;
-import android.view.View;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
@@ -61,31 +60,21 @@
return mRule != null;
}
+ @Override
public void updateState(Preference preference) {
- if (mRule == null) {
+ if (mRule == null || mFragment == null) {
return;
}
- if (mFragment != null) {
- LayoutPreference pref = (LayoutPreference) preference;
-
- if (mController == null) {
- mController = EntityHeaderController
- .newInstance(mFragment.getActivity(), mFragment,
- pref.findViewById(R.id.entity_header));
- }
-
- pref = mController.setIcon(getIcon())
- .setLabel(mRule.getName())
- .setPackageName(mRule.getOwner().getPackageName())
- .setUid(mContext.getUserId())
- .setHasAppInfoLink(false)
- .setButtonActions(EntityHeaderController.ActionType.ACTION_EDIT_PREFERENCE,
- EntityHeaderController.ActionType.ACTION_NONE)
- .done(mFragment.getActivity(), mContext);
-
- pref.findViewById(R.id.entity_header).setVisibility(View.VISIBLE);
+ if (mController == null) {
+ final LayoutPreference pref = (LayoutPreference) preference;
+ mController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment,
+ pref.findViewById(R.id.entity_header));
}
+
+ mController.setIcon(getIcon())
+ .setLabel(mRule.getName())
+ .done(mFragment.getActivity(), false /* rebindActions */);
}
private Drawable getIcon() {
diff --git a/src/com/android/settings/password/BiometricFragment.java b/src/com/android/settings/password/BiometricFragment.java
index fe0740b..bc0e5c7 100644
--- a/src/com/android/settings/password/BiometricFragment.java
+++ b/src/com/android/settings/password/BiometricFragment.java
@@ -130,8 +130,12 @@
.setDeviceCredentialAllowed(true)
.setSubtitle(mBundle.getString(BiometricPrompt.KEY_SUBTITLE))
.setDescription(mBundle.getString(BiometricPrompt.KEY_DESCRIPTION))
- .setConfirmationRequired(
- mBundle.getBoolean(BiometricPrompt.KEY_REQUIRE_CONFIRMATION, true))
+ .setTextForDeviceCredential(
+ mBundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_TITLE),
+ mBundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_SUBTITLE),
+ mBundle.getCharSequence(BiometricPrompt.KEY_DEVICE_CREDENTIAL_DESCRIPTION))
+ .setConfirmationRequired(mBundle.getBoolean(
+ BiometricPrompt.KEY_REQUIRE_CONFIRMATION, true))
.setDisallowBiometricsIfPolicyExists(mBundle.getBoolean(
BiometricPrompt.EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS, false));
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 6f505bd..83368f9 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -182,14 +182,7 @@
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);
@@ -200,6 +193,17 @@
bpBundle.putBoolean(BiometricPrompt.EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS,
mCheckDevicePolicyManager);
+ final @LockPatternUtils.CredentialType int credentialType = Utils.getCredentialType(
+ mContext, effectiveUserId);
+ if (mTitle == null) {
+ bpBundle.putString(BiometricPrompt.KEY_DEVICE_CREDENTIAL_TITLE,
+ getTitleFromCredentialType(credentialType, isManagedProfile));
+ }
+ if (mDetails == null) {
+ bpBundle.putString(BiometricPrompt.KEY_DEVICE_CREDENTIAL_DESCRIPTION,
+ getDetailsFromCredentialType(credentialType, isManagedProfile));
+ }
+
boolean launchedBiometric = false;
boolean launchedCDC = false;
// If the target is a managed user and user key not unlocked yet, we will force unlock
diff --git a/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java b/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
index ce036d2..852f286 100644
--- a/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
+++ b/src/com/android/settings/slices/SliceDeepLinkSpringBoard.java
@@ -20,6 +20,7 @@
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
+import android.util.EventLog;
import android.util.Log;
import com.android.settings.bluetooth.BluetoothSliceBuilder;
@@ -73,6 +74,11 @@
private static Uri parse(Uri uri) {
final String sliceParameter = uri.getQueryParameter(EXTRA_SLICE);
- return TextUtils.isEmpty(sliceParameter) ? null : Uri.parse(sliceParameter);
+ if (TextUtils.isEmpty(sliceParameter)) {
+ EventLog.writeEvent(0x534e4554, "122836081", -1, "");
+ return null;
+ } else {
+ return Uri.parse(sliceParameter);
+ }
}
}
diff --git a/src/com/android/settings/users/AddUserWhenLockedPreferenceController.java b/src/com/android/settings/users/AddUserWhenLockedPreferenceController.java
index f931fa4..34892fa 100644
--- a/src/com/android/settings/users/AddUserWhenLockedPreferenceController.java
+++ b/src/com/android/settings/users/AddUserWhenLockedPreferenceController.java
@@ -16,22 +16,29 @@
package com.android.settings.users;
import android.content.Context;
+import android.os.UserHandle;
import android.provider.Settings;
import androidx.preference.Preference;
+import com.android.internal.widget.LockPatternUtils;
import com.android.settings.core.TogglePreferenceController;
import com.android.settingslib.RestrictedSwitchPreference;
public class AddUserWhenLockedPreferenceController extends TogglePreferenceController {
private final UserCapabilities mUserCaps;
+ private LockPatternUtils mLockPatternUtils;
public AddUserWhenLockedPreferenceController(Context context, String key) {
super(context, key);
mUserCaps = UserCapabilities.create(context);
}
+ void setLockPatternUtils(LockPatternUtils lockPatternUtils) {
+ mLockPatternUtils = lockPatternUtils;
+ }
+
@Override
public void updateState(Preference preference) {
super.updateState(preference);
@@ -53,6 +60,8 @@
return DISABLED_FOR_USER;
} else if (mUserCaps.disallowAddUser() || mUserCaps.disallowAddUserSetByAdmin()) {
return DISABLED_FOR_USER;
+ } else if (!mLockPatternUtils.isSecure(UserHandle.myUserId())) {
+ return CONDITIONALLY_UNAVAILABLE;
} else {
return mUserCaps.mUserSwitcherEnabled ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index cd305e9..51da9d2 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -241,6 +241,9 @@
mAddUserWhenLockedPreferenceController = new AddUserWhenLockedPreferenceController(
activity, KEY_ADD_USER_WHEN_LOCKED);
+ mAddUserWhenLockedPreferenceController.setLockPatternUtils(
+ new LockPatternUtils(getPrefContext()));
+
mMultiUserFooterPreferenceController = new MultiUserFooterPreferenceController(activity,
KEY_MULTIUSER_FOOTER);
@@ -1290,8 +1293,11 @@
boolean suppressAllPage) {
final List<String> niks = super.getNonIndexableKeysFromXml(context, xmlResId,
suppressAllPage);
- new AddUserWhenLockedPreferenceController(context, KEY_ADD_USER_WHEN_LOCKED)
- .updateNonIndexableKeys(niks);
+ AddUserWhenLockedPreferenceController controller =
+ new AddUserWhenLockedPreferenceController(
+ context, KEY_ADD_USER_WHEN_LOCKED);
+ controller.setLockPatternUtils(new LockPatternUtils(context));
+ controller.updateNonIndexableKeys(niks);
new AutoSyncDataPreferenceController(context, null /* parent */)
.updateNonIndexableKeys(niks);
new AutoSyncPersonalDataPreferenceController(context, null /* parent */)
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 626e4f3..d9b9e3c 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -667,7 +667,7 @@
config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
if (mAccessPointSecurity == AccessPoint.SECURITY_EAP_SUITE_B) {
config.allowedKeyManagement.set(KeyMgmt.SUITE_B_192);
- config.requirePMF = true;
+ config.requirePmf = true;
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.GCMP_256);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
config.allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher
@@ -807,7 +807,7 @@
break;
case AccessPoint.SECURITY_SAE:
config.allowedKeyManagement.set(KeyMgmt.SAE);
- config.requirePMF = true;
+ config.requirePmf = true;
if (mPasswordView.length() != 0) {
String password = mPasswordView.getText().toString();
config.preSharedKey = '"' + password + '"';
@@ -816,7 +816,7 @@
case AccessPoint.SECURITY_OWE:
config.allowedKeyManagement.set(KeyMgmt.OWE);
- config.requirePMF = true;
+ config.requirePmf = true;
break;
default:
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 26042f5..8352a76 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -662,7 +662,7 @@
config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
if (mWifiEntrySecurity == WifiEntry.SECURITY_EAP_SUITE_B) {
config.allowedKeyManagement.set(KeyMgmt.SUITE_B_192);
- config.requirePMF = true;
+ config.requirePmf = true;
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.GCMP_256);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
config.allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher
@@ -801,7 +801,7 @@
break;
case WifiEntry.SECURITY_SAE:
config.allowedKeyManagement.set(KeyMgmt.SAE);
- config.requirePMF = true;
+ config.requirePmf = true;
if (mPasswordView.length() != 0) {
String password = mPasswordView.getText().toString();
config.preSharedKey = '"' + password + '"';
@@ -810,7 +810,7 @@
case WifiEntry.SECURITY_OWE:
config.allowedKeyManagement.set(KeyMgmt.OWE);
- config.requirePMF = true;
+ config.requirePmf = true;
break;
default:
diff --git a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
index 6a4774b..2f57249 100644
--- a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
@@ -36,7 +36,7 @@
implements PreferenceControllerMixin, SummaryUpdater.OnSummaryChangeListener,
LifecycleObserver, OnResume, OnPause, OnStart, OnStop {
- public static final String KEY_TOGGLE_WIFI = "toggle_wifi";
+ public static final String KEY_TOGGLE_WIFI = "main_toggle_wifi";
private MasterSwitchPreference mWifiPreference;
private WifiEnabler mWifiEnabler;
diff --git a/src/com/android/settings/wifi/WifiUtils.java b/src/com/android/settings/wifi/WifiUtils.java
index 4faf11f..08ba441 100644
--- a/src/com/android/settings/wifi/WifiUtils.java
+++ b/src/com/android/settings/wifi/WifiUtils.java
@@ -193,7 +193,7 @@
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
if (security == AccessPoint.SECURITY_EAP_SUITE_B) {
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SUITE_B_192);
- config.requirePMF = true;
+ config.requirePmf = true;
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.GCMP_256);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.GCMP_256);
config.allowedGroupManagementCiphers.set(WifiConfiguration.GroupMgmtCipher
@@ -207,7 +207,7 @@
break;
case AccessPoint.SECURITY_SAE:
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.SAE);
- config.requirePMF = true;
+ config.requirePmf = true;
if (!TextUtils.isEmpty(password)) {
config.preSharedKey = '"' + password + '"';
}
@@ -215,7 +215,7 @@
case AccessPoint.SECURITY_OWE:
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.OWE);
- config.requirePMF = true;
+ config.requirePmf = true;
break;
default:
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index cc9c22f..a00bb23 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -30,6 +30,7 @@
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.telephony.ims.ImsManager;
import android.telephony.ims.ImsMmTelManager;
import android.telephony.ims.ProvisioningManager;
import android.text.TextUtils;
@@ -46,7 +47,6 @@
import androidx.preference.PreferenceScreen;
import com.android.ims.ImsConfig;
-import com.android.ims.ImsManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.Phone;
import com.android.settings.R;
@@ -100,7 +100,7 @@
private boolean mUseWfcHomeModeForRoaming = false;
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
- private ImsManager mImsManager;
+ private com.android.ims.ImsManager mImsManager;
private ImsMmTelManager mImsMmTelManager;
private ProvisioningManager mProvisioningManager;
private TelephonyManager mTelephonyManager;
@@ -222,7 +222,7 @@
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
- if (action.equals(ImsManager.ACTION_IMS_REGISTRATION_ERROR)) {
+ if (action.equals(ImsManager.ACTION_WFC_IMS_REGISTRATION_ERROR)) {
// If this fragment is active then we are immediately
// showing alert on screen. There is no need to add
// notification in this case.
@@ -261,8 +261,8 @@
}
@VisibleForTesting
- ImsManager getImsManager() {
- return ImsManager.getInstance(getActivity(),
+ com.android.ims.ImsManager getImsManager() {
+ return com.android.ims.ImsManager.getInstance(getActivity(),
SubscriptionUtil.getPhoneId(getActivity(), mSubId));
}
@@ -305,7 +305,7 @@
mUpdateAddress.setOnPreferenceClickListener(mUpdateAddressListener);
mIntentFilter = new IntentFilter();
- mIntentFilter.addAction(ImsManager.ACTION_IMS_REGISTRATION_ERROR);
+ mIntentFilter.addAction(ImsManager.ACTION_WFC_IMS_REGISTRATION_ERROR);
}
@Override
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
index 895bdba..69adf55 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
@@ -43,12 +43,9 @@
import androidx.slice.builders.SliceAction;
import com.android.ims.ImsConfig;
-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.WifiCallingQueryImsState;
-import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.slices.SliceBroadcastReceiver;
import java.util.concurrent.Callable;
@@ -140,10 +137,7 @@
return null;
}
- final ImsManager imsManager = getImsManager(subId);
-
- if (!imsManager.isWfcEnabledByPlatform()
- || !isWfcProvisionedOnDevice(subId)) {
+ if (!queryImsState(subId).isWifiCallingProvisioned()) {
Log.d(TAG, "Wifi calling is either not provisioned or not enabled by Platform");
return null;
}
@@ -168,9 +162,8 @@
}
private boolean isWifiCallingEnabled() {
- final int subId = getDefaultVoiceSubId();
- return queryImsState(subId).isEnabledByUser()
- && queryImsState(subId).isAllowUserControl();
+ final WifiCallingQueryImsState queryState = queryImsState(getDefaultVoiceSubId());
+ return queryState.isEnabledByUser() && queryState.isAllowUserControl();
}
/**
@@ -224,23 +217,21 @@
CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL, subId, false);
final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
- final ImsManager imsManager = getImsManager(subId);
- final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
-
- if (!imsManager.isWfcEnabledByPlatform()
- || !isWfcProvisionedOnDevice(subId)) {
- Log.d(TAG, "Wifi calling is either not provisioned or not enabled by platform");
- return null;
- }
if (!isWifiCallingPrefEditable) {
Log.d(TAG, "Wifi calling preference is not editable");
return null;
}
+ if (!queryImsState(subId).isWifiCallingProvisioned()) {
+ Log.d(TAG, "Wifi calling is either not provisioned or not enabled by platform");
+ return null;
+ }
+
boolean isWifiCallingEnabled = false;
int wfcMode = -1;
try {
+ final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
isWifiCallingEnabled = isWifiCallingEnabled();
wfcMode = getWfcMode(imsMmTelManager);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
@@ -351,10 +342,6 @@
}
}
- protected ImsManager getImsManager(int subId) {
- return ImsManager.getInstance(mContext, SubscriptionUtil.getPhoneId(mContext, subId));
- }
-
protected ImsMmTelManager getImsMmTelManager(int subId) {
return ImsMmTelManager.createForSubscriptionId(subId);
}
@@ -382,11 +369,10 @@
final int subId = getDefaultVoiceSubId();
if (SubscriptionManager.isValidSubscriptionId(subId)) {
- final ImsManager imsManager = getImsManager(subId);
- if (imsManager.isWfcEnabledByPlatform()
- && isWfcProvisionedOnDevice(subId)) {
- final boolean currentValue = queryImsState(subId).isEnabledByUser()
- && queryImsState(subId).isAllowUserControl();
+ final WifiCallingQueryImsState queryState = queryImsState(subId);
+ if (queryState.isWifiCallingProvisioned()) {
+ final boolean currentValue = queryState.isEnabledByUser()
+ && queryState.isAllowUserControl();
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
currentValue);
final Intent activationAppIntent =
@@ -425,12 +411,11 @@
final boolean isWifiOnlySupported = isCarrierConfigManagerKeyEnabled(
CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, subId, true);
- final ImsManager imsManager = getImsManager(subId);
+ final WifiCallingQueryImsState queryState = queryImsState(subId);
if (isWifiCallingPrefEditable
- && imsManager.isWfcEnabledByPlatform()
- && isWfcProvisionedOnDevice(subId)
- && queryImsState(subId).isEnabledByUser()
- && queryImsState(subId).isAllowUserControl()) {
+ && queryState.isWifiCallingProvisioned()
+ && queryState.isEnabledByUser()
+ && queryState.isAllowUserControl()) {
// Change the preference only when wifi calling is enabled
// And when wifi calling preference is editable for the current carrier
final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
@@ -511,11 +496,6 @@
return SubscriptionManager.getDefaultVoiceSubscriptionId();
}
- @VisibleForTesting
- boolean isWfcProvisionedOnDevice(int subId) {
- return MobileNetworkUtils.isWfcProvisionedOnDevice(subId);
- }
-
/**
* Returns Intent of the activation app required to activate wifi calling or null if there is no
* need for activation.
diff --git a/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java b/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
index 3c3aa7d..fdd0bbe 100644
--- a/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
+++ b/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
@@ -253,7 +253,7 @@
final WifiConfiguration enhancedOpenNetworkWifiConfiguration =
getBasicWifiConfiguration();
enhancedOpenNetworkWifiConfiguration.allowedKeyManagement.set(KeyMgmt.OWE);
- enhancedOpenNetworkWifiConfiguration.requirePMF = true;
+ enhancedOpenNetworkWifiConfiguration.requirePmf = true;
wifiConfigurations.add(enhancedOpenNetworkWifiConfiguration);
return wifiConfigurations;
}
@@ -282,7 +282,7 @@
}
} else if (mSecurity.startsWith(SECURITY_SAE)) {
wifiConfiguration.allowedKeyManagement.set(KeyMgmt.SAE);
- wifiConfiguration.requirePMF = true;
+ wifiConfiguration.requirePmf = true;
if (mPreSharedKey.length() != 0) {
wifiConfiguration.preSharedKey = addQuotationIfNeeded(mPreSharedKey);
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
index 325e7f9..0adc6d5 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
@@ -22,7 +22,6 @@
import static org.mockito.Mockito.spy;
import android.content.Context;
-import android.provider.DeviceConfig;
import android.provider.Settings;
import android.view.accessibility.AccessibilityManager;
@@ -72,11 +71,9 @@
@Test
@Config(shadows = {ShadowDeviceConfig.class})
- public void testIsRampingRingerEnabled_bothFlagsOn_Enabled() {
+ public void testIsRampingRingerEnabled_settingsFlagOn_Enabled() {
Settings.Global.putInt(
mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 1 /* ON */);
- DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
- AccessibilitySettings.RAMPING_RINGER_ENABLED, "true", false /* makeDefault*/);
assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isTrue();
}
@@ -87,12 +84,4 @@
mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0 /* OFF */);
assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse();
}
-
- @Test
- @Config(shadows = {ShadowDeviceConfig.class})
- public void testIsRampingRingerEnabled_deviceConfigFlagOff_Disabled() {
- DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
- AccessibilitySettings.RAMPING_RINGER_ENABLED, "false", false /* makeDefault*/);
- assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse();
- }
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceControllerTest.java
index ad4195e..53f6cc0 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceControllerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 The Android Open Source Project
+ * 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.
@@ -16,141 +16,76 @@
package com.android.settings.accessibility;
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
+
import static com.google.common.truth.Truth.assertThat;
-import android.accessibilityservice.AccessibilityServiceInfo;
-import android.content.ComponentName;
import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
+import android.os.UserHandle;
import android.provider.Settings;
-import android.view.accessibility.AccessibilityManager;
-import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
+import androidx.preference.SwitchPreference;
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;
-import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowAccessibilityManager;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class AccessibilityShortcutPreferenceControllerTest {
- private final static String PACKAGE_NAME = "com.foo.bar";
- private final static String CLASS_NAME = PACKAGE_NAME + ".fake_a11y_service";
- private final static String COMPONENT_NAME = PACKAGE_NAME + "/" + CLASS_NAME;
- private final static String SERVICE_NAME = "fake_a11y_service";
- private final static int ON = 1;
- private final static int OFF = 0;
private Context mContext;
+ private SwitchPreference mPreference;
private AccessibilityShortcutPreferenceController mController;
- private ShadowAccessibilityManager mShadowAccessibilityManager;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
- mController = new AccessibilityShortcutPreferenceController(mContext, "shortcut_key");
- mShadowAccessibilityManager = Shadow.extract(AccessibilityManager.getInstance(mContext));
- mShadowAccessibilityManager.setInstalledAccessibilityServiceList(getMockServiceList());
+ mPreference = new SwitchPreference(mContext);
+ mController = new AccessibilityShortcutPreferenceController(mContext,
+ "accessibility_shortcut_preference");
}
@Test
- public void getAvailabilityStatus_hasInstalledA11yServices_shouldReturnAvailable() {
- assertThat(mController.getAvailabilityStatus())
- .isEqualTo(BasePreferenceController.AVAILABLE);
+ public void isChecked_enabledShortcutOnLockScreen_shouldReturnTrue() {
+ Settings.Secure.putIntForUser(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, ON, UserHandle.USER_CURRENT);
+
+ mController.updateState(mPreference);
+
+ assertThat(mController.isChecked()).isTrue();
+ assertThat(mPreference.isChecked()).isTrue();
}
@Test
- public void getAvailabilityStatus_noInstalledServices_shouldReturnDisabledDependentSetting() {
- mShadowAccessibilityManager.setInstalledAccessibilityServiceList(new ArrayList<>());
+ public void isChecked_disabledShortcutOnLockScreen_shouldReturnFalse() {
+ Settings.Secure.putIntForUser(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, OFF,
+ UserHandle.USER_CURRENT);
- assertThat(mController.getAvailabilityStatus())
- .isEqualTo(BasePreferenceController.DISABLED_DEPENDENT_SETTING);
+ mController.updateState(mPreference);
+
+ assertThat(mController.isChecked()).isFalse();
+ assertThat(mPreference.isChecked()).isFalse();
}
@Test
- @Config(shadows = {ShadowAccessibilityShortcutPreferenceFragment.class})
- public void getSummary_enabledAndSelectedA11yServices_shouldReturnSelectedServiceName() {
- ShadowAccessibilityShortcutPreferenceFragment.setServiceName(SERVICE_NAME);
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, ON);
+ public void setChecked_setTrue_shouldEnableShortcutOnLockScreen() {
+ mController.setChecked(true);
- assertThat(mController.getSummary()).isEqualTo(SERVICE_NAME);
+ assertThat(Settings.Secure.getIntForUser(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, OFF,
+ UserHandle.USER_CURRENT)).isEqualTo(ON);
}
@Test
- public void getSummary_enabledAndNoA11yServices_shouldReturnNoServiceInstalled() {
- mShadowAccessibilityManager.setInstalledAccessibilityServiceList(new ArrayList<>());
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, ON);
+ public void setChecked_setFalse_shouldDisableShortcutOnLockScreen() {
+ mController.setChecked(false);
- assertThat(mController.getSummary())
- .isEqualTo(mContext.getString(R.string.accessibility_no_services_installed));
- }
-
- @Test
- public void getSummary_disabledShortcut_shouldReturnOffSummary() {
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, OFF);
-
- assertThat(mController.getSummary())
- .isEqualTo(mContext.getString(R.string.accessibility_feature_state_off));
- }
-
- @Implements(AccessibilityShortcutPreferenceFragment.class)
- private static class ShadowAccessibilityShortcutPreferenceFragment {
- private static String sSelectedServiceName;
-
- public static void setServiceName(String selectedServiceName) {
- sSelectedServiceName = selectedServiceName;
- }
-
- @Implementation
- protected static CharSequence getServiceName(Context context) {
- return sSelectedServiceName;
- }
- }
-
- private AccessibilityServiceInfo getMockAccessibilityServiceInfo() {
- final ApplicationInfo applicationInfo = new ApplicationInfo();
- final ServiceInfo serviceInfo = new ServiceInfo();
- applicationInfo.packageName = PACKAGE_NAME;
- serviceInfo.packageName = PACKAGE_NAME;
- serviceInfo.name = CLASS_NAME;
- serviceInfo.applicationInfo = applicationInfo;
-
- final ResolveInfo resolveInfo = new ResolveInfo();
- resolveInfo.serviceInfo = serviceInfo;
-
- try {
- final AccessibilityServiceInfo info = new AccessibilityServiceInfo(resolveInfo,
- mContext);
- ComponentName componentName = ComponentName.unflattenFromString(COMPONENT_NAME);
- info.setComponentName(componentName);
- return info;
- } catch (XmlPullParserException | IOException e) {
- // Do nothing
- }
-
- return null;
- }
-
- private List<AccessibilityServiceInfo> getMockServiceList() {
- final List<AccessibilityServiceInfo> infoList = new ArrayList<>();
- infoList.add(getMockAccessibilityServiceInfo());
- return infoList;
+ assertThat(Settings.Secure.getIntForUser(mContext.getContentResolver(),
+ Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, ON,
+ UserHandle.USER_CURRENT)).isEqualTo(OFF);
}
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/DaltonizerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/DaltonizerPreferenceControllerTest.java
index 62eb074..1a00cc1 100644
--- a/tests/robotests/src/com/android/settings/accessibility/DaltonizerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/DaltonizerPreferenceControllerTest.java
@@ -34,7 +34,6 @@
private static final String PREF_KEY = "daltonizer_preference";
private static final int ON = 1;
private static final int OFF = 0;
- private static final String DALTONIZER_VALUE = "11";
private Context mContext;
private DaltonizerPreferenceController mController;
@@ -62,13 +61,4 @@
assertThat(mController.getSummary().toString().contains(
mContext.getText(R.string.accessibility_feature_state_off))).isTrue();
}
-
- @Test
- public void getSummary_selectProtanomaly_shouldReturnProtanomalySummary() {
- Settings.Secure.putString(mContext.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER, DALTONIZER_VALUE);
-
- assertThat(mController.getSummary().toString().contains(
- mContext.getText(R.string.daltonizer_mode_protanomaly))).isTrue();
- }
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java
index d23d2f0..cd1d17e 100644
--- a/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java
@@ -20,10 +20,8 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
import android.content.Context;
-import android.provider.DeviceConfig;
import android.provider.Settings;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
@@ -54,8 +52,6 @@
// Turn on both flags to enable ramping ringer.
Settings.Global.putInt(
mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 1 /* ON */);
- DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
- AccessibilitySettings.RAMPING_RINGER_ENABLED, "true", false /* makeDefault*/);
assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
Settings.Global.APPLY_RAMPING_RINGER);
}
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
index 9a4c56b..db5507a 100644
--- a/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettingsTest.java
@@ -20,10 +20,12 @@
import static org.robolectric.Shadows.shadowOf;
+import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.CrossProfileApps;
import android.content.pm.PackageManager;
+import android.content.pm.PermissionInfo;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Pair;
@@ -32,12 +34,10 @@
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;
@@ -47,6 +47,7 @@
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 int PACKAGE_UID = 0;
private static final String PERSONAL_CROSS_PROFILE_PACKAGE = "personalCrossProfilePackage";
private static final String PERSONAL_NON_CROSS_PROFILE_PACKAGE =
@@ -58,21 +59,17 @@
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);
+ public static final String INTERACT_ACROSS_PROFILES_PERMISSION =
+ "android.permission.INTERACT_ACROSS_PROFILES";
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 AppOpsManager mAppOpsManager = mContext.getSystemService(AppOpsManager.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(
@@ -87,7 +84,8 @@
shadowOf(mCrossProfileApps).addCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
shadowOf(mCrossProfileApps).addCrossProfilePackage(WORK_CROSS_PROFILE_PACKAGE);
- List<Pair<ApplicationInfo, UserHandle>> apps = mFragment.collectConfigurableApps();
+ List<Pair<ApplicationInfo, UserHandle>> apps = mFragment.collectConfigurableApps(
+ mPackageManager, mUserManager, mCrossProfileApps);
assertThat(apps.size()).isEqualTo(1);
assertThat(apps.get(0).first.packageName).isEqualTo(PERSONAL_CROSS_PROFILE_PACKAGE);
@@ -108,7 +106,8 @@
shadowOf(mCrossProfileApps).addCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
shadowOf(mCrossProfileApps).addCrossProfilePackage(WORK_CROSS_PROFILE_PACKAGE);
- List<Pair<ApplicationInfo, UserHandle>> apps = mFragment.collectConfigurableApps();
+ List<Pair<ApplicationInfo, UserHandle>> apps = mFragment.collectConfigurableApps(
+ mPackageManager, mUserManager, mCrossProfileApps);
assertThat(apps.size()).isEqualTo(1);
assertThat(apps.get(0).first.packageName).isEqualTo(PERSONAL_CROSS_PROFILE_PACKAGE);
@@ -122,8 +121,40 @@
PERSONAL_PROFILE_ID, PERSONAL_PROFILE_INSTALLED_PACKAGES);
shadowOf(mCrossProfileApps).addCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
- List<Pair<ApplicationInfo, UserHandle>> apps = mFragment.collectConfigurableApps();
+ List<Pair<ApplicationInfo, UserHandle>> apps = mFragment.collectConfigurableApps(
+ mPackageManager, mUserManager, mCrossProfileApps);
assertThat(apps).isEmpty();
}
+
+ @Test
+ public void getNumberOfEnabledApps_returnsNumberOfEnabledApps() {
+ 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(mCrossProfileApps).addCrossProfilePackage(PERSONAL_CROSS_PROFILE_PACKAGE);
+ shadowOf(mCrossProfileApps).addCrossProfilePackage(PERSONAL_NON_CROSS_PROFILE_PACKAGE);
+ String appOp = AppOpsManager.permissionToOp(INTERACT_ACROSS_PROFILES_PERMISSION);
+ shadowOf(mAppOpsManager).setMode(
+ appOp, PACKAGE_UID, PERSONAL_CROSS_PROFILE_PACKAGE, AppOpsManager.MODE_ALLOWED);
+ shadowOf(mAppOpsManager).setMode(
+ appOp, PACKAGE_UID, PERSONAL_CROSS_PROFILE_PACKAGE, AppOpsManager.MODE_IGNORED);
+ shadowOf(mPackageManager).addPermissionInfo(createCrossProfilesPermissionInfo());
+
+ int numOfApps = mFragment.getNumberOfEnabledApps(
+ mContext, mPackageManager, mUserManager, mCrossProfileApps);
+
+ assertThat(numOfApps).isEqualTo(1);
+ }
+
+ 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/development/AbstractBluetoothA2dpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
index bc495f6..772f9ae 100644
--- a/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceControllerTest.java
@@ -38,6 +38,7 @@
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;
@@ -98,6 +99,7 @@
}
@Test
+ @Ignore
public void updateState_option2Set_shouldUpdateToOption2() {
when(mBluetoothCodecConfig.getSampleRate()).thenReturn(
BluetoothCodecConfig.SAMPLE_RATE_48000);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
index 7ff179e..0041920 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
@@ -35,6 +35,7 @@
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;
@@ -101,17 +102,16 @@
}
@Test
+ @Ignore
public void onIndexUpdated_checkFlow() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mCodecConfigAAC);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.onIndexUpdated(mCurrentConfig);
verify(mController).writeConfigurationValues(mCurrentConfig);
- verify(mBluetoothA2dp).setCodecConfigPreference(
- mBluetoothA2dp.getActiveDevice(), mCodecConfigAAC);
+ verify(mBluetoothA2dp).setCodecConfigPreference(null, mCodecConfigAAC);
assertThat(mPreference.getSummary()).isEqualTo(SUMMARY);
}
@@ -136,15 +136,14 @@
assertThat(mController.getCurrentCodecConfig()).isNull();
mController.onBluetoothServiceConnected(mBluetoothA2dp);
- when(mBluetoothA2dp.getCodecStatus(mBluetoothA2dp.getActiveDevice())).thenReturn(null);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(null);
assertThat(mController.getCurrentCodecConfig()).isNull();
}
@Test
public void getCurrentCodecConfig_verifyConfig() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
assertThat(mController.getCurrentCodecConfig()).isEqualTo(mCodecConfigAAC);
@@ -153,8 +152,7 @@
@Test
public void getSelectableConfigs_verifyConfig() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs);
@@ -163,8 +161,7 @@
@Test
public void getSelectableByCodecType_verifyConfig() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
assertThat(mController.getSelectableByCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC))
@@ -174,8 +171,7 @@
@Test
public void getSelectableByCodecType_unavailable() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
assertThat(mController.getSelectableByCodecType(
@@ -185,8 +181,7 @@
@Test
public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() {
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
verify(mBluetoothA2dpConfigStore).setCodecType(mCodecConfigAAC.getCodecType());
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
index 7c5e86e..0061fc0 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
@@ -92,8 +92,7 @@
public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(0);
@@ -122,8 +121,7 @@
public void getSelectableIndex_verifyList() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
List<Integer> indexList = new ArrayList<>();
indexList.add(mPreference.getDefaultIndex());
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
index 32651ba..326cc22 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
@@ -92,8 +92,7 @@
public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(0);
@@ -119,8 +118,7 @@
public void getSelectableIndex_verifyList() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
List<Integer> indexList = new ArrayList<>();
indexList.add(mPreference.getDefaultIndex());
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
index f93766f..f4ed811 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
@@ -99,8 +99,7 @@
public void writeConfigurationValues_selectDefault_setHighest() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(0);
@@ -112,8 +111,7 @@
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(1);
@@ -140,8 +138,7 @@
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(2);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java
index 0701e78..1f0daa3 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java
@@ -91,7 +91,7 @@
@Test
public void updateState_codecSupported_setEnable() {
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
- when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
@@ -102,7 +102,7 @@
@Test
public void updateState_codecNotSupported_setDisable() {
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
- when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_NOT_SUPPORTED);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
@@ -113,9 +113,9 @@
@Test
public void updateState_codecSupportedAndEnabled_checked() {
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
- when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
- when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.getOptionalCodecsEnabled(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
@@ -126,9 +126,9 @@
@Test
public void updateState_codecSupportedAndDisabled_notChecked() {
when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
- when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
- when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
+ when(mBluetoothA2dp.getOptionalCodecsEnabled(mActiveDevice)).thenReturn(
mBluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
index 30e3f31..35bd704 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
@@ -110,8 +110,7 @@
public void updateState_codeTypeIsLDAC_enablePreference() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigLDAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
@@ -122,8 +121,7 @@
public void updateState_codeTypeAAC_disablePreference() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
index 089acc5..d274a57 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
@@ -93,8 +93,7 @@
mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
mController.writeConfigurationValues(0);
@@ -126,8 +125,7 @@
public void getSelectableIndex_verifyList() {
BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
- when(mBluetoothA2dp.getCodecStatus(
- mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+ when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
mController.onBluetoothServiceConnected(mBluetoothA2dp);
List<Integer> indexList = new ArrayList<>();
indexList.add(mController.getDefaultIndex());
diff --git a/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceControllerTest.java
index 1dac131..a2d23b6 100644
--- a/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceControllerTest.java
@@ -105,4 +105,20 @@
verify(mGraphicsDriverContentObserver).unregister(mResolver);
}
+
+ @Test
+ public void updateState_available_visible() {
+ when(mController.getAvailabilityStatus()).thenReturn(AVAILABLE_UNSEARCHABLE);
+ mController.updateState(mPreference);
+
+ verify(mPreference).setVisible(true);
+ }
+
+ @Test
+ public void updateState_unavailable_invisible() {
+ when(mController.getAvailabilityStatus()).thenReturn(CONDITIONALLY_UNAVAILABLE);
+ mController.updateState(mPreference);
+
+ verify(mPreference).setVisible(false);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
index 851dfe0..395c8a4 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
@@ -43,6 +43,7 @@
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.content.pm.PackageInfo;
@@ -80,6 +81,7 @@
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowPackageManager;
+import org.robolectric.shadows.ShadowTelephonyManager;
import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
@@ -93,7 +95,6 @@
@Mock
private SimStatusDialogFragment mDialog;
- @Mock
private TelephonyManager mTelephonyManager;
@Mock
private SubscriptionInfo mSubscriptionInfo;
@@ -115,7 +116,6 @@
private PersistableBundle mPersistableBundle;
@Mock
private EuiccManager mEuiccManager;
- @Mock
private SubscriptionManager mSubscriptionManager;
private SimStatusDialogController mController;
@@ -131,10 +131,22 @@
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
+ mContext = spy(RuntimeEnvironment.application);
when(mDialog.getContext()).thenReturn(mContext);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
+
+ mSubscriptionManager = spy(mContext.getSystemService(SubscriptionManager.class));
+
+ mTelephonyManager = spy(mContext.getSystemService(TelephonyManager.class));
+ final ShadowTelephonyManager shadowTelephonyMgr = shadowOf(mTelephonyManager);
+ shadowTelephonyMgr.setTelephonyManagerForSubscriptionId(
+ SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, mTelephonyManager);
+ doReturn(2).when(mTelephonyManager).getCardIdForDefaultEuicc();
+ doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mTelephonyManager).getDataNetworkType();
+
+ doReturn(mEuiccManager).when(mContext).getSystemService(EuiccManager.class);
+
mController = spy(new SimStatusDialogController(mDialog, mLifecycle, 0 /* phone id */));
ShadowDeviceInfoUtils.setPhoneNumber("");
//CellSignalStrength setup
@@ -156,9 +168,9 @@
ReflectionHelpers.setField(mController, "mSubscriptionManager", mSubscriptionManager);
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
- when(mTelephonyManager.getUiccCardsInfo()).thenReturn(new ArrayList<UiccCardInfo>());
- when(mTelephonyManager.getLogicalToPhysicalSlotMapping()).thenReturn(
- new HashMap<Integer, Integer>());
+ doReturn(new ArrayList<UiccCardInfo>()).when(mTelephonyManager).getUiccCardsInfo();
+ doReturn(new HashMap<Integer, Integer>()).when(mTelephonyManager)
+ .getLogicalToPhysicalSlotMapping();
when(mEuiccManager.isEnabled()).thenReturn(false);
when(mEuiccManager.getEid()).thenReturn("");
@@ -168,7 +180,6 @@
when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL))
.thenReturn(true);
- when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
doReturn(mServiceState).when(mTelephonyManager).getServiceState();
doReturn(mSignalStrength).when(mTelephonyManager).getSignalStrength();
@@ -185,7 +196,6 @@
}
@Test
- @Ignore
public void initialize_updateNetworkProviderWithFoobarCarrier_shouldUpdateCarrierWithFoobar() {
final CharSequence carrierName = "foobar";
doReturn(carrierName).when(mSubscriptionInfo).getCarrierName();
@@ -196,7 +206,6 @@
}
@Test
- @Ignore
public void initialize_updatePhoneNumberWith1111111111_shouldUpdatePhoneNumber() {
ShadowDeviceInfoUtils.setPhoneNumber("1111111111");
@@ -209,7 +218,6 @@
}
@Test
- @Ignore
public void initialize_updateLatestAreaInfoWithCdmaPhone_shouldRemoveOperatorInfoSetting() {
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
@@ -220,7 +228,6 @@
}
@Test
- @Ignore
public void initialize_updateServiceStateWithInService_shouldUpdateTextToBeCInService() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
@@ -231,7 +238,6 @@
}
@Test
- @Ignore
public void initialize_updateServiceStateWithPowerOff_shouldUpdateTextAndResetSignalStrength() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_POWER_OFF);
when(mPersistableBundle.getBoolean(
@@ -245,7 +251,6 @@
}
@Test
- @Ignore
public void initialize_updateVoiceDataOutOfService_shouldUpdateSettingAndResetSignalStrength() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
when(mServiceState.getDataRegistrationState()).thenReturn(
@@ -261,7 +266,6 @@
}
@Test
- @Ignore
public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateTextToBeInService() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
@@ -275,7 +279,6 @@
}
@Test
- @Ignore
public void initialize_updateSignalStrengthWithLte50Wcdma40_shouldUpdateSignalStrengthTo50() {
final int lteDbm = 50;
final int lteAsu = 50;
@@ -293,7 +296,6 @@
}
@Test
- @Ignore
public void initialize_updateSignalStrengthWithLte50Cdma30_shouldUpdateSignalStrengthTo50() {
final int lteDbm = 50;
final int lteAsu = 50;
@@ -311,7 +313,6 @@
}
@Test
- @Ignore
public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateSignalStrengthTo50() {
when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
@@ -332,7 +333,6 @@
}
@Test
- @Ignore
public void initialize_updateVoiceNetworkTypeWithEdge_shouldUpdateSettingToEdge() {
when(mTelephonyManager.getVoiceNetworkType()).thenReturn(
TelephonyManager.NETWORK_TYPE_EDGE);
@@ -344,7 +344,6 @@
}
@Test
- @Ignore
public void initialize_updateDataNetworkTypeWithEdge_shouldUpdateSettingToEdge() {
when(mTelephonyManager.getDataNetworkType()).thenReturn(
TelephonyManager.NETWORK_TYPE_EDGE);
@@ -356,7 +355,6 @@
}
@Test
- @Ignore
public void initialize_updateRoamingStatusIsRoaming_shouldSetSettingToRoaming() {
when(mServiceState.getRoaming()).thenReturn(true);
@@ -367,7 +365,6 @@
}
@Test
- @Ignore
public void initialize_updateRoamingStatusNotRoaming_shouldSetSettingToRoamingOff() {
when(mServiceState.getRoaming()).thenReturn(false);
@@ -378,7 +375,6 @@
}
@Test
- @Ignore
public void initialize_doNotShowIccid_shouldRemoveIccidSetting() {
when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL)).thenReturn(false);
@@ -390,7 +386,6 @@
}
@Test
- @Ignore
public void initialize_doNotShowSignalStrength_shouldRemoveSignalStrengthSetting() {
when(mPersistableBundle.getBoolean(
CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL))
@@ -403,7 +398,6 @@
}
@Test
- @Ignore
public void initialize_showSignalStrengthAndIccId_shouldShowSignalStrengthAndIccIdSetting() {
// getConfigForSubId is nullable, so make sure the default behavior is correct
when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(null);
@@ -416,7 +410,6 @@
}
@Test
- @Ignore
public void initialize_showIccid_shouldSetIccidToSetting() {
final String iccid = "12351351231241";
when(mPersistableBundle.getBoolean(
@@ -429,7 +422,6 @@
}
@Test
- @Ignore
public void initialize_updateEid_shouldNotSetEid() {
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
@@ -468,7 +460,6 @@
}
@Test
- @Ignore
public void initialize_updateEid_shouldSetEidFromCard() {
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
@@ -507,7 +498,6 @@
}
@Test
- @Ignore
public void initialize_updateEid_shouldSetEidFromManager() {
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
@@ -549,7 +539,6 @@
}
@Test
- @Ignore
public void initialize_updateEid_shouldRemoveEid() {
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
@@ -589,7 +578,6 @@
}
@Test
- @Ignore
public void initialize_updateEid_shouldNotSetEidInSingleSimMode() {
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
@@ -619,7 +607,6 @@
}
@Test
- @Ignore
public void initialize_updateEid_shouldSetEidInSingleSimModeWithEnabledEuicc() {
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
@@ -651,7 +638,6 @@
}
@Test
- @Ignore
public void initialize_updateEid_shouldSetEidInSingleSimModeWithDisabledEuicc() {
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
@@ -683,7 +669,6 @@
}
@Test
- @Ignore
public void initialize_updateEid_shouldRemoveEidInSingleSimMode() {
when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
@@ -763,7 +748,6 @@
}
@Test
- @Ignore
public void initialize_nullSignalStrength_noCrash() {
doReturn(null).when(mTelephonyManager).getSignalStrength();
// we should not crash when running the following line
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index ebb5292..5e49aa0 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -20,7 +20,6 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.mock;
@@ -120,7 +119,7 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mActivity).startActivityForResultAsUser(argumentCaptor.capture(), anyInt(),
+ verify(mActivity).startActivityAsUser(argumentCaptor.capture(),
nullable(UserHandle.class));
final Intent intent = argumentCaptor.getValue();
@@ -138,8 +137,8 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
- anyInt(), nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+ nullable(UserHandle.class));
final Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -165,8 +164,8 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
- anyInt(), nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+ nullable(UserHandle.class));
final Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -184,8 +183,8 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
- anyInt(), nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+ nullable(UserHandle.class));
Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -221,8 +220,8 @@
.isTrue();
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
- anyInt(), nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+ nullable(UserHandle.class));
Intent intent = argumentCaptor.getValue();
Intent browseIntent = mVolume.buildBrowseIntent();
@@ -238,8 +237,8 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
- anyInt(), nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+ nullable(UserHandle.class));
Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -256,8 +255,8 @@
mController.handlePreferenceTreeClick(mPreference);
final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
- anyInt(), nullable(UserHandle.class));
+ verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+ nullable(UserHandle.class));
Intent intent = argumentCaptor.getValue();
assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/CardDatabaseHelperTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/CardDatabaseHelperTest.java
index 36e4f04..7c76999 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/CardDatabaseHelperTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/CardDatabaseHelperTest.java
@@ -67,18 +67,8 @@
CardDatabaseHelper.CardColumns.SCORE,
CardDatabaseHelper.CardColumns.SLICE_URI,
CardDatabaseHelper.CardColumns.CATEGORY,
- CardDatabaseHelper.CardColumns.LOCALIZED_TO_LOCALE,
CardDatabaseHelper.CardColumns.PACKAGE_NAME,
CardDatabaseHelper.CardColumns.APP_VERSION,
- CardDatabaseHelper.CardColumns.TITLE_RES_NAME,
- CardDatabaseHelper.CardColumns.TITLE_TEXT,
- CardDatabaseHelper.CardColumns.SUMMARY_RES_NAME,
- CardDatabaseHelper.CardColumns.SUMMARY_TEXT,
- CardDatabaseHelper.CardColumns.ICON_RES_NAME,
- CardDatabaseHelper.CardColumns.ICON_RES_ID,
- CardDatabaseHelper.CardColumns.CARD_ACTION,
- CardDatabaseHelper.CardColumns.EXPIRE_TIME_MS,
- CardDatabaseHelper.CardColumns.SUPPORT_HALF_WIDTH,
CardDatabaseHelper.CardColumns.CARD_DISMISSED,
};
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
index 00993f6..fceb79d 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
@@ -17,6 +17,7 @@
package com.android.settings.homepage.contextualcards;
import static com.android.settings.homepage.contextualcards.ContextualCardLoader.DEFAULT_CARD_COUNT;
+import static com.android.settings.intelligence.ContextualCardProto.ContextualCard.Category.STICKY_VALUE;
import static com.google.common.truth.Truth.assertThat;
@@ -82,16 +83,41 @@
@Test
public void getDisplayableCards_fourEligibleCards_shouldShowDefaultCardCount() {
- final List<ContextualCard> fourCards = getContextualCardList();
- doReturn(fourCards).when(mContextualCardLoader).filterEligibleCards(anyList());
+ final List<ContextualCard> cards = getContextualCardList().stream().limit(4)
+ .collect(Collectors.toList());
+ doReturn(cards).when(mContextualCardLoader).filterEligibleCards(anyList());
- final List<ContextualCard> result = mContextualCardLoader
- .getDisplayableCards(fourCards);
+ final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
assertThat(result).hasSize(DEFAULT_CARD_COUNT);
}
@Test
+ public void getDisplayableCards_oneStickyCard_shouldShowOneStickyCardAtTheTail() {
+ final List<ContextualCard> cards = getContextualCardList().stream().limit(5)
+ .collect(Collectors.toList());
+ doReturn(cards).when(mContextualCardLoader).filterEligibleCards(anyList());
+
+ final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
+
+ assertThat(result).hasSize(DEFAULT_CARD_COUNT);
+ assertThat(result.get(DEFAULT_CARD_COUNT - 1).getCategory()).isEqualTo(STICKY_VALUE);
+ }
+
+ @Test
+ public void getDisplayableCards_threeStickyCards_shouldShowThreeStickyCardAtTheTail() {
+ final List<ContextualCard> cards = getContextualCardList();
+ doReturn(cards).when(mContextualCardLoader).filterEligibleCards(anyList());
+
+ final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
+
+ assertThat(result).hasSize(DEFAULT_CARD_COUNT);
+ for (int i = 1; i <= Math.min(3, DEFAULT_CARD_COUNT); i++) {
+ assertThat(result.get(DEFAULT_CARD_COUNT - i).getCategory()).isEqualTo(STICKY_VALUE);
+ }
+ }
+
+ @Test
public void getDisplayableCards_refreshCardUri_shouldLogContextualCard() {
mContextualCardLoader.mNotifyUri = CardContentProvider.REFRESH_CARD_URI;
@@ -128,20 +154,20 @@
private List<ContextualCard> getContextualCardList() {
final List<ContextualCard> cards = new ArrayList<>();
cards.add(new ContextualCard.Builder()
- .setName("test_wifi")
+ .setName("test_low_storage")
.setCardType(ContextualCard.CardType.SLICE)
- .setSliceUri(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI)
+ .setSliceUri(CustomSliceRegistry.LOW_STORAGE_SLICE_URI)
.build());
cards.add(new ContextualCard.Builder()
.setName("test_flashlight")
.setCardType(ContextualCard.CardType.SLICE)
- .setSliceUri(
- Uri.parse("content://com.android.settings.test.slices/action/flashlight"))
+ .setSliceUri(Uri.parse(
+ "content://com.android.settings.test.slices/action/flashlight"))
.build());
cards.add(new ContextualCard.Builder()
- .setName("test_connected")
+ .setName("test_dark_theme")
.setCardType(ContextualCard.CardType.SLICE)
- .setSliceUri(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI)
+ .setSliceUri(CustomSliceRegistry.DARK_THEME_SLICE_URI)
.build());
cards.add(new ContextualCard.Builder()
.setName("test_gesture")
@@ -149,6 +175,24 @@
.setSliceUri(Uri.parse(
"content://com.android.settings.test.slices/action/gesture_pick_up"))
.build());
+ cards.add(new ContextualCard.Builder()
+ .setName("test_wifi")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI)
+ .setCategory(STICKY_VALUE)
+ .build());
+ cards.add(new ContextualCard.Builder()
+ .setName("test_connected")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI)
+ .setCategory(STICKY_VALUE)
+ .build());
+ cards.add(new ContextualCard.Builder()
+ .setName("test_sticky")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(Uri.parse("content://com.android.settings.test.slices/action/sticky"))
+ .setCategory(STICKY_VALUE)
+ .build());
return cards;
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
index d179cae..8958d6e 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
@@ -565,7 +565,27 @@
}
@Test
+ public void getCardsWithViewType_hasOneStickySlice_shouldHaveOneStickyCard() {
+ FeatureFlagUtils.setEnabled(mContext, FeatureFlags.CONTEXTUAL_HOME2, true);
+ final List<ContextualCard> cards = new ArrayList<>();
+ cards.add(buildContextualCard(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI.toString()));
+ cards.add(buildContextualCard(CustomSliceRegistry.LOW_STORAGE_SLICE_URI.toString()));
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.STICKY_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE
+ );
+ final List<ContextualCard> cardListWithWifi = buildCategoriedCards(cards, categories);
+
+ final List<ContextualCard> result = mManager.getCardsWithViewType(cardListWithWifi);
+
+ assertThat(result).hasSize(cards.size());
+ assertThat(result.get(0).getViewType()).isEqualTo(VIEW_TYPE_STICKY);
+ assertThat(result.get(1).getViewType()).isEqualTo(VIEW_TYPE_FULL_WIDTH);
+ }
+
+ @Test
public void getCardsWithViewType_hasWifiSlice_shouldHaveOneStickyCard() {
+ FeatureFlagUtils.setEnabled(mContext, FeatureFlags.CONTEXTUAL_HOME2, false);
final List<ContextualCard> cards = new ArrayList<>();
cards.add(buildContextualCard(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI.toString()));
cards.add(buildContextualCard(CustomSliceRegistry.LOW_STORAGE_SLICE_URI.toString()));
@@ -584,6 +604,7 @@
@Test
public void getCardsWithViewType_hasBluetoothDeviceSlice_shouldHaveOneStickyCard() {
+ FeatureFlagUtils.setEnabled(mContext, FeatureFlags.CONTEXTUAL_HOME2, false);
final List<ContextualCard> cards = new ArrayList<>();
cards.add(buildContextualCard(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI.toString()));
cards.add(buildContextualCard(CustomSliceRegistry.LOW_STORAGE_SLICE_URI.toString()));
@@ -602,6 +623,7 @@
@Test
public void getCardsWithViewType_hasWifiAndBtDeviceSlice_shouldHaveTwoStickyCards() {
+ FeatureFlagUtils.setEnabled(mContext, FeatureFlags.CONTEXTUAL_HOME2, false);
final List<ContextualCard> cards = new ArrayList<>();
cards.add(buildContextualCard(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI.toString()));
cards.add(buildContextualCard(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI.toString()));
@@ -624,6 +646,7 @@
@Test
public void getCardsWithViewType_noWifiOrBtDeviceSlice_shouldNotHaveStickyCard() {
+ FeatureFlagUtils.setEnabled(mContext, FeatureFlags.CONTEXTUAL_HOME2, false);
final List<Integer> categories = Arrays.asList(
ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
@@ -683,8 +706,8 @@
cards.add(new ContextualCard.Builder()
.setName("test_flashlight")
.setCardType(ContextualCard.CardType.SLICE)
- .setSliceUri(
- Uri.parse("content://com.android.settings.test.slices/action/flashlight"))
+ .setSliceUri(Uri.parse(
+ "content://com.android.settings.test.slices/action/flashlight"))
.setViewType(VIEW_TYPE_FULL_WIDTH)
.build());
cards.add(new ContextualCard.Builder()
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
index 3777920..23ae2f3 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
@@ -76,18 +76,6 @@
}
@Test
- public void isCardEligibleToDisplay_customCard_returnTrue() {
- final ContextualCard customCard = new ContextualCard.Builder()
- .setName("custom_card")
- .setCardType(ContextualCard.CardType.DEFAULT)
- .setTitleText("custom_title")
- .setSummaryText("custom_summary")
- .build();
-
- assertThat(mEligibleCardChecker.isCardEligibleToDisplay(customCard)).isTrue();
- }
-
- @Test
public void isCardEligibleToDisplay_invalidScheme_returnFalse() {
final Uri sliceUri = Uri.parse("contet://com.android.settings.slices/action/flashlight");
diff --git a/tests/robotests/src/com/android/settings/network/AllInOneTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/AllInOneTetherPreferenceControllerTest.java
new file mode 100644
index 0000000..c74e669
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/AllInOneTetherPreferenceControllerTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothPan;
+import android.bluetooth.BluetoothProfile;
+import android.content.Context;
+import android.content.SharedPreferences;
+
+import com.android.settings.widget.MasterSwitchPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.util.ReflectionHelpers;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+@RunWith(RobolectricTestRunner.class)
+public class AllInOneTetherPreferenceControllerTest {
+
+ @Mock
+ private Context mContext;
+ @Mock
+ private BluetoothAdapter mBluetoothAdapter;
+ @Mock
+ private MasterSwitchPreference mPreference;
+ @Mock
+ private SharedPreferences mSharedPreferences;
+
+ private AllInOneTetherPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mController = spy(AllInOneTetherPreferenceController.class);
+ ReflectionHelpers.setField(mController, "mContext", mContext);
+ ReflectionHelpers.setField(mController, "mBluetoothAdapter", mBluetoothAdapter);
+ ReflectionHelpers.setField(mController, "mPreference", mPreference);
+ ReflectionHelpers
+ .setField(mController, "mTetherEnablerSharedPreferences", mSharedPreferences);
+ }
+
+ @Test
+ public void onCreate_shouldInitBluetoothPan() {
+ when(mBluetoothAdapter.getState()).thenReturn(BluetoothAdapter.STATE_ON);
+ mController.onCreate();
+
+ verify(mBluetoothAdapter).getState();
+ verify(mBluetoothAdapter).getProfileProxy(mContext, mController.mBtProfileServiceListener,
+ BluetoothProfile.PAN);
+ }
+
+ @Test
+ public void onCreate_shouldNotInitBluetoothPanWhenBluetoothOff() {
+ when(mBluetoothAdapter.getState()).thenReturn(BluetoothAdapter.STATE_OFF);
+ mController.onCreate();
+
+ verify(mBluetoothAdapter).getState();
+ verifyNoMoreInteractions(mBluetoothAdapter);
+ }
+
+ @Test
+ public void goThroughLifecycle_shouldDestroyBluetoothProfile() {
+ final BluetoothPan pan = mock(BluetoothPan.class);
+ final AtomicReference<BluetoothPan> panRef =
+ ReflectionHelpers.getField(mController, "mBluetoothPan");
+ panRef.set(pan);
+
+ mController.onDestroy();
+
+ verify(mBluetoothAdapter).closeProfileProxy(BluetoothProfile.PAN, pan);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java b/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java
deleted file mode 100644
index d2a7129..0000000
--- a/tests/robotests/src/com/android/settings/network/ims/MockImsQueryResult.java
+++ /dev/null
@@ -1,38 +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.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
index 42ddd70..84399a2 100644
--- a/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java
+++ b/tests/robotests/src/com/android/settings/network/ims/MockVolteQueryImsState.java
@@ -27,9 +27,9 @@
*/
public class MockVolteQueryImsState extends VolteQueryImsState {
- private ImsQuery mIsTtyOnVolteEnabled;
- private ImsQuery mIsProvisionedOnDevice;
- private ImsQuery mIsEnabledByUser;
+ private Boolean mIsTtyOnVolteEnabled;
+ private Boolean mIsProvisionedOnDevice;
+ private Boolean mIsEnabledByUser;
/**
* Constructor
@@ -46,11 +46,11 @@
}
public void setIsTtyOnVolteEnabled(boolean enabled) {
- mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
+ mIsTtyOnVolteEnabled = enabled;
}
@Override
- ImsQuery isTtyOnVolteEnabled(int subId) {
+ boolean isTtyOnVolteEnabled(int subId) {
if (mIsTtyOnVolteEnabled != null) {
return mIsTtyOnVolteEnabled;
}
@@ -58,11 +58,11 @@
}
public void setIsProvisionedOnDevice(boolean isProvisioned) {
- mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
+ mIsProvisionedOnDevice = isProvisioned;
}
@Override
- ImsQuery isProvisionedOnDevice(int subId) {
+ boolean isProvisionedOnDevice(int subId) {
if (mIsProvisionedOnDevice != null) {
return mIsProvisionedOnDevice;
}
@@ -70,11 +70,11 @@
}
public void setIsEnabledByUser(boolean enabled) {
- mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
+ mIsEnabledByUser = enabled;
}
@Override
- ImsQuery isEnabledByUser(int subId) {
+ boolean isEnabledByUser(int subId) {
if (mIsEnabledByUser != null) {
return mIsEnabledByUser;
}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
index b5971e9..4fd7d0c 100644
--- a/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
+++ b/tests/robotests/src/com/android/settings/network/ims/MockVtQueryImsState.java
@@ -26,9 +26,9 @@
*/
public class MockVtQueryImsState extends VtQueryImsState {
- private ImsQuery mIsTtyOnVolteEnabled;
- private ImsQuery mIsProvisionedOnDevice;
- private ImsQuery mIsEnabledByUser;
+ private Boolean mIsTtyOnVolteEnabled;
+ private Boolean mIsProvisionedOnDevice;
+ private Boolean mIsEnabledByUser;
/**
* Constructor
@@ -45,11 +45,11 @@
}
public void setIsTtyOnVolteEnabled(boolean enabled) {
- mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
+ mIsTtyOnVolteEnabled = enabled;
}
@Override
- ImsQuery isTtyOnVolteEnabled(int subId) {
+ boolean isTtyOnVolteEnabled(int subId) {
if (mIsTtyOnVolteEnabled != null) {
return mIsTtyOnVolteEnabled;
}
@@ -57,11 +57,11 @@
}
public void setIsProvisionedOnDevice(boolean isProvisioned) {
- mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
+ mIsProvisionedOnDevice = isProvisioned;
}
@Override
- ImsQuery isProvisionedOnDevice(int subId) {
+ boolean isProvisionedOnDevice(int subId) {
if (mIsProvisionedOnDevice != null) {
return mIsProvisionedOnDevice;
}
@@ -69,11 +69,11 @@
}
public void setIsEnabledByUser(boolean enabled) {
- mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
+ mIsEnabledByUser = enabled;
}
@Override
- ImsQuery isEnabledByUser(int subId) {
+ boolean isEnabledByUser(int subId) {
if (mIsEnabledByUser != null) {
return mIsEnabledByUser;
}
diff --git a/tests/robotests/src/com/android/settings/network/ims/MockWifiCallingQueryImsState.java b/tests/robotests/src/com/android/settings/network/ims/MockWifiCallingQueryImsState.java
index aa30aa0..8123c93 100644
--- a/tests/robotests/src/com/android/settings/network/ims/MockWifiCallingQueryImsState.java
+++ b/tests/robotests/src/com/android/settings/network/ims/MockWifiCallingQueryImsState.java
@@ -26,9 +26,9 @@
*/
public class MockWifiCallingQueryImsState extends WifiCallingQueryImsState {
- private ImsQuery mIsTtyOnVolteEnabled;
- private ImsQuery mIsProvisionedOnDevice;
- private ImsQuery mIsEnabledByUser;
+ private Boolean mIsTtyOnVolteEnabled;
+ private Boolean mIsProvisionedOnDevice;
+ private Boolean mIsEnabledByUser;
/**
* Constructor
@@ -45,11 +45,11 @@
}
public void setIsTtyOnVolteEnabled(boolean enabled) {
- mIsTtyOnVolteEnabled = new MockImsQueryResult.BooleanResult(enabled);
+ mIsTtyOnVolteEnabled = enabled;
}
@Override
- ImsQuery isTtyOnVolteEnabled(int subId) {
+ boolean isTtyOnVolteEnabled(int subId) {
if (mIsTtyOnVolteEnabled != null) {
return mIsTtyOnVolteEnabled;
}
@@ -57,11 +57,11 @@
}
public void setIsProvisionedOnDevice(boolean isProvisioned) {
- mIsProvisionedOnDevice = new MockImsQueryResult.BooleanResult(isProvisioned);
+ mIsProvisionedOnDevice = isProvisioned;
}
@Override
- ImsQuery isProvisionedOnDevice(int subId) {
+ boolean isProvisionedOnDevice(int subId) {
if (mIsProvisionedOnDevice != null) {
return mIsProvisionedOnDevice;
}
@@ -69,11 +69,11 @@
}
public void setIsEnabledByUser(boolean enabled) {
- mIsEnabledByUser = new MockImsQueryResult.BooleanResult(enabled);
+ mIsEnabledByUser = enabled;
}
@Override
- ImsQuery isEnabledByUser(int subId) {
+ boolean isEnabledByUser(int subId) {
if (mIsEnabledByUser != null) {
return mIsEnabledByUser;
}
diff --git a/tests/robotests/src/com/android/settings/network/telephony/RoamingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/RoamingPreferenceControllerTest.java
index 0abd6d5..092b9b7 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/RoamingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/RoamingPreferenceControllerTest.java
@@ -117,10 +117,10 @@
}
@Test
- public void handlePreferenceTreeClick_needDialog_showDialog() {
+ public void setChecked_needDialog_showDialog() {
doReturn(true).when(mController).isDialogNeeded();
- mController.handlePreferenceTreeClick(mPreference);
+ mController.setChecked(true);
verify(mFragmentManager).beginTransaction();
}
diff --git a/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java
index b27b636..9e0f2cc 100644
--- a/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/users/AddUserWhenLockedPreferenceControllerTest.java
@@ -18,6 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
+import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -27,6 +28,8 @@
import androidx.preference.PreferenceScreen;
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.core.BasePreferenceController;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -51,13 +54,16 @@
private Context mContext;
private ShadowUserManager mUserManager;
private AddUserWhenLockedPreferenceController mController;
+ private LockPatternUtils mLockPatternUtils;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
+ mLockPatternUtils = mock(LockPatternUtils.class);
mUserManager = ShadowUserManager.getShadow();
mController = new AddUserWhenLockedPreferenceController(mContext, "fake_key");
+ mController.setLockPatternUtils(mLockPatternUtils);
mUserManager.setSupportsMultipleUsers(true);
}
@@ -69,6 +75,7 @@
@Test
public void displayPref_NotAdmin_shouldNotDisplay() {
mUserManager.setIsAdminUser(false);
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
when(preference.getKey()).thenReturn(mController.getPreferenceKey());
when(mScreen.findPreference(preference.getKey())).thenReturn(preference);
@@ -81,6 +88,7 @@
@Test
public void updateState_NotAdmin_shouldNotDisplayPreference() {
mUserManager.setIsAdminUser(false);
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
mController.updateState(preference);
@@ -93,8 +101,10 @@
mUserManager.setIsAdminUser(true);
mUserManager.setUserSwitcherEnabled(true);
mUserManager.setSupportsMultipleUsers(true);
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
final AddUserWhenLockedPreferenceController controller =
new AddUserWhenLockedPreferenceController(mContext, "fake_key");
+ controller.setLockPatternUtils(mLockPatternUtils);
final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
controller.updateState(preference);
@@ -143,4 +153,40 @@
assertThat(Global.getInt(mContext.getContentResolver(), Global.ADD_USERS_WHEN_LOCKED, 0))
.isEqualTo(0);
}
+
+ @Test
+ public void updateState_insecureLockScreen_shouldNotDisplayPreference() {
+ mUserManager.setIsAdminUser(true);
+ mUserManager.setUserSwitcherEnabled(true);
+ mUserManager.setSupportsMultipleUsers(true);
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
+ final AddUserWhenLockedPreferenceController controller =
+ new AddUserWhenLockedPreferenceController(mContext, "fake_key");
+ controller.setLockPatternUtils(mLockPatternUtils);
+ final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
+
+ controller.updateState(preference);
+
+ verify(preference).setVisible(false);
+ assertThat(controller.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
+ }
+
+ @Test
+ public void updateState_secureLockScreen_shouldDisplayPreference() {
+ mUserManager.setIsAdminUser(true);
+ mUserManager.setUserSwitcherEnabled(true);
+ mUserManager.setSupportsMultipleUsers(true);
+ when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
+ final AddUserWhenLockedPreferenceController controller =
+ new AddUserWhenLockedPreferenceController(mContext, "fake_key");
+ controller.setLockPatternUtils(mLockPatternUtils);
+ final RestrictedSwitchPreference preference = mock(RestrictedSwitchPreference.class);
+
+ controller.updateState(preference);
+
+ verify(preference).setVisible(true);
+ assertThat(controller.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.AVAILABLE);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
index aaff22a..f537be3 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
@@ -107,6 +107,7 @@
mQueryImsState = spy(new WifiCallingQueryImsState(mContext, SUB_ID));
doReturn(true).when(mQueryImsState).isEnabledByUser();
+ doReturn(true).when(mQueryImsState).isWifiCallingProvisioned();
mWfcSliceHelper = spy(new FakeWifiCallingSliceHelper(mContext));
doReturn(mQueryImsState).when(mWfcSliceHelper).queryImsState(anyInt());
@@ -117,6 +118,8 @@
@Test
public void test_CreateWifiCallingSlice_invalidSubId() {
+ doReturn(true).when(mQueryImsState).isEnabledByUser();
+ doReturn(false).when(mQueryImsState).isWifiCallingProvisioned();
mWfcSliceHelper.setDefaultVoiceSubId(-1);
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
@@ -127,7 +130,7 @@
@Test
public void test_CreateWifiCallingSlice_wfcNotSupported() {
- when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(false);
+ doReturn(false).when(mQueryImsState).isWifiCallingProvisioned();
final Slice slice = mWfcSliceHelper.createWifiCallingSlice(
CustomSliceRegistry.WIFI_CALLING_URI);
@@ -143,8 +146,7 @@
turned off) we need to guide the user to wifi calling settings
activity so the user can perform the activation there.(PrimaryAction)
*/
- when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
- when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
+ doReturn(true).when(mQueryImsState).isWifiCallingProvisioned();
doReturn(false).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(false);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -161,8 +163,7 @@
@Test
public void test_CreateWifiCallingSlice_success() {
- when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
- when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
+ doReturn(true).when(mQueryImsState).isWifiCallingProvisioned();
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -176,8 +177,7 @@
@Test
public void test_SettingSliceProvider_getsRightSliceWifiCalling() {
- when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
- when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
+ doReturn(true).when(mQueryImsState).isWifiCallingProvisioned();
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockCarrierConfigManager.getConfigForSubId(1)).thenReturn(null);
@@ -192,8 +192,7 @@
@Test
public void test_SliceBroadcastReceiver_toggleOnWifiCalling() {
- when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
- when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
+ doReturn(true).when(mQueryImsState).isWifiCallingProvisioned();
doReturn(false).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mSlicesFeatureProvider.getNewWifiCallingSliceHelper(mContext))
@@ -217,8 +216,7 @@
@Test
public void test_CreateWifiCallingPreferenceSlice_prefNotEditable() {
- when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
- when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
+ doReturn(true).when(mQueryImsState).isWifiCallingProvisioned();
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
mWfcSliceHelper.setIsWifiCallingPrefEditable(false);
@@ -232,8 +230,7 @@
@Test
public void test_CreateWifiCallingPreferenceSlice_wfcOff() {
- when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
- when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
+ doReturn(true).when(mQueryImsState).isWifiCallingProvisioned();
doReturn(false).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
mWfcSliceHelper.setIsWifiCallingPrefEditable(true);
@@ -249,8 +246,7 @@
@Test
public void test_CreateWifiCallingPreferenceSlice_success() {
- when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
- when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
+ doReturn(true).when(mQueryImsState).isWifiCallingProvisioned();
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
@@ -267,8 +263,7 @@
@Test
public void test_SettingsSliceProvider_getWfcPreferenceSlice() {
- when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
- when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
+ doReturn(true).when(mQueryImsState).isWifiCallingProvisioned();
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
@@ -286,8 +281,7 @@
}
@Test
public void test_SliceBroadcastReceiver_setWfcPrefCellularPref() {
- when(mMockImsManager.isWfcEnabledByPlatform()).thenReturn(true);
- when(mWfcSliceHelper.isWfcProvisionedOnDevice(anyInt())).thenReturn(true);
+ doReturn(true).when(mQueryImsState).isWifiCallingProvisioned();
doReturn(true).when(mQueryImsState).isEnabledByUser();
when(mMockImsManager.isNonTtyOrTtyOnVolteEnabled()).thenReturn(true);
when(mMockImsMmTelManager.getVoWiFiModeSetting()).thenReturn(
@@ -441,12 +435,6 @@
return mMockCarrierConfigManager;
}
- @Override
- protected ImsManager getImsManager(int subId) {
- return mMockImsManager;
- }
-
- @Override
protected ImsMmTelManager getImsMmTelManager(int subId) {
return mMockImsMmTelManager;
}
diff --git a/tests/unit/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java b/tests/unit/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java
deleted file mode 100644
index 0c27379..0000000
--- a/tests/unit/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java
+++ /dev/null
@@ -1,124 +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.accessibility;
-
-import static androidx.test.espresso.Espresso.onView;
-import static androidx.test.espresso.assertion.ViewAssertions.matches;
-import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
-import static androidx.test.espresso.matcher.ViewMatchers.isChecked;
-import static androidx.test.espresso.matcher.ViewMatchers.isNotChecked;
-import static androidx.test.espresso.matcher.ViewMatchers.withParent;
-import static androidx.test.espresso.matcher.ViewMatchers.withText;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.Matchers.allOf;
-
-import android.app.Instrumentation;
-import android.os.Bundle;
-
-import android.provider.Settings;
-import android.widget.CompoundButton;
-
-import androidx.test.InstrumentationRegistry;
-import androidx.test.rule.ActivityTestRule;
-import androidx.test.runner.AndroidJUnit4;
-
-import com.android.settings.R;
-import com.android.settings.Settings.AccessibilitySettingsActivity;
-import com.android.settings.core.InstrumentedPreferenceFragment;
-import com.android.settings.core.SubSettingLauncher;
-
-import org.hamcrest.Matcher;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-public class AccessibilityShortcutPreferenceFragmentTest {
- @Rule
- public final ActivityTestRule<AccessibilitySettingsActivity> mActivityRule =
- new ActivityTestRule<>(AccessibilitySettingsActivity.class, true);
-
- private final Instrumentation mInstrumentation = InstrumentationRegistry.getInstrumentation();
- private AccessibilityShortcutPreferenceFragment mAccessibilityShortcutPreferenceFragment;
- private AccessibilitySettingsActivity mActivity;
-
- @Before
- public void setUp() {
- mActivity = mActivityRule.getActivity();
- }
-
- @Test
- public void lockScreenPreference_setOnBeforeDialogShown_isOn() {
- setDialogShown(false);
- setOnLockscreen(true);
- startFragment();
- assertLockscreenSwitchIsCheckedIs(true);
- }
-
- @Test
- public void lockScreenPreference_defaultAfterDialogShown_isOn() {
- setDialogShown(true);
- setOnLockscreen(null);
- startFragment();
- assertLockscreenSwitchIsCheckedIs(true);
- }
-
- private void startFragment() {
- mInstrumentation.runOnMainSync(() -> {
- new SubSettingLauncher(mActivity)
- .setDestination(AccessibilityShortcutPreferenceFragment.class.getName())
- .setArguments(new Bundle())
- .setSourceMetricsCategory(
- InstrumentedPreferenceFragment.METRICS_CATEGORY_UNKNOWN)
- .launch();
- });
- }
-
- private void setDialogShown(boolean shown) {
- Settings.Secure.putInt(mActivity.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, shown ? 1 : 0);
- }
-
- private void setOnLockscreen(Boolean onLockscreen) {
- if (onLockscreen == null) {
- Settings.Secure.putString(mActivity.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, null);
- } else {
- Settings.Secure.putInt(mActivity.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, onLockscreen ? 1 : 0);
- }
- }
-
- private void assertLockscreenSwitchIsCheckedIs(boolean isChecked) {
- // Identify the switch by looking for a grandparent that has a descendent with the
- // switch label. To disambiguate, make sure that grandparent doesn't also have a descendant
- // with the title of the main switch
- final String lockScreenSwitchTitle =
- mActivity.getString(R.string.accessibility_shortcut_service_on_lock_screen_title);
- final String mainSwitchTitle =
- mActivity.getString(R.string.accessibility_service_master_switch_title);
- Matcher isCheckedMatcher = (isChecked) ? isChecked() : isNotChecked();
- Matcher hasLockScreenTitleDescendant = hasDescendant(withText(lockScreenSwitchTitle));
- Matcher noMainSwitchTitleDescendant = not(hasDescendant(withText(mainSwitchTitle)));
- onView(allOf(withParent(withParent(allOf(
- hasLockScreenTitleDescendant, noMainSwitchTitleDescendant))),
- instanceOf(CompoundButton.class))).check(matches(isCheckedMatcher));
- }
-}