Merge "Wifi Sharing page uses a new enum for telemetry." into main
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 678f81f..f1c91ee 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -5187,6 +5187,15 @@
<activity android:name=".spa.SpaBridgeActivity" android:exported="false"/>
<activity android:name=".spa.SpaAppBridgeActivity" android:exported="false"/>
+ <activity
+ android:name=".spa.search.SpaSearchLandingActivity"
+ android:exported="true">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.SPA_SEARCH_LANDING" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
<activity android:name=".Settings$FingerprintSettingsActivityV2"
android:label="@string/security_settings_fingerprint_preference_title"
android:exported="false"
diff --git a/aconfig/accessibility/accessibility_flags.aconfig b/aconfig/accessibility/accessibility_flags.aconfig
index 2c92547..3ed618b 100644
--- a/aconfig/accessibility/accessibility_flags.aconfig
+++ b/aconfig/accessibility/accessibility_flags.aconfig
@@ -11,6 +11,16 @@
}
flag {
+ name: "audio_balance_state_description"
+ namespace: "accessibility"
+ description: "Provides a more valuable state description to the audio balance slider."
+ bug: "319575109"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+flag {
name: "edit_shortcuts_in_full_screen"
namespace: "accessibility"
description: "Show the edit shorcuts screen in full screen, since the shortcut options are increasing."
diff --git a/res/drawable/ic_zen_mode_action_change_icon.xml b/res/drawable/ic_zen_mode_action_change_icon.xml
deleted file mode 100644
index 4cf4167..0000000
--- a/res/drawable/ic_zen_mode_action_change_icon.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-Copyright (C) 2024 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:tint="?android:attr/colorControlNormal"
- android:viewportHeight="960"
- android:viewportWidth="960">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M620,440Q645,440 662.5,422.5Q680,405 680,380Q680,355 662.5,337.5Q645,320 620,320Q595,320 577.5,337.5Q560,355 560,380Q560,405 577.5,422.5Q595,440 620,440ZM340,440Q365,440 382.5,422.5Q400,405 400,380Q400,355 382.5,337.5Q365,320 340,320Q315,320 297.5,337.5Q280,355 280,380Q280,405 297.5,422.5Q315,440 340,440ZM480,700Q548,700 603.5,661.5Q659,623 684,560L276,560Q301,623 356.5,661.5Q412,700 480,700ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800Z" />
-</vector>
\ No newline at end of file
diff --git a/res/layout/bluetooth_pin_confirm.xml b/res/layout/bluetooth_pin_confirm.xml
index fb3435b..9387d5d 100644
--- a/res/layout/bluetooth_pin_confirm.xml
+++ b/res/layout/bluetooth_pin_confirm.xml
@@ -20,13 +20,13 @@
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
- android:layout_width="match_parent">
+ android:layout_width="match_parent"
+ android:paddingTop="@dimen/bluetooth_dialog_padding_top">
<LinearLayout
android:paddingStart="16dip"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:layout_marginTop="@dimen/bluetooth_dialog_padding_top"
android:orientation="vertical">
<TextView
@@ -85,7 +85,7 @@
android:orientation="horizontal">
<LinearLayout
android:layout_height="wrap_content"
- android:layout_width="wrap_content"
+ android:layout_width="0dp"
android:layout_weight="1"
android:layout_marginEnd="10dp"
android:orientation="vertical">
@@ -105,7 +105,6 @@
android:id="@+id/phonebook_sharing_message_confirm_pin"
android:layout_width="wrap_content"
android:layout_height="48dp"
- android:layout_weight="0"
android:gravity="center_vertical"
android:contentDescription="@string/bluetooth_pairing_phonebook_toggle_text"
android:switchMinWidth="48dp" />
diff --git a/res/layout/pointer_icon_stroke_style_layout.xml b/res/layout/pointer_icon_stroke_style_layout.xml
new file mode 100644
index 0000000..acf919a
--- /dev/null
+++ b/res/layout/pointer_icon_stroke_style_layout.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ Copyright 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"
+ android:orientation="vertical"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart">
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/pointer_stroke_style_padding"
+ android:text="@string/pointer_stroke_style"
+ android:textAlignment="viewStart"
+ android:textAppearance="?android:attr/textAppearanceListItem" />
+
+ <RadioGroup
+ android:id="@+id/button_holder"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_marginTop="@dimen/pointer_stroke_style_padding"
+ android:layout_marginBottom="@dimen/pointer_stroke_style_padding"
+ android:padding="@dimen/pointer_stroke_style_padding">
+ <RadioButton android:id="@+id/stroke_style_white"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/pointer_stroke_style_padding"
+ android:text="@string/pointer_stroke_style_name_white"/>
+ <RadioButton android:id="@+id/stroke_style_black"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/pointer_stroke_style_padding"
+ android:text="@string/pointer_stroke_style_name_black"/>
+ <RadioButton android:id="@+id/stroke_style_none"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/pointer_stroke_style_padding"
+ android:text="@string/pointer_stroke_style_name_none"/>
+ </RadioGroup>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/private_space_education_screen.xml b/res/layout/private_space_education_screen.xml
index 4df92b7..3afe7f9 100644
--- a/res/layout/private_space_education_screen.xml
+++ b/res/layout/private_space_education_screen.xml
@@ -53,7 +53,7 @@
android:src="@drawable/counter_1_24dp" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
- android:layout_toRightOf="@+id/lockIcon"
+ android:layout_toEndOf="@+id/lockIcon"
android:text="@string/private_space_separate_account_text"/>
</RelativeLayout>
<RelativeLayout
@@ -64,7 +64,7 @@
android:src="@drawable/counter_2_24dp" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
- android:layout_toRightOf="@+id/bellIcon"
+ android:layout_toEndOf="@+id/bellIcon"
android:text="@string/private_space_protected_lock_text"/>
</RelativeLayout>
<RelativeLayout
@@ -77,7 +77,7 @@
android:src="@drawable/counter_3_24dp" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
- android:layout_toRightOf="@+id/appsIcon"
+ android:layout_toEndOf="@+id/appsIcon"
android:text="@string/private_space_install_apps_text"/>
</RelativeLayout>
<TextView
@@ -94,7 +94,7 @@
android:src="@drawable/ic_private_space_edu_icon" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
- android:layout_toRightOf="@+id/eduIcon"
+ android:layout_toEndOf="@+id/eduIcon"
android:text="@string/private_space_apps_stopped_text"/>
</RelativeLayout>
<Space
@@ -112,13 +112,13 @@
android:id="@+id/info"
style="@style/PrivateSpaceBulletPointTextFontStyle"
android:textSize = "14sp"
- android:layout_toRightOf="@+id/infoIcon"
+ android:layout_toEndOf="@+id/infoIcon"
android:text="@string/private_space_apps_permission_text"/>
<TextView
android:id="@+id/learn_more"
style="@style/PrivateSpaceSetupSubHeaderStyle"
android:layout_below="@id/info"
- android:layout_alignLeft="@+id/info"
+ android:layout_alignStart="@+id/info"
android:paddingTop="24dp"
android:paddingLeft="16dp"
android:text="@string/private_space_learn_more_text"/>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ce48720..8a96727 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -179,6 +179,7 @@
<dimen name="pointer_fill_style_circle_padding">8dp</dimen>
<dimen name="pointer_fill_style_shape_default_stroke">1dp</dimen>
<dimen name="pointer_fill_style_shape_hovered_stroke">3dp</dimen>
+ <dimen name="pointer_stroke_style_padding">8dp</dimen>
<dimen name="pointer_scale_padding">8dp</dimen>
<item name="pointer_scale_size_start" format="float" type="dimen">1.0</item>
<item name="pointer_scale_size_end" format="float" type="dimen">2.5</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6d976ba..3063f77 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4501,6 +4501,14 @@
<string name="pointer_fill_style_pink_button">Change pointer fill style to pink</string>
<!-- Content description for blue pointer fill style. [CHAR LIMIT=60] -->
<string name="pointer_fill_style_blue_button">Change pointer fill style to blue</string>
+ <!-- Title text for mouse pointer stroke style. [CHAR LIMIT=35] -->
+ <string name="pointer_stroke_style">Pointer stroke style</string>
+ <!-- White value for pointer stroke style. [CHAR LIMIT=35] -->
+ <string name="pointer_stroke_style_name_white">White</string>
+ <!-- Black value pointer stroke style. [CHAR LIMIT=35] -->
+ <string name="pointer_stroke_style_name_black">Black</string>
+ <!-- None value for pointer stroke style. [CHAR LIMIT=35] -->
+ <string name="pointer_stroke_style_name_none">None</string>
<!-- Title for the button to trigger the 'touch gesture' education. [CHAR LIMIT=35] -->
<string name="trackpad_touch_gesture">Learn touchpad gestures</string>
<!-- Search keywords for "touchpad" -->
@@ -8043,8 +8051,11 @@
<!-- Do not disturb: Delete text button presented in a dialog to confirm the user would like to delete the selected DND rules. [CHAR LIMIT=30] -->
<string name="zen_mode_schedule_delete">Delete</string>
+ <!-- Priority Modes: Menu option for renaming a mode on its configuration page [CHAR LIMIT=40] -->
+ <string name="zen_mode_menu_rename_mode">Rename</string>
+
<!-- Do not disturb: Menu option for deleting a mode on its configuration page [CHAR LIMIT=40] -->
- <string name="zen_mode_menu_delete_mode">Delete mode</string>
+ <string name="zen_mode_menu_delete_mode">Delete</string>
<!-- Do not disturb: Confirmation dialog asking the user whether they would like to delete the named mode [CHAR LIMIT: 40] -->
<string name="zen_mode_delete_mode_confirmation">Delete \"<xliff:g id="mode" example="My Schedule">%1$s</xliff:g>\" mode?</string>
@@ -9336,8 +9347,6 @@
<string name="zen_mode_apps_priority_apps">Selected apps</string>
<!-- [CHAR LIMIT=60] Zen mode settings: no apps will be able to bypass dnd -->
<string name="zen_mode_apps_none_apps">None</string>
- <!-- [CHAR LIMIT=60] Zen mode settings: all apps will be able to bypass dnd -->
- <string name="zen_mode_apps_all_apps">All</string>
<!-- [CHAR LIMIT=NONE] Zen mode settings: Lists apps that can bypass DND. For example, "Nest, Messages, and 2 more can interrupt". -->
<string name="zen_mode_apps_subtext">
{count, plural, offset:2
@@ -9451,17 +9460,8 @@
<!-- [CHAR LIMIT=NONE] Zen mode summary spoken when changing mode by voice: Turn on all notifications. -->
<string name="zen_mode_summary_always">Change to always interrupt</string>
- <!-- [CHAR LIMIT=20] Caption of the action button to change the name of a mode. -->
- <string name="zen_mode_action_change_name">Rename</string>
-
- <!-- [CHAR LIMIT=20] Caption of the action button to change the icon of a mode. -->
- <string name="zen_mode_action_change_icon">Change icon</string>
-
- <!-- [CHAR LIMIT=40] Zen mode settings: Title for the "choose mode icon" screen -->
- <string name="zen_mode_icon_picker_title">Change icon</string>
-
<!-- Priority Modes: Title for the "rename mode" screen [CHAR LIMIT=20] -->
- <string name="zen_mode_rename_title">Rename</string>
+ <string name="zen_mode_rename_title">Edit mode</string>
<!-- Priority Modes: Title for the "add mode" screen [CHAR LIMIT=20] -->
<string name="zen_mode_new_custom_title">Add mode</string>
@@ -13489,6 +13489,10 @@
<string name="live_caption_disabled">Off</string>
<!-- Summary of the Live Caption enabled state. -->
<string name="live_caption_enabled">On</string>
+ <!-- State description for the Audio Balance seek bar, with left reported before right. -->
+ <string name="audio_seek_bar_state_left_first">Audio %1$d%% left, %2$d%% right</string>
+ <!-- State description for the Audio Balance seek bar, with right reported before left. -->
+ <string name="audio_seek_bar_state_right_first">Audio %1$d%% right, %2$d%% left</string>
<!-- Warning text about the visibility of device name. [CHAR LIMIT=NONE] -->
<string name="about_phone_device_name_warning">Your device name is visible to apps you installed. It may also be seen by other people when you connect to Bluetooth devices, connect to a Wi-Fi network or set up a Wi-Fi hotspot.</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0bd0406..2d40af0 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -982,14 +982,15 @@
</style>
<style name="PrivateSpaceBulletPointTextFontStyle" parent="@style/PrivateSpaceSetupTextFontStyle">
- <item name="android:paddingLeft">16dp</item>
+ <item name="android:paddingStart">16dp</item>
<item name="android:textSize">16sp</item>
+ <item name="android:textAlignment">viewStart</item>
</style>
<style name="PrivateSpaceBulletPointIconStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
- <item name="android:layout_alignParentLeft">true</item>
+ <item name="android:layout_alignParentStart">true</item>
<item name="android:layout_alignParentTop">true</item>
</style>
diff --git a/res/xml/modes_rule_settings.xml b/res/xml/modes_rule_settings.xml
index 5be206e..0c687b2 100644
--- a/res/xml/modes_rule_settings.xml
+++ b/res/xml/modes_rule_settings.xml
@@ -28,10 +28,6 @@
android:selectable="false"
android:layout="@layout/modes_activation_button"/>
- <com.android.settingslib.widget.ActionButtonsPreference
- android:key="actions"
- android:selectable="true" />
-
<PreferenceCategory
android:title="@string/mode_interruption_filter_title"
android:key="modes_filters">
diff --git a/res/xml/security_advanced_settings.xml b/res/xml/security_advanced_settings.xml
index c220e99..f1556d6 100644
--- a/res/xml/security_advanced_settings.xml
+++ b/res/xml/security_advanced_settings.xml
@@ -140,13 +140,13 @@
settings:controller="com.android.settings.security.VisiblePatternProfilePreferenceController" />
<com.android.settingslib.RestrictedPreference
- android:key="fingerprint_settings_profile"
- android:title="@string/security_settings_work_fingerprint_preference_title"
+ android:key="face_settings_profile"
+ android:title="@string/security_settings_face_profile_preference_title"
android:summary="@string/summary_placeholder" />
<com.android.settingslib.RestrictedPreference
- android:key="face_settings_profile"
- android:title="@string/security_settings_face_profile_preference_title"
+ android:key="fingerprint_settings_profile"
+ android:title="@string/security_settings_work_fingerprint_preference_title"
android:summary="@string/summary_placeholder" />
<com.android.settingslib.RestrictedPreference
diff --git a/res/xml/security_settings_combined_biometric_profile.xml b/res/xml/security_settings_combined_biometric_profile.xml
index 1ab4106..42078f5 100644
--- a/res/xml/security_settings_combined_biometric_profile.xml
+++ b/res/xml/security_settings_combined_biometric_profile.xml
@@ -27,19 +27,19 @@
android:title="@string/biometric_settings_category_ways_to_unlock">
<com.android.settingslib.RestrictedPreference
- android:key="biometric_fingerprint_settings_profile"
- android:title="@string/security_settings_work_fingerprint_preference_title"
- android:summary="@string/summary_placeholder"
- settings:keywords="@string/keywords_fingerprint_settings"
- settings:controller="com.android.settings.biometrics.combination.BiometricFingerprintProfileStatusPreferenceController" />
-
- <com.android.settingslib.RestrictedPreference
android:key="biometric_face_settings_profile"
android:title="@string/security_settings_face_profile_preference_title"
android:summary="@string/summary_placeholder"
settings:keywords="@string/keywords_face_settings"
settings:controller="com.android.settings.biometrics.combination.BiometricFaceProfileStatusPreferenceController" />
+ <com.android.settingslib.RestrictedPreference
+ android:key="biometric_fingerprint_settings_profile"
+ android:title="@string/security_settings_work_fingerprint_preference_title"
+ android:summary="@string/summary_placeholder"
+ settings:keywords="@string/keywords_fingerprint_settings"
+ settings:controller="com.android.settings.biometrics.combination.BiometricFingerprintProfileStatusPreferenceController" />
+
</PreferenceCategory>
<PreferenceCategory
diff --git a/res/xml/trackpad_settings.xml b/res/xml/trackpad_settings.xml
index 04422dd..a479e17 100644
--- a/res/xml/trackpad_settings.xml
+++ b/res/xml/trackpad_settings.xml
@@ -68,6 +68,12 @@
android:order="50"
settings:controller="com.android.settings.inputmethod.PointerFillStylePreferenceController"/>
+ <com.android.settings.inputmethod.PointerStrokeStylePreference
+ android:key="pointer_stroke_style"
+ android:title="@string/pointer_stroke_style"
+ android:order="60"
+ settings:controller="com.android.settings.inputmethod.PointerStrokeStylePreferenceController"/>
+
<com.android.settings.widget.LabeledSeekBarPreference
android:key="pointer_scale"
android:title="@string/pointer_scale"
diff --git a/res/xml/zen_mode_apps_settings.xml b/res/xml/zen_mode_apps_settings.xml
index 4ee14e4..a452143 100644
--- a/res/xml/zen_mode_apps_settings.xml
+++ b/res/xml/zen_mode_apps_settings.xml
@@ -34,11 +34,6 @@
android:title="@string/zen_mode_apps_none_apps"
settings:searchable="false"/>
- <com.android.settingslib.widget.SelectorWithWidgetPreference
- android:key="zen_mode_apps_all"
- android:title="@string/zen_mode_apps_all_apps"
- settings:searchable="false"/>
-
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/settings/accessibility/BalanceSeekBar.java b/src/com/android/settings/accessibility/BalanceSeekBar.java
index 19301ae..7441d6f 100644
--- a/src/com/android/settings/accessibility/BalanceSeekBar.java
+++ b/src/com/android/settings/accessibility/BalanceSeekBar.java
@@ -20,6 +20,7 @@
import static com.android.settings.Utils.isNightMode;
+import android.annotation.StringRes;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
@@ -86,6 +87,14 @@
Settings.System.putFloatForUser(mContext.getContentResolver(),
Settings.System.MASTER_BALANCE, balance, UserHandle.USER_CURRENT);
}
+ final int max = getMax();
+ if (Flags.audioBalanceStateDescription() && max > 0) {
+ seekBar.setStateDescription(createStateDescription(mContext,
+ R.string.audio_seek_bar_state_left_first,
+ R.string.audio_seek_bar_state_right_first,
+ progress,
+ max));
+ }
// If fromUser is false, the call is a set from the framework on creation or on
// internal update. The progress may be zero, ignore (don't change system settings).
@@ -161,5 +170,19 @@
canvas.restore();
super.onDraw(canvas);
}
+
+ private static CharSequence createStateDescription(Context context,
+ @StringRes int resIdLeftFirst, @StringRes int resIdRightFirst,
+ int progress, float max) {
+ final boolean isLayoutRtl = context.getResources().getConfiguration().getLayoutDirection()
+ == LAYOUT_DIRECTION_RTL;
+ final int rightPercent = (int) (100 * (progress / max));
+ final int leftPercent = 100 - rightPercent;
+ if (rightPercent > leftPercent || (rightPercent == leftPercent && isLayoutRtl)) {
+ return context.getString(resIdRightFirst, rightPercent, leftPercent);
+ } else {
+ return context.getString(resIdLeftFirst, leftPercent, rightPercent);
+ }
+ }
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
index 3fa811a..2e5daeb 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
@@ -43,7 +43,6 @@
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HeadsetProfile;
-import com.android.settingslib.bluetooth.HearingAidProfile;
import com.android.settingslib.bluetooth.LeAudioProfile;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.bluetooth.LocalBluetoothProfile;
@@ -95,6 +94,7 @@
new HashMap<String, List<CachedBluetoothDevice>>();
private boolean mIsLeContactSharingEnabled = false;
private boolean mIsLeAudioToggleEnabled = false;
+ private boolean mIsLeAudioOnlyDevice = false;
@VisibleForTesting
PreferenceCategory mProfilesContainer;
@@ -345,6 +345,11 @@
result.remove(mManager.getProfileManager().getA2dpProfile());
result.remove(mManager.getProfileManager().getHeadsetProfile());
}
+ boolean hearingAidSupported = result.contains(
+ mManager.getProfileManager().getHearingAidProfile());
+ if (leAudioSupported && !classicAudioSupported && !hearingAidSupported) {
+ mIsLeAudioOnlyDevice = true;
+ }
Log.d(TAG, "getProfiles:Map:" + mProfileDeviceMap);
return result;
}
@@ -513,19 +518,6 @@
refresh();
}
- private boolean isLeAudioOnlyDevice() {
- if (mCachedDevice.getProfiles().stream()
- .noneMatch(profile -> profile instanceof LeAudioProfile)) {
- return false;
- }
- return mCachedDevice.getProfiles().stream()
- .noneMatch(
- profile ->
- profile instanceof HearingAidProfile
- || profile instanceof A2dpProfile
- || profile instanceof HeadsetProfile);
- }
-
private void updateLeAudioConfig() {
mIsLeContactSharingEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
SettingsUIDeviceConfig.BT_LE_AUDIO_CONTACT_SHARING_ENABLED, true);
@@ -534,7 +526,7 @@
boolean isLeEnabledByDefault =
SystemProperties.getBoolean(LE_AUDIO_CONNECTION_BY_DEFAULT_PROPERTY, true);
mIsLeAudioToggleEnabled = isLeAudioToggleVisible || isLeEnabledByDefault;
- if (Flags.hideLeAudioToggleForLeAudioOnlyDevice() && isLeAudioOnlyDevice()) {
+ if (Flags.hideLeAudioToggleForLeAudioOnlyDevice() && mIsLeAudioOnlyDevice) {
mIsLeAudioToggleEnabled = false;
Log.d(
TAG,
diff --git a/src/com/android/settings/inputmethod/PointerStrokeStylePreference.java b/src/com/android/settings/inputmethod/PointerStrokeStylePreference.java
new file mode 100644
index 0000000..1c02332
--- /dev/null
+++ b/src/com/android/settings/inputmethod/PointerStrokeStylePreference.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.inputmethod;
+
+import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_STROKE_BLACK;
+import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_STROKE_NONE;
+import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_STROKE_WHITE;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.util.AttributeSet;
+import android.view.PointerIcon;
+import android.widget.LinearLayout;
+import android.widget.RadioButton;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settings.R;
+
+public class PointerStrokeStylePreference extends Preference {
+
+ public PointerStrokeStylePreference(@NonNull Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ setLayoutResource(R.layout.pointer_icon_stroke_style_layout);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
+ super.onBindViewHolder(holder);
+
+ LinearLayout buttonHolder = (LinearLayout) holder.findViewById(R.id.button_holder);
+ // Intercept hover events so setting row does not highlight when hovering buttons.
+ buttonHolder.setOnHoverListener((v, e) -> true);
+
+ int currentStroke = getPreferenceDataStore().getInt(Settings.System.POINTER_STROKE_STYLE,
+ POINTER_ICON_VECTOR_STYLE_STROKE_WHITE);
+ initRadioButton(holder, R.id.stroke_style_white, POINTER_ICON_VECTOR_STYLE_STROKE_WHITE,
+ currentStroke);
+ initRadioButton(holder, R.id.stroke_style_black, POINTER_ICON_VECTOR_STYLE_STROKE_BLACK,
+ currentStroke);
+ initRadioButton(holder, R.id.stroke_style_none, POINTER_ICON_VECTOR_STYLE_STROKE_NONE,
+ currentStroke);
+ }
+
+ private void initRadioButton(@NonNull PreferenceViewHolder holder, int id, int strokeStyle,
+ int currentStroke) {
+ RadioButton radioButton = (RadioButton) holder.findViewById(id);
+ if (radioButton == null) {
+ return;
+ }
+ radioButton.setOnCheckedChangeListener((v, isChecked) -> {
+ if (isChecked) {
+ getPreferenceDataStore().putInt(Settings.System.POINTER_STROKE_STYLE, strokeStyle);
+ }
+ });
+ radioButton.setChecked(currentStroke == strokeStyle);
+ radioButton.setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_ARROW));
+ }
+}
diff --git a/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceController.java b/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceController.java
new file mode 100644
index 0000000..e4ea996
--- /dev/null
+++ b/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceController.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.inputmethod;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.provider.Settings;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceDataStore;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.core.BasePreferenceController;
+
+public class PointerStrokeStylePreferenceController extends BasePreferenceController {
+
+ @VisibleForTesting
+ static final String KEY_POINTER_STROKE_STYLE = "pointer_stroke_style";
+
+ public PointerStrokeStylePreferenceController(@NonNull Context context) {
+ super(context, KEY_POINTER_STROKE_STYLE);
+ }
+
+ @AvailabilityStatus
+ public int getAvailabilityStatus() {
+ return android.view.flags.Flags.enableVectorCursorA11ySettings() ? AVAILABLE
+ : CONDITIONALLY_UNAVAILABLE;
+ }
+
+ @Override
+ public void displayPreference(@NonNull PreferenceScreen screen) {
+ super.displayPreference(screen);
+ Preference pointerStrokeStylePreference = screen.findPreference(KEY_POINTER_STROKE_STYLE);
+ if (pointerStrokeStylePreference == null) {
+ return;
+ }
+ pointerStrokeStylePreference.setPreferenceDataStore(new PreferenceDataStore() {
+ @Override
+ public void putInt(@NonNull String key, int value) {
+ Settings.System.putIntForUser(mContext.getContentResolver(), key, value,
+ UserHandle.USER_CURRENT);
+ }
+
+ @Override
+ public int getInt(@NonNull String key, int defValue) {
+ return Settings.System.getIntForUser(mContext.getContentResolver(), key, defValue,
+ UserHandle.USER_CURRENT);
+ }
+ });
+ }
+}
diff --git a/src/com/android/settings/network/MobileNetworkRepository.java b/src/com/android/settings/network/MobileNetworkRepository.java
index bd892c8..9901929 100644
--- a/src/com/android/settings/network/MobileNetworkRepository.java
+++ b/src/com/android/settings/network/MobileNetworkRepository.java
@@ -474,30 +474,16 @@
return null;
} else {
getUiccInfoBySubscriptionInfo(uiccSlotInfos, subInfo);
- SubscriptionInfo firstRemovableSubInfo = SubscriptionUtil.getFirstRemovableSubscription(
- context);
if (DEBUG) {
Log.d(TAG, "convert subscriptionInfo to entity for subId = " + subId);
}
- return new SubscriptionInfoEntity(String.valueOf(subId),
- subInfo.getSimSlotIndex(),
- subInfo.getCarrierId(), subInfo.getDisplayName().toString(),
- subInfo.getCarrierName() != null ? subInfo.getCarrierName().toString() : "",
- subInfo.getDataRoaming(), subInfo.getMccString(), subInfo.getMncString(),
- subInfo.getCountryIso(), subInfo.isEmbedded(), mCardId,
- subInfo.getPortIndex(), subInfo.isOpportunistic(),
- String.valueOf(subInfo.getGroupUuid()),
- subInfo.getSubscriptionType(),
+ return new SubscriptionInfoEntity(String.valueOf(subId), subInfo.getSimSlotIndex(),
+ subInfo.isEmbedded(), subInfo.isOpportunistic(),
SubscriptionUtil.getUniqueSubscriptionDisplayName(subInfo, context).toString(),
SubscriptionUtil.isSubscriptionVisible(mSubscriptionManager, context, subInfo),
- SubscriptionUtil.getFormattedPhoneNumber(context, subInfo),
- firstRemovableSubInfo == null ? false
- : firstRemovableSubInfo.getSubscriptionId() == subId,
SubscriptionUtil.isDefaultSubscription(context, subId),
mSubscriptionManager.isValidSubscriptionId(subId),
- mSubscriptionManager.isUsableSubscriptionId(subId),
mSubscriptionManager.isActiveSubscriptionId(subId),
- true /*availableSubInfo*/,
mSubscriptionManager.getActiveDataSubscriptionId() == subId);
}
}
diff --git a/src/com/android/settings/notification/modes/ZenModeActionsPreferenceController.java b/src/com/android/settings/notification/modes/ZenModeActionsPreferenceController.java
deleted file mode 100644
index c3f38d0..0000000
--- a/src/com/android/settings/notification/modes/ZenModeActionsPreferenceController.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.notification.modes;
-
-import static android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID;
-
-import android.content.Context;
-import android.os.Bundle;
-
-import androidx.annotation.NonNull;
-import androidx.preference.Preference;
-
-import com.android.settings.R;
-import com.android.settings.core.SubSettingLauncher;
-import com.android.settingslib.notification.modes.ZenMode;
-import com.android.settingslib.widget.ActionButtonsPreference;
-
-class ZenModeActionsPreferenceController extends AbstractZenModePreferenceController {
-
- ZenModeActionsPreferenceController(@NonNull Context context, @NonNull String key) {
- super(context, key);
- }
-
- @Override
- void updateState(Preference preference, @NonNull ZenMode zenMode) {
- ActionButtonsPreference buttonsPreference = (ActionButtonsPreference) preference;
-
- // TODO: b/346278854 - Add rename action (with setButton1Enabled(zenMode.canEditName())
- buttonsPreference.setButton1Text(R.string.zen_mode_action_change_name);
- buttonsPreference.setButton1Icon(R.drawable.ic_mode_edit);
- buttonsPreference.setButton1Enabled(false);
-
- buttonsPreference.setButton2Text(R.string.zen_mode_action_change_icon);
- buttonsPreference.setButton2Icon(R.drawable.ic_zen_mode_action_change_icon);
- buttonsPreference.setButton2Enabled(zenMode.canEditIcon());
- buttonsPreference.setButton2OnClickListener(v -> {
- Bundle bundle = new Bundle();
- bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, zenMode.getId());
- new SubSettingLauncher(mContext)
- .setDestination(ZenModeEditNameIconFragment.class.getName())
- // TODO: b/332937635 - Update metrics category
- .setSourceMetricsCategory(0)
- .setArguments(bundle)
- .launch();
- });
- }
-}
diff --git a/src/com/android/settings/notification/modes/ZenModeEditNameIconFragment.java b/src/com/android/settings/notification/modes/ZenModeEditNameIconFragment.java
index 7889dd7..a0c2cf1 100644
--- a/src/com/android/settings/notification/modes/ZenModeEditNameIconFragment.java
+++ b/src/com/android/settings/notification/modes/ZenModeEditNameIconFragment.java
@@ -39,7 +39,7 @@
@Override
public void onStart() {
super.onStart();
- requireActivity().setTitle(R.string.zen_mode_icon_picker_title);
+ requireActivity().setTitle(R.string.zen_mode_rename_title);
}
@Override
diff --git a/src/com/android/settings/notification/modes/ZenModeFragment.java b/src/com/android/settings/notification/modes/ZenModeFragment.java
index 748c735..c5b52a9 100644
--- a/src/com/android/settings/notification/modes/ZenModeFragment.java
+++ b/src/com/android/settings/notification/modes/ZenModeFragment.java
@@ -38,8 +38,9 @@
public class ZenModeFragment extends ZenModeFragmentBase {
- // for mode deletion menu
- private static final int DELETE_MODE = 1;
+ // for mode context menu
+ private static final int RENAME_MODE = 1;
+ private static final int DELETE_MODE = 2;
private ModeMenuProvider mModeMenuProvider;
@@ -54,7 +55,6 @@
prefControllers.add(new ZenModeHeaderController(context, "header", this));
prefControllers.add(
new ZenModeButtonPreferenceController(context, "activate", this, mBackend));
- prefControllers.add(new ZenModeActionsPreferenceController(context, "actions"));
prefControllers.add(new ZenModePeopleLinkPreferenceController(
context, "zen_mode_people", mHelperBackend));
prefControllers.add(new ZenModeAppsLinkPreferenceController(
@@ -127,14 +127,18 @@
}
private class ModeMenuProvider implements MenuProvider {
- private ZenMode mZenMode;
- ModeMenuProvider(ZenMode mode) {
+ @NonNull private final ZenMode mZenMode;
+
+ ModeMenuProvider(@NonNull ZenMode mode) {
mZenMode = mode;
}
@Override
public void onCreateMenu(@NonNull Menu menu, @NonNull MenuInflater menuInflater) {
- if (mZenMode != null && mZenMode.canBeDeleted()) {
+ if (mZenMode.canEditNameAndIcon()) {
+ menu.add(Menu.NONE, RENAME_MODE, Menu.NONE, R.string.zen_mode_menu_rename_mode);
+ }
+ if (mZenMode.canBeDeleted()) {
// Only deleteable modes should get a delete menu option.
menu.add(Menu.NONE, DELETE_MODE, Menu.NONE, R.string.zen_mode_menu_delete_mode);
}
@@ -142,23 +146,25 @@
@Override
public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
- if (mZenMode != null) {
- if (menuItem.getItemId() == DELETE_MODE) {
- new AlertDialog.Builder(mContext)
- .setTitle(mContext.getString(R.string.zen_mode_delete_mode_confirmation,
- mZenMode.getRule().getName()))
- .setPositiveButton(R.string.zen_mode_schedule_delete,
- (dialog, which) -> {
- // start finishing before calling removeMode() so that we
- // don't try to update this activity with a nonexistent mode
- // when the zen mode config is updated
- finish();
- mBackend.removeMode(mZenMode);
- })
- .setNegativeButton(R.string.cancel, null)
- .show();
- return true;
- }
+ if (menuItem.getItemId() == RENAME_MODE) {
+ // TODO: b/332937635 - Update metrics category
+ ZenSubSettingLauncher.forModeFragment(mContext, ZenModeEditNameIconFragment.class,
+ mZenMode.getId(), 0).launch();
+ } else if (menuItem.getItemId() == DELETE_MODE) {
+ new AlertDialog.Builder(mContext)
+ .setTitle(mContext.getString(R.string.zen_mode_delete_mode_confirmation,
+ mZenMode.getRule().getName()))
+ .setPositiveButton(R.string.zen_mode_schedule_delete,
+ (dialog, which) -> {
+ // start finishing before calling removeMode() so that we
+ // don't try to update this activity with a nonexistent mode
+ // when the zen mode config is updated
+ finish();
+ mBackend.removeMode(mZenMode);
+ })
+ .setNegativeButton(R.string.cancel, null)
+ .show();
+ return true;
}
return false;
}
diff --git a/src/com/android/settings/notification/modes/ZenSubSettingLauncher.java b/src/com/android/settings/notification/modes/ZenSubSettingLauncher.java
index 529f7fa..00c21bb 100644
--- a/src/com/android/settings/notification/modes/ZenSubSettingLauncher.java
+++ b/src/com/android/settings/notification/modes/ZenSubSettingLauncher.java
@@ -23,6 +23,7 @@
import android.os.Bundle;
import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.dashboard.DashboardFragment;
class ZenSubSettingLauncher {
@@ -32,7 +33,7 @@
}
static SubSettingLauncher forModeFragment(Context context,
- Class<? extends ZenModeFragmentBase> fragmentClass, String modeId,
+ Class<? extends DashboardFragment> fragmentClass, String modeId,
int sourceMetricsCategory) {
Bundle bundle = new Bundle();
bundle.putString(EXTRA_AUTOMATIC_ZEN_RULE_ID, modeId);
diff --git a/src/com/android/settings/search/SearchFeatureProviderImpl.kt b/src/com/android/settings/search/SearchFeatureProviderImpl.kt
index 2ea9910..b1378ab 100644
--- a/src/com/android/settings/search/SearchFeatureProviderImpl.kt
+++ b/src/com/android/settings/search/SearchFeatureProviderImpl.kt
@@ -22,11 +22,18 @@
import android.net.Uri
import android.provider.Settings
import com.android.settings.search.SearchIndexableResourcesFactory.createSearchIndexableResources
+import com.android.settings.spa.search.SpaSearchRepository
import com.android.settingslib.search.SearchIndexableResources
/** FeatureProvider for the refactored search code. */
open class SearchFeatureProviderImpl : SearchFeatureProvider {
- private val lazySearchIndexableResources by lazy { createSearchIndexableResources() }
+ private val lazySearchIndexableResources by lazy {
+ createSearchIndexableResources().apply {
+ for (searchIndexableData in SpaSearchRepository().getSearchIndexableDataList()) {
+ addIndex(searchIndexableData)
+ }
+ }
+ }
override fun verifyLaunchSearchResultPageCaller(context: Context, callerPackage: String) {
require(callerPackage.isNotEmpty()) {
diff --git a/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt b/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt
index 873a2c3..b9a375c 100644
--- a/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt
+++ b/src/com/android/settings/spa/network/NetworkCellularGroupProvider.kt
@@ -46,10 +46,14 @@
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.android.settings.R
+import com.android.settings.flags.Flags
import com.android.settings.network.SubscriptionInfoListViewModel
+import com.android.settings.network.SubscriptionUtil
import com.android.settings.network.telephony.DataSubscriptionRepository
import com.android.settings.network.telephony.MobileDataRepository
+import com.android.settings.network.telephony.requireSubscriptionManager
import com.android.settings.spa.network.PrimarySimRepository.PrimarySimInfo
+import com.android.settings.spa.search.SearchablePage
import com.android.settings.wifi.WifiPickerTrackerHelper
import com.android.settingslib.spa.framework.common.SettingsEntryBuilder
import com.android.settingslib.spa.framework.common.SettingsPageProvider
@@ -62,6 +66,7 @@
import com.android.settingslib.spa.widget.scaffold.RegularScaffold
import com.android.settingslib.spa.widget.ui.Category
import com.android.settingslib.spaprivileged.framework.common.broadcastReceiverFlow
+import com.android.settingslib.spaprivileged.framework.common.userManager
import com.android.settingslib.spaprivileged.settingsprovider.settingsGlobalBooleanFlow
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -78,7 +83,7 @@
/**
* Showing the sim onboarding which is the process flow of sim switching on.
*/
-open class NetworkCellularGroupProvider : SettingsPageProvider {
+open class NetworkCellularGroupProvider : SettingsPageProvider, SearchablePage {
override val name = fileName
override val metricsCategory = SettingsEnums.MOBILE_NETWORK_LIST
private val owner = createSettingsPage()
@@ -191,8 +196,24 @@
open fun OtherSection(){
// Do nothing
}
+
+ override fun getSearchableTitles(context: Context): List<String> {
+ if (!isPageSearchable(context)) return emptyList()
+ return buildList {
+ if (context.requireSubscriptionManager().activeSubscriptionInfoCount > 0) {
+ add(context.getString(R.string.mobile_data_settings_title))
+ }
+ }
+ }
+
companion object {
const val fileName = "NetworkCellularGroupProvider"
+
+ private fun isPageSearchable(context: Context) =
+ Flags.isDualSimOnboardingEnabled() &&
+ SubscriptionUtil.isSimHardwareVisible(context) &&
+ !com.android.settingslib.Utils.isWifiOnly(context) &&
+ context.userManager.isAdminUser
}
}
diff --git a/src/com/android/settings/spa/search/SearchablePage.kt b/src/com/android/settings/spa/search/SearchablePage.kt
new file mode 100644
index 0000000..2364514
--- /dev/null
+++ b/src/com/android/settings/spa/search/SearchablePage.kt
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.spa.search
+
+import android.content.Context
+
+interface SearchablePage {
+
+ /** Gets the searchable titles at the current moment. */
+ fun getSearchableTitles(context: Context): List<String>
+}
diff --git a/src/com/android/settings/spa/search/SpaSearchLandingActivity.kt b/src/com/android/settings/spa/search/SpaSearchLandingActivity.kt
new file mode 100644
index 0000000..8c2bc37
--- /dev/null
+++ b/src/com/android/settings/spa/search/SpaSearchLandingActivity.kt
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.spa.search
+
+import android.app.Activity
+import android.os.Bundle
+import com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY
+import com.android.settings.overlay.FeatureFactory.Companion.featureFactory
+import com.android.settings.password.PasswordUtils
+import com.android.settings.spa.SpaDestination
+
+class SpaSearchLandingActivity : Activity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ if (!isValidCall()) return
+
+ val destination = intent.getStringExtra(EXTRA_FRAGMENT_ARG_KEY)
+ if (destination.isNullOrBlank()) return
+
+ SpaDestination(destination = destination, highlightMenuKey = null)
+ .startFromExportedActivity(this)
+ finish()
+ }
+
+ private fun isValidCall() =
+ PasswordUtils.getCallingAppPackageName(activityToken) ==
+ featureFactory.searchFeatureProvider.getSettingsIntelligencePkgName(this)
+}
diff --git a/src/com/android/settings/spa/search/SpaSearchRepository.kt b/src/com/android/settings/spa/search/SpaSearchRepository.kt
new file mode 100644
index 0000000..d37c50c
--- /dev/null
+++ b/src/com/android/settings/spa/search/SpaSearchRepository.kt
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.spa.search
+
+import android.content.Context
+import android.provider.SearchIndexableResource
+import android.util.Log
+import androidx.annotation.VisibleForTesting
+import com.android.settingslib.search.Indexable
+import com.android.settingslib.search.SearchIndexableData
+import com.android.settingslib.search.SearchIndexableRaw
+import com.android.settingslib.spa.framework.common.SettingsPageProvider
+import com.android.settingslib.spa.framework.common.SpaEnvironment
+import com.android.settingslib.spa.framework.common.SpaEnvironmentFactory
+
+class SpaSearchRepository(
+ private val spaEnvironment: SpaEnvironment = SpaEnvironmentFactory.instance,
+) {
+ fun getSearchIndexableDataList(): List<SearchIndexableData> {
+ Log.d(TAG, "getSearchIndexableDataList")
+ return spaEnvironment.pageProviderRepository.value.getAllProviders().mapNotNull { page ->
+ if (page is SearchablePage) {
+ page.createSearchIndexableData(page::getSearchableTitles)
+ } else null
+ }
+ }
+
+ companion object {
+ private const val TAG = "SpaSearchRepository"
+
+ @VisibleForTesting
+ fun SettingsPageProvider.createSearchIndexableData(
+ titlesProvider: (context: Context) -> List<String>,
+ ): SearchIndexableData {
+ val searchIndexProvider =
+ object : Indexable.SearchIndexProvider {
+ override fun getXmlResourcesToIndex(
+ context: Context,
+ enabled: Boolean,
+ ): List<SearchIndexableResource> = emptyList()
+
+ override fun getRawDataToIndex(
+ context: Context,
+ enabled: Boolean,
+ ): List<SearchIndexableRaw> = emptyList()
+
+ override fun getDynamicRawDataToIndex(
+ context: Context,
+ enabled: Boolean,
+ ): List<SearchIndexableRaw> =
+ titlesProvider(context).map { title ->
+ createSearchIndexableRaw(context, title)
+ }
+
+ override fun getNonIndexableKeys(context: Context): List<String> = emptyList()
+ }
+ return SearchIndexableData(this::class.java, searchIndexProvider)
+ }
+
+ private fun SettingsPageProvider.createSearchIndexableRaw(context: Context, title: String) =
+ SearchIndexableRaw(context).apply {
+ key = name
+ this.title = title
+ intentAction = SEARCH_LANDING_ACTION
+ packageName = context.packageName
+ className = SpaSearchLandingActivity::class.qualifiedName
+ }
+
+ private const val SEARCH_LANDING_ACTION = "android.settings.SPA_SEARCH_LANDING"
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/MainClearTest.java b/tests/robotests/src/com/android/settings/MainClearTest.java
index 1136d94..187fce1 100644
--- a/tests/robotests/src/com/android/settings/MainClearTest.java
+++ b/tests/robotests/src/com/android/settings/MainClearTest.java
@@ -138,7 +138,11 @@
// Make scrollView only have one child
when(mScrollView.getChildAt(0)).thenReturn(mLinearLayout);
when(mScrollView.getChildCount()).thenReturn(1);
- doReturn(mActivity).when(mMainClear).getActivity();
+ doReturn(mMockActivity).when(mMainClear).getActivity();
+ when(mMockActivity.getSystemService(BiometricManager.class)).thenReturn(mBiometricManager);
+ when(mBiometricManager.canAuthenticate(
+ BiometricManager.Authenticators.MANDATORY_BIOMETRICS))
+ .thenReturn(BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE);
}
@After
diff --git a/tests/robotests/src/com/android/settings/accessibility/BalanceSeekBarTest.java b/tests/robotests/src/com/android/settings/accessibility/BalanceSeekBarTest.java
index ce2a571..d74794f 100644
--- a/tests/robotests/src/com/android/settings/accessibility/BalanceSeekBarTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/BalanceSeekBarTest.java
@@ -28,23 +28,32 @@
import static org.robolectric.Shadows.shadowOf;
import android.content.Context;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
import android.util.AttributeSet;
import android.widget.SeekBar;
+import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowSystemSettings;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import java.util.Locale;
+
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {
ShadowSystemSettings.class,
})
public class BalanceSeekBarTest {
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
+
// Fix the maximum process value to 200 for testing the BalanceSeekBar.
// It affects the SeekBar value of center(100) and snapThreshold(200 * SNAP_TO_PERCENTAGE).
private static final int MAX_PROGRESS_VALUE = 200;
@@ -143,6 +152,58 @@
assertThat(mSeekBar.getProgress()).isEqualTo(progressWithoutThreshold);
}
+ @Test
+ @EnableFlags(Flags.FLAG_AUDIO_BALANCE_STATE_DESCRIPTION)
+ public void onProgressChanged_getStateDescription_centered_leftFirst() {
+ // Seek bar centered
+ int progress = (int) (0.50f * MAX_PROGRESS_VALUE);
+ mSeekBar.setMax(MAX_PROGRESS_VALUE);
+
+ mProxySeekBarListener.onProgressChanged(mSeekBar, progress, true);
+
+ assertThat(mSeekBar.getStateDescription()).isEqualTo(
+ mContext.getString(R.string.audio_seek_bar_state_left_first, 50, 50));
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_AUDIO_BALANCE_STATE_DESCRIPTION)
+ public void onProgressChanged_getStateDescription_centered_rtl_rightFirst() {
+ // RTL layout
+ mContext.getResources().getConfiguration().setLayoutDirection(new Locale("iw", "IL"));
+ // Seek bar centered
+ int progress = (int) (0.50f * MAX_PROGRESS_VALUE);
+ mSeekBar.setMax(MAX_PROGRESS_VALUE);
+
+ mProxySeekBarListener.onProgressChanged(mSeekBar, progress, true);
+
+ assertThat(mSeekBar.getStateDescription()).isEqualTo(
+ mContext.getString(R.string.audio_seek_bar_state_right_first, 50, 50));
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_AUDIO_BALANCE_STATE_DESCRIPTION)
+ public void onProgressChanged_getStateDescription_25percent_leftFirst() {
+ // Seek bar 3/4th toward the left
+ int progress = (int) (0.25f * MAX_PROGRESS_VALUE);
+ mSeekBar.setMax(MAX_PROGRESS_VALUE);
+ mProxySeekBarListener.onProgressChanged(mSeekBar, progress, true);
+
+ assertThat(mSeekBar.getStateDescription()).isEqualTo(
+ mContext.getString(R.string.audio_seek_bar_state_left_first, 75, 25));
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_AUDIO_BALANCE_STATE_DESCRIPTION)
+ public void onProgressChanged_getStateDescription_75percent_rightFirst() {
+ // Seek bar 3/4th toward the right
+ int progress = (int) (0.75f * MAX_PROGRESS_VALUE);
+ mSeekBar.setMax(MAX_PROGRESS_VALUE);
+ mProxySeekBarListener.onProgressChanged(mSeekBar, progress, true);
+
+ assertThat(mSeekBar.getStateDescription()).isEqualTo(
+ mContext.getString(R.string.audio_seek_bar_state_right_first, 75, 25));
+ }
+
// method to get the center from BalanceSeekBar for testing setMax().
private int getBalanceSeekBarCenter(BalanceSeekBar seekBar) {
return seekBar.getMax() / 2;
diff --git a/tests/robotests/src/com/android/settings/biometrics/combination/CombinedBiometricProfileSettingsTest.java b/tests/robotests/src/com/android/settings/biometrics/combination/CombinedBiometricProfileSettingsTest.java
index a0ef57f..8593860 100644
--- a/tests/robotests/src/com/android/settings/biometrics/combination/CombinedBiometricProfileSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/combination/CombinedBiometricProfileSettingsTest.java
@@ -31,9 +31,11 @@
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.Intent;
+import android.hardware.biometrics.BiometricManager;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
@@ -102,6 +104,8 @@
private FaceStatusPreferenceController mFaceStatusPreferenceController;
@Mock
private FaceManager mFaceManager;
+ @Mock
+ private BiometricManager mBiometricManager;
@Before
public void setUp() {
@@ -114,6 +118,10 @@
mContext = spy(ApplicationProvider.getApplicationContext());
mFragment = spy(new TestCombinedBiometricProfileSettings(mContext));
doReturn(mActivity).when(mFragment).getActivity();
+ doReturn(mBiometricManager).when(mActivity).getSystemService(BiometricManager.class);
+ when(mBiometricManager.canAuthenticate(
+ BiometricManager.Authenticators.MANDATORY_BIOMETRICS))
+ .thenReturn(BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE);
ReflectionHelpers.setField(mFragment, "mDashboardFeatureProvider",
FakeFeatureFactory.setupForTest().dashboardFeatureProvider);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
index 9b92234..2d1f4c0 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java
@@ -90,6 +90,9 @@
@Mock
private CachedBluetoothDeviceManager mCachedBluetoothDeviceManager;
+ private @Mock A2dpProfile mA2dpProfile;
+ private @Mock LeAudioProfile mLeAudioProfile;
+
@Override
public void setUp() {
super.setUp();
@@ -103,11 +106,13 @@
mConnectableProfiles = new ArrayList<>();
when(mLocalManager.getProfileManager()).thenReturn(mProfileManager);
when(mLocalManager.getCachedDeviceManager()).thenReturn(mCachedBluetoothDeviceManager);
+ setUpMockProfiles();
when(mCachedBluetoothDeviceManager.getCachedDevicesCopy())
.thenReturn(ImmutableList.of(mCachedDevice));
- when(mCachedDevice.getConnectableProfiles()).thenAnswer(invocation ->
- new ArrayList<>(mConnectableProfiles)
- );
+ when(mCachedDevice.getConnectableProfiles())
+ .thenAnswer(invocation -> new ArrayList<>(mConnectableProfiles));
+ when(mCachedDevice.getProfiles())
+ .thenAnswer(invocation -> ImmutableList.of(mConnectableProfiles));
setupDevice(mDeviceConfig);
mController = new BluetoothDetailsProfilesController(mContext, mFragment, mLocalManager,
@@ -389,21 +394,36 @@
assertThat(mDevice.getMessageAccessPermission()).isEqualTo(BluetoothDevice.ACCESS_ALLOWED);
}
- private A2dpProfile addMockA2dpProfile(boolean preferred, boolean supportsHighQualityAudio,
- boolean highQualityAudioEnabled) {
- A2dpProfile profile = mock(A2dpProfile.class);
- when(mProfileManager.getProfileByName(eq(profile.toString()))).thenReturn(profile);
- when(profile.getNameResource(mDevice))
+ private void setUpMockProfiles() {
+ when(mA2dpProfile.toString()).thenReturn("A2DP");
+ when(mProfileManager.getProfileByName(eq(mA2dpProfile.toString())))
+ .thenReturn(mA2dpProfile);
+ when(mA2dpProfile.getNameResource(any()))
.thenReturn(com.android.settingslib.R.string.bluetooth_profile_a2dp);
- when(profile.getHighQualityAudioOptionLabel(mDevice)).thenReturn(
+ when(mA2dpProfile.getHighQualityAudioOptionLabel(any())).thenReturn(
mContext.getString(com.android.settingslib.R
.string.bluetooth_profile_a2dp_high_quality_unknown_codec));
- when(profile.supportsHighQualityAudio(mDevice)).thenReturn(supportsHighQualityAudio);
- when(profile.isHighQualityAudioEnabled(mDevice)).thenReturn(highQualityAudioEnabled);
- when(profile.isEnabled(mDevice)).thenReturn(preferred);
- when(profile.isProfileReady()).thenReturn(true);
- mConnectableProfiles.add(profile);
- return profile;
+ when(mA2dpProfile.isProfileReady()).thenReturn(true);
+ when(mProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile);
+
+ when(mLeAudioProfile.toString()).thenReturn("LE_AUDIO");
+ when(mLeAudioProfile.getNameResource(any()))
+ .thenReturn(com.android.settingslib.R.string.bluetooth_profile_le_audio);
+ when(mLeAudioProfile.isProfileReady()).thenReturn(true);
+ when(mProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile);
+ }
+
+ private void addA2dpProfileToDevice(boolean preferred, boolean supportsHighQualityAudio,
+ boolean highQualityAudioEnabled) {
+ when(mA2dpProfile.supportsHighQualityAudio(any())).thenReturn(supportsHighQualityAudio);
+ when(mA2dpProfile.isHighQualityAudioEnabled(any())).thenReturn(highQualityAudioEnabled);
+ when(mA2dpProfile.isEnabled(any())).thenReturn(preferred);
+ mConnectableProfiles.add(mA2dpProfile);
+ }
+
+ private void addLeAudioProfileToDevice(boolean enabled) {
+ when(mLeAudioProfile.isEnabled(any())).thenReturn(enabled);
+ mConnectableProfiles.add(mLeAudioProfile);
}
private SwitchPreferenceCompat getHighQualityAudioPref() {
@@ -414,7 +434,7 @@
@Test
public void highQualityAudio_prefIsPresentWhenSupported() {
setupDevice(makeDefaultDeviceConfig());
- addMockA2dpProfile(true, true, true);
+ addA2dpProfileToDevice(true, true, true);
showScreen(mController);
SwitchPreferenceCompat pref = getHighQualityAudioPref();
assertThat(pref.getKey()).isEqualTo(
@@ -431,7 +451,7 @@
@Test
public void highQualityAudio_prefIsAbsentWhenNotSupported() {
setupDevice(makeDefaultDeviceConfig());
- addMockA2dpProfile(true, false, false);
+ addA2dpProfileToDevice(true, false, false);
showScreen(mController);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(2);
SwitchPreferenceCompat pref = (SwitchPreferenceCompat) mProfiles.getPreference(0);
@@ -444,7 +464,7 @@
@Test
public void highQualityAudio_busyDeviceDisablesSwitch() {
setupDevice(makeDefaultDeviceConfig());
- addMockA2dpProfile(true, true, true);
+ addA2dpProfileToDevice(true, true, true);
when(mCachedDevice.isBusy()).thenReturn(true);
showScreen(mController);
SwitchPreferenceCompat pref = getHighQualityAudioPref();
@@ -454,17 +474,17 @@
@Test
public void highQualityAudio_mediaAudioDisabledAndReEnabled() {
setupDevice(makeDefaultDeviceConfig());
- A2dpProfile audioProfile = addMockA2dpProfile(true, true, true);
+ addA2dpProfileToDevice(true, true, true);
showScreen(mController);
assertThat(mProfiles.getPreferenceCount()).isEqualTo(3);
// Disabling media audio should cause the high quality audio switch to disappear, but not
// the regular audio one.
SwitchPreferenceCompat audioPref =
- (SwitchPreferenceCompat) mScreen.findPreference(audioProfile.toString());
+ (SwitchPreferenceCompat) mScreen.findPreference(mA2dpProfile.toString());
audioPref.performClick();
- verify(audioProfile).setEnabled(mDevice, false);
- when(audioProfile.isEnabled(mDevice)).thenReturn(false);
+ verify(mA2dpProfile).setEnabled(mDevice, false);
+ when(mA2dpProfile.isEnabled(mDevice)).thenReturn(false);
mController.onDeviceAttributesChanged();
assertThat(audioPref.isVisible()).isTrue();
SwitchPreferenceCompat highQualityAudioPref = getHighQualityAudioPref();
@@ -472,8 +492,8 @@
// And re-enabling media audio should make high quality switch to reappear.
audioPref.performClick();
- verify(audioProfile).setEnabled(mDevice, true);
- when(audioProfile.isEnabled(mDevice)).thenReturn(true);
+ verify(mA2dpProfile).setEnabled(mDevice, true);
+ when(mA2dpProfile.isEnabled(mDevice)).thenReturn(true);
mController.onDeviceAttributesChanged();
highQualityAudioPref = getHighQualityAudioPref();
assertThat(highQualityAudioPref.isVisible()).isTrue();
@@ -482,9 +502,9 @@
@Test
public void highQualityAudio_mediaAudioStartsDisabled() {
setupDevice(makeDefaultDeviceConfig());
- A2dpProfile audioProfile = addMockA2dpProfile(false, true, true);
+ addA2dpProfileToDevice(false, true, true);
showScreen(mController);
- SwitchPreferenceCompat audioPref = mScreen.findPreference(audioProfile.toString());
+ SwitchPreferenceCompat audioPref = mScreen.findPreference(mA2dpProfile.toString());
SwitchPreferenceCompat highQualityAudioPref = getHighQualityAudioPref();
assertThat(audioPref).isNotNull();
assertThat(audioPref.isChecked()).isFalse();
@@ -522,15 +542,9 @@
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_BLUETOOTH_PROFILE_TOGGLE_VISIBILITY_CHECKER);
setupDevice(makeDefaultDeviceConfig());
- LeAudioProfile leAudioProfile = mock(LeAudioProfile.class);
- when(leAudioProfile.getNameResource(mDevice))
- .thenReturn(com.android.settingslib.R.string.bluetooth_profile_le_audio);
- when(leAudioProfile.isProfileReady()).thenReturn(true);
- when(leAudioProfile.toString()).thenReturn("LE_AUDIO");
- when(mProfileManager.getLeAudioProfile()).thenReturn(leAudioProfile);
+ addA2dpProfileToDevice(true, true, true);
when(mFeatureProvider.getInvisibleProfilePreferenceKeys(any(), any()))
- .thenReturn(ImmutableSet.of("LE_AUDIO"));
- mConnectableProfiles.add(leAudioProfile);
+ .thenReturn(ImmutableSet.of("A2DP"));
showScreen(mController);
@@ -543,15 +557,9 @@
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_BLUETOOTH_PROFILE_TOGGLE_VISIBILITY_CHECKER);
setupDevice(makeDefaultDeviceConfig());
- LeAudioProfile leAudioProfile = mock(LeAudioProfile.class);
- when(leAudioProfile.getNameResource(mDevice))
- .thenReturn(com.android.settingslib.R.string.bluetooth_profile_le_audio);
- when(leAudioProfile.isProfileReady()).thenReturn(true);
- when(leAudioProfile.toString()).thenReturn("LE_AUDIO");
- when(mProfileManager.getLeAudioProfile()).thenReturn(leAudioProfile);
+ addA2dpProfileToDevice(true, true, true);
when(mFeatureProvider.getInvisibleProfilePreferenceKeys(any(), any()))
- .thenReturn(ImmutableSet.of("A2DP"));
- mConnectableProfiles.add(leAudioProfile);
+ .thenReturn(ImmutableSet.of("LE_AUDIO"));
showScreen(mController);
@@ -563,19 +571,8 @@
public void classicAudioDeviceWithLeAudio_showLeAudioToggle() {
mSetFlagsRule.enableFlags(Flags.FLAG_HIDE_LE_AUDIO_TOGGLE_FOR_LE_AUDIO_ONLY_DEVICE);
setupDevice(makeDefaultDeviceConfig());
-
- LeAudioProfile leAudioProfile = mock(LeAudioProfile.class);
- when(leAudioProfile.getNameResource(mDevice))
- .thenReturn(com.android.settingslib.R.string.bluetooth_profile_le_audio);
- when(leAudioProfile.isProfileReady()).thenReturn(true);
- when(leAudioProfile.toString()).thenReturn("LE_AUDIO");
- when(mProfileManager.getLeAudioProfile()).thenReturn(leAudioProfile);
- mConnectableProfiles.add(leAudioProfile);
- when(mCachedDevice.getProfiles())
- .thenAnswer(
- invocation ->
- ImmutableList.of(
- leAudioProfile, addMockA2dpProfile(false, false, false)));
+ addLeAudioProfileToDevice(false);
+ addA2dpProfileToDevice(false, false, false);
showScreen(mController);
@@ -587,16 +584,7 @@
public void leAudioOnlyDevice_hideLeAudioToggle() {
mSetFlagsRule.enableFlags(Flags.FLAG_HIDE_LE_AUDIO_TOGGLE_FOR_LE_AUDIO_ONLY_DEVICE);
setupDevice(makeDefaultDeviceConfig());
-
- LeAudioProfile leAudioProfile = mock(LeAudioProfile.class);
- when(leAudioProfile.getNameResource(mDevice))
- .thenReturn(com.android.settingslib.R.string.bluetooth_profile_le_audio);
- when(leAudioProfile.isProfileReady()).thenReturn(true);
- when(leAudioProfile.toString()).thenReturn("LE_AUDIO");
- when(mProfileManager.getLeAudioProfile()).thenReturn(leAudioProfile);
- mConnectableProfiles.add(leAudioProfile);
- when(mCachedDevice.getProfiles())
- .thenAnswer(invocation -> ImmutableList.of(leAudioProfile));
+ addLeAudioProfileToDevice(false);
showScreen(mController);
diff --git a/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceControllerTest.java
new file mode 100644
index 0000000..9b4d5ef
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceControllerTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.inputmethod;
+
+import static android.view.flags.Flags.enableVectorCursorA11ySettings;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.inputmethod.PointerStrokeStylePreferenceController.KEY_POINTER_STROKE_STYLE;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assume.assumeTrue;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+/** Tests for {@link PointerStrokeStylePreferenceController} */
+@RunWith(RobolectricTestRunner.class)
+public class PointerStrokeStylePreferenceControllerTest {
+ @Rule
+ public MockitoRule mMockitoRule = MockitoJUnit.rule();
+
+ @Mock
+ PreferenceScreen mPreferenceScreen;
+
+ private Context mContext;
+ private PointerStrokeStylePreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mController = new PointerStrokeStylePreferenceController(mContext);
+ }
+
+ @Test
+ public void displayPreference_initializeDataStore() {
+ Preference strokePreference = new Preference(mContext);
+ strokePreference.setKey(KEY_POINTER_STROKE_STYLE);
+ when(mPreferenceScreen.findPreference(eq(KEY_POINTER_STROKE_STYLE))).thenReturn(
+ strokePreference);
+
+ mController.displayPreference(mPreferenceScreen);
+
+ assertNotNull(strokePreference.getPreferenceDataStore());
+ }
+
+ @Test
+ public void getAvailabilityStatus_flagEnabled() {
+ assumeTrue(enableVectorCursorA11ySettings());
+
+ assertEquals(mController.getAvailabilityStatus(), AVAILABLE);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceTest.java b/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceTest.java
new file mode 100644
index 0000000..33b8592
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/inputmethod/PointerStrokeStylePreferenceTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.inputmethod;
+
+import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_STROKE_BLACK;
+import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_STROKE_WHITE;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.view.View;
+import android.widget.RadioButton;
+
+import androidx.preference.PreferenceDataStore;
+import androidx.preference.PreferenceViewHolder;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+/** Tests for {@link PointerStrokeStylePreference} */
+@RunWith(RobolectricTestRunner.class)
+public class PointerStrokeStylePreferenceTest {
+ @Rule
+ public MockitoRule mMockitoRule = MockitoJUnit.rule();
+
+ @Mock
+ PreferenceDataStore mPreferenceDataStore;
+
+ private Context mContext;
+ private PreferenceViewHolder mViewHolder;
+ private PointerStrokeStylePreference mPreference;
+
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ mPreference = new PointerStrokeStylePreference(mContext, null);
+ }
+
+ @Test
+ public void onBindViewHolder_getCurrentStrokeStyleFromDataStore() {
+ final View view = spy(View.inflate(mContext, mPreference.getLayoutResource(), null));
+ mViewHolder = PreferenceViewHolder.createInstanceForTests(view);
+ mPreference.setPreferenceDataStore(mPreferenceDataStore);
+
+ mPreference.onBindViewHolder(mViewHolder);
+
+ verify(mPreferenceDataStore).getInt(Settings.System.POINTER_STROKE_STYLE,
+ POINTER_ICON_VECTOR_STYLE_STROKE_WHITE);
+ }
+
+ @Test
+ public void setChecked_radioButtonUpdatesDataStore() {
+ final View view = spy(View.inflate(mContext, mPreference.getLayoutResource(), null));
+ mViewHolder = PreferenceViewHolder.createInstanceForTests(view);
+ mPreference.setPreferenceDataStore(mPreferenceDataStore);
+ RadioButton radioButton = (RadioButton) view.findViewById(R.id.stroke_style_black);
+ mPreference.onBindViewHolder(mViewHolder);
+
+ radioButton.setChecked(true);
+
+ verify(mPreferenceDataStore).getInt(Settings.System.POINTER_STROKE_STYLE,
+ POINTER_ICON_VECTOR_STYLE_STROKE_WHITE);
+ verify(mPreferenceDataStore).putInt(Settings.System.POINTER_STROKE_STYLE,
+ POINTER_ICON_VECTOR_STYLE_STROKE_BLACK);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModePreferenceControllerTest.java
index f611c9b..8d551e5 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModePreferenceControllerTest.java
@@ -109,20 +109,4 @@
verify(mPreference, never()).setSummary(anyString());
}
-
- @Test
- @EnableFlags(Flags.FLAG_MODES_UI)
- public void updateState_modesUi_resetsTitleAndFragment() {
- mController.updateState(mPreference);
- verify(mPreference).setTitle(anyInt()); // Resource IDs are ints
- verify(mPreference).setFragment(ZenModesListFragment.class.getCanonicalName());
- }
-
- @Test
- @DisableFlags(Flags.FLAG_MODES_UI)
- public void updateState_noModesUi_doesNotSetTitleAndFragment() {
- mController.updateState(mPreference);
- verify(mPreference, never()).setTitle(anyInt());
- verify(mPreference, never()).setFragment(anyString());
- }
}
diff --git a/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java b/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java
index e408cd0..b555f00 100644
--- a/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java
@@ -29,6 +29,7 @@
import android.text.TextUtils;
import com.android.settings.network.NetworkProviderSettings;
+import com.android.settings.spa.search.SearchablePage;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.FakeIndexProvider;
import com.android.settingslib.search.SearchIndexableData;
@@ -117,8 +118,10 @@
public void testAllClassNamesHaveProviders() {
for (SearchIndexableData data :
mSearchProvider.getSearchIndexableResources().getProviderValues()) {
- if (DatabaseIndexingUtils.getSearchIndexProvider(data.getTargetClass()) == null) {
- fail(data.getTargetClass().getName() + "is not an index provider");
+ Class<?> targetClass = data.getTargetClass();
+ if (DatabaseIndexingUtils.getSearchIndexProvider(targetClass) == null
+ && !SearchablePage.class.isAssignableFrom(targetClass)) {
+ fail(targetClass.getName() + " is not an index provider");
}
}
}
diff --git a/tests/spa_unit/src/com/android/settings/spa/search/SpaSearchRepositoryTest.kt b/tests/spa_unit/src/com/android/settings/spa/search/SpaSearchRepositoryTest.kt
new file mode 100644
index 0000000..911dfd2
--- /dev/null
+++ b/tests/spa_unit/src/com/android/settings/spa/search/SpaSearchRepositoryTest.kt
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.spa.search
+
+import android.content.Context
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.android.settings.spa.search.SpaSearchRepository.Companion.createSearchIndexableData
+import com.android.settingslib.spa.framework.common.SettingsPageProvider
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.kotlin.mock
+
+@RunWith(AndroidJUnit4::class)
+class SpaSearchRepositoryTest {
+
+ @Test
+ fun createSearchIndexableData() {
+ val pageProvider =
+ object : SettingsPageProvider {
+ override val name = PAGE_NAME
+ }
+
+ val searchIndexableData = pageProvider.createSearchIndexableData { listOf(TITLE) }
+ val dynamicRawDataToIndex =
+ searchIndexableData.searchIndexProvider.getDynamicRawDataToIndex(mock<Context>(), true)
+
+ assertThat(searchIndexableData.targetClass).isEqualTo(pageProvider::class.java)
+ assertThat(dynamicRawDataToIndex).hasSize(1)
+ assertThat(dynamicRawDataToIndex[0].title).isEqualTo(TITLE)
+ }
+
+ private companion object {
+ const val PAGE_NAME = "PageName"
+ const val TITLE = "Title"
+ }
+}
diff --git a/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
index 8a4acd2..1c482ef 100644
--- a/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
@@ -36,8 +36,6 @@
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.os.Looper;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
@@ -78,15 +76,8 @@
private static final String NOT_CONNECTED = "Not connected";
private static final String SUB_ID_1 = "1";
private static final String SUB_ID_2 = "2";
- private static final String INVALID_SUB_ID = "-1";
private static final String DISPLAY_NAME_1 = "Sub 1";
private static final String DISPLAY_NAME_2 = "Sub 2";
- private static final String SUB_MCC_1 = "123";
- private static final String SUB_MNC_1 = "456";
- private static final String SUB_MCC_2 = "223";
- private static final String SUB_MNC_2 = "456";
- private static final String SUB_COUNTRY_ISO_1 = "Sub 1";
- private static final String SUB_COUNTRY_ISO_2 = "Sub 2";
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@@ -178,14 +169,10 @@
}
private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, int slotId,
- int carrierId, String displayName, String mcc, String mnc, String countryIso,
- int cardId, boolean isVisible, boolean isValid, boolean isActive, boolean isAvailable,
+ String displayName, boolean isVisible, boolean isValid, boolean isActive,
boolean isActiveData) {
- return new SubscriptionInfoEntity(subId, slotId, carrierId,
- displayName, displayName, 0, mcc, mnc, countryIso, false, cardId,
- TelephonyManager.DEFAULT_PORT_INDEX, false, null,
- SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, isVisible,
- "1234567890", true, false, isValid, true, isActive, isAvailable, isActiveData);
+ return new SubscriptionInfoEntity(subId, slotId, false, false, displayName, isVisible,
+ false, isValid, isActive, isActiveData);
}
@Test
@@ -253,10 +240,10 @@
@Test
public void updateCellularSummary_getActiveSubscriptionInfo_cbrs() {
mController.setDefaultDataSubscriptionId(Integer.parseInt(SUB_ID_2));
- mActiveSubInfo = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, false, true, true, true, true);
- mDefaultDataSubInfo = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, false, true, true, true, false);
+ mActiveSubInfo = setupSubscriptionInfoEntity(SUB_ID_1, 1, DISPLAY_NAME_1,
+ false, true, true, true);
+ mDefaultDataSubInfo = setupSubscriptionInfoEntity(SUB_ID_2, 1, DISPLAY_NAME_2,
+ false, true, true, false);
mSubscriptionInfoEntityList.add(mActiveSubInfo);
mSubscriptionInfoEntityList.add(mDefaultDataSubInfo);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -265,8 +252,8 @@
mController.updateCellularSummary();
assertThat(mPreference.getSummary()).isEqualTo(DISPLAY_NAME_2);
- mActiveSubInfo = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+ mActiveSubInfo = setupSubscriptionInfoEntity(SUB_ID_1, 1, DISPLAY_NAME_1,
+ true, true, true, true);
mSubscriptionInfoEntityList.add(mActiveSubInfo);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
mController.onAvailableSubInfoChanged(mSubscriptionInfoEntityList);
diff --git a/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java b/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
index a98f83b..2b78212 100644
--- a/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
@@ -28,7 +28,6 @@
import android.content.Context;
import android.os.Looper;
import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
import android.text.TextUtils;
import androidx.lifecycle.LifecycleOwner;
@@ -63,12 +62,6 @@
private static final String KEY_PREFERENCE_CATEGORY_SIM = "provider_model_sim_category";
private static final String DISPLAY_NAME_1 = "Sub 1";
private static final String DISPLAY_NAME_2 = "Sub 2";
- private static final String SUB_MCC_1 = "123";
- private static final String SUB_MNC_1 = "456";
- private static final String SUB_MCC_2 = "223";
- private static final String SUB_MNC_2 = "456";
- private static final String SUB_COUNTRY_ISO_1 = "Sub 1";
- private static final String SUB_COUNTRY_ISO_2 = "Sub 2";
@Mock
private SubscriptionInfoEntity mSubInfo1;
@@ -140,12 +133,9 @@
}
private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, int slotId,
- int carrierId, String displayName, String mcc, String mnc, String countryIso,
- int cardId, boolean isValid, boolean isActive, boolean isAvailable) {
- return new SubscriptionInfoEntity(subId, slotId, carrierId, displayName, displayName, 0,
- mcc, mnc, countryIso, false, cardId, TelephonyManager.DEFAULT_PORT_INDEX, false,
- null, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, false,
- "1234567890", true, false, isValid, true, isActive, isAvailable, false);
+ String displayName, boolean isValid, boolean isActive) {
+ return new SubscriptionInfoEntity(subId, slotId, false, false, displayName, false,
+ false, isValid, isActive, false);
}
private String setSummaryResId(String resName, String value) {
@@ -159,8 +149,7 @@
@Test
@UiThreadTest
public void getSummary_tapToActivePSim() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, false, true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, DISPLAY_NAME_1, true, false);
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
displayPreferenceWithLifecycle();
@@ -172,8 +161,7 @@
@Test
@UiThreadTest
public void getSummary_inactivePSim() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, false, true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, DISPLAY_NAME_1, true, false);
doReturn(true).when(mSubscriptionManager).canDisablePhysicalSubscription();
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -187,8 +175,7 @@
@Test
@UiThreadTest
public void getSummary_defaultCalls() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, DISPLAY_NAME_1, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -209,8 +196,7 @@
defaultConfig.append(setSummaryResId("default_active_sim_calls"))
.append(", ")
.append(setSummaryResId("default_active_sim_sms"));
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, DISPLAY_NAME_1, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -228,10 +214,8 @@
@Test
@UiThreadTest
public void getAvailablePhysicalSubscription_withTwoPhysicalSims_returnTwo() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, DISPLAY_NAME_1, true, true);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, DISPLAY_NAME_2, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
diff --git a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
index 42e3a83..f5329fa 100644
--- a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
@@ -30,7 +30,6 @@
import android.telecom.TelecomManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;
@@ -70,15 +69,6 @@
private static final String DISPLAY_NAME_1 = "Sub 1";
private static final String DISPLAY_NAME_2 = "Sub 2";
private static final String DISPLAY_NAME_3 = "Sub 3";
- private static final String SUB_MCC_1 = "123";
- private static final String SUB_MNC_1 = "456";
- private static final String SUB_MCC_2 = "223";
- private static final String SUB_MNC_2 = "456";
- private static final String SUB_MCC_3 = "323";
- private static final String SUB_MNC_3 = "456";
- private static final String SUB_COUNTRY_ISO_1 = "Sub 1";
- private static final String SUB_COUNTRY_ISO_2 = "Sub 2";
- private static final String SUB_COUNTRY_ISO_3 = "Sub 3";
@Mock
private SubscriptionManager mSubMgr;
@@ -133,12 +123,9 @@
SubscriptionUtil.setActiveSubscriptionsForTesting(null);
}
- private SubscriptionInfoEntity setupSubscriptionInfoEntity(
- String subId, String displayName, String mcc, String mnc, String countryIso) {
- return new SubscriptionInfoEntity(subId, 1, 1, displayName, displayName, 0, mcc, mnc,
- countryIso, false, 1, TelephonyManager.DEFAULT_PORT_INDEX, false, null,
- SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, false, "1234567890",
- true, false, true, true, true, true, false);
+ private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, String displayName) {
+ return new SubscriptionInfoEntity(subId, 1, false, false, displayName, false, false, true,
+ true, false);
}
@Test
@@ -151,8 +138,7 @@
@Test
public void getSummary_singleSub() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1,
- SUB_COUNTRY_ISO_1);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1);
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mController.displayPreference(mScreen);
@@ -164,10 +150,8 @@
@Test
public void getSummary_twoSubs() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1,
- SUB_COUNTRY_ISO_1);
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, SUB_MCC_2, SUB_MNC_2,
- SUB_COUNTRY_ISO_2);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2);
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
@@ -180,10 +164,8 @@
@Test
public void onPreferenceChange_prefChangedToSub2_callbackCalledCorrectly() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1,
- SUB_COUNTRY_ISO_1);
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, SUB_MCC_2, SUB_MNC_2,
- SUB_COUNTRY_ISO_2);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
@@ -197,10 +179,8 @@
@Test
public void onPreferenceChange_prefChangedToAlwaysAsk_callbackCalledCorrectly() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1,
- SUB_COUNTRY_ISO_1);
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, SUB_MCC_2, SUB_MNC_2,
- SUB_COUNTRY_ISO_2);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
@@ -217,10 +197,8 @@
@Test
public void onPreferenceChange_prefBecomesAvailable_onPreferenceChangeCallbackNotNull() {
// Start with only one sub active, so the pref is not available
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1,
- SUB_COUNTRY_ISO_1);
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, SUB_MCC_2, SUB_MNC_2,
- SUB_COUNTRY_ISO_2);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
@@ -240,10 +218,8 @@
@Test
public void onSubscriptionsChanged_twoSubscriptionsDefaultChanges_selectedEntryGetsUpdated() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1,
- SUB_COUNTRY_ISO_1);
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, SUB_MCC_2, SUB_MNC_2,
- SUB_COUNTRY_ISO_2);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
@@ -261,10 +237,8 @@
@Test
public void onSubscriptionsChanged_goFromTwoSubscriptionsToOne_prefDisappears() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1,
- SUB_COUNTRY_ISO_1);
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, SUB_MCC_2, SUB_MNC_2,
- SUB_COUNTRY_ISO_2);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2);
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
@@ -287,10 +261,8 @@
@Test
@UiThreadTest
public void onSubscriptionsChanged_goFromOneSubscriptionToTwo_prefAppears() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1,
- SUB_COUNTRY_ISO_1);
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, SUB_MCC_2, SUB_MNC_2,
- SUB_COUNTRY_ISO_2);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2);
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mController.onActiveSubInfoChanged(mSubscriptionInfoEntityList);
@@ -309,12 +281,9 @@
@Test
public void onSubscriptionsChanged_goFromTwoToThreeSubscriptions_listGetsUpdated() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1,
- SUB_COUNTRY_ISO_1);
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, SUB_MCC_2, SUB_MNC_2,
- SUB_COUNTRY_ISO_2);
- mSubInfo3 = setupSubscriptionInfoEntity(SUB_ID_3, DISPLAY_NAME_3, SUB_MCC_3, SUB_MNC_3,
- SUB_COUNTRY_ISO_3);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2);
+ mSubInfo3 = setupSubscriptionInfoEntity(SUB_ID_3, DISPLAY_NAME_3);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
diff --git a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
index f31e274..6897c01 100644
--- a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
@@ -29,7 +29,6 @@
import android.content.Context;
import android.os.Looper;
import android.platform.test.flag.junit.SetFlagsRule;
-import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -75,8 +74,6 @@
@Mock
private SubscriptionManager mSubscriptionManager;
@Mock
- private SubscriptionInfo mSubscriptionInfo;
- @Mock
private FragmentTransaction mFragmentTransaction;
@Mock
private Lifecycle mLifecycle;
@@ -120,13 +117,10 @@
}
private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, String displayName,
- boolean isOpportunistic, boolean isValid, boolean isActive, boolean isAvailable) {
+ boolean isOpportunistic, boolean isValid, boolean isActive) {
int id = Integer.parseInt(subId);
- return new SubscriptionInfoEntity(subId, id, id,
- displayName, displayName, 0, "mcc", "mnc", "countryIso", false, id,
- TelephonyManager.DEFAULT_PORT_INDEX, isOpportunistic, null,
- SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, false,
- "1234567890", true, false, isValid, true, isActive, isAvailable, false);
+ return new SubscriptionInfoEntity(subId, id, false, isOpportunistic, displayName, false,
+ false, isValid, isActive, false);
}
private MobileNetworkInfoEntity setupMobileNetworkInfoEntity(String subId,
@@ -144,7 +138,7 @@
@Test
public void isDialogNeeded_disableSingleSim_returnFalse() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true);
mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
doReturn(1).when(mTelephonyManager).getActiveModemCount();
@@ -153,12 +147,12 @@
@Test
public void isDialogNeeded_enableNonDefaultSimInMultiSimMode_returnTrue() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true);
mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), false);
doReturn(1).when(mTelephonyManager).getActiveModemCount();
// Ideally, it would be better if we could set the default data subscription to
// SUB_ID_OTHER, and set that as an active subscription id.
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, false, true, true, true);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, false, true, true);
mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
doReturn(2).when(mTelephonyManager).getActiveModemCount();
@@ -180,7 +174,7 @@
@Test
public void onPreferenceChange_singleSim_On_shouldEnableData() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true);
mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
mController.setSubscriptionInfoEntity(mSubInfo1);
mController.setMobileNetworkInfoEntity(mNetworkInfo1);
@@ -194,7 +188,7 @@
@Test
public void onPreferenceChange_multiSim_On_shouldEnableData() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true);
mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
mController.setSubscriptionInfoEntity(mSubInfo1);
mController.setMobileNetworkInfoEntity(mNetworkInfo1);
@@ -219,7 +213,7 @@
@Test
public void updateState_opportunistic_disabled() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true);
mController.init(mFragmentManager, SUB_ID, mSubInfo1, mNetworkInfo1);
mController.updateState(mPreference);
@@ -231,7 +225,7 @@
@Test
public void updateState_notOpportunistic_enabled() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true);
mController.init(mFragmentManager, SUB_ID, mSubInfo1, mNetworkInfo1);
mController.updateState(mPreference);