Merge "Add config for showing/hiding emergency setting entry"
diff --git a/Android.bp b/Android.bp
index 2c3b2ec..0116237 100644
--- a/Android.bp
+++ b/Android.bp
@@ -59,7 +59,6 @@
"com.google.android.material_material",
"setupcompat",
"setupdesign",
- "androidx-constraintlayout_constraintlayout-solver",
"androidx.lifecycle_lifecycle-runtime",
"androidx.lifecycle_lifecycle-extensions",
"guava",
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6e82b11..9147605 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -112,6 +112,7 @@
<uses-permission android:name="android.permission.ALLOW_PLACE_IN_MULTI_PANE_SETTINGS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_APP_SPECIFIC_LOCALES" />
+ <uses-permission android:name="android.permission.QUERY_ADMIN_POLICY" />
<application
android:name=".SettingsApplication"
@@ -238,17 +239,14 @@
android:value="true" />
</activity>
- <activity android:name=".network.telephony.MobileNetworkActivity"
- android:label="@string/network_settings_title"
- android:exported="true"
- android:taskAffinity="com.android.settings.root"
- android:launchMode="singleTask"
- android:configChanges="orientation|screenSize|keyboardHidden">
- <!-- Note: Since the framework does not support the multiple requests of network scan
- from the UI, this singleTask can protect that there is only one
- Settings$NetworkSelectActivity which can request the network scan.
- If removing the "singleTask" in the future, please also modify the
- Settings$NetworkSelectActivity's structure. -->
+ <activity
+ android:name=".Settings$MobileNetworkActivity"
+ android:label="@string/network_settings_title"
+ android:configChanges="orientation|screenSize|keyboardHidden"
+ android:launchMode="singleInstance"
+ android:exported="true">
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.network.telephony.MobileNetworkSettings"/>
<intent-filter android:priority="1">
<!-- Displays the MobileNetworkActivity and opt-in dialog for capability discovery. -->
<action android:name="android.telephony.ims.action.SHOW_CAPABILITY_DISCOVERY_OPT_IN" />
@@ -259,14 +257,6 @@
</intent-filter>
</activity>
- <activity
- android:name=".Settings$SubscriptionSettingsActivity"
- android:label="@string/network_settings_title"
- android:exported="false">
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.network.telephony.MobileNetworkSettings"/>
- </activity>
-
<activity android:name=".Settings$MobileNetworkListActivity"
android:exported="true"
android:label="@string/network_settings_title">
@@ -549,7 +539,6 @@
<activity android:name="Settings$ApnSettingsActivity"
android:label="@string/apn_settings"
- android:launchMode="singleTask"
android:exported="true"
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter android:priority="1">
@@ -686,12 +675,12 @@
<activity android:name=".network.telephony.ToggleSubscriptionDialogActivity"
android:exported="false"
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
- android:theme="@style/Theme.AlertDialog"/>
+ android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/>
<activity android:name=".network.telephony.DeleteEuiccSubscriptionDialogActivity"
android:exported="false"
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
- android:theme="@style/Theme.AlertDialog"/>
+ android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/>
<activity
android:name="Settings$TetherSettingsActivity"
@@ -844,6 +833,18 @@
</activity>
<activity
+ android:name=".applications.appinfo.AppLocalePickerActivity"
+ android:label="@string/app_locale_picker_title"
+ android:exported="true" >
+ <intent-filter>
+ <action android:name="android.settings.APP_LOCALE_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.applications.appinfo.AppLocaleDetails" />
+ </activity>
+
+ <activity
android:name=".Settings$LanguageAndInputSettingsActivity"
android:label="@string/language_settings"
android:exported="true"
@@ -2974,6 +2975,12 @@
</activity>
<activity
+ android:name=".users.AddSupervisedUserActivity"
+ android:label="@*android:string/supervised_user_creation_label"
+ android:icon="@drawable/ic_settings_multiuser">
+ </activity>
+
+ <activity
android:name="Settings$PaymentSettingsActivity"
android:label="@string/nfc_payment_settings_title"
android:exported="true"
@@ -3422,7 +3429,7 @@
<activity
android:name=".sim.SimDialogActivity"
- android:theme="@style/Theme.AlertDialog"
+ android:theme="@style/Theme.AlertDialog.SimConfirmDialog"
android:label="@string/sim_settings_title"
android:launchMode="singleTop"
android:exported="true"
@@ -4273,14 +4280,14 @@
android:exported="false"
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
android:launchMode="singleInstance"
- android:theme="@style/Theme.AlertDialog"/>
+ android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/>
<activity
android:name=".sim.DsdsDialogActivity"
android:exported="false"
android:permission="android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS"
android:launchMode="singleInstance"
- android:theme="@style/Theme.AlertDialog"/>
+ android:theme="@style/Theme.AlertDialog.SimConfirmDialog"/>
<service android:name=".sim.SimNotificationService"
android:permission="android.permission.BIND_JOB_SERVICE" />
diff --git a/res/drawable/sim_confirm_dialog_btn_outline.xml b/res/drawable/sim_confirm_dialog_btn_outline.xml
new file mode 100644
index 0000000..5722f8c
--- /dev/null
+++ b/res/drawable/sim_confirm_dialog_btn_outline.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+ android:insetTop="16dp"
+ android:insetBottom="24dp">
+ <ripple android:color="?android:attr/colorControlHighlight">
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <solid android:color="@android:color/white"/>
+ <corners android:radius="24dp"/>
+ </shape>
+ </item>
+ <item>
+ <shape android:shape="rectangle">
+ <corners android:radius="24dp"/>
+ <solid android:color="@android:color/transparent"/>
+ <stroke android:color="?androidprv:attr/colorAccentPrimaryVariant"
+ android:width="1dp" />
+ <padding android:left="16dp"
+ android:top="8dp"
+ android:right="16dp"
+ android:bottom="8dp"/>
+ </shape>
+ </item>
+ </ripple>
+</inset>
diff --git a/res/drawable/sim_confirm_dialog_rounded_bg.xml b/res/drawable/sim_confirm_dialog_rounded_bg.xml
new file mode 100644
index 0000000..ab7e392
--- /dev/null
+++ b/res/drawable/sim_confirm_dialog_rounded_bg.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+ android:insetLeft="24dp"
+ android:insetRight="24dp">
+ <shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@color/settingslib_state_on_color"/>
+ <corners
+ android:bottomLeftRadius="8dp"
+ android:topLeftRadius="8dp"
+ android:bottomRightRadius="8dp"
+ android:topRightRadius="8dp"
+ />
+ </shape>
+</inset>
diff --git a/res/layout/add_supervised_user.xml b/res/layout/add_supervised_user.xml
new file mode 100644
index 0000000..b95e0f7
--- /dev/null
+++ b/res/layout/add_supervised_user.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <Button
+ android:id="@+id/createSupervisedUser"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:text="@*android:string/supervised_user_creation_label" />
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/dream_start_button.xml b/res/layout/dream_start_button.xml
new file mode 100644
index 0000000..17ba78d
--- /dev/null
+++ b/res/layout/dream_start_button.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:gravity="bottom"
+ android:paddingStart="72dp"
+ android:paddingEnd="72dp"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <Button
+ android:id="@+id/dream_start_now_button"
+ style="@style/ActionPrimaryButton"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/screensaver_settings_dream_start"/>
+
+</LinearLayout>
diff --git a/res/layout/select_account_list_item.xml b/res/layout/select_account_list_item.xml
index 3587e55..716adff 100644
--- a/res/layout/select_account_list_item.xml
+++ b/res/layout/select_account_list_item.xml
@@ -16,42 +16,26 @@
<!-- Layout of a single item for displaying sim cards. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
+ android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="?android:attr/selectableItemBackground" >
-
- <ImageView android:id="@+id/icon"
- android:layout_width="48dp"
- android:layout_height="48dp"
- android:scaleType="center" />
-
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_marginStart="15dip"
- android:layout_marginEnd="6dip"
- android:layout_marginTop="6dip"
- android:layout_marginBottom="6dip"
+ android:minHeight="?attr/listPreferredItemHeightSmall"
+ android:background="@drawable/sim_confirm_dialog_rounded_bg"
+ android:gravity="center">
+ <TextView android:id="@+id/title"
+ android:textAppearance="@style/TextAppearance.SimConfirmDialogList"
+ android:gravity="start|center_vertical"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_width="0dp"
- android:layout_weight="1" >
- <TextView android:id="@+id/title"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:gravity="start|center_vertical"
- android:layout_marginLeft="8dp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
- <TextView android:id="@+id/summary"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:gravity="start|center_vertical"
- android:layout_marginLeft="8dp"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/title"
- android:textColor="?android:attr/textColorSecondary"
- android:layout_alignStart="@id/title" />
- </LinearLayout>
+ android:singleLine="true"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+ <TextView android:id="@+id/summary"
+ android:textAppearance="@style/TextAppearance.SimConfirmDialogList.Summary"
+ android:gravity="start|center_vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/title"
+ android:textColor="?android:attr/textColorSecondary"
+ android:layout_alignStart="@id/title" />
</LinearLayout>
diff --git a/res/layout/sim_confirm_dialog_item_multiple_enabled_profiles_supported.xml b/res/layout/sim_confirm_dialog_item_multiple_enabled_profiles_supported.xml
new file mode 100644
index 0000000..003cdbf
--- /dev/null
+++ b/res/layout/sim_confirm_dialog_item_multiple_enabled_profiles_supported.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?attr/listPreferredItemHeightSmall"
+ style="?attr/materialAlertDialogBodyTextStyle"
+ android:gravity="center"
+ android:paddingTop="?attr/listPreferredItemPaddingStart"
+ android:paddingBottom="?attr/listPreferredItemPaddingEnd"
+ android:paddingLeft="?attr/listPreferredItemPaddingLeft"
+ android:paddingRight="?attr/listPreferredItemPaddingRight"
+ android:background="@drawable/sim_confirm_dialog_rounded_bg"
+ android:textAppearance="@style/TextAppearance.SimConfirmDialogList"
+ />
diff --git a/res/layout/sim_confirm_dialog_multiple_enabled_profiles_supported.xml b/res/layout/sim_confirm_dialog_multiple_enabled_profiles_supported.xml
index 4404482..610bf3d 100644
--- a/res/layout/sim_confirm_dialog_multiple_enabled_profiles_supported.xml
+++ b/res/layout/sim_confirm_dialog_multiple_enabled_profiles_supported.xml
@@ -16,42 +16,49 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- style="@style/Theme.Material3.DayNight.Dialog.Alert">
+ android:orientation="vertical">
<TextView
android:id="@+id/msg"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ android:layout_height="wrap_content"
+ android:paddingEnd="24dp"
+ android:paddingTop="16dp"
+ android:paddingStart="24dp"
+ android:gravity="center"
+ android:textAppearance="@style/TextAppearance.DialogMessage"/>
<ListView
android:id="@+id/carrier_list"
- android:layout_width="wrap_content"
+ android:layout_gravity="center"
+ android:paddingTop="16dp"
+ android:dividerHeight="1dp"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
+ android:id="@+id/info_outline_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:minWidth="56dp"
android:gravity="start|top"
android:orientation="horizontal"
- android:paddingEnd="12dp"
+ android:paddingEnd="24dp"
android:paddingTop="16dp"
- android:paddingBottom="4dp"
+ android:paddingStart="24dp"
+ android:layout_marginBottom="16dp"
android:baselineAligned="true">
<ImageView
android:src="@drawable/ic_info_outline_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="?android:attr/textColorTertiary"/>
-
<TextView
android:id="@+id/info_outline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingTop="16dp"
- android:paddingBottom="8dp"
+ android:paddingLeft="16dp"
android:text="@string/sim_action_switch_sub_dialog_info_outline_for_turning_off"
- android:textColor="?android:attr/textColorSecondary" />
+ android:textColor="?android:attr/textColorSecondary"
+ android:textAppearance="@style/TextAppearance.DialogMessage"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/sim_confirm_dialog_title_multiple_enabled_profiles_supported.xml b/res/layout/sim_confirm_dialog_title_multiple_enabled_profiles_supported.xml
new file mode 100644
index 0000000..f43303f
--- /dev/null
+++ b/res/layout/sim_confirm_dialog_title_multiple_enabled_profiles_supported.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingEnd="24dp"
+ android:paddingTop="16dp"
+ android:paddingLeft="24dp"
+ android:gravity="center"
+ style="?android:attr/textAppearanceLarge"/>
diff --git a/res/values-night/styles.xml b/res/values-night/styles.xml
index 87159b8..a388855 100644
--- a/res/values-night/styles.xml
+++ b/res/values-night/styles.xml
@@ -16,9 +16,18 @@
-->
<resources>
+ <style name="Widget.ActionBar.Base" parent="@android:style/Widget.DeviceDefault.ActionBar.Solid">
+ <item name="android:background">?android:attr/colorPrimaryDark</item>
+ </style>
-<style name="Widget.ActionBar.Base" parent="@android:style/Widget.DeviceDefault.ActionBar.Solid">
- <item name="android:background">?android:attr/colorPrimaryDark</item>
-</style>
+ <style name="TextAppearance.SimConfirmDialogList" parent="@style/TextAppearance.DialogMessage">
+ <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+ <item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
+ </style>
+ <style name="TextAppearance.SimConfirmDialogList.Summary">
+ <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
+ <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
+ <item name="android:textColor">?android:attr/textColorPrimaryInverse</item>
+ </style>
</resources>
\ No newline at end of file
diff --git a/res/values-night/themes.xml b/res/values-night/themes.xml
index 946cd91..4564827 100644
--- a/res/values-night/themes.xml
+++ b/res/values-night/themes.xml
@@ -34,6 +34,12 @@
<item name="android:colorBackground">@*android:color/surface_dark</item>
</style>
+ <style name="Theme.AlertDialog.Base.Material3" parent="Theme.MaterialComponents.DayNight.Dialog.Alert">
+ <item name="colorPrimary">@*android:color/primary_device_default_settings</item>
+ <item name="colorAccent">@*android:color/accent_device_default_dark</item>
+ <item name="android:colorBackground">@*android:color/surface_dark</item>
+ </style>
+
<!-- Material theme for the pages containing TabLayout and ViewPager -->
<style name="Theme.TabTheme" parent="@style/Theme.MaterialComponents.DayNight">
<item name="colorPrimary">@*android:color/edge_effect_device_default_dark</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1669e76..c6c0599 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3249,6 +3249,8 @@
<string name="screensaver_settings_when_to_dream">When to start</string>
<!-- Dream settings screen, action label, current selected screen saver -->
<string name="screensaver_settings_current">Current screen saver</string>
+ <!-- Dream settings screen, button label to start dreaming [CHAR LIMIT=30] -->
+ <string name="screensaver_settings_dream_start">Start now</string>
<!-- Dream settings screen, button label for settings for a specific screensaver -->
<string name="screensaver_settings_button">Settings</string>
<!-- Sound & display settings screen, setting option name to change whether the screen adjusts automatically based on lighting conditions -->
@@ -5553,11 +5555,17 @@
<!-- Description for the seekbar that adjust auto click time. [CHAR_LIMIT=NONE] -->
<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. -->
- <string name="accessibility_notification_vibration_title">Notification vibration</string>
+ <string name="accessibility_vibration_settings_title">Vibration & haptics</string>
+ <!-- Title for the category of preferences to configure device vibrations related to calls. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_call_vibration_category_title">Calls</string>
+ <!-- Title for the category of preferences to configure device vibrations related to notifications and alarms. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_notification_alarm_vibration_category_title">Notifications and alarms</string>
+ <!-- Title for the category of preferences to configure device vibrations triggered by user interaction with the device. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_interactive_haptics_category_title">Interactive haptics</string>
<!-- Title for accessibility preference for configuring ring vibrations. [CHAR LIMIT=NONE] -->
<string name="accessibility_ring_vibration_title">Ring vibration</string>
+ <!-- Title for accessibility preference for configuring notification vibrations. -->
+ <string name="accessibility_notification_vibration_title">Notification vibration</string>
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
<string name="accessibility_touch_vibration_title">Touch feedback</string>
<!-- Used in the accessibility service settings to control turning on/off the service entirely [CHAR LIMIT=60] -->
@@ -8269,8 +8277,6 @@
<string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string>
<!-- Search keyword for "Wi-fi data usage" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_wifi_data_usage">data usage</string>
- <!-- Search keyword for "Vibrate on touch" settings. [CHAR_LIMIT=NONE]-->
- <string name="keywords_vibrate_on_touch">Stop vibration, tap, keyboard</string>
<!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_time_format">Use 24-hour format</string>
<!-- Search keyword for "Files" settings under Settings > Storage. [CHAR_LIMIT=NONE]-->
@@ -8406,11 +8412,12 @@
<!-- List of synonyms for touch vibration setting (where you get a haptic response for touching things on the screen), used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_touch_vibration">haptics, vibrate, screen, sensitivity</string>
-
<!-- List of synonyms for ring vibration setting (changes whether your phone vibrates when it rings), used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity, ring</string>
<!-- List of synonyms for notification vibration setting (changes whether your phone vibrates when it shows a notification), used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_notification_vibration">haptics, vibrate, sensitivity</string>
+ <!-- List of synonyms for vibration and haptics setting, used to match in settings search [CHAR LIMIT=NONE] -->
+ <string name="keywords_vibration">haptics, vibrate, vibration</string>
<!-- Battery Saver: Search terms for sticky battery saver preference [CHAR_LIMIT=NONE] -->
<string name="keywords_battery_saver_sticky">battery saver, sticky, persist, power saver, battery</string>
<!-- Battery Saver: Search terms for battery saver schedule preference. Feel free to add additional terms when translating if appropriate [CHAR_LIMIT=NONE] -->
@@ -8522,12 +8529,6 @@
<!-- Sound: Other sounds: Title for the option enabling touch sounds. [CHAR LIMIT=30] -->
<string name="touch_sounds_title">Touch sounds</string>
- <!-- Sound: Other sounds: Title for the option enabling haptic feedback on touch. [CHAR LIMIT=30] -->
- <string name="vibrate_on_touch_title">Touch vibration</string>
-
- <!-- Sound: Other sounds: Preference summary to the option enabling haptic feedback on touch. -->
- <string name="vibrate_on_touch_summary">Haptic feedback for tap, keyboard, and more</string>
-
<!-- Sound: Other sounds: Title for the option enabling dock audio media. [CHAR LIMIT=50] -->
<string name="dock_audio_media_title">Dock speaker plays</string>
@@ -12969,7 +12970,7 @@
<!-- Status message indicating the device is in the process of disconnecting from one mobile network and immediately connecting to another. [CHAR_LIMIT=NONE] -->
<string name="sim_action_enabling_sim_without_carrier_name">Connecting to network…</string>
<!-- Text of progress dialog indicating the subscription switch is in progress. [CHAR_LIMIT=NONE] -->
- <string name="sim_action_switch_sub_dialog_progress">Switching to <xliff:g id="carrier_name" example="Google Fi">%1$s</xliff:g></string>
+ <string name="sim_action_switch_sub_dialog_progress">Switching to <xliff:g id="carrier_name" example="Google Fi">%1$s</xliff:g> for calls and messages…</string>
<!-- Title of error message indicating that the device could not disconnect from one mobile network and immediately connect to another. [CHAR_LIMIT=NONE] -->
<string name="sim_action_enable_sim_fail_title">Can\u2019t switch carrier</string>
<!-- Body text of error message indicating the device could not disconnect from one mobile network and immediately connect to another, due to an unspecified issue. [CHAR_LIMIT=NONE] -->
@@ -13351,9 +13352,9 @@
<string name="lockscreen_privacy_wallet_summary">Allow access to wallet from lock screen and quick settings</string>
<!-- QR Code Scanner toggle name [CHAR LIMIT=60] -->
- <string name="lockscreen_privacy_qr_code_scanner_setting_toggle">Show QR Code Scanner</string>
+ <string name="lockscreen_privacy_qr_code_scanner_setting_toggle">Show QR Scanner</string>
<!-- QR Code Scanner summary [CHAR LIMIT=NONE] -->
- <string name="lockscreen_privacy_qr_code_scanner_summary">Allow access to QR code scanner from lock screen</string>
+ <string name="lockscreen_privacy_qr_code_scanner_summary">Allow access to QR scanner from lock screen</string>
<!-- Device controls toggle name [CHAR LIMIT=60] -->
<string name="lockscreen_privacy_controls_setting_toggle">Show device controls</string>
@@ -13608,8 +13609,6 @@
<string name="adaptive_brightness_main_switch_title">Use adaptive brightness</string>
<!-- Title for wifi calling main switch preferences. [CHAR LIMIT=50] -->
<string name="wifi_calling_main_switch_title">Use Wi‑Fi calling</string>
- <!-- Title for Screen saver main switch preferences. [CHAR LIMIT=50] -->
- <string name="screen_saver_main_switch_title">Use screen saver</string>
<!-- Default preference title for showing all apps on device [CHAR_LIMIT=50]-->
<string name="default_see_all_apps_title">See all apps</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8402dec..395a3bc 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -926,4 +926,25 @@
parent="@*android:style/TextAppearance.DeviceDefault">
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
+
+ <style name="TextAppearance.SimConfirmDialogList" parent="@style/TextAppearance.DialogMessage"/>
+
+ <style name="TextAppearance.SimConfirmDialogList.Summary">
+ <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
+ </style>
+
+ <style name="SimConfirmDialog.OutlineButton" parent="@android:style/Widget.Material.Button">
+ <item name="android:layout_marginStart">8dp</item>
+ <item name="android:layout_height">36dp</item>
+ <item name="android:minWidth">0dp</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:lineHeight">20sp</item>
+ <item name="android:fontFamily">@*android:string/config_bodyFontFamilyMedium</item>
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:background">@drawable/sim_confirm_dialog_btn_outline</item>
+ </style>
+
+ <style name="SimConfirmDialog.ButtonBarStyle" parent="@android:style/Widget.Material.ButtonBar">
+ <item name="android:paddingEnd">8dp</item>
+ </style>
</resources>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index d65c1b3..aae158b 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -151,6 +151,13 @@
<item name="buttonBarButtonStyle">@*android:style/Widget.DeviceDefault.Button.ButtonBar.AlertDialog</item>
</style>
+
+ <style name="Theme.AlertDialog.SimConfirmDialog">
+ <item name="buttonBarStyle">@style/SimConfirmDialog.ButtonBarStyle</item>
+ <item name="buttonBarButtonStyle">@style/SimConfirmDialog.OutlineButton</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
<style name="Theme.ConfirmDeviceCredentials" parent="Theme.SubSettings">
<item name="confirmDeviceCredentialsSideMargin">@dimen/confirm_credentials_side_margin</item>
<item name="confirmDeviceCredentialsTopMargin">@dimen/confirm_credentials_top_margin</item>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 61f527d..8113a9f 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -100,7 +100,8 @@
android:icon="@drawable/ic_vibration"
android:persistent="false"
android:title="@string/accessibility_vibration_settings_title"
- settings:controller="com.android.settings.accessibility.VibrationPreferenceController"/>
+ settings:controller="com.android.settings.accessibility.VibrationPreferenceController"
+ settings:keywords="@string/keywords_vibration"/>
</PreferenceCategory>
diff --git a/res/xml/accessibility_vibration_settings.xml b/res/xml/accessibility_vibration_settings.xml
index 87c2988..ff10611 100644
--- a/res/xml/accessibility_vibration_settings.xml
+++ b/res/xml/accessibility_vibration_settings.xml
@@ -20,24 +20,49 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/accessibility_vibration_settings_title">
- <Preference
- android:fragment="com.android.settings.accessibility.RingVibrationPreferenceFragment"
- android:key="ring_vibration_preference_screen"
- android:title="@string/accessibility_ring_vibration_title"
- settings:keywords="@string/keywords_ring_vibration"
- app:controller="com.android.settings.accessibility.RingVibrationIntensityPreferenceController" />
+ <PreferenceCategory
+ android:key="accessibility_call_vibration_category"
+ android:title="@string/accessibility_call_vibration_category_title">
- <Preference
- android:fragment="com.android.settings.accessibility.NotificationVibrationPreferenceFragment"
- android:key="notification_vibration_preference_screen"
- android:title="@string/accessibility_notification_vibration_title"
- settings:keywords="@string/keywords_notification_vibration"
- app:controller="com.android.settings.accessibility.NotificationVibrationIntensityPreferenceController" />
+ <Preference
+ android:fragment="com.android.settings.accessibility.RingVibrationPreferenceFragment"
+ android:key="ring_vibration_preference_screen"
+ android:title="@string/accessibility_ring_vibration_title"
+ settings:keywords="@string/keywords_ring_vibration"
+ app:controller="com.android.settings.accessibility.RingVibrationIntensityPreferenceController" />
- <Preference
- android:fragment="com.android.settings.accessibility.TouchVibrationPreferenceFragment"
- android:key="touch_vibration_preference_screen"
- android:title="@string/accessibility_touch_vibration_title"
- settings:keywords="@string/keywords_touch_vibration"
- app:controller="com.android.settings.accessibility.HapticFeedbackIntensityPreferenceController" />
+ <Preference
+ android:fragment="com.android.settings.sound.VibrateForCallsPreferenceFragment"
+ android:key="vibrate_for_calls"
+ android:title="@string/vibrate_when_ringing_title"
+ settings:controller="com.android.settings.sound.VibrateForCallsPreferenceController"/>
+
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="accessibility_notification_alarm_vibration_category"
+ android:title="@string/accessibility_notification_alarm_vibration_category_title">
+
+ <Preference
+ android:fragment="com.android.settings.accessibility.NotificationVibrationPreferenceFragment"
+ android:key="notification_vibration_preference_screen"
+ android:title="@string/accessibility_notification_vibration_title"
+ settings:keywords="@string/keywords_notification_vibration"
+ app:controller="com.android.settings.accessibility.NotificationVibrationIntensityPreferenceController" />
+
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="accessibility_interactive_haptics_category"
+ android:title="@string/accessibility_interactive_haptics_category_title">
+
+ <Preference
+ android:fragment="com.android.settings.accessibility.TouchVibrationPreferenceFragment"
+ android:key="touch_vibration_preference_screen"
+ android:title="@string/accessibility_touch_vibration_title"
+ settings:keywords="@string/keywords_touch_vibration"
+ app:controller="com.android.settings.accessibility.HapticFeedbackIntensityPreferenceController" />
+
+ </PreferenceCategory>
+
</PreferenceScreen>
diff --git a/res/xml/dream_fragment_overview.xml b/res/xml/dream_fragment_overview.xml
index 6e18a97..42b0334 100644
--- a/res/xml/dream_fragment_overview.xml
+++ b/res/xml/dream_fragment_overview.xml
@@ -19,11 +19,6 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/screensaver_settings_title">
- <com.android.settingslib.widget.MainSwitchPreference
- android:key="dream_start_now_button_container"
- android:title="@string/screen_saver_main_switch_title"
- settings:controller="com.android.settings.dream.StartNowPreferenceController"/>
-
<com.android.settings.widget.GearPreference
android:key="current_screensaver"
android:title="@string/screensaver_settings_current"
@@ -35,4 +30,12 @@
android:title="@string/screensaver_settings_when_to_dream"
android:fragment="com.android.settings.dream.WhenToDreamPicker" />
+ <PreferenceCategory>
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="dream_start_now_button_container"
+ android:layout="@layout/dream_start_button"
+ android:selectable="false"
+ settings:controller="com.android.settings.dream.StartNowPreferenceController" />
+ </PreferenceCategory>
+
</PreferenceScreen>
diff --git a/res/xml/other_sound_settings.xml b/res/xml/other_sound_settings.xml
index 7b3f362..d8396a4 100644
--- a/res/xml/other_sound_settings.xml
+++ b/res/xml/other_sound_settings.xml
@@ -44,12 +44,6 @@
android:key="touch_sounds"
android:title="@string/touch_sounds_title" />
- <!-- Vibrate on touch -->
- <SwitchPreference
- android:key="vibrate_on_touch"
- android:title="@string/vibrate_on_touch_title"
- android:summary="@string/vibrate_on_touch_summary" />
-
<!-- Dock speaker plays -->
<DropDownPreference
android:key="dock_audio_media"
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index a7b63a1..c1298db 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -119,14 +119,14 @@
settings:controller="com.android.settings.sound.MediaControlsParentPreferenceController"
settings:keywords="@string/keywords_media_controls"/>
- <!-- Also vibrate for calls -->
+ <!-- Also vibration -->
<Preference
- android:fragment="com.android.settings.sound.VibrateForCallsPreferenceFragment"
- android:key="vibrate_for_calls"
- android:title="@string/vibrate_when_ringing_title"
+ android:fragment="com.android.settings.accessibility.VibrationSettings"
+ android:key="vibration_and_haptics"
+ android:title="@string/accessibility_vibration_settings_title"
android:order="-90"
- settings:controller="com.android.settings.sound.VibrateForCallsPreferenceController"
- settings:keywords="@string/keywords_vibrate_for_calls"/>
+ settings:controller="com.android.settings.accessibility.VibrationPreferenceController"
+ settings:keywords="@string/keywords_vibration"/>
<com.android.settingslib.PrimarySwitchPreference
android:key="gesture_prevent_ringing_sound"
@@ -191,14 +191,6 @@
android:title="@string/touch_sounds_title"
android:order="-30"/>
- <!-- Vibrate on touch -->
- <SwitchPreference
- android:key="vibrate_on_touch"
- android:title="@string/vibrate_on_touch_title"
- android:summary="@string/vibrate_on_touch_summary"
- settings:keywords="@string/keywords_vibrate_on_touch"
- android:order="-25"/>
-
<!-- Dock speaker plays -->
<DropDownPreference
android:key="dock_audio_media"
diff --git a/res/xml/user_settings.xml b/res/xml/user_settings.xml
index 5cafa1a..b3dc2ea 100644
--- a/res/xml/user_settings.xml
+++ b/res/xml/user_settings.xml
@@ -43,6 +43,12 @@
android:icon="@drawable/ic_add_40dp"
android:order="20"/>
+ <com.android.settingslib.RestrictedPreference
+ android:key="supervised_user_add"
+ android:title="@*android:string/supervised_user_creation_label"
+ android:icon="@*android:drawable/ic_add_supervised_user"
+ android:order="25"/>
+
<com.android.settingslib.RestrictedSwitchPreference
android:key="user_settings_add_users_when_locked"
android:title="@string/user_add_on_lockscreen_menu"
diff --git a/src/com/android/settings/IccLockSettings.java b/src/com/android/settings/IccLockSettings.java
index e89e84b..71eb0f2 100644
--- a/src/com/android/settings/IccLockSettings.java
+++ b/src/com/android/settings/IccLockSettings.java
@@ -587,6 +587,7 @@
.inflate(com.android.internal.R.layout.transient_notification, null);
final TextView tv = (TextView) v.findViewById(com.android.internal.R.id.message);
tv.setText(errorMessage);
+ tv.setSingleLine(false);
final WindowManager.LayoutParams params = new WindowManager.LayoutParams();
final Configuration config = v.getContext().getResources().getConfiguration();
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 4e919d6..96f362c 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -16,16 +16,24 @@
package com.android.settings;
+import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.ims.ImsRcsManager;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
+import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.core.FeatureFlags;
import com.android.settings.enterprise.EnterprisePrivacySettings;
+import com.android.settings.network.SubscriptionUtil;
+import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.safetycenter.SafetyCenterStatus;
import com.android.settings.security.SecuritySettingsFeatureProvider;
import com.google.android.setupdesign.util.ThemeHelper;
@@ -131,6 +139,27 @@
/** Activity for the security dashboard. */
public static class SecurityDashboardActivity extends SettingsActivity {
+ private static final String TAG = "SecurityDashboardActivity";
+
+ @Override
+ protected void onCreate(Bundle savedState) {
+ super.onCreate(savedState);
+ handleSafetyCenterRedirection();
+ }
+
+ /** Redirects to SafetyCenter if enabled. */
+ @VisibleForTesting
+ public void handleSafetyCenterRedirection() {
+ if (SafetyCenterStatus.isEnabled()) {
+ try {
+ startActivity(new Intent(Intent.ACTION_SAFETY_CENTER));
+ finish();
+ } catch (ActivityNotFoundException e) {
+ Log.e(TAG, "Unable to open safety center", e);
+ }
+ }
+ }
+
/** Whether the given fragment is allowed. */
@VisibleForTesting
@Override
@@ -166,7 +195,30 @@
public static class LocationSettingsActivity extends SettingsActivity { /* empty */ }
public static class ScanningSettingsActivity extends SettingsActivity { /* empty */ }
public static class WifiScanningSettingsActivity extends SettingsActivity { /* empty */ }
- public static class PrivacyDashboardActivity extends SettingsActivity { /* empty */ }
+ /** Activity for the privacy dashboard. */
+ public static class PrivacyDashboardActivity extends SettingsActivity {
+
+ private static final String TAG = "PrivacyDashboardActivity";
+
+ @Override
+ protected void onCreate(Bundle savedState) {
+ super.onCreate(savedState);
+ handleSafetyCenterRedirection();
+ }
+
+ /** Redirects to SafetyCenter if enabled. */
+ @VisibleForTesting
+ public void handleSafetyCenterRedirection() {
+ if (SafetyCenterStatus.isEnabled()) {
+ try {
+ startActivity(new Intent(Intent.ACTION_SAFETY_CENTER));
+ finish();
+ } catch (ActivityNotFoundException e) {
+ Log.e(TAG, "Unable to open safety center", e);
+ }
+ }
+ }
+ }
public static class PrivacySettingsActivity extends SettingsActivity { /* empty */ }
public static class FactoryResetActivity extends SettingsActivity {
@Override
@@ -304,7 +356,51 @@
public static class WifiCallingDisclaimerActivity extends SettingsActivity { /* empty */ }
public static class MobileNetworkListActivity extends SettingsActivity {}
public static class PowerMenuSettingsActivity extends SettingsActivity {}
- public static class SubscriptionSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class MobileNetworkActivity extends SettingsActivity {
+
+ public static final String EXTRA_MMS_MESSAGE = "mms_message";
+ public static final String EXTRA_SHOW_CAPABILITY_DISCOVERY_OPT_IN =
+ "show_capability_discovery_opt_in";
+
+ @Override
+ public Intent getIntent() {
+ final Intent intent = new Intent(super.getIntent());
+ int subId = intent.getIntExtra(android.provider.Settings.EXTRA_SUB_ID,
+ SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+ SubscriptionInfo subInfo = SubscriptionUtil.getSubscriptionOrDefault(
+ getApplicationContext(), subId);
+ CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(
+ subInfo, getApplicationContext());
+ intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, title);
+ intent.putExtra(android.provider.Settings.EXTRA_SUB_ID, subId);
+ if (android.provider.Settings.ACTION_MMS_MESSAGE_SETTING.equals(intent.getAction())) {
+ // highlight "mms_message" preference.
+ intent.putExtra(EXTRA_FRAGMENT_ARG_KEY, EXTRA_MMS_MESSAGE);
+ }
+
+ if (doesIntentContainOptInAction(intent)) {
+ intent.putExtra(EXTRA_SHOW_CAPABILITY_DISCOVERY_OPT_IN,
+ maybeShowContactDiscoveryDialog(subId));
+ }
+
+ return intent;
+ }
+
+ private boolean maybeShowContactDiscoveryDialog(int subId) {
+ // If this activity was launched using ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN, show the
+ // associated dialog only if the opt-in has not been granted yet.
+ return MobileNetworkUtils.isContactDiscoveryVisible(getApplicationContext(), subId)
+ // has the user already enabled this configuration?
+ && !MobileNetworkUtils.isContactDiscoveryEnabled(
+ getApplicationContext(), subId);
+ }
+
+ public static boolean doesIntentContainOptInAction(Intent intent) {
+ String intentAction = (intent != null ? intent.getAction() : null);
+ return TextUtils.equals(intentAction,
+ ImsRcsManager.ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN);
+ }
+ }
/**
* Activity for BugReportHandlerPicker.
diff --git a/src/com/android/settings/applications/appinfo/AppLocaleDetails.java b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
index 742ce04..966f02d 100644
--- a/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
+++ b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
@@ -270,9 +270,14 @@
/** Gets per app's default locale */
public static Locale getAppDefaultLocale(Context context, String packageName) {
LocaleManager localeManager = context.getSystemService(LocaleManager.class);
- LocaleList localeList = (localeManager == null)
- ? new LocaleList() : localeManager.getApplicationLocales(packageName);
- return localeList.isEmpty() ? null : localeList.get(0);
+ try {
+ LocaleList localeList = (localeManager == null)
+ ? new LocaleList() : localeManager.getApplicationLocales(packageName);
+ return localeList.isEmpty() ? null : localeList.get(0);
+ } catch (IllegalArgumentException e) {
+ Log.w(TAG, "package name : " + packageName + " is not correct. " + e);
+ }
+ return null;
}
/** Sets per app's default language to system. */
diff --git a/src/com/android/settings/applications/appinfo/AppLocalePickerActivity.java b/src/com/android/settings/applications/appinfo/AppLocalePickerActivity.java
new file mode 100644
index 0000000..ce833ed
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/AppLocalePickerActivity.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.applications.appinfo;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.SettingsActivity;
+import com.android.settings.applications.AppInfoBase;
+
+/** Activity for the entry of {@link #AppLocaleDetails} from outside Settings app. */
+public class AppLocalePickerActivity extends SettingsActivity {
+ private static final String TAG = "AppLocalePickerActivity";
+
+ @Override
+ protected void onCreate(Bundle savedState) {
+ Intent intent = getEntryIntent(getIntent());
+ if (intent == null) {
+ finish();
+ return;
+ }
+ setIntent(intent);
+ super.onCreate(savedState);
+ }
+
+ @VisibleForTesting
+ Intent getEntryIntent(Intent intent) {
+ String callingPackage = getCallingPackage();
+ if (callingPackage == null || callingPackage.isEmpty()) {
+ Log.d(TAG, "No calling package name is found.");
+ return null;
+ }
+ final Bundle fragmentArgs = new Bundle();
+ fragmentArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, callingPackage);
+ return intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
+ }
+}
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index e94fafc..c88fe46 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -42,6 +42,7 @@
import com.android.settings.applications.UsageAccessDetails;
import com.android.settings.applications.appinfo.AlarmsAndRemindersDetails;
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
+import com.android.settings.applications.appinfo.AppLocaleDetails;
import com.android.settings.applications.appinfo.DrawOverlayDetails;
import com.android.settings.applications.appinfo.ExternalSourcesDetails;
import com.android.settings.applications.appinfo.ManageExternalStorageDetails;
@@ -331,7 +332,8 @@
MediaManagementAppsDetails.class.getName(),
AutoBrightnessSettings.class.getName(),
OneHandedSettings.class.getName(),
- MobileNetworkSettings.class.getName()
+ MobileNetworkSettings.class.getName(),
+ AppLocaleDetails.class.getName()
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
diff --git a/src/com/android/settings/dream/StartNowPreferenceController.java b/src/com/android/settings/dream/StartNowPreferenceController.java
index add1b58f..f270496 100644
--- a/src/com/android/settings/dream/StartNowPreferenceController.java
+++ b/src/com/android/settings/dream/StartNowPreferenceController.java
@@ -17,20 +17,23 @@
package com.android.settings.dream;
import android.content.Context;
+import android.widget.Button;
import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.widget.SettingsMainSwitchPreferenceController;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.dream.DreamBackend;
+import com.android.settingslib.widget.LayoutPreference;
/**
* Controller that used to enable screen saver
*/
-public class StartNowPreferenceController extends SettingsMainSwitchPreferenceController {
+public class StartNowPreferenceController extends BasePreferenceController {
private final DreamBackend mBackend;
private final MetricsFeatureProvider mMetricsFeatureProvider;
@@ -47,30 +50,23 @@
}
@Override
- public void updateState(Preference preference) {
- mSwitchPreference.setChecked(false);
- mSwitchPreference.setEnabled(mBackend.getWhenToDreamSetting() != DreamBackend.NEVER);
- }
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
- @Override
- public boolean isChecked() {
- return false;
- }
-
- @Override
- public boolean setChecked(boolean isChecked) {
- if (isChecked) {
- if (mSwitchPreference != null) {
- mMetricsFeatureProvider.logClickedPreference(mSwitchPreference,
- mSwitchPreference.getExtras().getInt(DashboardFragment.CATEGORY));
- }
+ final LayoutPreference pref = screen.findPreference(getPreferenceKey());
+ final Button startButton = pref.findViewById(R.id.dream_start_now_button);
+ startButton.setOnClickListener(v -> {
+ mMetricsFeatureProvider.logClickedPreference(pref,
+ pref.getExtras().getInt(DashboardFragment.CATEGORY));
mBackend.startDreaming();
- }
- return true;
+ });
}
@Override
- public int getSliceHighlightMenuRes() {
- return R.string.menu_key_display;
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ final Button startButton = ((LayoutPreference) preference)
+ .findViewById(R.id.dream_start_now_button);
+ startButton.setEnabled(mBackend.getWhenToDreamSetting() != DreamBackend.NEVER);
}
}
diff --git a/src/com/android/settings/network/MobileNetworkListController.java b/src/com/android/settings/network/MobileNetworkListController.java
index d7fc8b4..fd40c8f 100644
--- a/src/com/android/settings/network/MobileNetworkListController.java
+++ b/src/com/android/settings/network/MobileNetworkListController.java
@@ -16,6 +16,8 @@
package com.android.settings.network;
+import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
+
import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
@@ -34,7 +36,6 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
-import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -137,7 +138,8 @@
&& !SubscriptionUtil.showToggleForPhysicalSim(mSubscriptionManager)) {
SubscriptionUtil.startToggleSubscriptionDialogActivity(mContext, subId, true);
} else {
- final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
+ final Intent intent = new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
+ intent.setPackage(SETTINGS_PACKAGE_NAME);
intent.putExtra(Settings.EXTRA_SUB_ID, info.getSubscriptionId());
mContext.startActivity(intent);
}
diff --git a/src/com/android/settings/network/MobileNetworkPreferenceController.java b/src/com/android/settings/network/MobileNetworkPreferenceController.java
index 527a632..b49613a 100644
--- a/src/com/android/settings/network/MobileNetworkPreferenceController.java
+++ b/src/com/android/settings/network/MobileNetworkPreferenceController.java
@@ -18,6 +18,8 @@
import static android.os.UserHandle.myUserId;
import static android.os.UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS;
+import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
+
import static androidx.lifecycle.Lifecycle.Event;
import android.content.BroadcastReceiver;
@@ -38,7 +40,6 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.network.telephony.MobileNetworkActivity;
import com.android.settings.network.telephony.MobileNetworkUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.RestrictedPreference;
@@ -146,7 +147,8 @@
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (KEY_MOBILE_NETWORK_SETTINGS.equals(preference.getKey())) {
- final Intent intent = new Intent(mContext, MobileNetworkActivity.class);
+ final Intent intent = new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
+ intent.setPackage(SETTINGS_PACKAGE_NAME);
mContext.startActivity(intent);
return true;
}
diff --git a/src/com/android/settings/network/telephony/ConfirmDialogFragment.java b/src/com/android/settings/network/telephony/ConfirmDialogFragment.java
index bad981a..6352180 100644
--- a/src/com/android/settings/network/telephony/ConfirmDialogFragment.java
+++ b/src/com/android/settings/network/telephony/ConfirmDialogFragment.java
@@ -112,11 +112,9 @@
ArrayList<String> list = getArguments().getStringArrayList(ARG_LIST);
Log.i(TAG, "Showing dialog with title =" + title);
- AlertDialog.Builder builder =
- new AlertDialog.Builder(getContext())
- .setTitle(title)
- .setPositiveButton(posBtnString, this)
- .setNegativeButton(negBtnString, this);
+ AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
+ .setPositiveButton(posBtnString, this)
+ .setNegativeButton(negBtnString, this);
if (list != null && !list.isEmpty()) {
Log.i(TAG, "list =" + list.toString());
@@ -124,13 +122,22 @@
View content = LayoutInflater.from(getContext()).inflate(
R.layout.sim_confirm_dialog_multiple_enabled_profiles_supported, null);
+ if (!TextUtils.isEmpty(title)) {
+ View titleView = LayoutInflater.from(getContext()).inflate(
+ R.layout.sim_confirm_dialog_title_multiple_enabled_profiles_supported,
+ null);
+ TextView titleTextView = titleView.findViewById(R.id.title);
+ titleTextView.setText(title);
+ builder.setCustomTitle(titleTextView);
+ }
TextView dialogMessage = content.findViewById(R.id.msg);
if (!TextUtils.isEmpty(message) && dialogMessage != null) {
dialogMessage.setText(message);
}
final ArrayAdapter<String> arrayAdapterItems = new ArrayAdapter<String>(
- getContext(), android.R.layout.select_dialog_item, list);
+ getContext(),
+ R.layout.sim_confirm_dialog_item_multiple_enabled_profiles_supported, list);
final ListView lvItems = content.findViewById(R.id.carrier_list);
if (lvItems != null) {
lvItems.setAdapter(arrayAdapterItems);
@@ -153,6 +160,9 @@
}
builder.setView(content);
} else {
+ if (!TextUtils.isEmpty(title)) {
+ builder.setTitle(title);
+ }
if (!TextUtils.isEmpty(message)) {
builder.setMessage(message);
}
diff --git a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
index 1ac121e..69951bf 100644
--- a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
+++ b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
@@ -122,6 +122,7 @@
@Override
public boolean isChecked() {
+ mTelephonyManager = getTelephonyManager();
return mTelephonyManager.isDataEnabled();
}
@@ -152,8 +153,21 @@
public void init(FragmentManager fragmentManager, int subId) {
mFragmentManager = fragmentManager;
mSubId = subId;
- mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
- .createForSubscriptionId(mSubId);
+ mTelephonyManager = null;
+ mTelephonyManager = getTelephonyManager();
+ }
+
+ private TelephonyManager getTelephonyManager() {
+ if (mTelephonyManager != null) {
+ return mTelephonyManager;
+ }
+ TelephonyManager telMgr =
+ mContext.getSystemService(TelephonyManager.class);
+ if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ telMgr = telMgr.createForSubscriptionId(mSubId);
+ }
+ mTelephonyManager = telMgr;
+ return telMgr;
}
public void setWifiPickerTrackerHelper(WifiPickerTrackerHelper helper) {
@@ -163,6 +177,7 @@
@VisibleForTesting
boolean isDialogNeeded() {
final boolean enableData = !isChecked();
+ mTelephonyManager = getTelephonyManager();
final boolean isMultiSim = (mTelephonyManager.getActiveModemCount() > 1);
final int defaultSubId = mSubscriptionManager.getDefaultDataSubscriptionId();
final boolean needToDisableOthers = mSubscriptionManager
diff --git a/src/com/android/settings/network/telephony/MobileDataSlice.java b/src/com/android/settings/network/telephony/MobileDataSlice.java
index 22bb581..d25ae65 100644
--- a/src/com/android/settings/network/telephony/MobileDataSlice.java
+++ b/src/com/android/settings/network/telephony/MobileDataSlice.java
@@ -18,6 +18,8 @@
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
+import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
+
import android.annotation.ColorInt;
import android.app.PendingIntent;
import android.content.Context;
@@ -27,6 +29,7 @@
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
+import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -142,7 +145,8 @@
@Override
public Intent getIntent() {
- return new Intent(mContext, MobileNetworkActivity.class);
+ return new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS).setPackage(
+ SETTINGS_PACKAGE_NAME);
}
@Override
diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
deleted file mode 100644
index d3ff546..0000000
--- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.network.telephony;
-
-import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
-
-import android.app.Activity;
-import android.app.settings.SettingsEnums;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.UserManager;
-import android.provider.Settings;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-import android.telephony.ims.ImsRcsManager;
-import android.text.TextUtils;
-import android.util.Log;
-
-
-import com.android.settings.SettingsActivity;
-import com.android.settings.Utils;
-import com.android.settings.activityembedding.ActivityEmbeddingUtils;
-import com.android.settings.network.SubscriptionUtil;
-
-/**
- * Activity for displaying MobileNetworkSettings.
- *
- * @Deprecated The MobileNetworkActivity should be removed in Android U. Instead of using the
- * singleTask activity which will cause an additional window transition when users launch the SIMs
- * page, using the {@link com.android.settings.Settings.SubscriptionSettingsActivity} which can be
- * managed by {@link SettingsActivity} and be migrated into the Settings architecture.
- */
-@Deprecated
-public class MobileNetworkActivity extends Activity {
-
- private static final String TAG = "MobileNetworkActivity";
- public static final String SHOW_CAPABILITY_DISCOVERY_OPT_IN =
- "show_capability_discovery_opt_in";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- final UserManager userManager = this.getSystemService(UserManager.class);
- if (!userManager.isAdminUser()) {
- this.finish();
- return;
- }
-
- // TODO: Move these intent's extra into SubscriptionSettingsActivity if the
- // MobileNetworkActivity is removed in Android U.
- Intent intent = getIntent();
- if (intent == null) {
- Log.d(TAG, "onCreate(), intent = null");
- this.finish();
- return;
- }
-
- Intent trampolineIntent;
- final Intent subscriptionSettingsIntent = new Intent(this,
- com.android.settings.Settings.SubscriptionSettingsActivity.class);
- if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this) || !isTaskRoot()) {
- trampolineIntent = subscriptionSettingsIntent;
- } else {
- trampolineIntent = new Intent(Settings.ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY)
- .setPackage(Utils.SETTINGS_PACKAGE_NAME);
- trampolineIntent.putExtra(
- android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI,
- subscriptionSettingsIntent.toUri(Intent.URI_INTENT_SCHEME));
- }
-
- int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID,
- SubscriptionManager.INVALID_SUBSCRIPTION_ID);
- SubscriptionInfo subInfo = SubscriptionUtil.getSubscriptionOrDefault(this, subId);
- CharSequence title = SubscriptionUtil.getUniqueSubscriptionDisplayName(subInfo, this);
- trampolineIntent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, title);
- trampolineIntent.putExtra(Settings.EXTRA_SUB_ID, subId);
- if (Settings.ACTION_MMS_MESSAGE_SETTING.equals(intent.getAction())) {
- // highlight "mms_message" preference.
- trampolineIntent.putExtra(EXTRA_FRAGMENT_ARG_KEY, "mms_message");
- }
-
- if (doesIntentContainOptInAction(intent)) {
- trampolineIntent.putExtra(SHOW_CAPABILITY_DISCOVERY_OPT_IN,
- maybeShowContactDiscoveryDialog(subId));
- }
-
- startActivity(trampolineIntent);
- if (isTaskRoot()) {
- finishAndRemoveTask();
- } else {
- finish();
- }
- }
-
- private boolean maybeShowContactDiscoveryDialog(int subId) {
- // If this activity was launched using ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN, show the
- // associated dialog only if the opt-in has not been granted yet.
- return MobileNetworkUtils.isContactDiscoveryVisible(this, subId)
- // has the user already enabled this configuration?
- && !MobileNetworkUtils.isContactDiscoveryEnabled(this, subId);
- }
-
- public static boolean doesIntentContainOptInAction(Intent intent) {
- String intentAction = (intent != null ? intent.getAction() : null);
- return TextUtils.equals(intentAction,
- ImsRcsManager.ACTION_SHOW_CAPABILITY_DISCOVERY_OPT_IN);
- }
-}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index cf0f889..f1a4018 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -26,7 +26,6 @@
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
-import android.telephony.ims.ImsRcsManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
@@ -37,6 +36,7 @@
import androidx.preference.Preference;
import com.android.settings.R;
+import com.android.settings.Settings.MobileNetworkActivity;
import com.android.settings.datausage.BillingCyclePreferenceController;
import com.android.settings.datausage.DataUsageSummaryPreferenceController;
import com.android.settings.network.ActiveSubscriptionsListener;
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java
index 85623b8..ab53a3f 100644
--- a/src/com/android/settings/notification/SoundSettings.java
+++ b/src/com/android/settings/notification/SoundSettings.java
@@ -256,8 +256,6 @@
new DockingSoundPreferenceController(context, fragment, lifecycle);
final TouchSoundPreferenceController touchSoundPreferenceController =
new TouchSoundPreferenceController(context, fragment, lifecycle);
- final VibrateOnTouchPreferenceController vibrateOnTouchPreferenceController =
- new VibrateOnTouchPreferenceController(context, fragment, lifecycle);
final DockAudioMediaPreferenceController dockAudioMediaPreferenceController =
new DockAudioMediaPreferenceController(context, fragment, lifecycle);
final BootSoundPreferenceController bootSoundPreferenceController =
@@ -270,7 +268,6 @@
controllers.add(chargingSoundPreferenceController);
controllers.add(dockingSoundPreferenceController);
controllers.add(touchSoundPreferenceController);
- controllers.add(vibrateOnTouchPreferenceController);
controllers.add(dockAudioMediaPreferenceController);
controllers.add(bootSoundPreferenceController);
controllers.add(emergencyTonePreferenceController);
@@ -281,7 +278,6 @@
chargingSoundPreferenceController,
dockingSoundPreferenceController,
touchSoundPreferenceController,
- vibrateOnTouchPreferenceController,
dockAudioMediaPreferenceController,
bootSoundPreferenceController,
emergencyTonePreferenceController)));
diff --git a/src/com/android/settings/notification/VibrateOnTouchPreferenceController.java b/src/com/android/settings/notification/VibrateOnTouchPreferenceController.java
deleted file mode 100644
index 0ae4c03..0000000
--- a/src/com/android/settings/notification/VibrateOnTouchPreferenceController.java
+++ /dev/null
@@ -1,50 +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.notification;
-
-import static com.android.settings.notification.SettingPref.TYPE_SYSTEM;
-
-import android.content.Context;
-import android.os.Vibrator;
-import android.provider.Settings.System;
-
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-public class VibrateOnTouchPreferenceController extends SettingPrefController {
-
- private static final String KEY_VIBRATE_ON_TOUCH = "vibrate_on_touch";
-
- public VibrateOnTouchPreferenceController(Context context, SettingsPreferenceFragment parent,
- Lifecycle lifecycle) {
- super(context, parent, lifecycle);
- mPreference = new SettingPref(
- TYPE_SYSTEM, KEY_VIBRATE_ON_TOUCH, System.HAPTIC_FEEDBACK_ENABLED, 0) {
- @Override
- public boolean isApplicable(Context context) {
- return hasHaptic(context);
- }
- };
-
- }
-
- private static boolean hasHaptic(Context context) {
- final Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
- return vibrator != null && vibrator.hasVibrator();
- }
-
-}
diff --git a/src/com/android/settings/sim/SelectSpecificDataSimDialogFragment.java b/src/com/android/settings/sim/SelectSpecificDataSimDialogFragment.java
new file mode 100644
index 0000000..f5c2406
--- /dev/null
+++ b/src/com/android/settings/sim/SelectSpecificDataSimDialogFragment.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.sim;
+
+import android.app.Dialog;
+import android.app.settings.SettingsEnums;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.VisibleForTesting;
+import androidx.appcompat.app.AlertDialog;
+
+import com.android.settings.R;
+import com.android.settings.network.SubscriptionUtil;
+
+import java.util.List;
+
+/**
+ * Presents a dialog asking the user if they want to switch the data to another sim
+ */
+public class SelectSpecificDataSimDialogFragment extends SimDialogFragment implements
+ DialogInterface.OnClickListener {
+ private static final String TAG = "PreferredSimDialogFrag";
+
+ private SubscriptionInfo mSubscriptionInfo;
+
+ /**
+ * @return the dialog fragment.
+ */
+ public static SelectSpecificDataSimDialogFragment newInstance() {
+ final SelectSpecificDataSimDialogFragment
+ fragment = new SelectSpecificDataSimDialogFragment();
+ final Bundle args = initArguments(SimDialogActivity.DATA_PICK,
+ R.string.select_specific_sim_for_data_title);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
+ final AlertDialog dialog = new AlertDialog.Builder(getContext())
+ .setNegativeButton(R.string.sim_action_no_thanks, null)
+ .create();
+ updateDialog(dialog);
+ return dialog;
+ }
+
+ @Override
+ public void onClick(DialogInterface dialog, int buttonClicked) {
+ if (buttonClicked != DialogInterface.BUTTON_POSITIVE) {
+ return;
+ }
+ final SimDialogActivity activity = (SimDialogActivity) getActivity();
+ final SubscriptionInfo info = getTargetSubscriptionInfo();
+ if (info != null) {
+ activity.onSubscriptionSelected(getDialogType(), info.getSubscriptionId());
+ }
+ }
+
+ private SubscriptionInfo getNonDefaultDataSubscriptionInfo(SubscriptionInfo dds) {
+ List<SubscriptionInfo> subInfos = getSubscriptionManager().getActiveSubscriptionInfoList();
+ if (subInfos == null || dds == null) {
+ return null;
+ }
+ return subInfos.stream().filter(subinfo -> subinfo != dds).findFirst().orElse(null);
+ }
+
+ private SubscriptionInfo getDefaultDataSubId() {
+ return getSubscriptionManager().getDefaultDataSubscriptionInfo();
+ }
+
+ private void updateDialog(AlertDialog dialog) {
+ Log.d(TAG, "Dialog updated, dismiss status: " + mWasDismissed);
+ if (mWasDismissed) {
+ return;
+ }
+
+ SubscriptionInfo activeSubInfo = getDefaultDataSubId();
+ SubscriptionInfo newSubInfo = getNonDefaultDataSubscriptionInfo(activeSubInfo);
+
+ if (newSubInfo == null || activeSubInfo == null) {
+ dismiss();
+ return;
+ }
+
+ setTargetSubscriptionInfo(newSubInfo);
+
+ CharSequence newDataCarrierName = SubscriptionUtil.getUniqueSubscriptionDisplayName(
+ newSubInfo, getContext());
+ CharSequence currentDataCarrierName = SubscriptionUtil.getUniqueSubscriptionDisplayName(
+ activeSubInfo, getContext());
+
+ String positive = getContext().getString(
+ R.string.select_specific_sim_for_data_button, newDataCarrierName);
+ String message = getContext().getString(R.string.select_specific_sim_for_data_msg,
+ newDataCarrierName, currentDataCarrierName);
+
+ View content = LayoutInflater.from(getContext()).inflate(
+ R.layout.sim_confirm_dialog_multiple_enabled_profiles_supported, null);
+ TextView dialogMessage = content.findViewById(R.id.msg);
+ if (!TextUtils.isEmpty(message) && dialogMessage != null) {
+ dialogMessage.setText(message);
+ }
+
+ final ListView lvItems = content.findViewById(R.id.carrier_list);
+ if (lvItems != null) {
+ lvItems.setVisibility(View.GONE);
+ }
+ final LinearLayout infoOutline = content.findViewById(R.id.info_outline_layout);
+ if (infoOutline != null) {
+ infoOutline.setVisibility(View.GONE);
+ }
+ dialog.setView(content);
+
+ View titleView = LayoutInflater.from(getContext()).inflate(
+ R.layout.sim_confirm_dialog_title_multiple_enabled_profiles_supported, null);
+ TextView titleTextView = titleView.findViewById(R.id.title);
+ titleTextView.setText(getContext().getString(getTitleResId(), newDataCarrierName));
+
+ dialog.setCustomTitle(titleTextView);
+ dialog.setButton(AlertDialog.BUTTON_POSITIVE, positive, this);
+ }
+
+ private void setTargetSubscriptionInfo(SubscriptionInfo subInfo) {
+ mSubscriptionInfo = subInfo;
+ }
+
+ private SubscriptionInfo getTargetSubscriptionInfo() {
+ return mSubscriptionInfo;
+ }
+
+ @Override
+ public void updateDialog() {
+ updateDialog((AlertDialog) getDialog());
+ }
+
+ @VisibleForTesting
+ protected SubscriptionManager getSubscriptionManager() {
+ return getContext().getSystemService(SubscriptionManager.class);
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.DIALOG_PREFERRED_SIM_PICKER;
+ }
+}
diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java
index f9aca77..1125e1f 100644
--- a/src/com/android/settings/sim/SimDialogActivity.java
+++ b/src/com/android/settings/sim/SimDialogActivity.java
@@ -95,15 +95,16 @@
private SimDialogFragment createFragment(int dialogType) {
switch (dialogType) {
case DATA_PICK:
- return SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
- false /* includeAskEveryTime */);
+ return getDataPickDialogFramgent();
case CALLS_PICK:
return CallsSimListDialogFragment.newInstance(dialogType,
R.string.select_sim_for_calls,
- true /* includeAskEveryTime */);
+ true /* includeAskEveryTime */,
+ false /* isCancelItemShowed */);
case SMS_PICK:
return SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_sms,
- true /* includeAskEveryTime */);
+ true /* includeAskEveryTime */,
+ false /* isCancelItemShowed */);
case PREFERRED_PICK:
if (!getIntent().hasExtra(PREFERRED_SIM)) {
throw new IllegalArgumentException("Missing required extra " + PREFERRED_SIM);
@@ -111,12 +112,23 @@
return PreferredSimDialogFragment.newInstance();
case SMS_PICK_FOR_MESSAGE:
return SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_sms,
- false /* includeAskEveryTime */);
+ false /* includeAskEveryTime */,
+ false /* isCancelItemShowed */);
default:
throw new IllegalArgumentException("Invalid dialog type " + dialogType + " sent.");
}
}
+ private SimDialogFragment getDataPickDialogFramgent() {
+ if (SubscriptionManager.getDefaultDataSubscriptionId()
+ == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ return SimListDialogFragment.newInstance(DATA_PICK, R.string.select_sim_for_data,
+ false /* includeAskEveryTime */,
+ true /* isCancelItemShowed */);
+ }
+ return SelectSpecificDataSimDialogFragment.newInstance();
+ }
+
public void onSubscriptionSelected(int dialogType, int subId) {
if (getSupportFragmentManager().findFragmentByTag(Integer.toString(dialogType)) == null) {
Log.w(TAG, "onSubscriptionSelected ignored because stored fragment was null");
diff --git a/src/com/android/settings/sim/SimListDialogFragment.java b/src/com/android/settings/sim/SimListDialogFragment.java
index 2681d7b..629a087 100644
--- a/src/com/android/settings/sim/SimListDialogFragment.java
+++ b/src/com/android/settings/sim/SimListDialogFragment.java
@@ -29,7 +29,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
-import android.widget.ImageView;
+import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -38,7 +38,6 @@
import androidx.appcompat.app.AlertDialog;
import com.android.settings.R;
-import com.android.settings.Utils;
import com.android.settings.network.SubscriptionUtil;
import java.util.ArrayList;
@@ -52,16 +51,19 @@
DialogInterface.OnClickListener {
private static final String TAG = "SimListDialogFragment";
protected static final String KEY_INCLUDE_ASK_EVERY_TIME = "include_ask_every_time";
+ protected static final String KEY_SHOW_CANCEL_ITEM = "show_cancel_item";
+ private static final int LIST_VIEW_DIVIDER_LINE_WEIGHT = 2;
protected SelectSubscriptionAdapter mAdapter;
@VisibleForTesting
List<SubscriptionInfo> mSubscriptions;
public static SimListDialogFragment newInstance(int dialogType, int titleResId,
- boolean includeAskEveryTime) {
+ boolean includeAskEveryTime, boolean isCancelItemShowed) {
final SimListDialogFragment fragment = new SimListDialogFragment();
final Bundle args = initArguments(dialogType, titleResId);
args.putBoolean(KEY_INCLUDE_ASK_EVERY_TIME, includeAskEveryTime);
+ args.putBoolean(KEY_SHOW_CANCEL_ITEM, isCancelItemShowed);
fragment.setArguments(args);
return fragment;
}
@@ -72,12 +74,20 @@
mSubscriptions = new ArrayList<>();
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- builder.setTitle(getTitleResId());
+ View titleView = LayoutInflater.from(getContext()).inflate(
+ R.layout.sim_confirm_dialog_title_multiple_enabled_profiles_supported, null);
+ TextView titleTextView = titleView.findViewById(R.id.title);
+ titleTextView.setText(getContext().getString(getTitleResId()));
+ builder.setCustomTitle(titleTextView);
mAdapter = new SelectSubscriptionAdapter(builder.getContext(), mSubscriptions);
-
setAdapter(builder);
- final Dialog dialog = builder.create();
+
+ final AlertDialog dialog = builder.create();
+ ListView listView = dialog.getListView();
+ if (listView != null) {
+ listView.setDividerHeight(LIST_VIEW_DIVIDER_LINE_WEIGHT);
+ }
updateDialog();
return dialog;
}
@@ -112,10 +122,22 @@
}
return;
}
- if (getArguments().getBoolean(KEY_INCLUDE_ASK_EVERY_TIME)) {
- final List<SubscriptionInfo> tmp = new ArrayList<>(currentSubscriptions.size() + 1);
- tmp.add(null);
+ boolean includeAskEveryTime = getArguments().getBoolean(KEY_INCLUDE_ASK_EVERY_TIME);
+ boolean isCancelItemShowed = getArguments().getBoolean(KEY_SHOW_CANCEL_ITEM);
+ if (includeAskEveryTime || isCancelItemShowed) {
+ int arraySize = currentSubscriptions.size()
+ + (includeAskEveryTime ? 1 : 0)
+ + (isCancelItemShowed ? 1 : 0);
+ final List<SubscriptionInfo> tmp = new ArrayList<>(arraySize);
+ if (includeAskEveryTime) {
+ // add the value of 'AskEveryTime' item
+ tmp.add(null);
+ }
tmp.addAll(currentSubscriptions);
+ if (isCancelItemShowed) {
+ // add the value of 'Cancel' item
+ tmp.add(null);
+ }
currentSubscriptions = tmp;
}
if (currentSubscriptions.equals(mSubscriptions)) {
@@ -177,19 +199,23 @@
final TextView title = convertView.findViewById(R.id.title);
final TextView summary = convertView.findViewById(R.id.summary);
- final ImageView icon = convertView.findViewById(R.id.icon);
if (sub == null) {
- title.setText(R.string.sim_calls_ask_first_prefs_title);
- summary.setText("");
- icon.setImageDrawable(mContext.getDrawable(R.drawable.ic_feedback_24dp));
- icon.setImageTintList(
- Utils.getColorAttr(mContext, android.R.attr.textColorSecondary));
+ if (position == 0) {
+ title.setText(R.string.sim_calls_ask_first_prefs_title);
+ } else {
+ title.setText(R.string.sim_action_cancel);
+ }
+ summary.setVisibility(View.GONE);
} else {
title.setText(SubscriptionUtil.getUniqueSubscriptionDisplayName(sub, mContext));
- summary.setText(isMdnProvisioned(sub.getNumber()) ? sub.getNumber() : "");
- icon.setImageBitmap(sub.createIconBitmap(mContext));
-
+ String phoneNumber = isMdnProvisioned(sub.getNumber()) ? sub.getNumber() : "";
+ if (!TextUtils.isEmpty(phoneNumber)) {
+ summary.setVisibility(View.VISIBLE);
+ summary.setText(phoneNumber);
+ } else {
+ summary.setVisibility(View.GONE);
+ }
}
return convertView;
}
diff --git a/src/com/android/settings/sim/SimSelectNotification.java b/src/com/android/settings/sim/SimSelectNotification.java
index 6d15737..5902b92 100644
--- a/src/com/android/settings/sim/SimSelectNotification.java
+++ b/src/com/android/settings/sim/SimSelectNotification.java
@@ -53,7 +53,6 @@
import com.android.settings.HelpTrampoline;
import com.android.settings.R;
import com.android.settings.network.SubscriptionUtil;
-import com.android.settings.network.telephony.MobileNetworkActivity;
public class SimSelectNotification extends BroadcastReceiver {
private static final String TAG = "SimSelectNotification";
@@ -261,7 +260,7 @@
// Create the pending intent that will lead to the subscription setting page.
Intent resultIntent = new Intent(Settings.ACTION_MMS_MESSAGE_SETTING);
- resultIntent.setClass(context, MobileNetworkActivity.class);
+ resultIntent.setPackage(SETTINGS_PACKAGE_NAME);
resultIntent.putExtra(Settings.EXTRA_SUB_ID, subId);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
diff --git a/src/com/android/settings/users/AddSupervisedUserActivity.java b/src/com/android/settings/users/AddSupervisedUserActivity.java
new file mode 100644
index 0000000..f3c5867
--- /dev/null
+++ b/src/com/android/settings/users/AddSupervisedUserActivity.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.users;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.AlertDialog;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.NewUserRequest;
+import android.os.NewUserResponse;
+import android.os.UserManager;
+
+import androidx.annotation.Nullable;
+
+import com.android.settings.R;
+
+import java.util.Objects;
+import java.util.concurrent.Executors;
+import java.util.function.Consumer;
+
+/**
+ * Fallback activity for supervised user creation.
+ * Built to test {@link UserManager#createUser(NewUserRequest)} API.
+ */
+// TODO(b/209659998): [to-be-removed] fallback activity for supervised user creation.
+public class AddSupervisedUserActivity extends Activity {
+
+ private UserManager mUserManager;
+ private ActivityManager mActivityManager;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mUserManager = getSystemService(UserManager.class);
+ mActivityManager = getSystemService(ActivityManager.class);
+ setContentView(R.layout.add_supervised_user);
+ findViewById(R.id.createSupervisedUser).setOnClickListener(v -> createUser());
+ }
+
+ private void createUserAsync(final NewUserRequest request,
+ final Consumer<NewUserResponse> onResponse) {
+ Objects.requireNonNull(onResponse);
+
+ final Handler mMainThread = new Handler(Looper.getMainLooper());
+ Executors.newSingleThreadExecutor().execute(() -> {
+ final NewUserResponse response = mUserManager.createUser(request);
+ mMainThread.post(() -> onResponse.accept(response));
+ });
+ }
+
+ private void createUser() {
+ final NewUserRequest request = new NewUserRequest.Builder().build();
+
+ final AlertDialog pleaseWaitDialog = new AlertDialog.Builder(this)
+ .setMessage(getString(R.string.creating_new_user_dialog_message))
+ .setCancelable(false)
+ .create();
+
+ pleaseWaitDialog.show();
+ createUserAsync(request, response -> {
+ pleaseWaitDialog.dismiss();
+
+ if (response.isSuccessful()) {
+ mActivityManager.switchUser(response.getUser());
+ finish();
+ } else {
+ new AlertDialog.Builder(this)
+ .setTitle(getString(R.string.add_user_failed))
+ .setMessage(UserManager.UserOperationResult.class.getName()
+ + " = " + response.getOperationResult())
+ .setNeutralButton(getString(R.string.okay), null)
+ .show();
+ }
+ });
+ }
+}
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 096b6ee..c3f0439 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -115,6 +115,7 @@
private static final String KEY_USER_GUEST = "user_guest";
private static final String KEY_ADD_GUEST = "guest_add";
private static final String KEY_ADD_USER = "user_add";
+ private static final String KEY_ADD_SUPERVISED_USER = "supervised_user_add";
private static final String KEY_ADD_USER_WHEN_LOCKED = "user_settings_add_users_when_locked";
private static final String KEY_MULTIUSER_TOP_INTRO = "multiuser_top_intro";
@@ -165,10 +166,13 @@
@VisibleForTesting
RestrictedPreference mAddUser;
@VisibleForTesting
+ RestrictedPreference mAddSupervisedUser;
+ @VisibleForTesting
SparseArray<Bitmap> mUserIcons = new SparseArray<>();
private int mRemovingUserId = -1;
private boolean mAddingUser;
private boolean mGuestUserAutoCreated;
+ private String mConfigSupervisedUserCreationPackage;
private String mAddingUserName;
private UserCapabilities mUserCaps;
private boolean mShouldUpdateUserList = true;
@@ -300,6 +304,10 @@
}
mAddUser.setOnPreferenceClickListener(this);
+ setConfigSupervisedUserCreationPackage();
+ mAddSupervisedUser = findPreference(KEY_ADD_SUPERVISED_USER);
+ mAddSupervisedUser.setOnPreferenceClickListener(this);
+
activity.registerReceiverAsUser(
mUserChangeReceiver, UserHandle.ALL, USER_REMOVED_INTENT_FILTER, null, mHandler);
@@ -491,6 +499,21 @@
}
}
+ private void onAddSupervisedUserClicked() {
+ final Intent intent = new Intent()
+ .setAction(UserManager.ACTION_CREATE_SUPERVISED_USER)
+ .setPackage(mConfigSupervisedUserCreationPackage);
+
+ // TODO(b/209659998): [to-be-removed] fallback activity for supervised user creation.
+ if (getActivity().getPackageManager().resolveActivity(intent, 0) == null) {
+ intent
+ .setClass(getContext(), AddSupervisedUserActivity.class)
+ .setPackage(null);
+ }
+
+ startActivity(intent);
+ }
+
private void onRemoveUserClicked(int userId) {
synchronized (mUserLock) {
if (mRemovingUserId == -1 && !mAddingUser) {
@@ -1058,6 +1081,7 @@
updateAddGuest(context, users.stream().anyMatch(UserInfo::isGuest));
updateAddUser(context);
+ updateAddSupervisedUser(context);
if (!mUserCaps.mUserSwitcherEnabled) {
return;
@@ -1070,6 +1094,12 @@
}
+ @VisibleForTesting
+ void setConfigSupervisedUserCreationPackage() {
+ mConfigSupervisedUserCreationPackage = getPrefContext().getString(
+ com.android.internal.R.string.config_supervisedUserCreationPackage);
+ }
+
private boolean isCurrentUserGuest() {
return mUserCaps.mIsGuest;
}
@@ -1100,28 +1130,41 @@
}
private void updateAddUser(Context context) {
+ updateAddUserCommon(context, mAddUser, mUserCaps.mCanAddRestrictedProfile);
+ }
+
+ private void updateAddSupervisedUser(Context context) {
+ if (!TextUtils.isEmpty(mConfigSupervisedUserCreationPackage)) {
+ updateAddUserCommon(context, mAddSupervisedUser, false);
+ } else {
+ mAddSupervisedUser.setVisible(false);
+ }
+ }
+
+ private void updateAddUserCommon(Context context, RestrictedPreference addUser,
+ boolean canAddRestrictedProfile) {
if ((mUserCaps.mCanAddUser || mUserCaps.mDisallowAddUserSetByAdmin)
&& WizardManagerHelper.isDeviceProvisioned(context)
&& mUserCaps.mUserSwitcherEnabled) {
- mAddUser.setVisible(true);
- mAddUser.setSelectable(true);
+ addUser.setVisible(true);
+ addUser.setSelectable(true);
final boolean canAddMoreUsers =
mUserManager.canAddMoreUsers(UserManager.USER_TYPE_FULL_SECONDARY)
- || (mUserCaps.mCanAddRestrictedProfile
+ || (canAddRestrictedProfile
&& mUserManager.canAddMoreUsers(UserManager.USER_TYPE_FULL_RESTRICTED));
- mAddUser.setEnabled(canAddMoreUsers && !mAddingUser && canSwitchUserNow());
+ addUser.setEnabled(canAddMoreUsers && !mAddingUser && canSwitchUserNow());
if (!canAddMoreUsers) {
- mAddUser.setSummary(
+ addUser.setSummary(
getString(R.string.user_add_max_count, getRealUsersCount()));
} else {
- mAddUser.setSummary(null);
+ addUser.setSummary(null);
}
- if (mAddUser.isEnabled()) {
- mAddUser.setDisabledByAdmin(
+ if (addUser.isEnabled()) {
+ addUser.setDisabledByAdmin(
mUserCaps.mDisallowAddUser ? mUserCaps.mEnforcedAdmin : null);
}
} else {
- mAddUser.setVisible(false);
+ addUser.setVisible(false);
}
}
@@ -1206,6 +1249,9 @@
onAddUserClicked(USER_TYPE_USER);
}
return true;
+ } else if (pref == mAddSupervisedUser) {
+ onAddSupervisedUserClicked();
+ return true;
} else if (pref == mAddGuest) {
mAddGuest.setEnabled(false); // prevent multiple tap issue
mMetricsFeatureProvider.action(getActivity(), SettingsEnums.ACTION_USER_GUEST_ADD);
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
index 3636341..c73bffa 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
@@ -179,7 +179,8 @@
.setTitle(res.getText(R.string.wifi_calling_settings_title))
.addEndItem(
SliceAction.createToggle(
- getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED),
+ getBroadcastIntent(ACTION_WIFI_CALLING_CHANGED,
+ isWifiCallingEnabled),
null /* actionTitle */, isWifiCallingEnabled))
.setPrimaryAction(SliceAction.createDeeplink(
getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY),
@@ -316,7 +317,7 @@
final Resources res = getResourcesForSubId(subId);
return new RowBuilder()
.setTitle(res.getText(preferenceTitleResId))
- .setTitleItem(SliceAction.createToggle(getBroadcastIntent(action),
+ .setTitleItem(SliceAction.createToggle(getBroadcastIntent(action, checked),
icon, res.getText(preferenceTitleResId), checked));
}
@@ -370,25 +371,31 @@
public void handleWifiCallingChanged(Intent intent) {
final int subId = getDefaultVoiceSubId();
- if (SubscriptionManager.isValidSubscriptionId(subId)) {
+ if (SubscriptionManager.isValidSubscriptionId(subId)
+ && intent.hasExtra(EXTRA_TOGGLE_STATE)) {
final WifiCallingQueryImsState queryState = queryImsState(subId);
if (queryState.isWifiCallingProvisioned()) {
- final boolean currentValue = queryState.isEnabledByUser()
- && queryState.isAllowUserControl();
+ final boolean currentValue = isWifiCallingEnabled();
final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
currentValue);
final Intent activationAppIntent =
getWifiCallingCarrierActivityIntent(subId);
- if (!newValue || activationAppIntent == null) {
+ if ((newValue == currentValue) && activationAppIntent == null) {
// If either the action is to turn off wifi calling setting
// or there is no activation involved - Update the setting
- if (newValue != currentValue) {
- final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
- imsMmTelManager.setVoWiFiSettingEnabled(newValue);
- }
+ final ImsMmTelManager imsMmTelManager = getImsMmTelManager(subId);
+ imsMmTelManager.setVoWiFiSettingEnabled(!newValue);
+ } else {
+ Log.w(TAG, "action not taken: subId " + subId
+ + " from " + currentValue + " to " + newValue);
}
+ } else {
+ Log.w(TAG, "action not taken: subId " + subId + " needs provision");
}
+ } else {
+ Log.w(TAG, "action not taken: subId " + subId);
}
+
// notify change in slice in any case to get re-queried. This would result in displaying
// appropriate message with the updated setting.
mContext.getContentResolver().notifyChange(WIFI_CALLING_URI, null);
@@ -541,10 +548,20 @@
PendingIntent.FLAG_IMMUTABLE);
}
- private PendingIntent getBroadcastIntent(String action) {
+ /**
+ * Create PendingIntent for Slice.
+ * Note: SliceAction#createDeeplink() didn't support toggle status so far,
+ * therefore, embedding toggle status within PendingIntent.
+ *
+ * @param action Slice action
+ * @param isChecked Status when Slice created.
+ * @return PendingIntent
+ */
+ private PendingIntent getBroadcastIntent(String action, boolean isChecked) {
final Intent intent = new Intent(action);
intent.setClass(mContext, SliceBroadcastReceiver.class);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ intent.putExtra(EXTRA_TOGGLE_STATE, isChecked);
return PendingIntent.getBroadcast(mContext, 0 /* requestCode */, intent,
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
diff --git a/tests/componenttests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerComponentTest.java b/tests/componenttests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerComponentTest.java
index d80faf2..78a2c92 100644
--- a/tests/componenttests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerComponentTest.java
+++ b/tests/componenttests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerComponentTest.java
@@ -37,6 +37,7 @@
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
+import com.android.settings.Settings;
import com.android.settings.testutils.CommonUtils;
import com.android.settings.testutils.UiUtils;
@@ -68,7 +69,7 @@
Context.TELECOM_SERVICE);
@Rule
- public ActivityScenarioRule<com.android.settings.network.telephony.MobileNetworkActivity>
+ public ActivityScenarioRule<Settings.MobileNetworkActivity>
rule = new ActivityScenarioRule<>(
new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index bc25377..2945bef 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -37,7 +37,6 @@
"com.google.android.material_material",
"setupcompat",
"setupdesign",
- "androidx-constraintlayout_constraintlayout-solver",
"androidx.lifecycle_lifecycle-runtime",
"androidx.lifecycle_lifecycle-extensions",
"androidx.test.core",
diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
index 78a7a69..da7516b 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
@@ -250,4 +250,22 @@
verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice,
BluetoothDevicePreference.SortType.TYPE_NO_SORT);
}
+
+ @Test
+ public void forceUpdate_deviceIsSubDevice_doesNothing() {
+ final List<BluetoothDevice> bluetoothDevices = new ArrayList<>();
+ bluetoothDevices.add(mBluetoothDevice);
+
+ when(mBluetoothAdapter.isEnabled()).thenReturn(true);
+ when(mBluetoothAdapter.getMostRecentlyConnectedDevices()).thenReturn(bluetoothDevices);
+ when(mBluetoothManager.getCachedDeviceManager()).thenReturn(mDeviceManager);
+ when(mDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedBluetoothDevice);
+ when(mDeviceManager.isSubDevice(mBluetoothDevice)).thenReturn(true);
+
+ mBluetoothDeviceUpdater.forceUpdate();
+
+ verify(mBluetoothDeviceUpdater, never()).removePreference(mCachedBluetoothDevice);
+ verify(mBluetoothDeviceUpdater, never()).addPreference(mCachedBluetoothDevice,
+ BluetoothDevicePreference.SortType.TYPE_NO_SORT);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java
index 6c8a8f6..98ba1ce 100644
--- a/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java
@@ -16,17 +16,18 @@
package com.android.settings.dream;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.widget.Button;
import androidx.preference.PreferenceScreen;
+import com.android.settings.R;
import com.android.settingslib.dream.DreamBackend;
-import com.android.settingslib.widget.MainSwitchPreference;
+import com.android.settingslib.widget.LayoutPreference;
import org.junit.Before;
import org.junit.Test;
@@ -46,7 +47,9 @@
@Mock
private PreferenceScreen mScreen;
@Mock
- private MainSwitchPreference mPref;
+ private LayoutPreference mLayoutPref;
+ @Mock
+ private Button mButton;
@Mock
private DreamBackend mBackend;
@@ -56,36 +59,29 @@
mContext = spy(RuntimeEnvironment.application);
mController = new StartNowPreferenceController(mContext, "key");
- mPref = mock(MainSwitchPreference.class);
- when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPref);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mLayoutPref);
+ when(mLayoutPref.findViewById(R.id.dream_start_now_button)).thenReturn(mButton);
ReflectionHelpers.setField(mController, "mBackend", mBackend);
}
@Test
- public void displayPreference_shouldAddOnSwitchChangeListener() {
- mController.displayPreference(mScreen);
-
- verify(mPref).addOnSwitchChangeListener(mController);
- }
-
- @Test
- public void updateState_neverDreaming_preferenceShouldDidabled() {
+ public void updateState_neverDreaming_buttonShouldDidabled() {
when(mBackend.getWhenToDreamSetting()).thenReturn(DreamBackend.NEVER);
mController.displayPreference(mScreen);
- mController.updateState(mPref);
+ mController.updateState(mLayoutPref);
- verify(mPref).setEnabled(false);
+ verify(mButton).setEnabled(false);
}
@Test
- public void updateState_dreamIsAvailable_preferenceShouldEnabled() {
+ public void updateState_dreamIsAvailable_buttonShouldEnabled() {
when(mBackend.getWhenToDreamSetting()).thenReturn(DreamBackend.EITHER);
mController.displayPreference(mScreen);
- mController.updateState(mPref);
+ mController.updateState(mLayoutPref);
- verify(mPref).setEnabled(true);
+ verify(mButton).setEnabled(true);
}
}
diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
index 6870e7a..66536a5 100644
--- a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java
@@ -44,7 +44,7 @@
import androidx.lifecycle.Lifecycle;
import androidx.preference.PreferenceScreen;
-import com.android.settings.network.telephony.MobileNetworkActivity;
+import com.android.settings.Settings.MobileNetworkActivity;
import com.android.settings.widget.AddPreference;
import com.android.settingslib.RestrictedLockUtils;
@@ -212,86 +212,6 @@
}
@Test
- @Ignore
- public void getSummary_twoSubscriptions_correctSummaryAndFragment() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
- final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
- final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
- when(sub1.getSubscriptionId()).thenReturn(1);
- when(sub2.getSubscriptionId()).thenReturn(2);
-
- SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
- mController.displayPreference(mPreferenceScreen);
- mController.onResume();
- assertThat(mController.getSummary()).isEqualTo("2 SIMs");
- assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
- }
-
- @Test
- @Ignore
- public void getSummaryAfterUpdate_twoSubscriptionsBecomesOne_correctSummaryAndFragment() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
- final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
- final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
- when(sub1.getSubscriptionId()).thenReturn(1);
- when(sub2.getSubscriptionId()).thenReturn(2);
- when(sub1.getDisplayName()).thenReturn("sub1");
- when(sub2.getDisplayName()).thenReturn("sub2");
-
- SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
- SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
- mController.displayPreference(mPreferenceScreen);
- mController.onResume();
- assertThat(mController.getSummary()).isEqualTo("2 SIMs");
- assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
-
- // Simulate sub2 having disappeared - the end result should change to be the same as
- // if there were just one subscription.
- SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
- mController.onSubscriptionsChanged();
- assertThat(mController.getSummary()).isEqualTo("sub1");
- assertThat(mPreference.getFragment()).isNull();
- final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
- doNothing().when(mContext).startActivity(intentCaptor.capture());
- mPreference.getOnPreferenceClickListener().onPreferenceClick(mPreference);
- assertThat(intentCaptor.getValue().getComponent().getClassName()).isEqualTo(
- MobileNetworkActivity.class.getName());
- }
-
- @Test
- @Ignore
- public void getSummaryAfterUpdate_oneSubscriptionBecomesTwo_correctSummaryAndFragment() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
- final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
- final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
- when(sub1.getSubscriptionId()).thenReturn(1);
- when(sub2.getSubscriptionId()).thenReturn(2);
- when(sub1.getDisplayName()).thenReturn("sub1");
- when(sub2.getDisplayName()).thenReturn("sub2");
-
- when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(
- Arrays.asList(sub1));
- SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1));
- mController.displayPreference(mPreferenceScreen);
- mController.onResume();
- assertThat(mController.getSummary()).isEqualTo("sub1");
- assertThat(mPreference.getFragment()).isNull();
- final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
- doNothing().when(mContext).startActivity(intentCaptor.capture());
- mPreference.getOnPreferenceClickListener().onPreferenceClick(mPreference);
- assertThat(intentCaptor.getValue().getComponent().getClassName()).isEqualTo(
- MobileNetworkActivity.class.getName());
-
- // Simulate sub2 appearing in the list of subscriptions and check the results.
- SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
- mController.displayPreference(mPreferenceScreen);
- mController.onResume();
- assertThat(mController.getSummary()).isEqualTo("2 SIMs");
- assertThat(mPreference.getFragment()).isEqualTo(MobileNetworkListFragment.class.getName());
- }
-
- @Test
- @Ignore
public void getSummary_providerModel_Enabled() {
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
@@ -302,15 +222,9 @@
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
mController.displayPreference(mPreferenceScreen);
mController.onResume();
assertThat(mController.getSummary()).isEqualTo("sub1, sub2");
-
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, false);
- mController.displayPreference(mPreferenceScreen);
- mController.onResume();
- assertThat(mController.getSummary()).isEqualTo("2 SIMs");
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
deleted file mode 100644
index 5729208..0000000
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.network.telephony;
-
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.doReturn;
-import static org.robolectric.Shadows.shadowOf;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.os.UserManager;
-import android.provider.Settings;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-
-import androidx.test.core.app.ActivityScenario;
-import androidx.test.core.app.ApplicationProvider;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import com.android.settings.SettingsActivity;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowContextImpl;
-import org.robolectric.shadows.ShadowSubscriptionManager;
-import org.robolectric.shadows.ShadowSubscriptionManager.SubscriptionInfoBuilder;
-
-@RunWith(AndroidJUnit4.class)
-public class MobileNetworkActivityTest {
-
- private static final int SUB_ID = 1;
- private static final String DISPLAY_NAME = "SUB_ID";
-
- private Context mContext;
- private ShadowContextImpl mShadowContextImpl;
- private Intent mTestIntent;
- @Mock
- private UserManager mUserManager;
- private ShadowSubscriptionManager mSubscriptionManager;
- private SubscriptionInfo mSubscriptionInfo;
- private ActivityScenario<MobileNetworkActivity> mMobileNetworkActivity;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = ApplicationProvider.getApplicationContext();
- mShadowContextImpl = Shadow.extract(RuntimeEnvironment.application.getBaseContext());
- mSubscriptionManager = shadowOf(mContext.getSystemService(SubscriptionManager.class));
- mShadowContextImpl.setSystemService(Context.USER_SERVICE, mUserManager);
- doReturn(true).when(mUserManager).isAdminUser();
-
- mTestIntent = new Intent(mContext, MobileNetworkActivity.class);
- mSubscriptionInfo = SubscriptionInfoBuilder.newBuilder()
- .setId(SUB_ID).setDisplayName(DISPLAY_NAME).buildSubscriptionInfo();
- mTestIntent.putExtra(Settings.EXTRA_SUB_ID, SUB_ID);
- mTestIntent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE,
- mSubscriptionInfo.getDisplayName());
- }
-
- @After
- public void cleanUp() {
- if (mMobileNetworkActivity != null) {
- mMobileNetworkActivity.close();
- }
- }
-
- private ActivityScenario<MobileNetworkActivity> createTargetActivity(Intent activityIntent) {
- return ActivityScenario.launch(activityIntent);
- }
-
- @Test
- public void onCreate_getExtraFromIntent() {
- mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo);
- mMobileNetworkActivity = createTargetActivity(mTestIntent);
-
- mMobileNetworkActivity.onActivity(activity -> {
- final Bundle bundle = new Bundle();
- activity.onCreate(bundle);
- assertThat(bundle.getInt(Settings.EXTRA_SUB_ID)).isEqualTo(SUB_ID);
- assertThat(bundle.getString(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE)).isEqualTo(
- DISPLAY_NAME);
- });
- }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/VibrateOnTouchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VibrateOnTouchPreferenceControllerTest.java
deleted file mode 100644
index 2b2f02c..0000000
--- a/tests/robotests/src/com/android/settings/notification/VibrateOnTouchPreferenceControllerTest.java
+++ /dev/null
@@ -1,121 +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.notification;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.when;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.os.Vibrator;
-import android.provider.Settings.System;
-
-import androidx.fragment.app.FragmentActivity;
-import androidx.preference.PreferenceScreen;
-import androidx.preference.SwitchPreference;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class VibrateOnTouchPreferenceControllerTest {
-
- @Mock
- private PreferenceScreen mScreen;
- @Mock
- private FragmentActivity mActivity;
- @Mock
- private ContentResolver mContentResolver;
- @Mock
- private SoundSettings mSetting;
- @Mock
- private Context mContext;
- @Mock
- private Vibrator mVibrator;
-
- private VibrateOnTouchPreferenceController mController;
- private SwitchPreference mPreference;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- when(mActivity.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(mVibrator);
- when(mContext.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(mVibrator);
- when(mVibrator.hasVibrator()).thenReturn(true);
- when(mSetting.getActivity()).thenReturn(mActivity);
- when(mActivity.getContentResolver()).thenReturn(mContentResolver);
- mPreference = new SwitchPreference(RuntimeEnvironment.application);
- mController = new VibrateOnTouchPreferenceController(mContext, mSetting, null);
- when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
- doReturn(mScreen).when(mSetting).getPreferenceScreen();
- }
-
- @Test
- public void isAvailable_hasHaptic_shouldReturnTrue() {
- assertThat(mController.isAvailable()).isTrue();
- }
-
- @Test
- public void isAvailable_noHaptic_shouldReturnFalse() {
- when(mVibrator.hasVibrator()).thenReturn(false);
-
- assertThat(mController.isAvailable()).isFalse();
- }
-
- @Test
- public void displayPreference_hapticEnabled_shouldCheckedPreference() {
- System.putInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1);
-
- mController.displayPreference(mScreen);
-
- assertThat(mPreference.isChecked()).isTrue();
- }
-
- @Test
- public void displayPreference_hapticDisabled_shouldUncheckedPreference() {
- System.putInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 0);
-
- mController.displayPreference(mScreen);
-
- assertThat(mPreference.isChecked()).isFalse();
- }
-
- @Test
- public void onPreferenceChanged_preferenceChecked_shouldEnabledHaptic() {
- mController.displayPreference(mScreen);
-
- mPreference.getOnPreferenceChangeListener().onPreferenceChange(mPreference, true);
-
- assertThat(System.getInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1)).isEqualTo(1);
- }
-
- @Test
- public void onPreferenceChanged_preferenceUnchecked_shouldDisabledHaptic() {
- mController.displayPreference(mScreen);
-
- mPreference.getOnPreferenceChangeListener().onPreferenceChange(mPreference, false);
-
- assertThat(System.getInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1)).isEqualTo(0);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/sim/SimListDialogFragmentTest.java b/tests/robotests/src/com/android/settings/sim/SimListDialogFragmentTest.java
index 0fefbe0..070bcb1 100644
--- a/tests/robotests/src/com/android/settings/sim/SimListDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/sim/SimListDialogFragmentTest.java
@@ -53,7 +53,8 @@
final int dialogType = DATA_PICK;
setDialogType(dialogType);
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
- false /* includeAskEveryTime */));
+ false /* includeAskEveryTime */,
+ false /* isCancelItemShowed */));
doReturn(null).when(mFragment).getCurrentSubscriptions();
startDialog();
verify(mFragment).dismiss();
@@ -64,7 +65,8 @@
final int dialogType = DATA_PICK;
setDialogType(dialogType);
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
- false /* includeAskEveryTime */));
+ false /* includeAskEveryTime */,
+ false /* isCancelItemShowed */));
doReturn(Arrays.asList(mSim1, mSim2)).when(mFragment).getCurrentSubscriptions();
// Avoid problems robolectric has with our real adapter.
doNothing().when(mFragment).setAdapter(any());
@@ -84,7 +86,8 @@
final int dialogType = DATA_PICK;
setDialogType(dialogType);
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
- false /* includeAskEveryTime */));
+ false /* includeAskEveryTime */,
+ false /* isCancelItemShowed */));
doReturn(Arrays.asList(mSim1, mSim2)).when(mFragment).getCurrentSubscriptions();
// Avoid problems robolectric has with our real adapter.
doNothing().when(mFragment).setAdapter(any());
@@ -101,7 +104,8 @@
final int dialogType = SMS_PICK;
setDialogType(dialogType);
mFragment = spy(SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_sms,
- true /* includeAskEveryTime */));
+ true /* includeAskEveryTime */,
+ false /* isCancelItemShowed */));
doReturn(Arrays.asList(mSim1, mSim2)).when(mFragment).getCurrentSubscriptions();
// Avoid problems robolectric has with our real adapter.
doNothing().when(mFragment).setAdapter(any());
diff --git a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
index 9d35797..d8f3959 100644
--- a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
@@ -59,6 +59,7 @@
import com.android.settings.SettingsActivity;
import com.android.settings.SubSettings;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowDevicePolicyManager;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.RestrictedLockUtils;
@@ -85,7 +86,11 @@
import java.util.List;
@RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowUserManager.class, ShadowDevicePolicyManager.class})
+@Config(shadows = {
+ ShadowUserManager.class,
+ ShadowDevicePolicyManager.class,
+ SettingsShadowResources.class,
+})
public class UserSettingsTest {
private static final String KEY_USER_GUEST = "user_guest";
@@ -111,6 +116,8 @@
@Mock
private RestrictedPreference mAddUserPreference;
@Mock
+ private RestrictedPreference mAddSupervisedUserPreference;
+ @Mock
private RestrictedPreference mAddGuestPreference;
@Mock
private UserManager mUserManager;
@@ -161,6 +168,7 @@
mFragment.mMePreference = mMePreference;
mFragment.mAddUser = mAddUserPreference;
+ mFragment.mAddSupervisedUser = mAddSupervisedUserPreference;
mFragment.mAddGuest = mAddGuestPreference;
mFragment.mUserListCategory = mock(PreferenceCategory.class);
}
@@ -169,6 +177,7 @@
public void tearDown() {
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVICE_PROVISIONED, mProvisionedBackupValue);
+ SettingsShadowResources.reset();
}
@Test
@@ -694,6 +703,36 @@
verify(mUserManager).getUsers();
}
+ private void setConfigSupervisedUserCreationPackage(String value) {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.string.config_supervisedUserCreationPackage,
+ value
+ );
+ mFragment.setConfigSupervisedUserCreationPackage();
+ mUserCapabilities.mCanAddUser = true;
+ mFragment.updateUserList();
+ }
+
+ @Test
+ public void addSupervisedUserOption_resourceIsDefined_shouldBeDisplayed() {
+ try {
+ setConfigSupervisedUserCreationPackage("test");
+ verify(mAddSupervisedUserPreference).setVisible(true);
+ } finally {
+ SettingsShadowResources.reset();
+ }
+ }
+
+ @Test
+ public void addSupervisedUserOption_resourceIsNotDefined_shouldBeHidden() {
+ try {
+ setConfigSupervisedUserCreationPackage("");
+ verify(mAddSupervisedUserPreference).setVisible(false);
+ } finally {
+ SettingsShadowResources.reset();
+ }
+ }
+
private void givenUsers(UserInfo... userInfo) {
List<UserInfo> users = Arrays.asList(userInfo);
doReturn(users).when(mUserManager).getUsers();
diff --git a/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java b/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java
index 9789c5f..735992b 100644
--- a/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java
+++ b/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java
@@ -153,14 +153,6 @@
"Touch sounds", Settings.System.SOUND_EFFECTS_ENABLED));
}
- @MediumTest
- public void testOtherSoundsVibrateOnTap() throws Exception {
- loadOtherSoundsPage();
- assertTrue("Vibrate on tap not toggled",
- mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE,
- "Vibrate on tap", Settings.System.HAPTIC_FEEDBACK_ENABLED));
- }
-
private void loadOtherSoundsPage() throws Exception {
launchSoundSettings();
mHelper.scrollVert(false);
diff --git a/tests/unit/src/com/android/settings/applications/appinfo/AppLocalePickerActivityTest.java b/tests/unit/src/com/android/settings/applications/appinfo/AppLocalePickerActivityTest.java
new file mode 100644
index 0000000..f6f56d9
--- /dev/null
+++ b/tests/unit/src/com/android/settings/applications/appinfo/AppLocalePickerActivityTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.applications.appinfo;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Looper;
+
+import androidx.test.annotation.UiThreadTest;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settings.SettingsActivity;
+import com.android.settings.applications.AppInfoBase;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class AppLocalePickerActivityTest {
+ private TestAppLocalePickerActivity mActivity;
+
+ @Before
+ @UiThreadTest
+ public void setUp() {
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+ mActivity = new TestAppLocalePickerActivity();
+ }
+
+ @After
+ public void cleanUp() {
+ mActivity = null;
+ }
+
+ @Test
+ public void onCreate_getEntryIntent_returnNull() {
+ TestAppLocalePickerActivity.setCallingPackage(null);
+ Intent intent = new Intent();
+
+ assertThat(mActivity.getEntryIntent(intent)).isEqualTo(null);
+ }
+
+ @Test
+ public void onCreate_getEntryIntent_returnIntentWithPackageName() {
+ String callingPackageName = "com.example.android";
+ TestAppLocalePickerActivity.setCallingPackage(callingPackageName);
+ Intent intent = new Intent();
+
+ Intent entryIntent = mActivity.getEntryIntent(intent);
+
+ Bundle outputBundle =
+ entryIntent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
+ String packageName = outputBundle.getString(AppInfoBase.ARG_PACKAGE_NAME);
+ assertThat(packageName).isEqualTo(callingPackageName);
+ }
+
+ private static class TestAppLocalePickerActivity extends AppLocalePickerActivity {
+ private static String sCallingPackage;
+ @Override
+ public String getCallingPackage() {
+ return sCallingPackage;
+ }
+
+ public static void setCallingPackage(String packageName) {
+ sCallingPackage = packageName;
+ }
+ }
+}
diff --git a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderBackupCallingGroupTest.java b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderBackupCallingGroupTest.java
index e7a6af3..8396f1b 100644
--- a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderBackupCallingGroupTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderBackupCallingGroupTest.java
@@ -153,7 +153,6 @@
@Test
public void
shouldShowBackupCallingForSub_crossSimDisabled_returnFalse() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
doReturn(false).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(
mContext, SUB_ID_1);
@@ -163,7 +162,6 @@
@Test
public void shouldBackupCallingForSub_crossSimEnabled_returnTrue() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
doReturn(true).when(mNetworkProviderBackupCallingGroup).isCrossSimEnabledByPlatform(
mContext, SUB_ID_1);
diff --git a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroupTest.java b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroupTest.java
index 660772e..9cd12fe 100644
--- a/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroupTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/NetworkProviderWifiCallingGroupTest.java
@@ -147,7 +147,6 @@
@Test
public void
shouldShowWifiCallingForSub_wifiCallingDisabledWithWifiCallingNotReady_returnFalse() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
setWifiCallingEnabled(false);
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
@@ -157,7 +156,6 @@
@Test
public void shouldShowWifiCallingForSub_wifiCallingEnabledWithWifiCallingIsReady_returnTrue() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
setWifiCallingEnabled(true);
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
@@ -168,7 +166,6 @@
@Test
public void
shouldShowWifiCallingForSub_wifiCallingDisabledWithNoActivityHandleIntent_returnFalse() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
buildPhoneAccountConfigureIntent(false);
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
doReturn(mPhoneAccountHandle).when(mNetworkProviderWifiCallingGroup)
@@ -181,7 +178,6 @@
@Test
public void
shouldShowWifiCallingForSub_wifiCallingEnabledWithActivityHandleIntent_returnTrue() {
- FeatureFlagUtils.setEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL, true);
buildPhoneAccountConfigureIntent(true);
doReturn(mMockQueryWfcState).when(mNetworkProviderWifiCallingGroup).queryImsState(SUB_ID);
doReturn(mPhoneAccountHandle).when(mNetworkProviderWifiCallingGroup)
diff --git a/tests/unit/src/com/android/settings/privacy/PrivacyDashboardActivityTest.java b/tests/unit/src/com/android/settings/privacy/PrivacyDashboardActivityTest.java
new file mode 100644
index 0000000..2365553
--- /dev/null
+++ b/tests/unit/src/com/android/settings/privacy/PrivacyDashboardActivityTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.privacy;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import android.content.Intent;
+import android.provider.DeviceConfig;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import com.android.settings.Settings;
+import com.android.settings.SettingsActivity;
+import com.android.settings.safetycenter.SafetyCenterStatus;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+
+@RunWith(AndroidJUnit4.class)
+public class PrivacyDashboardActivityTest {
+
+ private static final String DEFAULT_FRAGMENT_CLASSNAME = "DefaultFragmentClassname";
+
+ private Settings.PrivacyDashboardActivity mActivity;
+
+ @Before
+ public void setUp() {
+ DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
+ DeviceConfig.NAMESPACE_PRIVACY);
+ final Intent intent = new Intent();
+ intent.setAction(android.provider.Settings.ACTION_PRIVACY_SETTINGS);
+ intent.setClass(InstrumentationRegistry.getInstrumentation().getTargetContext(),
+ Settings.PrivacyDashboardActivity.class);
+ intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, DEFAULT_FRAGMENT_CLASSNAME);
+ InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
+ try {
+ mActivity =
+ spy((Settings.PrivacyDashboardActivity) InstrumentationRegistry
+ .getInstrumentation().newActivity(
+ getClass().getClassLoader(),
+ Settings.PrivacyDashboardActivity.class.getName(),
+ intent));
+ } catch (Exception e) {
+ throw new RuntimeException(e); // nothing to do
+ }
+ });
+ doNothing().when(mActivity).startActivity(any(Intent.class));
+ }
+
+ @After
+ public void tearDown() {
+ DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
+ DeviceConfig.NAMESPACE_PRIVACY);
+ }
+
+ @Test
+ public void onCreate_whenSafetyCenterEnabled_redirectsToSafetyCenter() {
+ DeviceConfig.setProperty(
+ DeviceConfig.NAMESPACE_PRIVACY,
+ SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
+ /* value = */ Boolean.toString(true),
+ /* makeDefault = */ false);
+ final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
+
+ mActivity.handleSafetyCenterRedirection();
+
+ verify(mActivity).startActivity(intentCaptor.capture());
+ assertThat(intentCaptor.getValue().getAction()).isEqualTo(Intent.ACTION_SAFETY_CENTER);
+ }
+
+ @Test
+ public void onCreate_whenSafetyCenterDisabled_doesntRedirectToSafetyCenter() {
+ DeviceConfig.setProperty(
+ DeviceConfig.NAMESPACE_PRIVACY,
+ SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
+ /* value = */ Boolean.toString(false),
+ /* makeDefault = */ false);
+
+ mActivity.handleSafetyCenterRedirection();
+
+ verify(mActivity, times(0)).startActivity(any());
+ }
+}
diff --git a/tests/unit/src/com/android/settings/security/SecurityDashboardActivityTest.java b/tests/unit/src/com/android/settings/security/SecurityDashboardActivityTest.java
index 3bda96e..0406616 100644
--- a/tests/unit/src/com/android/settings/security/SecurityDashboardActivityTest.java
+++ b/tests/unit/src/com/android/settings/security/SecurityDashboardActivityTest.java
@@ -18,20 +18,29 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Intent;
+import android.provider.DeviceConfig;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import com.android.settings.Settings;
import com.android.settings.SettingsActivity;
+import com.android.settings.safetycenter.SafetyCenterStatus;
import com.android.settings.testutils.FakeFeatureFactory;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
import org.mockito.MockitoAnnotations;
@RunWith(AndroidJUnit4.class)
@@ -48,6 +57,8 @@
MockitoAnnotations.initMocks(this);
FakeFeatureFactory mFeatureFactory = FakeFeatureFactory.setupForTest();
mSecuritySettingsFeatureProvider = mFeatureFactory.getSecuritySettingsFeatureProvider();
+ DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
+ DeviceConfig.NAMESPACE_PRIVACY);
mDefaultIntent = new Intent();
mDefaultIntent.setAction(android.provider.Settings.ACTION_SECURITY_SETTINGS);
mDefaultIntent.setClass(InstrumentationRegistry.getInstrumentation().getTargetContext(),
@@ -56,15 +67,22 @@
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
try {
mActivity =
- (Settings.SecurityDashboardActivity) InstrumentationRegistry
+ spy((Settings.SecurityDashboardActivity) InstrumentationRegistry
.getInstrumentation().newActivity(
getClass().getClassLoader(),
Settings.SecurityDashboardActivity.class.getName(),
- mDefaultIntent);
+ mDefaultIntent));
} catch (Exception e) {
throw new RuntimeException(e); // nothing to do
}
});
+ doNothing().when(mActivity).startActivity(any(Intent.class));
+ }
+
+ @After
+ public void tearDown() {
+ DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
+ DeviceConfig.NAMESPACE_PRIVACY);
}
@Test
@@ -104,4 +122,32 @@
assertThat(mActivity.isValidFragment(ALTERNATIVE_FRAGMENT_CLASSNAME)).isTrue();
}
+
+ @Test
+ public void onCreate_whenSafetyCenterEnabled_redirectsToSafetyCenter() {
+ DeviceConfig.setProperty(
+ DeviceConfig.NAMESPACE_PRIVACY,
+ SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
+ /* value = */ Boolean.toString(true),
+ /* makeDefault = */ false);
+ final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
+
+ mActivity.handleSafetyCenterRedirection();
+
+ verify(mActivity).startActivity(intentCaptor.capture());
+ assertThat(intentCaptor.getValue().getAction()).isEqualTo(Intent.ACTION_SAFETY_CENTER);
+ }
+
+ @Test
+ public void onCreate_whenSafetyCenterDisabled_doesntRedirectToSafetyCenter() {
+ DeviceConfig.setProperty(
+ DeviceConfig.NAMESPACE_PRIVACY,
+ SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
+ /* value = */ Boolean.toString(false),
+ /* makeDefault = */ false);
+
+ mActivity.handleSafetyCenterRedirection();
+
+ verify(mActivity, times(0)).startActivity(any());
+ }
}