Merge "Create new sections for developer options" into main
diff --git a/Android.bp b/Android.bp
index c966eca..ed094cf 100644
--- a/Android.bp
+++ b/Android.bp
@@ -115,6 +115,7 @@
"device_policy_aconfig_flags_lib",
"keyboard_flags_lib",
"settings_connectivity_flags",
+ "com_android_systemui_flags_lib",
],
plugins: [
diff --git a/res/drawable/keyboard_arrow_left.xml b/res/drawable/keyboard_arrow_left.xml
new file mode 100644
index 0000000..77a2bfb
--- /dev/null
+++ b/res/drawable/keyboard_arrow_left.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2025 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="960" android:viewportHeight="960" android:tint="?attr/colorControlNormal" android:autoMirrored="true">
+ <path android:fillColor="@android:color/white" android:pathData="M560,720L320,480L560,240L616,296L432,480L616,664L560,720Z"/>
+</vector>
\ No newline at end of file
diff --git a/res/drawable/keyboard_arrow_right.xml b/res/drawable/keyboard_arrow_right.xml
new file mode 100644
index 0000000..5b0dd3d
--- /dev/null
+++ b/res/drawable/keyboard_arrow_right.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2025 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="960" android:viewportHeight="960" android:tint="?attr/colorControlNormal" android:autoMirrored="true">
+ <path android:fillColor="@android:color/white" android:pathData="M504,480L320,296L376,240L616,480L376,720L320,664L504,480Z" />
+</vector>
\ No newline at end of file
diff --git a/res/layout/accessibility_text_reading_preview.xml b/res/layout/accessibility_text_reading_preview.xml
index 830d9e6..9c3ce31 100644
--- a/res/layout/accessibility_text_reading_preview.xml
+++ b/res/layout/accessibility_text_reading_preview.xml
@@ -38,20 +38,45 @@
android:text="@string/screen_zoom_preview_title"
style="@style/AccessibilityTextReadingPreviewTitle" />
- <com.android.settings.accessibility.TextReadingPreviewPager
- android:id="@+id/preview_pager"
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="217dp"
- android:contentDescription="@string/preview_pager_content_description"
- android:nestedScrollingEnabled="true" />
-
- <com.android.settings.widget.DotsPageIndicator
- android:id="@+id/page_indicator"
- style="@style/PreviewPagerPageIndicator"
- android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:padding="6dp"
- android:visibility="gone" />
+ android:orientation="vertical">
+ <com.android.settings.accessibility.TextReadingPreviewPager
+ android:id="@+id/preview_pager"
+ android:layout_width="wrap_content"
+ android:layout_height="217dp"
+ android:contentDescription="@string/preview_pager_content_description"
+ android:nestedScrollingEnabled="true" />
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center_horizontal">
+ <ImageButton
+ android:id="@+id/preview_left_button"
+ android:src="@drawable/keyboard_arrow_left"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:layout_gravity="center_vertical"
+ style="?android:attr/borderlessButtonStyle" />
+ <com.android.settings.widget.DotsPageIndicator
+ android:id="@+id/page_indicator"
+ style="@style/PreviewPagerPageIndicator"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:padding="6dp"
+ android:visibility="gone" />
+ <ImageButton
+ android:id="@+id/preview_right_button"
+ android:src="@drawable/keyboard_arrow_right"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:layout_gravity="center_vertical"
+ style="?android:attr/borderlessButtonStyle" />
+ </LinearLayout>
+ </LinearLayout>
</LinearLayout>
</FrameLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 25fca26..94d6384 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -78,6 +78,11 @@
<!-- Content description for preview pager. [CHAR LIMIT=NONE] -->
<string name="preview_pager_content_description">Preview</string>
+ <!-- Previous button for preview pager. [CHAR LIMIT=NONE] -->
+ <string name="preview_pager_previous_button">Previous preview</string>
+ <!-- Next button for preview pager. [CHAR LIMIT=NONE] -->
+ <string name="preview_pager_next_button">Next preview</string>
+
<!-- Content description for qrcode image. [CHAR LIMIT=none]-->
<string name="qr_code_content_description">QR code</string>
@@ -305,8 +310,6 @@
<!-- Title for Bluetooth device group with media capability group [CHAR LIMIT=none]-->
<string name="connected_device_media_device_title">Media devices</string>
- <!-- Title for temporary bond device group [CHAR LIMIT=none]-->
- <string name="connected_device_temp_bond_device_title">Guest devices</string>
<!-- Title for Bluetooth device group with media capability group [CHAR LIMIT=none]-->
<string name="connected_device_call_device_title">Call devices</string>
<!-- Title for connected device group [CHAR LIMIT=none]-->
diff --git a/res/xml/connected_devices.xml b/res/xml/connected_devices.xml
index e8c169c..06fb5a7 100644
--- a/res/xml/connected_devices.xml
+++ b/res/xml/connected_devices.xml
@@ -26,17 +26,6 @@
settings:allowDividerBelow="true"
settings:controller="com.android.settings.slices.SlicePreferenceController" />
- <PreferenceCategory
- android:key="audio_sharing_device_list"
- android:title="@string/audio_sharing_device_group_title"
- settings:controller="com.android.settings.connecteddevice.audiosharing.AudioSharingDevicePreferenceController">
- </PreferenceCategory>
-
- <PreferenceCategory
- android:key="temp_bond_device_list"
- android:title="@string/connected_device_temp_bond_device_title"
- settings:controller="com.android.settings.connecteddevice.audiosharing.TemporaryBondDeviceGroupController" />
-
<Preference
android:fragment="com.android.settings.connecteddevice.audiosharing.AudioSharingDashboardFragment"
android:icon="@drawable/ic_bt_le_audio_sharing"
@@ -46,6 +35,12 @@
settings:searchable="false" />
<PreferenceCategory
+ android:key="audio_sharing_device_list"
+ android:title="@string/audio_sharing_device_group_title"
+ settings:controller="com.android.settings.connecteddevice.audiosharing.AudioSharingDevicePreferenceController">
+ </PreferenceCategory>
+
+ <PreferenceCategory
android:key="available_device_list"
android:title="@string/connected_device_media_device_title"
settings:controller="com.android.settings.connecteddevice.AvailableMediaDeviceGroupController" />
diff --git a/src/com/android/settings/accessibility/TextReadingPreviewPreference.java b/src/com/android/settings/accessibility/TextReadingPreviewPreference.java
index 9161171..717da70 100644
--- a/src/com/android/settings/accessibility/TextReadingPreviewPreference.java
+++ b/src/com/android/settings/accessibility/TextReadingPreviewPreference.java
@@ -22,6 +22,7 @@
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
+import android.widget.ImageButton;
import android.widget.LinearLayout;
import androidx.preference.Preference;
@@ -99,6 +100,23 @@
(DotsPageIndicator) holder.findViewById(R.id.page_indicator);
updateAdapterIfNeeded(viewPager, pageIndicator, mPreviewAdapter);
updatePagerAndIndicator(viewPager, pageIndicator);
+ viewPager.setClipToOutline(true);
+
+ int layoutDirection =
+ getContext().getResources().getConfiguration().getLayoutDirection();
+ int previousId = (layoutDirection == View.LAYOUT_DIRECTION_RTL)
+ ? R.id.preview_right_button : R.id.preview_left_button;
+ int nextId = (layoutDirection == View.LAYOUT_DIRECTION_RTL)
+ ? R.id.preview_left_button : R.id.preview_right_button;
+ final ImageButton previousButton = previewLayout.findViewById(previousId);
+ final ImageButton nextButton = previewLayout.findViewById(nextId);
+
+ previousButton.setOnClickListener((view) -> setCurrentItem(getCurrentItem() - 1));
+ previousButton.setContentDescription(getContext().getString(
+ R.string.preview_pager_previous_button));
+ nextButton.setOnClickListener((view) -> setCurrentItem(getCurrentItem() + 1));
+ previousButton.setContentDescription(getContext().getString(
+ R.string.preview_pager_next_button));
}
@Override
@@ -158,7 +176,9 @@
Preconditions.checkNotNull(mPreviewAdapter,
"Preview adapter is null, you should init the preview adapter first");
- if (currentItem != mCurrentItem) {
+ if (currentItem < 0 || currentItem >= mPreviewAdapter.getCount()) {
+ return;
+ } else if (currentItem != mCurrentItem) {
mCurrentItem = currentItem;
notifyChanged();
}
diff --git a/src/com/android/settings/applications/specialaccess/notificationaccess/ApprovalPreferenceController.java b/src/com/android/settings/applications/specialaccess/notificationaccess/ApprovalPreferenceController.java
index 8ddf9f9..21f5a12 100644
--- a/src/com/android/settings/applications/specialaccess/notificationaccess/ApprovalPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/notificationaccess/ApprovalPreferenceController.java
@@ -22,7 +22,6 @@
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.os.AsyncTask;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
@@ -139,13 +138,8 @@
public void disable(final ComponentName cn) {
logSpecialPermissionChange(true, cn.getPackageName());
mNm.setNotificationListenerAccessGranted(cn, false);
- if (!mNm.isNotificationPolicyAccessGrantedForPackage(
- cn.getPackageName())) {
- if (android.app.Flags.modesApi()) {
- mNm.removeAutomaticZenRules(cn.getPackageName(), /* fromUser= */ true);
- } else {
- mNm.removeAutomaticZenRules(cn.getPackageName());
- }
+ if (!mNm.isNotificationPolicyAccessGrantedForPackage(cn.getPackageName())) {
+ mNm.removeAutomaticZenRules(cn.getPackageName(), /* fromUser= */ true);
}
}
diff --git a/src/com/android/settings/applications/specialaccess/notificationaccess/FriendlyWarningDialogFragment.java b/src/com/android/settings/applications/specialaccess/notificationaccess/FriendlyWarningDialogFragment.java
index c92f734..9782303 100644
--- a/src/com/android/settings/applications/specialaccess/notificationaccess/FriendlyWarningDialogFragment.java
+++ b/src/com/android/settings/applications/specialaccess/notificationaccess/FriendlyWarningDialogFragment.java
@@ -56,7 +56,7 @@
NotificationAccessDetails parent = (NotificationAccessDetails) getTargetFragment();
final String summary = getResources().getString(
- Flags.modesApi() && Flags.modesUi()
+ Flags.modesUi()
? R.string.notification_listener_disable_modes_warning_summary
: R.string.notification_listener_disable_warning_summary,
label);
diff --git a/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java b/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
index 53181fd..2b6e6ca 100644
--- a/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
+++ b/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
@@ -98,7 +98,7 @@
((TextView) content.findViewById(R.id.prompt)).setText(prompt);
((TextView) content.findViewById(R.id.settings_description)).setText(
- Flags.modesApi() && Flags.modesUi()
+ Flags.modesUi()
? R.string.nls_feature_modes_settings_summary
: R.string.nls_feature_settings_summary);
diff --git a/src/com/android/settings/applications/specialaccess/zenaccess/FriendlyWarningDialogFragment.java b/src/com/android/settings/applications/specialaccess/zenaccess/FriendlyWarningDialogFragment.java
index 38317ed..02c3830 100644
--- a/src/com/android/settings/applications/specialaccess/zenaccess/FriendlyWarningDialogFragment.java
+++ b/src/com/android/settings/applications/specialaccess/zenaccess/FriendlyWarningDialogFragment.java
@@ -59,12 +59,12 @@
final String label = args.getString(KEY_LABEL);
final String title = getResources().getString(
- Flags.modesApi() && Flags.modesUi()
+ Flags.modesUi()
? R.string.zen_modes_access_revoke_warning_dialog_title
: R.string.zen_access_revoke_warning_dialog_title,
label);
final String summary = getResources()
- .getString(Flags.modesApi() && Flags.modesUi()
+ .getString(Flags.modesUi()
? R.string.zen_modes_access_revoke_warning_dialog_summary
: R.string.zen_access_revoke_warning_dialog_summary);
diff --git a/src/com/android/settings/applications/specialaccess/zenaccess/ScaryWarningDialogFragment.java b/src/com/android/settings/applications/specialaccess/zenaccess/ScaryWarningDialogFragment.java
index b489602..7389334 100644
--- a/src/com/android/settings/applications/specialaccess/zenaccess/ScaryWarningDialogFragment.java
+++ b/src/com/android/settings/applications/specialaccess/zenaccess/ScaryWarningDialogFragment.java
@@ -57,12 +57,12 @@
final String label = args.getString(KEY_LABEL);
final String title = getResources().getString(
- Flags.modesApi() && Flags.modesUi()
+ Flags.modesUi()
? R.string.zen_modes_access_warning_dialog_title
: R.string.zen_access_warning_dialog_title,
label);
final String summary = getResources()
- .getString(Flags.modesApi() && Flags.modesUi()
+ .getString(Flags.modesUi()
? R.string.zen_modes_access_warning_dialog_summary
: R.string.zen_access_warning_dialog_summary);
diff --git a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java
index cfeeb0d..bf3b31d 100644
--- a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java
+++ b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessController.java
@@ -56,7 +56,7 @@
public void displayPreference(PreferenceScreen screen) {
Preference preference = screen.findPreference(getPreferenceKey());
if (preference != null) {
- preference.setTitle(Flags.modesApi() && Flags.modesUi()
+ preference.setTitle(Flags.modesUi()
? R.string.manage_zen_modes_access_title
: R.string.manage_zen_access_title);
}
@@ -116,11 +116,7 @@
public static void deleteRules(final Context context, final String pkg) {
final NotificationManager mgr = context.getSystemService(NotificationManager.class);
- if (android.app.Flags.modesApi()) {
- mgr.removeAutomaticZenRules(pkg, /* fromUser= */ true);
- } else {
- mgr.removeAutomaticZenRules(pkg);
- }
+ mgr.removeAutomaticZenRules(pkg, /* fromUser= */ true);
}
@VisibleForTesting
diff --git a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessDetails.java b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessDetails.java
index 9e71f7a..8241594 100644
--- a/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessDetails.java
+++ b/src/com/android/settings/applications/specialaccess/zenaccess/ZenAccessDetails.java
@@ -51,7 +51,7 @@
@Override
public void onResume() {
super.onResume();
- requireActivity().setTitle(Flags.modesApi() && Flags.modesUi()
+ requireActivity().setTitle(Flags.modesUi()
? R.string.manage_zen_modes_access_title
: R.string.manage_zen_access_title);
}
@@ -89,7 +89,7 @@
preference.setSummary(getString(R.string.zen_access_disabled_package_warning));
return;
}
- preference.setTitle(Flags.modesApi() && Flags.modesUi()
+ preference.setTitle(Flags.modesUi()
? R.string.zen_modes_access_detail_switch
: R.string.zen_access_detail_switch);
preference.setChecked(ZenAccessController.hasAccess(context, mPackageName));
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index 6773fdc..31ebeb7 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -1067,8 +1067,11 @@
mRemovalSidecar.setListener(mRemovalListener);
}
- mCalibrator = FeatureFactory.getFeatureFactory().getFingerprintFeatureProvider()
- .getUdfpsEnrollCalibrator(getActivity().getApplicationContext(), null, null);
+ if (!mLaunchedConfirm && !mIsEnrolling) {
+ mCalibrator = FeatureFactory.getFeatureFactory().getFingerprintFeatureProvider()
+ .getUdfpsEnrollCalibrator(getActivity().getApplicationContext(), null,
+ null);
+ }
}
private void updatePreferences() {
@@ -1517,6 +1520,11 @@
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
intent.putExtra(BiometricEnrollBase.EXTRA_KEY_CHALLENGE, mChallenge);
}
+
+ if (mCalibrator != null) {
+ intent.putExtras(mCalibrator.getExtrasForNextIntent());
+ }
+
startActivityForResult(intent, AUTO_ADD_FIRST_FINGERPRINT_REQUEST);
}
diff --git a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
index d97e93b..dab696e 100644
--- a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java
@@ -26,7 +26,6 @@
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.flags.Flags;
import com.android.settingslib.utils.ThreadUtils;
/** Controller to maintain available media Bluetooth devices */
@@ -61,14 +60,6 @@
@Override
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
- // If the device is temporary bond, it shouldn't be shown here.
- if (Flags.enableTemporaryBondDevicesUi()
- && BluetoothUtils.isTemporaryBondDevice(cachedDevice.getDevice())) {
- Log.d(TAG,
- "isFilterMatched() Filter out temporary bond device " + cachedDevice.getName());
- return false;
- }
-
final int currentAudioProfile;
if (mAudioMode == AudioManager.MODE_RINGTONE
@@ -88,7 +79,8 @@
// If device is LE Audio, it is compatible with HFP and A2DP.
// It would show in Available Devices group if the audio sharing flag is disabled or
// the device is not in the audio sharing session.
- if (cachedDevice.isConnectedLeAudioDevice()) {
+ if (cachedDevice.isConnectedLeAudioDevice()
+ || cachedDevice.hasConnectedLeAudioMemberDevice()) {
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)
&& BluetoothUtils.hasConnectedBroadcastSource(
cachedDevice, mLocalBtManager)) {
diff --git a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
index 03473cf..a0f5ea2 100644
--- a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java
@@ -57,14 +57,6 @@
@Override
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
- // If the device is temporary bond, it shouldn't be shown here.
- if (Flags.enableTemporaryBondDevicesUi()
- && BluetoothUtils.isTemporaryBondDevice(cachedDevice.getDevice())) {
- Log.d(TAG,
- "isFilterMatched() Filter out temporary bond device " + cachedDevice.getName());
- return false;
- }
-
final int currentAudioProfile;
if (mAudioMode == AudioManager.MODE_RINGTONE
@@ -85,7 +77,12 @@
// If device is Hearing Aid or LE Audio, it is compatible with HFP and A2DP.
// It would not show in Connected Devices group.
if (cachedDevice.isConnectedAshaHearingAidDevice()
- || cachedDevice.isConnectedLeAudioDevice()) {
+ || cachedDevice.isConnectedLeAudioDevice()
+ || cachedDevice.hasConnectedLeAudioMemberDevice()) {
+ if (DBG) {
+ Log.d(TAG, "isFilterMatched() device : " + cachedDevice.getName()
+ + ", isFilterMatched : false, ha or lea device");
+ }
return false;
}
// According to the current audio profile type,
diff --git a/src/com/android/settings/communal/CommunalPreferenceController.java b/src/com/android/settings/communal/CommunalPreferenceController.java
index f937468..e44afab 100644
--- a/src/com/android/settings/communal/CommunalPreferenceController.java
+++ b/src/com/android/settings/communal/CommunalPreferenceController.java
@@ -21,7 +21,6 @@
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.flags.Flags;
/**
* Controls the top-level Communal settings preference.
@@ -40,14 +39,15 @@
* Returns whether communal preferences are available.
*/
public static boolean isAvailable(Context context) {
+ if (!Utils.canCurrentUserDream(context)) {
+ return false;
+ }
+
if (context.getResources().getBoolean(R.bool.config_show_communal_settings)) {
- return Utils.canCurrentUserDream(context);
+ return true;
}
- if (context.getResources().getBoolean(R.bool.config_show_communal_settings_mobile)) {
- return Flags.enableHubModeSettingsOnMobile() && Utils.canCurrentUserDream(context);
- }
-
- return false;
+ return com.android.systemui.Flags.glanceableHubV2()
+ && context.getResources().getBoolean(R.bool.config_show_communal_settings_mobile);
}
}
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
index 528d128..65258fc 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
@@ -27,7 +27,6 @@
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.connecteddevice.audiosharing.AudioSharingDevicePreferenceController;
-import com.android.settings.connecteddevice.audiosharing.TemporaryBondDeviceGroupController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.overlay.SurveyFeatureProvider;
@@ -35,7 +34,6 @@
import com.android.settings.slices.SlicePreferenceController;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.HearingAidStatsLogUtils;
-import com.android.settingslib.flags.Flags;
import com.android.settingslib.search.SearchIndexable;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
@@ -84,9 +82,6 @@
}
if (BluetoothUtils.isAudioSharingUIAvailable(context)) {
use(AudioSharingDevicePreferenceController.class).init(this);
- if (Flags.enableTemporaryBondDevicesUi()) {
- use(TemporaryBondDeviceGroupController.class).init(this);
- }
}
use(AvailableMediaDeviceGroupController.class).init(this);
use(ConnectedDeviceGroupController.class).init(this);
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdater.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdater.java
index e57e53e..884c781 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdater.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdater.java
@@ -29,7 +29,6 @@
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.flags.Flags;
import com.android.settingslib.utils.ThreadUtils;
public class AudioSharingBluetoothDeviceUpdater extends BluetoothDeviceUpdater
@@ -52,20 +51,13 @@
@Override
public boolean isFilterMatched(CachedBluetoothDevice cachedDevice) {
- // If the device is temporary bond, it shouldn't be shown here.
- if (Flags.enableTemporaryBondDevicesUi()
- && BluetoothUtils.isTemporaryBondDevice(cachedDevice.getDevice())) {
- Log.d(TAG,
- "isFilterMatched() Filter out temporary bond device " + cachedDevice.getName());
- return false;
- }
-
boolean isFilterMatched = false;
if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) {
// If device is LE audio device and has a broadcast source,
// it would show in audio sharing devices group.
if (BluetoothUtils.isAudioSharingUIAvailable(mContext)
- && cachedDevice.isConnectedLeAudioDevice()
+ && (cachedDevice.isConnectedLeAudioDevice()
+ || cachedDevice.hasConnectedLeAudioMemberDevice())
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mLocalBtManager)) {
isFilterMatched = true;
}
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java
index 25180d8..a95f401 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceController.java
@@ -67,7 +67,6 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.stream.Collectors;
/** PreferenceController to control the dialog to choose the active device for calls and alarms */
public class AudioSharingCallAudioPreferenceController extends AudioSharingBasePreferenceController
@@ -404,21 +403,11 @@
private void updateDeviceItemsInSharingSession() {
mGroupedConnectedDevices = AudioSharingUtils.fetchConnectedDevicesByGroupId(mBtManager);
- if (Flags.enableTemporaryBondDevicesUi()) {
- mGroupedConnectedDevices =
- mGroupedConnectedDevices.entrySet().stream()
- .filter(entry -> !anyTemporaryBondDevice(entry.getValue()))
- .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
- }
mDeviceItemsInSharingSession =
AudioSharingUtils.buildOrderedConnectedLeadAudioSharingDeviceItem(
mBtManager, mGroupedConnectedDevices, /* filterByInSharing= */ true);
}
- private boolean anyTemporaryBondDevice(List<BluetoothDevice> connectedDevices) {
- return connectedDevices.stream().anyMatch(BluetoothUtils::isTemporaryBondDevice);
- }
-
@Nullable
private Pair<Integer, AudioSharingDeviceItem> getActiveItemWithIndex() {
List<AudioSharingDeviceItem> deviceItems = new ArrayList<>(mDeviceItemsInSharingSession);
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdater.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdater.java
index 548d17c..7f12ec8 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdater.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdater.java
@@ -62,7 +62,8 @@
if (isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)) {
// If device is LE audio device and in a sharing session on current sharing device,
// it would show in volume control group.
- if (cachedDevice.isConnectedLeAudioDevice()
+ if ((cachedDevice.isConnectedLeAudioDevice()
+ || cachedDevice.hasConnectedLeAudioMemberDevice())
&& BluetoothUtils.isBroadcasting(mBtManager)
&& BluetoothUtils.hasConnectedBroadcastSource(cachedDevice, mBtManager)) {
isFilterMatched = true;
diff --git a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupController.java b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupController.java
index be0ee0b..7b670a8 100644
--- a/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupController.java
+++ b/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupController.java
@@ -51,10 +51,9 @@
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
import com.android.settingslib.bluetooth.VolumeControlProfile;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -73,8 +72,9 @@
private final Executor mExecutor;
private final ContentObserver mSettingsObserver;
@Nullable private PreferenceGroup mPreferenceGroup;
- private List<AudioSharingDeviceVolumePreference> mVolumePreferences = new ArrayList<>();
- private Map<Integer, Integer> mValueMap = new HashMap<Integer, Integer>();
+ private CopyOnWriteArraySet<AudioSharingDeviceVolumePreference> mVolumePreferences =
+ new CopyOnWriteArraySet<>();
+ private ConcurrentHashMap<Integer, Integer> mValueMap = new ConcurrentHashMap<>();
private AtomicBoolean mCallbacksRegistered = new AtomicBoolean(false);
@VisibleForTesting
@@ -104,8 +104,8 @@
+ finalVolume
+ " for "
+ device.getAnonymizedAddress());
- mContext.getMainExecutor()
- .execute(() -> preference.setProgress(finalVolume));
+ AudioSharingUtils.postOnMainThread(mContext,
+ () -> preference.setProgress(finalVolume));
break;
}
}
@@ -196,7 +196,9 @@
public void onChange(boolean selfChange) {
Log.d(TAG, "onChange, fallback device group id has been changed");
for (AudioSharingDeviceVolumePreference preference : mVolumePreferences) {
- preference.setOrder(getPreferenceOrderForDevice(preference.getCachedDevice()));
+ int order = getPreferenceOrderForDevice(preference.getCachedDevice());
+ Log.d(TAG, "onChange: set order to " + order + " for " + preference);
+ AudioSharingUtils.postOnMainThread(mContext, () -> preference.setOrder(order));
}
}
}
@@ -240,52 +242,54 @@
@Override
public void onDeviceAdded(Preference preference) {
- if (mPreferenceGroup != null) {
- if (mPreferenceGroup.getPreferenceCount() == 0) {
- mPreferenceGroup.setVisible(true);
+ if (!(preference instanceof AudioSharingDeviceVolumePreference)) {
+ Log.d(TAG, "Skip onDeviceAdded, invalid preference type");
+ return;
+ }
+ var volumePref = (AudioSharingDeviceVolumePreference) preference;
+ mVolumePreferences.add(volumePref);
+ AudioSharingUtils.postOnMainThread(mContext, () -> {
+ if (mPreferenceGroup != null) {
+ if (mPreferenceGroup.getPreferenceCount() == 0) {
+ mPreferenceGroup.setVisible(true);
+ }
+ mPreferenceGroup.addPreference(volumePref);
}
- mPreferenceGroup.addPreference(preference);
- }
- if (preference instanceof AudioSharingDeviceVolumePreference) {
- var volumePref = (AudioSharingDeviceVolumePreference) preference;
- CachedBluetoothDevice cachedDevice = volumePref.getCachedDevice();
- volumePref.setOrder(getPreferenceOrderForDevice(cachedDevice));
- mVolumePreferences.add(volumePref);
- if (volumePref.getProgress() > 0) return;
- int volume = mValueMap.getOrDefault(BluetoothUtils.getGroupId(cachedDevice), -1);
- // If the volume is invalid, try to get the volume from AudioManager.STREAM_MUSIC
- int finalVolume = getAudioVolumeIfNeeded(volume);
- Log.d(
- TAG,
- "onDeviceAdded: set volume to "
- + finalVolume
- + " for "
- + cachedDevice.getDevice().getAnonymizedAddress());
- AudioSharingUtils.postOnMainThread(mContext, () -> volumePref.setProgress(finalVolume));
- }
+ });
+ CachedBluetoothDevice cachedDevice = volumePref.getCachedDevice();
+ String address = cachedDevice.getDevice() == null ? "null"
+ : cachedDevice.getDevice().getAnonymizedAddress();
+ int order = getPreferenceOrderForDevice(cachedDevice);
+ Log.d(TAG, "onDeviceAdded: set order to " + order + " for " + address);
+ AudioSharingUtils.postOnMainThread(mContext, () -> volumePref.setOrder(order));
+ int volume = mValueMap.getOrDefault(BluetoothUtils.getGroupId(cachedDevice), -1);
+ // If the volume is invalid, try to get the volume from AudioManager.STREAM_MUSIC
+ int finalVolume = getAudioVolumeIfNeeded(volume);
+ Log.d(TAG, "onDeviceAdded: set volume to " + finalVolume + " for " + address);
+ AudioSharingUtils.postOnMainThread(mContext, () -> volumePref.setProgress(finalVolume));
}
@Override
public void onDeviceRemoved(Preference preference) {
- if (mPreferenceGroup != null) {
- mPreferenceGroup.removePreference(preference);
- if (mPreferenceGroup.getPreferenceCount() == 0) {
- mPreferenceGroup.setVisible(false);
- }
+ if (!(preference instanceof AudioSharingDeviceVolumePreference)) {
+ Log.d(TAG, "Skip onDeviceRemoved, invalid preference type");
+ return;
}
- if (preference instanceof AudioSharingDeviceVolumePreference) {
- var volumePref = (AudioSharingDeviceVolumePreference) preference;
- if (mVolumePreferences.contains(volumePref)) {
- mVolumePreferences.remove(volumePref);
- }
- CachedBluetoothDevice device = volumePref.getCachedDevice();
- Log.d(
- TAG,
- "onDeviceRemoved: "
- + (device == null
- ? "null"
- : device.getDevice().getAnonymizedAddress()));
+ var volumePref = (AudioSharingDeviceVolumePreference) preference;
+ if (mVolumePreferences.contains(volumePref)) {
+ mVolumePreferences.remove(volumePref);
}
+ String address = volumePref.getCachedDevice().getDevice() == null ? "null"
+ : volumePref.getCachedDevice().getDevice().getAnonymizedAddress();
+ Log.d(TAG, "onDeviceRemoved: " + address);
+ AudioSharingUtils.postOnMainThread(mContext, () -> {
+ if (mPreferenceGroup != null) {
+ mPreferenceGroup.removePreference(volumePref);
+ if (mPreferenceGroup.getPreferenceCount() == 0) {
+ mPreferenceGroup.setVisible(false);
+ }
+ }
+ });
}
@Override
diff --git a/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupController.java b/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupController.java
deleted file mode 100644
index ff3aa2c..0000000
--- a/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupController.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.connecteddevice.audiosharing;
-
-import android.content.Context;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.VisibleForTesting;
-import androidx.lifecycle.DefaultLifecycleObserver;
-import androidx.lifecycle.LifecycleOwner;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceGroup;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.bluetooth.BluetoothDeviceUpdater;
-import com.android.settings.bluetooth.Utils;
-import com.android.settings.connecteddevice.DevicePreferenceCallback;
-import com.android.settings.core.BasePreferenceController;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settingslib.bluetooth.BluetoothCallback;
-import com.android.settingslib.bluetooth.BluetoothEventManager;
-import com.android.settingslib.bluetooth.BluetoothUtils;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.flags.Flags;
-import com.android.settingslib.utils.ThreadUtils;
-
-/**
- * Controller to maintain the {@link androidx.preference.PreferenceGroup} for all connected
- * temporary bond devices. It uses {@link DevicePreferenceCallback} to add/remove
- * {@link Preference}
- */
-public class TemporaryBondDeviceGroupController extends BasePreferenceController implements
- DefaultLifecycleObserver, DevicePreferenceCallback, BluetoothCallback {
- private static final String TAG = "TemporaryBondDeviceGroupController";
- private static final String KEY = "temp_bond_device_list";
-
- @Nullable
- private final BluetoothEventManager mEventManager;
- @Nullable
- private PreferenceGroup mPreferenceGroup;
- @Nullable
- private BluetoothDeviceUpdater mBluetoothDeviceUpdater;
-
-
- public TemporaryBondDeviceGroupController(@NonNull Context context) {
- super(context, KEY);
- LocalBluetoothManager btManager = Utils.getLocalBtManager(mContext);
- mEventManager = btManager == null ? null : btManager.getEventManager();
- }
-
- @Override
- public void onStart(@NonNull LifecycleOwner owner) {
- if (!isAvailable()) {
- Log.d(TAG, "Skip onStart(), feature is not supported.");
- return;
- }
- if (mEventManager == null) {
- Log.d(TAG, "onStart() Bluetooth is not supported on this device");
- return;
- }
- var unused = ThreadUtils.postOnBackgroundThread(() -> {
- mEventManager.registerCallback(this);
- if (mBluetoothDeviceUpdater != null) {
- mBluetoothDeviceUpdater.registerCallback();
- mBluetoothDeviceUpdater.refreshPreference();
- }
- });
- }
-
- @Override
- public void onStop(@NonNull LifecycleOwner owner) {
- var unused = ThreadUtils.postOnBackgroundThread(() -> {
- if (mBluetoothDeviceUpdater != null) {
- mBluetoothDeviceUpdater.unregisterCallback();
- }
- if (mEventManager != null) {
- mEventManager.unregisterCallback(this);
- return;
- }
- Log.d(TAG, "onStop() Bluetooth is not supported on this device");
- });
- }
-
- @Override
- public void displayPreference(@NonNull PreferenceScreen screen) {
- super.displayPreference(screen);
- mPreferenceGroup = screen.findPreference(KEY);
- if (mPreferenceGroup != null) {
- mPreferenceGroup.setVisible(false);
- }
-
- if (isAvailable() && mBluetoothDeviceUpdater != null) {
- mBluetoothDeviceUpdater.setPrefContext(screen.getContext());
- mBluetoothDeviceUpdater.forceUpdate();
- }
- }
-
- @Override
- public void onDeviceAdded(@NonNull Preference preference) {
- if (mPreferenceGroup != null) {
- mPreferenceGroup.addPreference(preference);
- Log.d(TAG, "Temporary bond device added");
- if (mPreferenceGroup.getPreferenceCount() == 1) {
- mPreferenceGroup.setVisible(true);
- }
- }
- }
-
- @Override
- public void onDeviceRemoved(@NonNull Preference preference) {
- if (mPreferenceGroup != null) {
- mPreferenceGroup.removePreference(preference);
- Log.d(TAG, "Temporary bond device removed");
- if (mPreferenceGroup.getPreferenceCount() == 0) {
- mPreferenceGroup.setVisible(false);
- }
- }
- }
-
- @Override
- public int getAvailabilityStatus() {
- return (BluetoothUtils.isAudioSharingUIAvailable(mContext)
- && mBluetoothDeviceUpdater != null && Flags.enableTemporaryBondDevicesUi())
- ? AVAILABLE_UNSEARCHABLE
- : UNSUPPORTED_ON_DEVICE;
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY;
- }
-
- /**
- * Initialize the controller.
- *
- * @param fragment The fragment to provide the context and metrics category for {@link
- * TemporaryBondDeviceGroupUpdater} and provide the host for dialogs.
- */
- public void init(@NonNull DashboardFragment fragment) {
- mBluetoothDeviceUpdater = new TemporaryBondDeviceGroupUpdater(fragment.getContext(),
- TemporaryBondDeviceGroupController.this,
- fragment.getMetricsCategory());
- }
-
- @VisibleForTesting
- void setBluetoothDeviceUpdater(@Nullable BluetoothDeviceUpdater bluetoothDeviceUpdater) {
- mBluetoothDeviceUpdater = bluetoothDeviceUpdater;
- }
-
- @VisibleForTesting
- void setPreferenceGroup(@Nullable PreferenceGroup preferenceGroup) {
- mPreferenceGroup = preferenceGroup;
- }
-}
diff --git a/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdater.java b/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdater.java
deleted file mode 100644
index 59e37c5..0000000
--- a/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdater.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.connecteddevice.audiosharing;
-
-import android.content.Context;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-
-import com.android.settings.bluetooth.BluetoothDeviceUpdater;
-import com.android.settings.connecteddevice.DevicePreferenceCallback;
-import com.android.settingslib.bluetooth.BluetoothUtils;
-import com.android.settingslib.bluetooth.CachedBluetoothDevice;
-import com.android.settingslib.flags.Flags;
-
-/** Maintain and update connected temporary bond bluetooth devices */
-public class TemporaryBondDeviceGroupUpdater extends BluetoothDeviceUpdater {
- private static final String TAG = "TemporaryBondDeviceGroupUpdater";
- private static final String PREF_KEY_PREFIX = "temp_bond_bt_";
-
- public TemporaryBondDeviceGroupUpdater(
- @NonNull Context context,
- @NonNull DevicePreferenceCallback devicePreferenceCallback,
- int metricsCategory) {
- super(context, devicePreferenceCallback, metricsCategory);
- }
-
- @Override
- public boolean isFilterMatched(@NonNull CachedBluetoothDevice cachedDevice) {
- // Only connected temporary bond device should be shown in this section when Audio
- // sharing UI is available.
- boolean isFilterMatched = Flags.enableTemporaryBondDevicesUi()
- && BluetoothUtils.isTemporaryBondDevice(cachedDevice.getDevice())
- && isDeviceConnected(cachedDevice) && isDeviceInCachedDevicesList(cachedDevice)
- && BluetoothUtils.isAudioSharingUIAvailable(mContext);
- Log.d(
- TAG,
- "isFilterMatched() device : "
- + cachedDevice.getName()
- + ", isFilterMatched : "
- + isFilterMatched);
- return isFilterMatched;
- }
-
- @Override
- protected String getPreferenceKeyPrefix() {
- return PREF_KEY_PREFIX;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- protected void update(CachedBluetoothDevice cachedBluetoothDevice) {
- super.update(cachedBluetoothDevice);
- Log.d(TAG, "Map : " + mPreferenceMap);
- }
-}
diff --git a/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragment.java b/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragment.java
index af03bab..5de96b3 100644
--- a/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragment.java
+++ b/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragment.java
@@ -59,6 +59,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.function.Consumer;
/**
* The Settings screen for External Displays configuration and connection management.
@@ -85,8 +86,6 @@
BUILTIN_DISPLAY_LIST(70, "builtin_display_list_preference",
R.string.builtin_display_settings_category),
- DISPLAYS_LIST(80, "displays_list_preference", null),
-
// If shown, footer should appear below everything.
FOOTER(90, "footer_preference", null);
@@ -334,15 +333,6 @@
}
@NonNull
- private PreferenceCategory getDisplaysListPreference(@NonNull Context context) {
- if (mDisplaysPreference == null) {
- mDisplaysPreference = new PreferenceCategory(context);
- PrefBasics.DISPLAYS_LIST.apply(mDisplaysPreference);
- }
- return mDisplaysPreference;
- }
-
- @NonNull
private PreferenceCategory getBuiltinDisplayListPreference(@NonNull Context context) {
if (mBuiltinDisplayPreference == null) {
mBuiltinDisplayPreference = new PreferenceCategory(context);
@@ -455,6 +445,26 @@
EXTERNAL_DISPLAY_NOT_FOUND_FOOTER_RESOURCE));
}
+ private static PreferenceCategory getCategoryForDisplay(@NonNull Display display,
+ @NonNull PrefRefresh screen, @NonNull Context context) {
+ // The rest of the settings are in a category with the display name as the title.
+ String categoryKey = "expanded_display_items_" + display.getDisplayId();
+ var category = (PreferenceCategory) screen.findUnusedPreference(categoryKey);
+
+ if (category != null) {
+ screen.addPreference(category);
+ } else {
+ category = new PreferenceCategory(context);
+ screen.addPreference(category);
+ category.setPersistent(false);
+ category.setKey(categoryKey);
+ category.setTitle(display.getName());
+ category.setOrder(PrefBasics.BUILTIN_DISPLAY_LIST.order + 1);
+ }
+
+ return category;
+ }
+
private void showDisplaySettings(@NonNull Display display, @NonNull PrefRefresh screen,
@NonNull Context context) {
final var isEnabled = mInjector != null && mInjector.isDisplayEnabled(display);
@@ -469,8 +479,18 @@
if (!isTopologyPaneEnabled(mInjector)) {
screen.addPreference(updateIllustrationImage(context, displayRotation));
}
- screen.addPreference(updateResolutionPreference(context, display));
- screen.addPreference(updateRotationPreference(context, display, displayRotation));
+
+ Consumer<Preference> adder;
+ if (isTopologyPaneEnabled(mInjector)) {
+ adder = getCategoryForDisplay(display, screen, context)::addPreference;
+ // The category may have already been populated if it was retrieved from the PrefRefresh
+ // backup, but we still need to update resolution and rotation items.
+ } else {
+ adder = screen::addPreference;
+ }
+
+ adder.accept(updateResolutionPreference(context, display));
+ adder.accept(updateRotationPreference(context, display, displayRotation));
if (isResolutionSettingEnabled(mInjector)) {
// Do not show the footer about changing resolution affecting apps. This is not in the
// UX design for v2, and there is no good place to put it, since (a) if it is on the
@@ -483,12 +503,12 @@
// TODO(b/352648432): probably remove footer once the pane and rest of v2 UI is in
// place.
if (!isTopologyPaneEnabled(mInjector)) {
- screen.addPreference(updateFooterPreference(context,
+ adder.accept(updateFooterPreference(context,
EXTERNAL_DISPLAY_CHANGE_RESOLUTION_FOOTER_RESOURCE));
}
}
if (isDisplaySizeSettingEnabled(mInjector)) {
- screen.addPreference(updateSizePreference(context));
+ adder.accept(updateSizePreference(context));
}
}
@@ -508,23 +528,28 @@
private void showDisplaysList(@NonNull List<Display> displaysToShow,
@NonNull PrefRefresh screen, @NonNull Context context) {
maybeAddV2Components(context, screen);
- var displayGroupPref = getDisplaysListPreference(context);
- if (!displaysToShow.isEmpty()) {
- screen.addPreference(displayGroupPref);
- }
- try (var groupCleanable = new PrefRefresh(displayGroupPref)) {
- for (var display : displaysToShow) {
- var pref = getDisplayPreference(context, display, groupCleanable);
- pref.setSummary(display.getMode().getPhysicalWidth() + " x "
- + display.getMode().getPhysicalHeight());
- }
+ int order = PrefBasics.BUILTIN_DISPLAY_LIST.order;
+ for (var display : displaysToShow) {
+ var pref = getDisplayPreference(context, display, screen, ++order);
+ pref.setSummary(display.getMode().getPhysicalWidth() + " x "
+ + display.getMode().getPhysicalHeight());
}
}
+ @VisibleForTesting
+ static String displayListDisplayCategoryKey(int displayId) {
+ return "display_list_display_category_" + displayId;
+ }
+
+ @VisibleForTesting
+ static String resolutionRotationPreferenceKey(int displayId) {
+ return "display_id_" + displayId;
+ }
+
private Preference getDisplayPreference(@NonNull Context context,
- @NonNull Display display, @NonNull PrefRefresh groupCleanable) {
- var itemKey = "display_id_" + display.getDisplayId();
- var categoryKey = itemKey + "_category";
+ @NonNull Display display, @NonNull PrefRefresh groupCleanable, int categoryOrder) {
+ var itemKey = resolutionRotationPreferenceKey(display.getDisplayId());
+ var categoryKey = displayListDisplayCategoryKey(display.getDisplayId());
var category = (PreferenceCategory) groupCleanable.findUnusedPreference(categoryKey);
if (category != null) {
@@ -534,6 +559,7 @@
category = new PreferenceCategory(context);
category.setPersistent(false);
category.setKey(categoryKey);
+ category.setOrder(categoryOrder);
// Must add the category to the hierarchy before adding its descendants. Otherwise
// the category will not have a preference manager, which causes an exception when a
// child is added to it.
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index c0caff7..cb8e6fc 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -475,7 +475,10 @@
updatePrivateStorageCategoryPreferencesOrder();
mIsPreferenceOrderedBySize = true;
}
- setPrivateStorageCategoryPreferencesVisibility(true);
+
+ if (isValidPrivateVolume()) {
+ setPrivateStorageCategoryPreferencesVisibility(true);
+ }
}
private StorageCacheHelper.StorageCache getSizeInfo(
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java b/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java
index 314ccec..795420c 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java
@@ -16,7 +16,6 @@
package com.android.settings.homepage.contextualcards.conditional;
-import android.app.Flags;
import android.app.NotificationManager;
import android.app.settings.SettingsEnums;
import android.content.BroadcastReceiver;
@@ -87,12 +86,8 @@
@Override
public void onActionClick() {
- if (Flags.modesApi()) {
- mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_OFF, null, TAG,
- /* fromUser= */ true);
- } else {
- mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_OFF, null, TAG);
- }
+ mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_OFF, null, TAG,
+ /* fromUser= */ true);
}
@Override
diff --git a/src/com/android/settings/network/telephony/SubscriptionActivationRepository.kt b/src/com/android/settings/network/telephony/SubscriptionActivationRepository.kt
index 185af0c..a7f6a0b 100644
--- a/src/com/android/settings/network/telephony/SubscriptionActivationRepository.kt
+++ b/src/com/android/settings/network/telephony/SubscriptionActivationRepository.kt
@@ -52,7 +52,7 @@
Log.i(TAG, "Unable to toggle subscription due to unusable subscription ID.")
return
}
- if (!active && isEmergencyCallbackMode(subId)) {
+ if (isEmergencyCallbackMode(subId)) {
val intent = Intent(ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS).apply {
setPackage(Utils.PHONE_PACKAGE_NAME)
}
diff --git a/src/com/android/settings/notification/modes/AbstractZenModeHeaderController.java b/src/com/android/settings/notification/modes/AbstractZenModeHeaderController.java
index 1d1b07d..3d25926 100644
--- a/src/com/android/settings/notification/modes/AbstractZenModeHeaderController.java
+++ b/src/com/android/settings/notification/modes/AbstractZenModeHeaderController.java
@@ -59,7 +59,7 @@
@Override
public boolean isAvailable() {
- return Flags.modesApi() && Flags.modesUi();
+ return Flags.modesUi();
}
protected void setUpHeader(PreferenceScreen screen, int iconSizePx) {
diff --git a/src/com/android/settings/notification/modes/ZenSettingsObserver.java b/src/com/android/settings/notification/modes/ZenSettingsObserver.java
index 0f22d7d..280d76c 100644
--- a/src/com/android/settings/notification/modes/ZenSettingsObserver.java
+++ b/src/com/android/settings/notification/modes/ZenSettingsObserver.java
@@ -43,7 +43,7 @@
}
void register() {
- if (Flags.modesApi() && Flags.modesUi()) {
+ if (Flags.modesUi()) {
mContext.getContentResolver().registerContentObserver(ZEN_MODE_URI, false, this);
mContext.getContentResolver().registerContentObserver(ZEN_MODE_CONFIG_ETAG_URI, false,
this);
@@ -51,7 +51,7 @@
}
void unregister() {
- if (Flags.modesApi() && Flags.modesUi()) {
+ if (Flags.modesUi()) {
mContext.getContentResolver().unregisterContentObserver(this);
}
}
diff --git a/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceController.java b/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceController.java
index 3a809d0..59c0a5c 100644
--- a/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceController.java
+++ b/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceController.java
@@ -167,7 +167,7 @@
mMetricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_ZEN_MODE_RULE_NAME_CHANGE_OK);
AutomaticZenRule rule;
- if (Flags.modesApi() && Flags.modesUi()) {
+ if (Flags.modesUi()) {
rule = new AutomaticZenRule.Builder(ruleName, mRuleInfo.defaultConditionId)
.setType(mRuleInfo.type)
.setOwner(mRuleInfo.serviceComponent)
diff --git a/src/com/android/settings/notification/zen/ZenAccessSettings.java b/src/com/android/settings/notification/zen/ZenAccessSettings.java
index ebf91bf..6727bfb 100644
--- a/src/com/android/settings/notification/zen/ZenAccessSettings.java
+++ b/src/com/android/settings/notification/zen/ZenAccessSettings.java
@@ -76,7 +76,7 @@
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- setEmptyText(Flags.modesApi() && Flags.modesUi()
+ setEmptyText(Flags.modesUi()
? R.string.zen_modes_access_empty_text
: R.string.zen_access_empty_text);
}
@@ -89,7 +89,7 @@
@Override
public void onResume() {
super.onResume();
- requireActivity().setTitle(Flags.modesApi() && Flags.modesUi()
+ requireActivity().setTitle(Flags.modesUi()
? R.string.manage_zen_modes_access_title
: R.string.manage_zen_access_title);
reloadList();
@@ -145,7 +145,7 @@
pref.setOnPreferenceClickListener(preference -> {
AppInfoBase.startAppInfoFragment(
ZenAccessDetails.class /* fragment */,
- getString(Flags.modesApi() && Flags.modesUi()
+ getString(Flags.modesUi()
? R.string.manage_zen_modes_access_title
: R.string.manage_zen_access_title),
pkg,
diff --git a/src/com/android/settings/notification/zen/ZenModeBackend.java b/src/com/android/settings/notification/zen/ZenModeBackend.java
index 2eb87c5..093da67 100644
--- a/src/com/android/settings/notification/zen/ZenModeBackend.java
+++ b/src/com/android/settings/notification/zen/ZenModeBackend.java
@@ -95,32 +95,19 @@
}
protected boolean updateZenRule(String id, AutomaticZenRule rule) {
- if (android.app.Flags.modesApi()) {
- return mNotificationManager.updateAutomaticZenRule(id, rule, /* fromUser= */ true);
- } else {
- return NotificationManager.from(mContext).updateAutomaticZenRule(id, rule);
- }
+ return mNotificationManager.updateAutomaticZenRule(id, rule, /* fromUser= */ true);
}
protected void setZenMode(int zenMode) {
- if (android.app.Flags.modesApi()) {
- mNotificationManager.setZenMode(zenMode, null, TAG, /* fromUser= */ true);
- } else {
- NotificationManager.from(mContext).setZenMode(zenMode, null, TAG);
- }
+ mNotificationManager.setZenMode(zenMode, null, TAG, /* fromUser= */ true);
mZenMode = getZenMode();
}
protected void setZenModeForDuration(int minutes) {
Uri conditionId = ZenModeConfig.toTimeCondition(mContext, minutes,
ActivityManager.getCurrentUser(), true).id;
- if (android.app.Flags.modesApi()) {
- mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS,
- conditionId, TAG, /* fromUser= */ true);
- } else {
- mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS,
- conditionId, TAG);
- }
+ mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS,
+ conditionId, TAG, /* fromUser= */ true);
mZenMode = getZenMode();
}
@@ -190,14 +177,9 @@
int priorityConversationSenders) {
mPolicy = new NotificationManager.Policy(priorityCategories, priorityCallSenders,
priorityMessageSenders, suppressedVisualEffects, priorityConversationSenders);
- if (android.app.Flags.modesApi()) {
- mNotificationManager.setNotificationPolicy(mPolicy, /* fromUser= */ true);
- } else {
- mNotificationManager.setNotificationPolicy(mPolicy);
- }
+ mNotificationManager.setNotificationPolicy(mPolicy, /* fromUser= */ true);
}
-
private int getNewSuppressedEffects(boolean suppress, int effectType) {
int effects = mPolicy.suppressedVisualEffects;
@@ -373,11 +355,7 @@
}
public boolean removeZenRule(String ruleId) {
- if (android.app.Flags.modesApi()) {
- return mNotificationManager.removeAutomaticZenRule(ruleId, /* fromUser= */ true);
- } else {
- return NotificationManager.from(mContext).removeAutomaticZenRule(ruleId);
- }
+ return mNotificationManager.removeAutomaticZenRule(ruleId, /* fromUser= */ true);
}
public NotificationManager.Policy getConsolidatedPolicy() {
@@ -386,11 +364,7 @@
protected String addZenRule(AutomaticZenRule rule) {
try {
- if (android.app.Flags.modesApi()) {
- return mNotificationManager.addAutomaticZenRule(rule, /* fromUser= */ true);
- } else {
- return NotificationManager.from(mContext).addAutomaticZenRule(rule);
- }
+ return mNotificationManager.addAutomaticZenRule(rule, /* fromUser= */ true);
} catch (Exception e) {
return null;
}
diff --git a/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java b/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java
index 4c647cc..9e23e36 100644
--- a/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java
+++ b/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java
@@ -104,16 +104,11 @@
Bundle bundle = new Bundle();
bundle.putString(ZenCustomRuleSettings.RULE_ID, mId);
- // When modes_api flag is on, we skip the radio button screen distinguishing
- // between "default" and "custom" and take users directly to the custom
- // settings screen.
- String destination = ZenCustomRuleSettings.class.getName();
- int sourceMetricsCategory = 0;
- if (Flags.modesApi()) {
- // From ZenRuleCustomPolicyPreferenceController#launchCustomSettings
- destination = ZenCustomRuleConfigSettings.class.getName();
- sourceMetricsCategory = SettingsEnums.ZEN_CUSTOM_RULE_SOUND_SETTINGS;
- }
+ // Skip the radio button screen distinguishing between "default" and
+ // "custom" and take users directly to the custom settings screen.
+ // From ZenRuleCustomPolicyPreferenceController#launchCustomSettings
+ String destination = ZenCustomRuleConfigSettings.class.getName();
+ int sourceMetricsCategory = SettingsEnums.ZEN_CUSTOM_RULE_SOUND_SETTINGS;
new SubSettingLauncher(mContext)
.setDestination(destination)
.setArguments(bundle)
@@ -165,7 +160,7 @@
protected void updateScheduleRule(ZenModeConfig.ScheduleInfo schedule) {
mRule.setConditionId(ZenModeConfig.toScheduleConditionId(schedule));
- if (Flags.modesApi() && Flags.modesUi()) {
+ if (Flags.modesUi()) {
mRule.setTriggerDescription(
SystemZenRules.getTriggerDescriptionForScheduleTime(mContext, schedule));
}
@@ -174,7 +169,7 @@
protected void updateEventRule(ZenModeConfig.EventInfo event) {
mRule.setConditionId(ZenModeConfig.toEventConditionId(event));
- if (Flags.modesApi() && Flags.modesUi()) {
+ if (Flags.modesUi()) {
mRule.setTriggerDescription(
SystemZenRules.getTriggerDescriptionForScheduleEvent(mContext, event));
}
diff --git a/src/com/android/settings/notification/zen/ZenModeSliceBuilder.java b/src/com/android/settings/notification/zen/ZenModeSliceBuilder.java
index d16b1e4..8adeac5 100644
--- a/src/com/android/settings/notification/zen/ZenModeSliceBuilder.java
+++ b/src/com/android/settings/notification/zen/ZenModeSliceBuilder.java
@@ -19,7 +19,6 @@
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
import android.annotation.ColorInt;
-import android.app.Flags;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.settings.SettingsEnums;
@@ -117,12 +116,8 @@
} else {
zenMode = Settings.Global.ZEN_MODE_OFF;
}
- if (Flags.modesApi()) {
- NotificationManager.from(context).setZenMode(zenMode, /* conditionId= */ null, TAG,
- /* fromUser= */ true);
- } else {
- NotificationManager.from(context).setZenMode(zenMode, null /* conditionId */, TAG);
- }
+ NotificationManager.from(context).setZenMode(zenMode, /* conditionId= */ null, TAG,
+ /* fromUser= */ true);
// Do not notifyChange on Uri. The service takes longer to update the current value than it
// does for the Slice to check the current value again. Let {@link SliceBroadcastRelay}
// handle it.
diff --git a/src/com/android/settings/notification/zen/ZenRuleButtonsPreferenceController.java b/src/com/android/settings/notification/zen/ZenRuleButtonsPreferenceController.java
index 082b2a5..2ae1137 100644
--- a/src/com/android/settings/notification/zen/ZenRuleButtonsPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenRuleButtonsPreferenceController.java
@@ -19,19 +19,14 @@
import android.app.AutomaticZenRule;
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import androidx.fragment.app.Fragment;
-import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
-import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.widget.ActionButtonsPreference;
@@ -87,7 +82,6 @@
mMetricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_ZEN_MODE_RULE_NAME_CHANGE_OK);
mRule.setName(ruleName);
- mRule.setModified(true);
mBackend.updateZenRule(mId, mRule);
}
});
diff --git a/src/com/android/settings/notification/zen/ZenRulePreference.java b/src/com/android/settings/notification/zen/ZenRulePreference.java
index 0630213..32b2a88 100644
--- a/src/com/android/settings/notification/zen/ZenRulePreference.java
+++ b/src/com/android/settings/notification/zen/ZenRulePreference.java
@@ -143,8 +143,7 @@
private String computeRuleSummary(AutomaticZenRule rule) {
if (rule != null) {
- if (Flags.modesApi() && Flags.modesUi()
- && !TextUtils.isEmpty(rule.getTriggerDescription())) {
+ if (Flags.modesUi() && !TextUtils.isEmpty(rule.getTriggerDescription())) {
return rule.getTriggerDescription();
}
diff --git a/src/com/android/settings/notification/zen/ZenRuleSelectionDialog.java b/src/com/android/settings/notification/zen/ZenRuleSelectionDialog.java
index 4896066..7a1df04 100644
--- a/src/com/android/settings/notification/zen/ZenRuleSelectionDialog.java
+++ b/src/com/android/settings/notification/zen/ZenRuleSelectionDialog.java
@@ -181,7 +181,7 @@
rt.title = mContext.getString(R.string.zen_schedule_rule_type_name);
rt.packageName = ZenModeConfig.getEventConditionProvider().getPackageName();
rt.defaultConditionId = ZenModeConfig.toScheduleConditionId(schedule);
- if (Flags.modesApi() && Flags.modesUi()) {
+ if (Flags.modesUi()) {
rt.type = AutomaticZenRule.TYPE_SCHEDULE_TIME;
rt.defaultTriggerDescription = SystemZenRules.getTriggerDescriptionForScheduleTime(
mContext, schedule);
@@ -201,7 +201,7 @@
rt.title = mContext.getString(R.string.zen_event_rule_type_name);
rt.packageName = ZenModeConfig.getScheduleConditionProvider().getPackageName();
rt.defaultConditionId = ZenModeConfig.toEventConditionId(event);
- if (Flags.modesApi() && Flags.modesUi()) {
+ if (Flags.modesUi()) {
rt.type = AutomaticZenRule.TYPE_SCHEDULE_CALENDAR;
rt.defaultTriggerDescription = SystemZenRules.getTriggerDescriptionForScheduleEvent(
mContext, event);
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index 80f73b9..7892ac4 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -560,6 +560,7 @@
setupPasswordRequirementsView(headerLayout);
mPasswordRestrictionView.setLayoutManager(new LinearLayoutManager(getActivity()));
+ mPasswordRestrictionView.setAccessibilityLiveRegion(ACCESSIBILITY_LIVE_REGION_POLITE);
mPasswordEntry = view.findViewById(R.id.password_entry);
mPasswordEntry.setOnEditorActionListener(this);
mPasswordEntry.addTextChangedListener(this);
@@ -770,7 +771,7 @@
// If the stage changed, announce the header for accessibility. This
// is a no-op when accessibility is disabled.
if (previousStage != stage) {
- mLayout.announceForAccessibility(mLayout.getHeaderText());
+ getActivity().setTitle(mLayout.getHeaderText());
}
}
diff --git a/src/com/android/settings/password/PasswordRequirementAdapter.java b/src/com/android/settings/password/PasswordRequirementAdapter.java
index b17f864..157a716 100644
--- a/src/com/android/settings/password/PasswordRequirementAdapter.java
+++ b/src/com/android/settings/password/PasswordRequirementAdapter.java
@@ -20,9 +20,9 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.TextView;
-import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.R;
@@ -67,14 +67,19 @@
}
@Override
- public void onViewAttachedToWindow(@NonNull PasswordRequirementViewHolder holder) {
- holder.mDescriptionText.announceForAccessibility(holder.mDescriptionText.getText());
- }
-
- @Override
public void onBindViewHolder(PasswordRequirementViewHolder holder, int position) {
final int fontSize = mContext.getResources().getDimensionPixelSize(
R.dimen.password_requirement_font_size);
+
+ final String requirement = mRequirements[position];
+ holder.mDescriptionText.setAccessibilityDelegate(new View.AccessibilityDelegate() {
+ @Override
+ public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
+ super.onInitializeAccessibilityNodeInfo(host, info);
+ holder.mDescriptionText.setStateDescription(requirement);
+ }
+ });
+
holder.mDescriptionText.setText(mRequirements[position]);
if (mIsTooShortError) {
holder.mDescriptionText.setTextAppearance(R.style.ScreenLockPasswordHintTextFontStyle);
diff --git a/src/com/android/settings/shortcut/ShortcutsUpdateReceiver.java b/src/com/android/settings/shortcut/ShortcutsUpdateReceiver.java
index 657af5b..3fde390 100644
--- a/src/com/android/settings/shortcut/ShortcutsUpdateReceiver.java
+++ b/src/com/android/settings/shortcut/ShortcutsUpdateReceiver.java
@@ -32,7 +32,7 @@
@Override
public void onReceive(@NonNull Context context, @NonNull Intent intent) {
- if (!Flags.modesApi() || !Flags.modesUi()) {
+ if (!Flags.modesUi()) {
return;
}
diff --git a/src/com/android/settings/shortcut/ShortcutsUpdater.java b/src/com/android/settings/shortcut/ShortcutsUpdater.java
index 90a60fd..30cb5c1 100644
--- a/src/com/android/settings/shortcut/ShortcutsUpdater.java
+++ b/src/com/android/settings/shortcut/ShortcutsUpdater.java
@@ -86,7 +86,7 @@
private static ComponentName maybeGetReplacingComponent(Context context, ComponentName cn) {
// ZenModeSettingsActivity is replaced by ModesSettingsActivity and will be deleted
// soon (so we shouldn't use ZenModeSettingsActivity.class).
- if (Flags.modesApi() && Flags.modesUi()
+ if (Flags.modesUi()
&& cn.getClassName().endsWith("Settings$ZenModeSettingsActivity")) {
return new ComponentName(context, Settings.ModesSettingsActivity.class);
}
diff --git a/src/com/android/settings/sound/TopLevelSoundPreferenceController.java b/src/com/android/settings/sound/TopLevelSoundPreferenceController.java
index ddc3399..c219d7c 100644
--- a/src/com/android/settings/sound/TopLevelSoundPreferenceController.java
+++ b/src/com/android/settings/sound/TopLevelSoundPreferenceController.java
@@ -33,7 +33,7 @@
@Override
public void updateState(Preference preference) {
super.updateState(preference);
- preference.setSummary(Flags.modesApi() && Flags.modesUi()
+ preference.setSummary(Flags.modesUi()
? R.string.sound_dashboard_summary
: R.string.sound_dashboard_summary_with_dnd);
}
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index 464d970..bb70a70 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -77,6 +77,7 @@
"platform-test-annotations",
"testables",
"android.app.flags-aconfig-java",
+ "com_android_systemui_flags_lib",
],
libs: [
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
index 2251c3b..87d7aed 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
@@ -283,6 +283,28 @@
}
@Test
+ public void
+ onProfileConnectionStateChanged_hasLeaMemberConnected_notInCallFlagOff_addPref() {
+ mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
+ setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
+ when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
+ .thenReturn(true);
+ when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
+ when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
+ when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mBroadcastReceiveState));
+ List<Long> bisSyncState = new ArrayList<>();
+ bisSyncState.add(1L);
+ when(mBroadcastReceiveState.getBisSyncState()).thenReturn(bisSyncState);
+
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+
+ verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
+ }
+
+ @Test
public void onProfileConnectionStateChanged_leaConnected_notInCallNotInSharing_addPref() {
mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
@@ -300,6 +322,25 @@
}
@Test
+ public void
+ onProfileConnectionStateChanged_hasLeaMemberConnected_notInCallNotInSharing_addPref() {
+ mSetFlagsRule.enableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
+ setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
+ when(mBluetoothDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class)))
+ .thenReturn(true);
+ when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
+ when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
+ when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of());
+
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+
+ verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice);
+ }
+
+ @Test
public void onProfileConnectionStateChanged_leaConnected_inCallSharingFlagOff_addPref() {
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_IN_CALL);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
index ad155ff..b2babc3 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
@@ -68,9 +68,6 @@
private static final String MAC_ADDRESS = "04:52:C7:0B:D8:3C";
private static final String TEST_EXCLUSIVE_MANAGER = "com.test.manager";
- private static final String TEMP_BOND_METADATA =
- "<TEMP_BOND_TYPE>le_audio_sharing</TEMP_BOND_TYPE>";
- private static final int METADATA_FAST_PAIR_CUSTOMIZED_FIELDS = 25;
@Rule
public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
@@ -273,6 +270,20 @@
}
@Test
+ public void onProfileConnectionStateChanged_hasLeaMemberConnected_inCall_removesPreference() {
+ setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_IN_CALL);
+ when(mBluetoothDeviceUpdater
+ .isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
+ when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
+ when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
+
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
+
+ verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
+ }
+
+ @Test
public void onProfileConnectionStateChanged_leAudioDeviceConnected_notInCall_removesPreference()
{
setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
@@ -285,6 +296,22 @@
verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
}
+
+ @Test
+ public void
+ onProfileConnectionStateChanged_hasLeaMemberConnected_notInCall_removesPreference() {
+ setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
+ when(mBluetoothDeviceUpdater
+ .isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
+ when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
+ when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
+
+ mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED, BluetoothProfile.LE_AUDIO);
+
+ verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
+ }
+
@Test
public void onProfileConnectionStateChanged_deviceIsNotInList_inCall_invokesRemovesPreference()
{
@@ -408,22 +435,6 @@
verify(mBluetoothDeviceUpdater, never()).addPreference(mCachedBluetoothDevice);
}
- @Test
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI)
- public void update_temporaryBondDevice_removePreference() {
- setUpDeviceUpdaterWithAudioMode(AudioManager.MODE_NORMAL);
- when(mBluetoothDeviceUpdater
- .isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
- when(mCachedBluetoothDevice.isConnectedHfpDevice()).thenReturn(true);
- when(mBluetoothDevice.getMetadata(METADATA_FAST_PAIR_CUSTOMIZED_FIELDS))
- .thenReturn(TEMP_BOND_METADATA.getBytes());
-
- mBluetoothDeviceUpdater.update(mCachedBluetoothDevice);
-
- verify(mBluetoothDeviceUpdater).removePreference(mCachedBluetoothDevice);
- verify(mBluetoothDeviceUpdater, never()).addPreference(mCachedBluetoothDevice);
- }
-
private void setUpDeviceUpdaterWithAudioMode(int audioMode) {
mAudioManager.setMode(audioMode);
mBluetoothDeviceUpdater = spy(new ConnectedBluetoothDeviceUpdater(mContext,
diff --git a/tests/robotests/src/com/android/settings/communal/CommunalPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/communal/CommunalPreferenceControllerTest.java
index b88b1aa..cc970eb 100644
--- a/tests/robotests/src/com/android/settings/communal/CommunalPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/communal/CommunalPreferenceControllerTest.java
@@ -17,6 +17,7 @@
package com.android.settings.communal;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2;
import static com.google.common.truth.Truth.assertThat;
@@ -34,7 +35,6 @@
import android.platform.test.flag.junit.SetFlagsRule;
import com.android.settings.R;
-import com.android.settings.flags.Flags;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowUserManager;
@@ -87,7 +87,7 @@
}
@Test
- @EnableFlags(Flags.FLAG_ENABLE_HUB_MODE_SETTINGS_ON_MOBILE)
+ @EnableFlags(FLAG_GLANCEABLE_HUB_V2)
public void isAvailable_communalOnMobileEnabled_shouldBeTrueForPrimaryUser() {
setCommunalEnabled(false);
setCommunalOnMobileEnabled(true);
@@ -96,7 +96,7 @@
}
@Test
- @EnableFlags(Flags.FLAG_ENABLE_HUB_MODE_SETTINGS_ON_MOBILE)
+ @EnableFlags(FLAG_GLANCEABLE_HUB_V2)
public void isAvailable_communalOnMobileEnabled_shouldBeFalseForSecondaryUser() {
setCommunalEnabled(false);
setCommunalOnMobileEnabled(true);
@@ -105,7 +105,7 @@
}
@Test
- @EnableFlags(Flags.FLAG_ENABLE_HUB_MODE_SETTINGS_ON_MOBILE)
+ @EnableFlags(FLAG_GLANCEABLE_HUB_V2)
public void isAvailable_communalOnMobileDisabled_shouldBeFalseForPrimaryUser() {
setCommunalEnabled(false);
setCommunalOnMobileEnabled(false);
@@ -114,8 +114,8 @@
}
@Test
- @DisableFlags(Flags.FLAG_ENABLE_HUB_MODE_SETTINGS_ON_MOBILE)
- public void isAvailable_hubModeSettingsOnMobileFlagDisabled_shouldBeFalseForPrimaryUser() {
+ @DisableFlags(FLAG_GLANCEABLE_HUB_V2)
+ public void isAvailable_glanceableHubV2FlagDisabled_shouldBeFalseForPrimaryUser() {
setCommunalEnabled(false);
setCommunalOnMobileEnabled(true);
mShadowUserManager.setUserForeground(true);
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
index a1cc1d8..ecf6d00 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java
@@ -75,7 +75,6 @@
private static final String KEY_AUDIO_SHARING_SETTINGS =
"connected_device_audio_sharing_settings";
private static final String KEY_ADD_BT_DEVICES = "add_bt_devices";
- private static final String KEY_TEMPORARY_BOND_DEVICES = "temp_bond_device_list";
private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui";
private static final String SLICE_ACTION = "com.android.settings.SEARCH_RESULT_TRAMPOLINE";
@@ -130,8 +129,7 @@
KEY_SAVED_DEVICE_SEE_ALL,
KEY_FAST_PAIR_DEVICE_SEE_ALL,
KEY_AUDIO_SHARING_DEVICES,
- KEY_AUDIO_SHARING_SETTINGS,
- KEY_TEMPORARY_BOND_DEVICES);
+ KEY_AUDIO_SHARING_SETTINGS);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdaterTest.java
index 12e03d4..84fd820 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingBluetoothDeviceUpdaterTest.java
@@ -153,6 +153,11 @@
@Test
public void onProfileConnectionStateChanged_leaDeviceConnected_flagOff_removesPref() {
setupPreferenceMapWithDevice(false);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -172,6 +177,11 @@
@Test
public void onProfileConnectionStateChanged_leaConnected_flagOff_hysteresisMode_removesPref() {
setupPreferenceMapWithDevice(true);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
mSetFlagsRule.disableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING);
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -191,6 +201,11 @@
@Test
public void onProfileConnectionStateChanged_leaConnected_noSource_removesPref() {
setupPreferenceMapWithDevice(false);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -210,6 +225,11 @@
@Test
public void onProfileConnectionStateChanged_leaConnected_noSource_hysteresisMode_removesPref() {
setupPreferenceMapWithDevice(true);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -229,6 +249,11 @@
@Test
public void onProfileConnectionStateChanged_deviceIsNotInList_removesPref() {
setupPreferenceMapWithDevice(false);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
mCachedDevices.clear();
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
@@ -249,6 +274,11 @@
@Test
public void onProfileConnectionStateChanged_deviceIsNotInList_hysteresisMode_removesPref() {
setupPreferenceMapWithDevice(true);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
mCachedDevices.clear();
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
@@ -269,6 +299,11 @@
@Test
public void onProfileConnectionStateChanged_leaDisconnected_removesPref() {
setupPreferenceMapWithDevice(false);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -288,6 +323,11 @@
@Test
public void onProfileConnectionStateChanged_leaDisconnected_hysteresisMode_removesPref() {
setupPreferenceMapWithDevice(true);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -307,6 +347,11 @@
@Test
public void onProfileConnectionStateChanged_leaDisconnecting_removesPref() {
setupPreferenceMapWithDevice(false);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
doReturn(false).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -325,6 +370,11 @@
@Test
public void onProfileConnectionStateChanged_leaDisconnecting_hysteresisMode_removesPref() {
setupPreferenceMapWithDevice(true);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
doReturn(false).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -344,6 +394,29 @@
public void onProfileConnectionStateChanged_leaConnected_hasSource_addsPref() {
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
setupPreferenceMapWithDevice(false);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
+
+ verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
+ assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
+ assertThat(((BluetoothDevicePreference) captor.getValue()).getBluetoothDevice())
+ .isEqualTo(mCachedBluetoothDevice);
+ }
+
+ @Test
+ public void onProfileConnectionStateChanged_hasLeaMemberConnected_hasSource_addsPref() {
+ ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
+ setupPreferenceMapWithDevice(false);
+ when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
+ when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
@@ -355,6 +428,30 @@
public void onProfileConnectionStateChanged_leaConnected_hasSource_hysteresisMode_addsPref() {
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
setupPreferenceMapWithDevice(true);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
+
+ verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
+ assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
+ assertThat(((BluetoothDevicePreference) captor.getValue()).getBluetoothDevice())
+ .isEqualTo(mCachedBluetoothDevice);
+ }
+
+ @Test
+ public void
+ onProfileConnectionStateChanged_hasLeaMemberConnected_hasSource_hysteresis_addsPref() {
+ ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
+ setupPreferenceMapWithDevice(true);
+ when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
+ when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
assertThat(captor.getValue() instanceof BluetoothDevicePreference).isTrue();
@@ -397,10 +494,5 @@
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of(mState));
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
doReturn(true).when(mCachedBluetoothDevice).isConnectedLeAudioDevice();
- mDeviceUpdater.onProfileConnectionStateChanged(
- mCachedBluetoothDevice,
- BluetoothProfile.STATE_CONNECTED,
- BluetoothProfile.LE_AUDIO);
- shadowOf(Looper.getMainLooper()).idle();
}
}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java
index a2ac0cc..4f6fed7 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingCallAudioPreferenceControllerTest.java
@@ -43,7 +43,6 @@
import android.content.Context;
import android.database.ContentObserver;
import android.os.Looper;
-import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings;
import android.view.View;
@@ -111,11 +110,8 @@
private static final String PREF_KEY = "calls_and_alarms";
private static final String TEST_DEVICE_NAME1 = "test1";
private static final String TEST_DEVICE_NAME2 = "test2";
- private static final String TEMP_BOND_METADATA =
- "<TEMP_BOND_TYPE>le_audio_sharing</TEMP_BOND_TYPE>";
private static final int TEST_DEVICE_GROUP_ID1 = 1;
private static final int TEST_DEVICE_GROUP_ID2 = 2;
- private static final int METADATA_FAST_PAIR_CUSTOMIZED_FIELDS = 25;
private static final String TEST_SETTINGS_KEY =
"bluetooth_le_broadcast_fallback_active_group_id";
@@ -448,23 +444,6 @@
}
@Test
- @EnableFlags(Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI)
- public void displayPreference_hasTemporaryBondDevice_doNotShow() {
- Settings.Secure.putInt(mContentResolver, TEST_SETTINGS_KEY, TEST_DEVICE_GROUP_ID1);
- when(mCachedDevice1.isActiveDevice(BluetoothProfile.LE_AUDIO)).thenReturn(true);
- when(mBroadcast.isEnabled(any())).thenReturn(true);
- when(mAssistant.getAllConnectedDevices()).thenReturn(ImmutableList.of(mDevice1, mDevice2));
- when(mAssistant.getAllSources(any())).thenReturn(ImmutableList.of(mState));
- when(mDevice2.getMetadata(METADATA_FAST_PAIR_CUSTOMIZED_FIELDS)).thenReturn(
- TEMP_BOND_METADATA.getBytes());
-
- mController.displayPreference(mScreen);
- shadowOf(Looper.getMainLooper()).idle();
-
- assertThat(mController.mGroupedConnectedDevices).hasSize(0);
- }
-
- @Test
public void displayPreference_clickToShowCorrectDialog() {
AlertDialog latestAlertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
if (latestAlertDialog != null) {
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdaterTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdaterTest.java
index 95e51e9..2bdd0da 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeControlUpdaterTest.java
@@ -127,6 +127,11 @@
@Test
public void onProfileConnectionStateChanged_leaDeviceConnected_noSharing_removesPref() {
setupPreferenceMapWithDevice();
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
when(mBroadcast.isEnabled(null)).thenReturn(false);
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -146,6 +151,11 @@
@Test
public void onProfileConnectionStateChanged_leaDeviceConnected_noSource_removesPref() {
setupPreferenceMapWithDevice();
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of());
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -165,6 +175,11 @@
@Test
public void onProfileConnectionStateChanged_deviceIsNotInList_removesPref() {
setupPreferenceMapWithDevice();
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
mCachedDevices.clear();
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
@@ -185,6 +200,11 @@
@Test
public void onProfileConnectionStateChanged_leaDeviceDisconnected_removesPref() {
setupPreferenceMapWithDevice();
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(false);
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -204,6 +224,11 @@
@Test
public void onProfileConnectionStateChanged_leaDeviceDisconnecting_removesPref() {
setupPreferenceMapWithDevice();
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
@@ -224,6 +249,29 @@
public void onProfileConnectionStateChanged_leaDeviceConnected_hasSource_addsPreference() {
ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
setupPreferenceMapWithDevice();
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
+
+ verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
+ assertThat(captor.getValue() instanceof AudioSharingDeviceVolumePreference).isTrue();
+ assertThat(((AudioSharingDeviceVolumePreference) captor.getValue()).getCachedDevice())
+ .isEqualTo(mCachedBluetoothDevice);
+ }
+
+ @Test
+ public void onProfileConnectionStateChanged_hasLeaMemberConnected_hasSource_addsPreference() {
+ ArgumentCaptor<Preference> captor = ArgumentCaptor.forClass(Preference.class);
+ setupPreferenceMapWithDevice();
+ when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(false);
+ when(mCachedBluetoothDevice.hasConnectedLeAudioMemberDevice()).thenReturn(true);
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
verify(mDevicePreferenceCallback).onDeviceAdded(captor.capture());
assertThat(captor.getValue() instanceof AudioSharingDeviceVolumePreference).isTrue();
@@ -262,6 +310,12 @@
@Test
public void refreshPreference_doNothing() {
setupPreferenceMapWithDevice();
+ mDeviceUpdater.onProfileConnectionStateChanged(
+ mCachedBluetoothDevice,
+ BluetoothProfile.STATE_CONNECTED,
+ BluetoothProfile.LE_AUDIO);
+ shadowOf(Looper.getMainLooper()).idle();
+
verify(mDevicePreferenceCallback).onDeviceAdded(any(Preference.class));
when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(ImmutableList.of());
mDeviceUpdater.refreshPreference();
@@ -276,10 +330,5 @@
when(mAssistant.getAllSources(mBluetoothDevice)).thenReturn(ImmutableList.of(mState));
when(mDeviceUpdater.isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedLeAudioDevice()).thenReturn(true);
- mDeviceUpdater.onProfileConnectionStateChanged(
- mCachedBluetoothDevice,
- BluetoothProfile.STATE_CONNECTED,
- BluetoothProfile.LE_AUDIO);
- shadowOf(Looper.getMainLooper()).idle();
}
}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupControllerTest.java
index bac8b30..a739bb3 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/AudioSharingDeviceVolumeGroupControllerTest.java
@@ -309,6 +309,8 @@
when(mPreference1.getProgress()).thenReturn(TEST_VOLUME_VALUE);
mController.setPreferenceGroup(mPreferenceGroup);
mController.onDeviceAdded(mPreference1);
+ shadowOf(Looper.getMainLooper()).idle();
+
verify(mPreferenceGroup).setVisible(true);
assertThat(mPreferenceGroup.isVisible()).isTrue();
}
@@ -365,6 +367,8 @@
mPreferenceGroup.addPreference(mPreference1);
mController.setPreferenceGroup(mPreferenceGroup);
mController.onDeviceRemoved(mPreference1);
+ shadowOf(Looper.getMainLooper()).idle();
+
verify(mPreferenceGroup).setVisible(false);
assertThat(mPreferenceGroup.isVisible()).isFalse();
}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupControllerTest.java
deleted file mode 100644
index a85555d..0000000
--- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupControllerTest.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.connecteddevice.audiosharing;
-
-import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothStatusCodes;
-import android.content.Context;
-import android.platform.test.annotations.RequiresFlagsDisabled;
-import android.platform.test.annotations.RequiresFlagsEnabled;
-import android.platform.test.flag.junit.CheckFlagsRule;
-import android.platform.test.flag.junit.DeviceFlagsValueProvider;
-
-import androidx.lifecycle.LifecycleOwner;
-import androidx.preference.Preference;
-import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceGroup;
-import androidx.preference.PreferenceManager;
-import androidx.preference.PreferenceScreen;
-import androidx.test.core.app.ApplicationProvider;
-
-import com.android.settings.bluetooth.Utils;
-import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
-import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
-import com.android.settingslib.bluetooth.BluetoothCallback;
-import com.android.settingslib.bluetooth.BluetoothEventManager;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.flags.Flags;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadow.api.Shadow;
-
-/** Tests for {@link TemporaryBondDeviceGroupController}. */
-@RunWith(RobolectricTestRunner.class)
-@Config(
- shadows = {
- ShadowBluetoothAdapter.class,
- ShadowBluetoothUtils.class
- })
-public class TemporaryBondDeviceGroupControllerTest {
- private static final String KEY = "temp_bond_device_list";
- private static final String PREFERENCE_KEY_1 = "pref_key_1";
-
- @Rule
- public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
-
- @Mock
- private TemporaryBondDeviceGroupUpdater mBluetoothDeviceUpdater;
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private PreferenceManager mPreferenceManager;
- @Mock
- private LocalBluetoothManager mLocalBtManager;
- @Mock
- private BluetoothEventManager mEventManager;
- @Mock private PreferenceScreen mScreen;
-
-
- private PreferenceGroup mPreferenceGroup;
- private Context mContext;
- private Preference mPreference;
- private TemporaryBondDeviceGroupController mTemporaryBondDeviceGroupController;
- private LifecycleOwner mLifecycleOwner;
- private Lifecycle mLifecycle;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = ApplicationProvider.getApplicationContext();
- mPreference = new Preference(mContext);
- mPreference.setKey(PREFERENCE_KEY_1);
- mPreferenceGroup = spy(new PreferenceCategory(mContext));
- when(mPreferenceGroup.getPreferenceManager()).thenReturn(mPreferenceManager);
- mLifecycleOwner = () -> mLifecycle;
- mLifecycle = new Lifecycle(mLifecycleOwner);
- when(mScreen.getContext()).thenReturn(mContext);
- when(mScreen.findPreference(KEY)).thenReturn(mPreferenceGroup);
-
- ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBtManager;
- mLocalBtManager = Utils.getLocalBtManager(mContext);
- when(mLocalBtManager.getEventManager()).thenReturn(mEventManager);
- ShadowBluetoothAdapter shadowBluetoothAdapter = Shadow.extract(
- BluetoothAdapter.getDefaultAdapter());
- shadowBluetoothAdapter.setEnabled(true);
- shadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported(
- BluetoothStatusCodes.FEATURE_SUPPORTED);
- shadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported(
- BluetoothStatusCodes.FEATURE_SUPPORTED);
-
- mTemporaryBondDeviceGroupController = spy(new TemporaryBondDeviceGroupController(mContext));
- mTemporaryBondDeviceGroupController.setBluetoothDeviceUpdater(mBluetoothDeviceUpdater);
- mTemporaryBondDeviceGroupController.setPreferenceGroup(mPreferenceGroup);
- }
-
- @Test
- @RequiresFlagsDisabled(Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI)
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
- public void onStart_flagOff_doNothing() {
- mTemporaryBondDeviceGroupController.onStart(mLifecycleOwner);
-
- verify(mEventManager, never()).registerCallback(any(BluetoothCallback.class));
- verify(mBluetoothDeviceUpdater, never()).registerCallback();
- verify(mBluetoothDeviceUpdater, never()).refreshPreference();
- }
-
- @Test
- @RequiresFlagsDisabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI)
- public void onStart_audioSharingUINotAvailable_doNothing() {
- mTemporaryBondDeviceGroupController.onStart(mLifecycleOwner);
-
- verify(mEventManager, never()).registerCallback(any(BluetoothCallback.class));
- verify(mBluetoothDeviceUpdater, never()).registerCallback();
- verify(mBluetoothDeviceUpdater, never()).refreshPreference();
- }
-
- @Test
- @RequiresFlagsEnabled({Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI,
- Flags.FLAG_ENABLE_LE_AUDIO_SHARING})
- public void onStart_registerCallbacks() {
- mTemporaryBondDeviceGroupController.onStart(mLifecycleOwner);
-
- verify(mEventManager).registerCallback(any(BluetoothCallback.class));
- verify(mBluetoothDeviceUpdater).registerCallback();
- verify(mBluetoothDeviceUpdater).refreshPreference();
- }
-
- @Test
- @RequiresFlagsEnabled({Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI,
- Flags.FLAG_ENABLE_LE_AUDIO_SHARING})
- public void onStop_unregisterCallbacks() {
- mTemporaryBondDeviceGroupController.onStop(mLifecycleOwner);
-
- verify(mEventManager).unregisterCallback(any(BluetoothCallback.class));
- verify(mBluetoothDeviceUpdater).unregisterCallback();
- }
-
- @Test
- @RequiresFlagsDisabled(Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI)
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
- public void displayPreference_flagOff_doNothing() {
- mTemporaryBondDeviceGroupController.displayPreference(mScreen);
-
- assertThat(mPreferenceGroup.isVisible()).isFalse();
- verify(mBluetoothDeviceUpdater, never()).forceUpdate();
- }
-
- @Test
- @RequiresFlagsDisabled(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
- @RequiresFlagsEnabled(Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI)
- public void displayPreference_audioSharingUINotAvailable_doNothing() {
- mTemporaryBondDeviceGroupController.displayPreference(mScreen);
-
- assertThat(mPreferenceGroup.isVisible()).isFalse();
- verify(mBluetoothDeviceUpdater, never()).forceUpdate();
- }
-
- @Test
- @RequiresFlagsEnabled({Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI,
- Flags.FLAG_ENABLE_LE_AUDIO_SHARING})
- public void displayPreference_updateDeviceList() {
- mTemporaryBondDeviceGroupController.displayPreference(mScreen);
-
- assertThat(mPreferenceGroup.isVisible()).isFalse();
- verify(mBluetoothDeviceUpdater).setPrefContext(mContext);
- verify(mBluetoothDeviceUpdater).forceUpdate();
- }
-
- @Test
- public void onDeviceAdded_firstAdd_becomeVisibleAndPreferenceAdded() {
- mTemporaryBondDeviceGroupController.onDeviceAdded(mPreference);
-
- assertThat(mPreferenceGroup.isVisible()).isTrue();
- assertThat(mPreferenceGroup.getPreferenceCount()).isEqualTo(1);
- }
-
- @Test
- public void onDeviceRemoved_lastRemove_becomeInvisibleAndPreferenceRemoved() {
- mPreferenceGroup.addPreference(mPreference);
-
- mTemporaryBondDeviceGroupController.onDeviceRemoved(mPreference);
-
- assertThat(mPreferenceGroup.isVisible()).isFalse();
- assertThat(mPreferenceGroup.getPreferenceCount()).isEqualTo(0);
- }
-
- @Test
- public void onDeviceRemoved_notLastRemove_stillVisible() {
- mPreferenceGroup.setVisible(true);
- mPreferenceGroup.addPreference(mPreference);
- mPreferenceGroup.addPreference(new Preference(mContext));
-
- mTemporaryBondDeviceGroupController.onDeviceRemoved(mPreference);
-
- assertThat(mPreferenceGroup.isVisible()).isTrue();
- assertThat(mPreferenceGroup.getPreferenceCount()).isEqualTo(1);
- }
-
- @Test
- public void getPreferenceKey_returnsCorrectKey() {
- assertThat(mTemporaryBondDeviceGroupController.getPreferenceKey()).isEqualTo(KEY);
- }
-
- @Test
- @RequiresFlagsEnabled({Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI,
- Flags.FLAG_ENABLE_LE_AUDIO_SHARING})
- public void getAvailabilityStatus_returnsAvailable() {
- assertThat(mTemporaryBondDeviceGroupController.getAvailabilityStatus()).isEqualTo(
- AVAILABLE_UNSEARCHABLE);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdaterTest.java b/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdaterTest.java
deleted file mode 100644
index 0b34c10..0000000
--- a/tests/robotests/src/com/android/settings/connecteddevice/audiosharing/TemporaryBondDeviceGroupUpdaterTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2025 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.connecteddevice.audiosharing;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothStatusCodes;
-import android.content.Context;
-import android.platform.test.annotations.RequiresFlagsEnabled;
-import android.platform.test.flag.junit.CheckFlagsRule;
-import android.platform.test.flag.junit.DeviceFlagsValueProvider;
-
-import androidx.test.core.app.ApplicationProvider;
-
-import com.android.settings.bluetooth.Utils;
-import com.android.settings.connecteddevice.DevicePreferenceCallback;
-import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
-import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
-import com.android.settingslib.bluetooth.CachedBluetoothDevice;
-import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
-import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.flags.Flags;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadow.api.Shadow;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-/** Tests for {@link TemporaryBondDeviceGroupUpdater}. */
-@RunWith(RobolectricTestRunner.class)
-@Config(
- shadows = {
- ShadowBluetoothAdapter.class,
- ShadowBluetoothUtils.class
- })
-public class TemporaryBondDeviceGroupUpdaterTest {
- private static final String TAG = "TemporaryBondDeviceGroupUpdater";
- private static final String PREF_KEY_PREFIX = "temp_bond_bt_";
- private static final String TEMP_BOND_METADATA =
- "<TEMP_BOND_TYPE>le_audio_sharing</TEMP_BOND_TYPE>";
- private static final int METADATA_FAST_PAIR_CUSTOMIZED_FIELDS = 25;
-
- @Rule
- public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
-
- @Mock
- private DevicePreferenceCallback mDevicePreferenceCallback;
- @Mock
- private CachedBluetoothDevice mCachedBluetoothDevice;
- @Mock
- private BluetoothDevice mBluetoothDevice;
- @Mock
- private LocalBluetoothManager mLocalBtManager;
- @Mock
- private CachedBluetoothDeviceManager mCachedDeviceManager;
-
- private TemporaryBondDeviceGroupUpdater mDeviceUpdater;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- ShadowBluetoothAdapter shadowBluetoothAdapter = Shadow.extract(
- BluetoothAdapter.getDefaultAdapter());
- shadowBluetoothAdapter.setEnabled(true);
- shadowBluetoothAdapter.setIsLeAudioBroadcastSourceSupported(
- BluetoothStatusCodes.FEATURE_SUPPORTED);
- shadowBluetoothAdapter.setIsLeAudioBroadcastAssistantSupported(
- BluetoothStatusCodes.FEATURE_SUPPORTED);
- Context context = ApplicationProvider.getApplicationContext();
- ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBtManager;
- mLocalBtManager = Utils.getLocalBtManager(context);
- when(mLocalBtManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
- when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
- Collection<CachedBluetoothDevice> cachedDevices = new ArrayList<>();
- cachedDevices.add(mCachedBluetoothDevice);
- when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(cachedDevices);
- mDeviceUpdater =
- spy(
- new TemporaryBondDeviceGroupUpdater(
- context, mDevicePreferenceCallback, /* metricsCategory= */ 0));
- mDeviceUpdater.setPrefContext(context);
- }
-
- @After
- public void tearDown() {
- ShadowBluetoothUtils.reset();
- }
-
- @Test
- @RequiresFlagsEnabled({Flags.FLAG_ENABLE_TEMPORARY_BOND_DEVICES_UI,
- Flags.FLAG_ENABLE_LE_AUDIO_SHARING})
- public void isFilterMatched_isTemporaryBondDevice_returnsTrue() {
- when(mBluetoothDevice.isConnected()).thenReturn(true);
- when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
- when(mBluetoothDevice.getMetadata(METADATA_FAST_PAIR_CUSTOMIZED_FIELDS))
- .thenReturn(TEMP_BOND_METADATA.getBytes());
-
- assertThat(mDeviceUpdater.isFilterMatched(mCachedBluetoothDevice)).isTrue();
- }
-
- @Test
- public void getLogTag_returnsCorrectTag() {
- assertThat(mDeviceUpdater.getLogTag()).isEqualTo(TAG);
- }
-
- @Test
- public void getPreferenceKey_returnsCorrectKey() {
- assertThat(mDeviceUpdater.getPreferenceKeyPrefix()).isEqualTo(PREF_KEY_PREFIX);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java
index 6dca4fc..676f84d 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java
@@ -102,7 +102,7 @@
private ZenModeConfig getMutedAllConfig() {
final ZenModeConfig config = new ZenModeConfig();
config.applyNotificationPolicy(new NotificationManager.Policy(0, 0, 0));
- config.areChannelsBypassingDnd = false;
+ config.hasPriorityChannels = false;
return config;
}
}
diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeSetCalendarPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeSetCalendarPreferenceControllerTest.java
index 42aa498..f0c2369 100644
--- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeSetCalendarPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeSetCalendarPreferenceControllerTest.java
@@ -85,7 +85,7 @@
}
@Test
- @EnableFlags({Flags.FLAG_MODES_API, Flags.FLAG_MODES_UI})
+ @EnableFlags(Flags.FLAG_MODES_UI)
public void updateEventMode_updatesConditionAndTriggerDescription() {
ZenMode mode = new TestModeBuilder()
.setPackage(SystemZenRules.PACKAGE_ANDROID)
diff --git a/tests/robotests/src/com/android/settings/notification/modes/ZenModeSetSchedulePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/modes/ZenModeSetSchedulePreferenceControllerTest.java
index c378e9d..b446d71 100644
--- a/tests/robotests/src/com/android/settings/notification/modes/ZenModeSetSchedulePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/modes/ZenModeSetSchedulePreferenceControllerTest.java
@@ -80,7 +80,7 @@
}
@Test
- @EnableFlags({Flags.FLAG_MODES_API, Flags.FLAG_MODES_UI})
+ @EnableFlags(Flags.FLAG_MODES_UI)
public void updateScheduleRule_updatesConditionAndTriggerDescription() {
ZenMode mode = new TestModeBuilder()
.setPackage(SystemZenRules.PACKAGE_ANDROID)
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
index 63da3c4..120390d 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModeBackendTest.java
@@ -213,11 +213,7 @@
mBackend.saveConversationSenders(CONVERSATION_SENDERS_NONE);
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
- if (android.app.Flags.modesApi()) {
- verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
- } else {
- verify(mNotificationManager).setNotificationPolicy(captor.capture());
- }
+ verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
Policy expected = new Policy(
PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
@@ -241,11 +237,7 @@
mBackend.saveConversationSenders(CONVERSATION_SENDERS_ANYONE);
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
- if (android.app.Flags.modesApi()) {
- verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
- } else {
- verify(mNotificationManager).setNotificationPolicy(captor.capture());
- }
+ verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
| PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
@@ -270,11 +262,7 @@
mBackend.saveSenders(PRIORITY_CATEGORY_CALLS, PRIORITY_SENDERS_ANY);
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
- if (android.app.Flags.modesApi()) {
- verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
- } else {
- verify(mNotificationManager).setNotificationPolicy(captor.capture());
- }
+ verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
| PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModeEventRuleSettingsTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModeEventRuleSettingsTest.java
index 05c3603..ef0b862 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModeEventRuleSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModeEventRuleSettingsTest.java
@@ -107,7 +107,7 @@
}
@Test
- @EnableFlags({Flags.FLAG_MODES_API, Flags.FLAG_MODES_UI})
+ @EnableFlags(Flags.FLAG_MODES_UI)
public void updateEventRule_updatesConditionAndTriggerDescription() {
mFragment.setBackend(mBackend);
mFragment.mId = "id";
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModeScheduleRuleSettingsTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModeScheduleRuleSettingsTest.java
index 90e44e6..bb102c0 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModeScheduleRuleSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModeScheduleRuleSettingsTest.java
@@ -107,7 +107,7 @@
}
@Test
- @EnableFlags({Flags.FLAG_MODES_API, Flags.FLAG_MODES_UI})
+ @EnableFlags(Flags.FLAG_MODES_UI)
public void updateScheduleRule_updatesConditionAndTriggerDescription() {
mFragment.setBackend(mBackend);
mFragment.mId = "id";
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModeSliceBuilderTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModeSliceBuilderTest.java
index 3f9e486..ddc3d80 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModeSliceBuilderTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModeSliceBuilderTest.java
@@ -117,11 +117,7 @@
ZenModeSliceBuilder.handleUriChange(mContext, intent);
- if (android.app.Flags.modesApi()) {
- verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any(), eq(true));
- } else {
- verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any());
- }
+ verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any(), eq(true));
}
@Test
@@ -131,10 +127,6 @@
ZenModeSliceBuilder.handleUriChange(mContext, intent);
- if (android.app.Flags.modesApi()) {
- verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any(), eq(true));
- } else {
- verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any());
- }
+ verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any(), eq(true));
}
}
diff --git a/tests/spa_unit/src/com/android/settings/network/telephony/SubscriptionActivationRepositoryTest.kt b/tests/spa_unit/src/com/android/settings/network/telephony/SubscriptionActivationRepositoryTest.kt
index 427ab7b..01015be 100644
--- a/tests/spa_unit/src/com/android/settings/network/telephony/SubscriptionActivationRepositoryTest.kt
+++ b/tests/spa_unit/src/com/android/settings/network/telephony/SubscriptionActivationRepositoryTest.kt
@@ -17,12 +17,15 @@
package com.android.settings.network.telephony
import android.content.Context
+import android.content.Intent
+import android.os.UserHandle
import android.telephony.SubscriptionManager
import android.telephony.TelephonyManager
import android.telephony.TelephonyManager.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.network.SatelliteRepository
+import com.android.settings.network.SimOnboardingActivity
import com.android.settingslib.spa.testutils.firstWithTimeoutOrNull
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.flow.flowOf
@@ -33,6 +36,7 @@
import org.mockito.kotlin.argThat
import org.mockito.kotlin.doNothing
import org.mockito.kotlin.doReturn
+import org.mockito.kotlin.eq
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.spy
@@ -108,6 +112,17 @@
}
@Test
+ fun setActive_turnOnAndIsEmergencyCallbackMode() = runBlocking {
+ mockTelephonyManager.stub {
+ on { emergencyCallbackMode } doReturn true
+ }
+
+ repository.setActive(subId = SUB_ID, active = true)
+
+ verify(context).startActivity(argThat { action == ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS })
+ }
+
+ @Test
fun setActive_turnOffAndIsEmergencyCallbackMode() = runBlocking {
mockTelephonyManager.stub {
on { emergencyCallbackMode } doReturn true
@@ -131,6 +146,19 @@
})
}
+ @Test
+ fun setActive_turnOnAndNotEmergencyCallbackMode() = runBlocking {
+ mockTelephonyManager.stub {
+ on { emergencyCallbackMode } doReturn false
+ }
+
+ repository.setActive(subId = SUB_ID, active = true)
+
+ verify(context).startActivityAsUser(argThat {
+ component?.className == SimOnboardingActivity::class.qualifiedName
+ }, eq(UserHandle.CURRENT))
+ }
+
private companion object {
const val SUB_ID = 1
}
diff --git a/tests/unit/src/com/android/settings/applications/specialaccess/notificationaccess/ApprovalPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/specialaccess/notificationaccess/ApprovalPreferenceControllerTest.java
index e488792..bcfaa3d 100644
--- a/tests/unit/src/com/android/settings/applications/specialaccess/notificationaccess/ApprovalPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/specialaccess/notificationaccess/ApprovalPreferenceControllerTest.java
@@ -28,14 +28,12 @@
import static org.mockito.Mockito.when;
import android.app.AppOpsManager;
-import android.app.Flags;
import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
-import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
@@ -50,7 +48,6 @@
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -188,7 +185,6 @@
}
@Test
- @EnableFlags(Flags.FLAG_MODES_API)
public void disable() {
when(mNm.isNotificationPolicyAccessGrantedForPackage(anyString())).thenReturn(false);
mController.disable(mCn);
diff --git a/tests/unit/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragmentTest.java b/tests/unit/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragmentTest.java
index 12af772..623b209 100644
--- a/tests/unit/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragmentTest.java
+++ b/tests/unit/src/com/android/settings/connecteddevice/display/ExternalDisplayPreferenceFragmentTest.java
@@ -22,6 +22,8 @@
import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_SETTINGS_RESOURCE;
import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.EXTERNAL_DISPLAY_SIZE_SUMMARY_RESOURCE;
import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.PREVIOUSLY_SHOWN_LIST_KEY;
+import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.displayListDisplayCategoryKey;
+import static com.android.settings.connecteddevice.display.ExternalDisplayPreferenceFragment.resolutionRotationPreferenceKey;
import static com.android.settings.flags.Flags.FLAG_DISPLAY_SIZE_CONNECTED_DISPLAY_SETTING;
import static com.android.settings.flags.Flags.FLAG_DISPLAY_TOPOLOGY_PANE_IN_DISPLAY_LIST;
import static com.android.settingslib.widget.FooterPreference.KEY_FOOTER;
@@ -79,6 +81,19 @@
assertThat(mPreferenceIdFromResource).isEqualTo(EXTERNAL_DISPLAY_SETTINGS_RESOURCE);
}
+ private void assertDisplayList(boolean present, int displayId) {
+ // In display list fragment, there is a combined resolution/rotation preference key.
+ var category = mPreferenceScreen.findPreference(displayListDisplayCategoryKey(displayId));
+ var pref = mPreferenceScreen.findPreference(resolutionRotationPreferenceKey(displayId));
+ if (present) {
+ assertThat(category).isNotNull();
+ assertThat(pref).isNotNull();
+ } else {
+ assertThat(category).isNull();
+ assertThat(pref).isNull();
+ }
+ }
+
@Test
@UiThreadTest
public void testShowDisplayList() {
@@ -89,19 +104,26 @@
fragment.onSaveInstanceStateCallback(outState);
assertThat(outState.getBoolean(PREVIOUSLY_SHOWN_LIST_KEY)).isFalse();
assertThat(mHandler.getPendingMessages().size()).isEqualTo(1);
- PreferenceCategory pref = mPreferenceScreen.findPreference(PrefBasics.DISPLAYS_LIST.key);
- assertThat(pref).isNull();
+
+ // Combined resolution/refresh rate are not available in displays list because the pane is
+ // disabled (v1 UI).
+ assertDisplayList(false, EXTERNAL_DISPLAY_ID);
+ assertDisplayList(false, OVERLAY_DISPLAY_ID);
+ // Individual resolution preference is not available in displays list.
+ assertThat(mPreferenceScreen.<Preference>findPreference(
+ PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.key))
+ .isNull();
+
verify(mMockedInjector, never()).getAllDisplays();
mHandler.flush();
assertThat(mHandler.getPendingMessages().size()).isEqualTo(0);
verify(mMockedInjector).getAllDisplays();
- pref = mPreferenceScreen.findPreference(PrefBasics.DISPLAYS_LIST.key);
- assertThat(pref).isNotNull();
- assertThat(pref.getPreferenceCount()).isEqualTo(2);
+ assertDisplayList(true, EXTERNAL_DISPLAY_ID);
+ assertDisplayList(true, OVERLAY_DISPLAY_ID);
fragment.onSaveInstanceStateCallback(outState);
assertThat(outState.getBoolean(PREVIOUSLY_SHOWN_LIST_KEY)).isTrue();
- pref = mPreferenceScreen.findPreference(PrefBasics.DISPLAY_TOPOLOGY.key);
+ Preference pref = mPreferenceScreen.findPreference(PrefBasics.DISPLAY_TOPOLOGY.key);
assertThat(pref).isNull();
pref = mPreferenceScreen.findPreference(PrefBasics.BUILTIN_DISPLAY_LIST.key);
@@ -122,8 +144,7 @@
pref = mPreferenceScreen.findPreference(PrefBasics.MIRROR.key);
assertThat(pref).isNotNull();
- pref = mPreferenceScreen.findPreference(PrefBasics.DISPLAYS_LIST.key);
- assertThat(pref).isNull();
+ assertDisplayList(false, mDisplays[1].getDisplayId());
PreferenceCategory listPref =
mPreferenceScreen.findPreference(PrefBasics.BUILTIN_DISPLAY_LIST.key);
@@ -148,11 +169,10 @@
pref = mPreferenceScreen.findPreference(PrefBasics.MIRROR.key);
assertThat(pref).isNull();
- PreferenceCategory listPref =
- mPreferenceScreen.findPreference(PrefBasics.DISPLAYS_LIST.key);
- assertThat(listPref).isNull();
+ assertDisplayList(false, EXTERNAL_DISPLAY_ID);
+ assertDisplayList(false, OVERLAY_DISPLAY_ID);
- listPref = mPreferenceScreen.findPreference(PrefBasics.BUILTIN_DISPLAY_LIST.key);
+ var listPref = mPreferenceScreen.findPreference(PrefBasics.BUILTIN_DISPLAY_LIST.key);
assertThat(listPref).isNull();
}
@@ -161,19 +181,23 @@
public void testLaunchDisplaySettingFromList() {
initFragment();
mHandler.flush();
- PreferenceCategory pref = mPreferenceScreen.findPreference(PrefBasics.DISPLAYS_LIST.key);
- assertThat(pref).isNotNull();
- var display1Category = (PreferenceCategory) pref.getPreference(0);
+ assertDisplayList(true, EXTERNAL_DISPLAY_ID);
+ assertDisplayList(true, OVERLAY_DISPLAY_ID);
+ PreferenceCategory display1Category = mPreferenceScreen.findPreference(
+ displayListDisplayCategoryKey(EXTERNAL_DISPLAY_ID));
var display1Pref = (DisplayPreference) display1Category.getPreference(0);
- var display2Category = (PreferenceCategory) pref.getPreference(1);
+ PreferenceCategory display2Category = mPreferenceScreen.findPreference(
+ displayListDisplayCategoryKey(OVERLAY_DISPLAY_ID));
var display2Pref = (DisplayPreference) display2Category.getPreference(0);
- assertThat(display1Pref.getKey()).isEqualTo("display_id_" + 1);
+ assertThat(display1Pref.getKey()).isEqualTo(
+ resolutionRotationPreferenceKey(EXTERNAL_DISPLAY_ID));
assertThat("" + display1Category.getTitle()).isEqualTo("HDMI");
assertThat("" + display1Pref.getSummary()).isEqualTo("1920 x 1080");
display1Pref.onPreferenceClick(display1Pref);
assertThat(mDisplayIdArg).isEqualTo(1);
verify(mMockedMetricsLogger).writePreferenceClickMetric(display1Pref);
- assertThat(display2Pref.getKey()).isEqualTo("display_id_" + 2);
+ assertThat(display2Pref.getKey()).isEqualTo(
+ resolutionRotationPreferenceKey(OVERLAY_DISPLAY_ID));
assertThat("" + display2Category.getTitle()).isEqualTo("Overlay #1");
assertThat("" + display2Pref.getSummary()).isEqualTo("1240 x 780");
display2Pref.onPreferenceClick(display2Pref);
@@ -190,9 +214,12 @@
// Only one display available
doReturn(new Display[] {mDisplays[1]}).when(mMockedInjector).getAllDisplays();
mHandler.flush();
- PreferenceCategory pref = mPreferenceScreen.findPreference(PrefBasics.DISPLAYS_LIST.key);
- assertThat(pref).isNotNull();
- assertThat(pref.getPreferenceCount()).isEqualTo(1);
+ int attachedId = mDisplays[1].getDisplayId();
+ assertDisplayList(true, attachedId);
+ assertThat(mPreferenceScreen.<Preference>findPreference(
+ resolutionRotationPreferenceKey(attachedId)))
+ .isNotNull();
+ assertDisplayList(false, mDisplays[2].getDisplayId());
}
@Test
@@ -205,8 +232,7 @@
// Init
initFragment();
mHandler.flush();
- PreferenceCategory list = mPreferenceScreen.findPreference(PrefBasics.DISPLAYS_LIST.key);
- assertThat(list).isNull();
+ assertDisplayList(false, mDisplays[1].getDisplayId());
var pref = mPreferenceScreen.findPreference(PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.key);
assertThat(pref).isNotNull();
pref = mPreferenceScreen.findPreference(PrefBasics.EXTERNAL_DISPLAY_ROTATION.key);
@@ -227,8 +253,8 @@
// Init
initFragment();
mHandler.flush();
- PreferenceCategory list = mPreferenceScreen.findPreference(PrefBasics.DISPLAYS_LIST.key);
- assertThat(list).isNull();
+ assertDisplayList(false, mDisplays[1].getDisplayId());
+ assertDisplayList(false, mDisplays[2].getDisplayId());
var pref = mPreferenceScreen.findPreference(PrefBasics.EXTERNAL_DISPLAY_RESOLUTION.key);
assertThat(pref).isNotNull();
pref = mPreferenceScreen.findPreference(PrefBasics.EXTERNAL_DISPLAY_ROTATION.key);
diff --git a/tests/unit/src/com/android/settings/connecteddevice/display/ExternalDisplayTestBase.java b/tests/unit/src/com/android/settings/connecteddevice/display/ExternalDisplayTestBase.java
index ea76118..fcc3daa 100644
--- a/tests/unit/src/com/android/settings/connecteddevice/display/ExternalDisplayTestBase.java
+++ b/tests/unit/src/com/android/settings/connecteddevice/display/ExternalDisplayTestBase.java
@@ -49,6 +49,9 @@
import org.mockito.MockitoAnnotations;
public class ExternalDisplayTestBase {
+ static final int EXTERNAL_DISPLAY_ID = 1;
+ static final int OVERLAY_DISPLAY_ID = 2;
+
@Mock
ExternalDisplaySettingsConfiguration.Injector mMockedInjector;
@Mock
@@ -115,7 +118,7 @@
}
Display createExternalDisplay() throws RemoteException {
- int displayId = 1;
+ int displayId = EXTERNAL_DISPLAY_ID;
var displayInfo = new DisplayInfo();
doReturn(displayInfo).when(mMockedIDisplayManager).getDisplayInfo(displayId);
displayInfo.displayId = displayId;
@@ -134,7 +137,7 @@
}
Display createOverlayDisplay() throws RemoteException {
- int displayId = 2;
+ int displayId = OVERLAY_DISPLAY_ID;
var displayInfo = new DisplayInfo();
doReturn(displayInfo).when(mMockedIDisplayManager).getDisplayInfo(displayId);
displayInfo.displayId = displayId;