Merge "Add Ethernet tethering subtext for tablet project" into tm-qpr-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f51719b..1e45bf3 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -146,6 +146,7 @@
                   android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout|smallestScreenSize">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -231,6 +232,7 @@
                 <action android:name="android.settings.WIRELESS_SETTINGS" />
                 <action android:name="android.settings.AIRPLANE_MODE_SETTINGS" />
                 <action android:name="com.android.settings.sim.SIM_SUB_INFO_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter>
@@ -262,6 +264,7 @@
                 <action android:name="android.settings.NETWORK_OPERATOR_SETTINGS" />
                 <action android:name="android.settings.DATA_ROAMING_SETTINGS" />
                 <action android:name="android.settings.MMS_MESSAGE_SETTING" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
         </activity>
@@ -289,6 +292,7 @@
             android:icon="@drawable/ic_homepage_connected_device">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.BLUETOOTH_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -338,6 +342,7 @@
             android:configChanges="orientation|keyboardHidden|screenSize">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.WIFI_SETTINGS"/>
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT"/>
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -449,6 +454,7 @@
             android:configChanges="orientation|keyboardHidden|screenSize">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.WIFI_IP_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter>
@@ -785,6 +791,7 @@
             android:icon="@drawable/ic_homepage_vpn">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.VPN_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <action android:name="android.net.vpn.SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
@@ -821,6 +828,7 @@
             android:icon="@drawable/ic_settings_date_time">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.DATE_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter>
@@ -844,6 +852,7 @@
             android:icon="@drawable/ic_settings_language">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.LOCALE_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter>
@@ -901,6 +910,7 @@
             android:label="@string/available_virtual_keyboard_category">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.INPUT_METHOD_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -915,6 +925,7 @@
             android:label="@string/assist_and_voice_input_title">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.VOICE_INPUT_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -1033,6 +1044,7 @@
             </intent-filter>
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ZEN_MODE_PRIORITY_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter android:priority="41">
@@ -1092,6 +1104,7 @@
             </intent-filter>
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -1194,6 +1207,7 @@
             <intent-filter android:priority="1">
                 <action android:name="com.android.settings.DISPLAY_SETTINGS" />
                 <action android:name="android.settings.DISPLAY_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter android:priority="30">
@@ -1239,6 +1253,7 @@
             </intent-filter>
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NIGHT_DISPLAY_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -1299,6 +1314,7 @@
                   android:icon="@drawable/ic_homepage_about">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.DEVICE_INFO_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <action android:name="android.settings.DEVICE_NAME" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
@@ -1383,6 +1399,7 @@
                 <action android:name="android.settings.APPLICATION_SETTINGS" />
                 <action android:name="android.settings.MANAGE_APPLICATIONS_SETTINGS" />
                 <action android:name="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter android:priority="20">
@@ -1442,6 +1459,7 @@
             android:label="@string/high_power_apps">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -1639,6 +1657,7 @@
             android:configChanges="orientation|keyboardHidden|screenSize">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.LOCATION_SOURCE_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter android:priority="52">
@@ -1697,6 +1716,7 @@
             android:configChanges="orientation|keyboardHidden|screenSize">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.SECURITY_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <action android:name="android.credentials.UNLOCK" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
@@ -1779,6 +1799,7 @@
                   android:icon="@drawable/ic_settings_privacy">
             <intent-filter>
                 <action android:name="android.settings.PRIVACY_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter>
@@ -1900,6 +1921,7 @@
             android:label="@string/usage_access_title">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.USAGE_ACCESS_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -1948,6 +1970,7 @@
             android:configChanges="orientation|keyboardHidden|screenSize">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ACCESSIBILITY_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter android:priority="60">
@@ -2097,6 +2120,7 @@
             android:label="@string/accessibility_captioning_title">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.CAPTIONING_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -2250,6 +2274,7 @@
             android:theme="@style/GlifTheme.Light">
             <intent-filter>
                 <action android:name="android.settings.BIOMETRIC_ENROLL" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
         </activity>
@@ -2266,6 +2291,7 @@
             android:theme="@style/GlifTheme.Light">
             <intent-filter>
                 <action android:name="android.settings.FINGERPRINT_ENROLL" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
         </activity>
@@ -2431,6 +2457,7 @@
             <intent-filter android:priority="1">
                 <action android:name="android.settings.INTERNAL_STORAGE_SETTINGS" />
                 <action android:name="android.settings.MEMORY_CARD_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter android:priority="50">
@@ -2585,6 +2612,7 @@
             android:icon="@drawable/ic_settings_print">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ACTION_PRINT_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter>
@@ -2782,6 +2810,7 @@
             android:icon="@drawable/ic_cast_24dp">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.CAST_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -2861,6 +2890,7 @@
             android:icon="@drawable/ic_homepage_battery">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.BATTERY_SAVER_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -2920,6 +2950,7 @@
             android:label="@string/header_add_an_account">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ADD_ACCOUNT_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -2958,6 +2989,7 @@
             android:icon="@drawable/ic_homepage_data_usage">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.DATA_USAGE_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter android:priority="3">
@@ -2990,6 +3022,7 @@
             android:icon="@drawable/ic_settings_display">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.DREAM_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -3041,6 +3074,7 @@
             android:icon="@drawable/ic_settings_nfc_payment">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NFC_PAYMENT_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter>
@@ -3093,6 +3127,7 @@
             android:label="@string/manage_notification_access_title" >
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -3107,6 +3142,7 @@
             android:label="@string/notification_assistant_title">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NOTIFICATION_ASSISTANT_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -3311,6 +3347,7 @@
             <intent-filter android:priority="1">
                 <action android:name="com.android.settings.SOUND_SETTINGS" />
                 <action android:name="android.settings.SOUND_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <action android:name="android.settings.ACTION_OTHER_SOUND_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
@@ -3409,6 +3446,7 @@
             android:enabled="@bool/config_show_regulatory_info">
             <intent-filter>
                 <action android:name="android.settings.SHOW_REGULATORY_INFO" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -3637,6 +3675,7 @@
             android:label="@string/write_settings_title">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.action.MANAGE_WRITE_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -3899,6 +3938,7 @@
             android:icon="@drawable/ic_homepage_accounts">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.SYNC_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter android:priority="53">
@@ -4103,6 +4143,7 @@
                   android:label="@string/connected_device_connections_title">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NFC_SETTINGS" />
+                <category android:name="android.intent.category.BROWSABLE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter android:priority="1">
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 0632f72..a8bd35c 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1650,4 +1650,9 @@
          [CHAR LIMIT=NONE] -->
     <string-array name="allowlist_hide_summary_in_battery_usage" translatable="false">
     </string-array>
+
+    <!-- Array containing help message codes that should not be displayed
+         during fingerprint enrollment. -->
+    <integer-array name="fingerprint_acquired_ignore_list">
+    </integer-array>
 </resources>
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollSidecar.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollSidecar.java
index d8ecd20..d1e512e 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollSidecar.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollSidecar.java
@@ -21,9 +21,14 @@
 import android.hardware.fingerprint.FingerprintManager;
 import android.util.Log;
 
+import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.R;
 import com.android.settings.biometrics.BiometricEnrollSidecar;
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * Sidecar fragment to handle the state around fingerprint enrollment.
  */
@@ -32,11 +37,19 @@
 
     private FingerprintUpdater mFingerprintUpdater;
     private @FingerprintManager.EnrollReason int mEnrollReason;
+    private Set<Integer> mHelpIgnore;
 
     @Override
     public void onAttach(Activity activity) {
         super.onAttach(activity);
         mFingerprintUpdater = new FingerprintUpdater(activity);
+        final int[] ignoreAcquiredInfo = getResources().getIntArray(
+                R.array.fingerprint_acquired_ignore_list);
+        mHelpIgnore = new HashSet<>();
+        for (int acquiredInfo: ignoreAcquiredInfo) {
+            mHelpIgnore.add(acquiredInfo);
+        }
+        mHelpIgnore = Collections.unmodifiableSet(mHelpIgnore);
     }
 
     @Override
@@ -49,7 +62,6 @@
                     getString(R.string.fingerprint_intro_error_unknown));
             return;
         }
-
         mFingerprintUpdater.enroll(mToken, mEnrollmentCancel, mUserId, mEnrollmentCallback,
                 mEnrollReason);
     }
@@ -58,7 +70,7 @@
         mEnrollReason = enrollReason;
     }
 
-    private FingerprintManager.EnrollmentCallback mEnrollmentCallback
+    @VisibleForTesting FingerprintManager.EnrollmentCallback mEnrollmentCallback
             = new FingerprintManager.EnrollmentCallback() {
 
         @Override
@@ -68,6 +80,9 @@
 
         @Override
         public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
+            if (mHelpIgnore.contains(helpMsgId)) {
+                return;
+            }
             FingerprintEnrollSidecar.super.onEnrollmentHelp(helpMsgId, helpString);
         }
 
diff --git a/src/com/android/settings/media/MediaOutputIndicatorWorker.java b/src/com/android/settings/media/MediaOutputIndicatorWorker.java
index 09e0672..bf1e06e 100644
--- a/src/com/android/settings/media/MediaOutputIndicatorWorker.java
+++ b/src/com/android/settings/media/MediaOutputIndicatorWorker.java
@@ -165,6 +165,13 @@
         return mPackageName;
     }
 
+    /** Check if this device supports LE Audio Broadcast feature */
+    public boolean isBroadcastSupported() {
+        LocalBluetoothLeBroadcast broadcast =
+                mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile();
+        return broadcast != null ? true : false;
+    }
+
     public boolean isDeviceBroadcasting() {
         LocalBluetoothLeBroadcast broadcast =
                 mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile();
diff --git a/src/com/android/settings/notification/MediaVolumePreferenceController.java b/src/com/android/settings/notification/MediaVolumePreferenceController.java
index 2466b77..0ddba08 100644
--- a/src/com/android/settings/notification/MediaVolumePreferenceController.java
+++ b/src/com/android/settings/notification/MediaVolumePreferenceController.java
@@ -93,7 +93,7 @@
 
     @VisibleForTesting
     boolean isSupportEndItem() {
-        return isConnectedBLEDevice();
+        return getWorker() != null && getWorker().isBroadcastSupported() && isConnectedBLEDevice();
     }
 
     private boolean isConnectedBLEDevice() {
diff --git a/src/com/android/settings/sound/AudioSwitchPreferenceController.java b/src/com/android/settings/sound/AudioSwitchPreferenceController.java
index 38fecfc..6475257 100644
--- a/src/com/android/settings/sound/AudioSwitchPreferenceController.java
+++ b/src/com/android/settings/sound/AudioSwitchPreferenceController.java
@@ -53,6 +53,7 @@
 import com.android.settingslib.core.lifecycle.events.OnStop;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.FutureTask;
@@ -227,7 +228,7 @@
         }
         final List<BluetoothDevice> devices = leAudioProfile.getConnectedDevices();
         for (BluetoothDevice device : devices) {
-            if (device.isConnected()) {
+            if (device.isConnected() && isDeviceInCachedList(device)) {
                 connectedDevices.add(device);
             }
         }
@@ -235,6 +236,22 @@
     }
 
     /**
+     * Confirm if the device exists in the cached devices list. If return true, it means
+     * the device is main device in the LE Audio device group. Otherwise, the device is the member
+     * device in the group.
+     */
+    protected boolean isDeviceInCachedList(BluetoothDevice device) {
+        Collection<CachedBluetoothDevice> cachedDevices =
+                mLocalBluetoothManager.getCachedDeviceManager().getCachedDevicesCopy();
+        for (CachedBluetoothDevice cachedDevice : cachedDevices) {
+            if (cachedDevice.getDevice().equals(device)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
      * get hearing aid profile connected device, exclude other devices with same hiSyncId.
      */
     protected List<BluetoothDevice> getConnectedHearingAidDevices() {
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
index a9f4182..b049b7b 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
@@ -18,6 +18,7 @@
 
 import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_POWER_BUTTON;
 import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_OPTICAL;
+import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UNKNOWN;
 
 import static com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling.KEY_STATE_PREVIOUS_ROTATION;
 import static com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling.SFPS_STAGE_NO_ANIMATION;
@@ -35,6 +36,8 @@
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.mock;
+
 
 import android.content.Context;
 import android.content.res.ColorStateList;
@@ -52,6 +55,8 @@
 import android.view.Surface;
 import android.widget.TextView;
 
+import androidx.annotation.Nullable;
+
 import com.android.settings.R;
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.widget.RingProgressBar;
@@ -59,7 +64,6 @@
 import com.airbnb.lottie.LottieAnimationView;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
@@ -100,16 +104,39 @@
     }
 
     @Test
-    @Ignore
     public void fingerprintEnrollHelp_shouldShowHelpText() {
-        EnrollmentCallback enrollmentCallback = verifyAndCaptureEnrollmentCallback();
+        initializeActivityFor(TYPE_UNKNOWN);
+        TestFingerprintEnrollSidecar sidecar = new TestFingerprintEnrollSidecar();
+        Resources resources = mock(Resources.class);
+        doReturn(resources).when(mContext).getResources();
+        when(resources.getIntArray(R.array.fingerprint_acquired_ignore_list))
+                .thenReturn(new int[]{3});
 
-        enrollmentCallback.onEnrollmentProgress(123);
-        enrollmentCallback.onEnrollmentHelp(
-                FingerprintManager.FINGERPRINT_ERROR_UNABLE_TO_PROCESS, "test enrollment help");
+        sidecar.setListener(mActivity);
+        sidecar.onAttach(mActivity);
+        sidecar.mEnrollmentCallback.onEnrollmentHelp(5,
+                "Help message should be displayed.");
 
         TextView errorText = mActivity.findViewById(R.id.error_text);
-        assertThat(errorText.getText()).isEqualTo("test enrollment help");
+        assertThat(errorText.getText()).isEqualTo("Help message should be displayed.");
+    }
+
+    @Test
+    public void fingerprintEnrollHelp_shouldNotShowHelpText() {
+        initializeActivityFor(TYPE_UNKNOWN);
+        TestFingerprintEnrollSidecar sidecar = new TestFingerprintEnrollSidecar();
+        Resources resources = mock(Resources.class);
+        doReturn(resources).when(mContext).getResources();
+        when(resources.getIntArray(R.array.fingerprint_acquired_ignore_list))
+                .thenReturn(new int[]{3});
+
+        sidecar.setListener(mActivity);
+        sidecar.onAttach(mActivity);
+        sidecar.mEnrollmentCallback.onEnrollmentHelp(3,
+                "Help message should not be displayed.");
+
+        TextView errorText = mActivity.findViewById(R.id.error_text);
+        assertThat(errorText.getText()).isEqualTo("");
     }
 
     @Test
@@ -319,4 +346,12 @@
 
         return callbackCaptor.getValue();
     }
+
+    private class TestFingerprintEnrollSidecar extends FingerprintEnrollSidecar {
+        @Nullable
+        @Override
+        public Context getContext() {
+            return mContext;
+        }
+    }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
index 2339f4c..cd06bae 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputIndicatorWorkerTest.java
@@ -38,11 +38,14 @@
 import android.media.session.PlaybackState;
 import android.net.Uri;
 
+import com.android.settings.bluetooth.Utils;
 import com.android.settings.slices.ShadowSliceBackgroundWorker;
 import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
 import com.android.settingslib.bluetooth.BluetoothEventManager;
+import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcast;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
 import com.android.settingslib.media.LocalMediaManager;
 
 import org.junit.Before;
@@ -69,13 +72,17 @@
     @Mock
     private BluetoothEventManager mBluetoothEventManager;
     @Mock
-    private LocalBluetoothManager mLocalBluetoothManager;
+    private LocalBluetoothManager mLocalBtManager;
+    @Mock
+    private LocalBluetoothProfileManager mLocalBluetoothProfileManager;
     @Mock
     private MediaSessionManager mMediaSessionManager;
     @Mock
     private MediaController mMediaController;
     @Mock
     private LocalMediaManager mLocalMediaManager;
+    @Mock
+    private LocalBluetoothLeBroadcast mLeAudioBroadcastProfile;
 
     private Context mContext;
     private MediaOutputIndicatorWorker mMediaOutputIndicatorWorker;
@@ -84,14 +91,18 @@
     private List<MediaController> mMediaControllers = new ArrayList<>();
     private PlaybackState mPlaybackState;
     private MediaController.PlaybackInfo mPlaybackInfo;
+    private LocalBluetoothManager mLocalBluetoothManager;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mShadowApplication = ShadowApplication.getInstance();
         mContext = spy(RuntimeEnvironment.application);
-        ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
+        ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBtManager;
+        mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
         when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
+        when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
+        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(null);
         mMediaOutputIndicatorWorker = new MediaOutputIndicatorWorker(mContext, URI);
         doReturn(mMediaSessionManager).when(mContext).getSystemService(MediaSessionManager.class);
         mMediaControllers.add(mMediaController);
@@ -284,4 +295,22 @@
 
         assertThat(mMediaOutputIndicatorWorker.getActiveLocalMediaController()).isNull();
     }
+
+    @Test
+    public void isBroadcastSupported_leAudioBroadcastProfileIsNull_returnFalse() {
+        mMediaOutputIndicatorWorker.mLocalMediaManager = mLocalMediaManager;
+        mMediaOutputIndicatorWorker.onSlicePinned();
+
+        assertThat(mMediaOutputIndicatorWorker.isBroadcastSupported()).isFalse();
+    }
+
+    @Test
+    public void isBroadcastSupported_leAudioBroadcastProfileNotNull_returnTrue() {
+        mMediaOutputIndicatorWorker.mLocalMediaManager = mLocalMediaManager;
+        mMediaOutputIndicatorWorker.onSlicePinned();
+        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile())
+                .thenReturn(mLeAudioBroadcastProfile);
+
+        assertThat(mMediaOutputIndicatorWorker.isBroadcastSupported()).isTrue();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
index 56e83bb..2d023d7 100644
--- a/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
@@ -113,13 +113,23 @@
 
     @Test
     public void isSupportEndItem_withBleDevice_returnsTrue() {
+        doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
         doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
 
         assertThat(mController.isSupportEndItem()).isTrue();
     }
 
     @Test
+    public void isSupportEndItem_notSupportedBroadcast_returnsFalse() {
+        doReturn(false).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
+        doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
+
+        assertThat(mController.isSupportEndItem()).isFalse();
+    }
+
+    @Test
     public void isSupportEndItem_withNonBleDevice_returnsFalse() {
+        doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
         doReturn(mDevice2).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
 
         assertThat(mController.isSupportEndItem()).isFalse();
@@ -127,6 +137,7 @@
 
     @Test
     public void getSliceEndItem_NotSupportEndItem_getsNullSliceAction() {
+        doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
         doReturn(mDevice2).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
 
         final SliceAction sliceAction = mController.getSliceEndItem(mContext);
@@ -136,6 +147,7 @@
 
     @Test
     public void getSliceEndItem_deviceIsBroadcasting_getsBroadcastIntent() {
+        doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
         doReturn(mDevice1).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
         doReturn(true).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting();
         doReturn(mMediaController).when(sMediaOutputIndicatorWorker)
@@ -155,6 +167,7 @@
         final CachedBluetoothDevice cachedDevice = mock(CachedBluetoothDevice.class);
         when(((BluetoothMediaDevice) device).getCachedDevice()).thenReturn(cachedDevice);
         when(device.isBLEDevice()).thenReturn(true);
+        doReturn(true).when(sMediaOutputIndicatorWorker).isBroadcastSupported();
         doReturn(device).when(sMediaOutputIndicatorWorker).getCurrentConnectedMediaDevice();
         doReturn(false).when(sMediaOutputIndicatorWorker).isDeviceBroadcasting();
         doReturn(mMediaController).when(sMediaOutputIndicatorWorker)
diff --git a/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java
index 77ddfbd..151d1f2 100644
--- a/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/sound/AudioOutputSwitchPreferenceControllerTest.java
@@ -51,6 +51,8 @@
 import com.android.settingslib.bluetooth.A2dpProfile;
 import com.android.settingslib.bluetooth.BluetoothCallback;
 import com.android.settingslib.bluetooth.BluetoothEventManager;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
 import com.android.settingslib.bluetooth.HeadsetProfile;
 import com.android.settingslib.bluetooth.HearingAidProfile;
 import com.android.settingslib.bluetooth.LeAudioProfile;
@@ -71,6 +73,7 @@
 import org.robolectric.shadows.ShadowPackageManager;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
@@ -103,6 +106,12 @@
     private HearingAidProfile mHearingAidProfile;
     @Mock
     private LeAudioProfile mLeAudioProfile;
+    @Mock
+    private CachedBluetoothDeviceManager mCachedDeviceManager;
+    @Mock
+    private CachedBluetoothDevice mCachedBluetoothDeviceL;
+    @Mock
+    private CachedBluetoothDevice mCachedBluetoothDeviceR;
 
     private Context mContext;
     private PreferenceScreen mScreen;
@@ -121,6 +130,7 @@
     private List<BluetoothDevice> mLeAudioActiveDevices;
     private List<BluetoothDevice> mEmptyDevices;
     private ShadowPackageManager mPackageManager;
+    private Collection<CachedBluetoothDevice> mCachedDevices;
 
     @Before
     public void setUp() {
@@ -135,6 +145,7 @@
 
         when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
         when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
+        when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
         when(mLocalBluetoothProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile);
         when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
         when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile);
@@ -145,6 +156,11 @@
         mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
         mBluetoothAdapter = mBluetoothManager.getAdapter();
 
+        mCachedDevices = new ArrayList<>();
+        mCachedDevices.add(mCachedBluetoothDeviceL);
+        mCachedDevices.add(mCachedBluetoothDeviceR);
+        when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
+
         mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
         when(mBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_1);
         when(mBluetoothDevice.isConnected()).thenReturn(true);
@@ -397,6 +413,7 @@
 
     @Test
     public void getConnectedLeAudioDevices_connectedLeAudioDevice_shouldAddDeviceToList() {
+        when(mCachedBluetoothDeviceL.getDevice()).thenReturn(mBluetoothDevice);
         mEmptyDevices.clear();
         mProfileConnectedDevices.clear();
         mProfileConnectedDevices.add(mBluetoothDevice);
@@ -409,22 +426,45 @@
 
     @Test
     public void getConnectedLeAudioDevices_disconnectedLeAudioDevice_shouldNotAddDeviceToList() {
-        BluetoothDevice connectdBtLeAduioDevice =
+        BluetoothDevice connectedBtLeAduioDevice =
                 spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2));
-        when(connectdBtLeAduioDevice.isConnected()).thenReturn(true);
-        BluetoothDevice disonnectdBtLeAduioDevice =
+        when(connectedBtLeAduioDevice.isConnected()).thenReturn(true);
+        BluetoothDevice disconnectedBtLeAduioDevice =
                 spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_3));
-        when(disonnectdBtLeAduioDevice.isConnected()).thenReturn(false);
+        when(disconnectedBtLeAduioDevice.isConnected()).thenReturn(false);
+        when(mCachedBluetoothDeviceL.getDevice()).thenReturn(mBluetoothDevice);
+        when(mCachedBluetoothDeviceR.getDevice()).thenReturn(connectedBtLeAduioDevice);
         mEmptyDevices.clear();
         mProfileConnectedDevices.clear();
         mProfileConnectedDevices.add(mBluetoothDevice);
-        mProfileConnectedDevices.add(connectdBtLeAduioDevice);
-        mProfileConnectedDevices.add(disonnectdBtLeAduioDevice);
+        mProfileConnectedDevices.add(connectedBtLeAduioDevice);
+        mProfileConnectedDevices.add(disconnectedBtLeAduioDevice);
         when(mLeAudioProfile.getConnectedDevices()).thenReturn(mProfileConnectedDevices);
 
         mEmptyDevices.addAll(mController.getConnectedLeAudioDevices());
 
-        assertThat(mEmptyDevices).containsExactly(mBluetoothDevice, connectdBtLeAduioDevice);
+        assertThat(mEmptyDevices).containsExactly(mBluetoothDevice, connectedBtLeAduioDevice);
+    }
+
+    @Test
+    public void getConnectedLeAudioDevices_notInCachedDeviceList_shouldNotAddDeviceToList() {
+        BluetoothDevice connectedBtLeAduioDevice1 =
+                spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2));
+        when(connectedBtLeAduioDevice1.isConnected()).thenReturn(true);
+        BluetoothDevice connectedBtLeAduioDevice2 =
+                spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_3));
+        when(connectedBtLeAduioDevice2.isConnected()).thenReturn(true);
+        when(mCachedBluetoothDeviceL.getDevice()).thenReturn(mBluetoothDevice);
+        when(mCachedBluetoothDeviceR.getDevice()).thenReturn(connectedBtLeAduioDevice1);
+        mEmptyDevices.clear();
+        mProfileConnectedDevices.clear();
+        mProfileConnectedDevices.add(connectedBtLeAduioDevice1);
+        mProfileConnectedDevices.add(connectedBtLeAduioDevice2);
+        when(mLeAudioProfile.getConnectedDevices()).thenReturn(mProfileConnectedDevices);
+
+        mEmptyDevices.addAll(mController.getConnectedLeAudioDevices());
+
+        assertThat(mEmptyDevices).containsExactly(connectedBtLeAduioDevice1);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java
index 7543b5f..cc2606b 100644
--- a/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceControllerTest.java
@@ -45,6 +45,8 @@
 import com.android.settings.testutils.shadow.ShadowAudioManager;
 import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
 import com.android.settingslib.bluetooth.BluetoothEventManager;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
 import com.android.settingslib.bluetooth.HeadsetProfile;
 import com.android.settingslib.bluetooth.HearingAidProfile;
 import com.android.settingslib.bluetooth.LeAudioProfile;
@@ -63,6 +65,7 @@
 import org.robolectric.shadows.ShadowBluetoothDevice;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
@@ -100,6 +103,12 @@
     private LeAudioProfile mLeAudioProfile;
     @Mock
     private AudioSwitchPreferenceController.AudioSwitchCallback mAudioSwitchPreferenceCallback;
+    @Mock
+    private CachedBluetoothDeviceManager mCachedDeviceManager;
+    @Mock
+    private CachedBluetoothDevice mCachedBluetoothDeviceL;
+    @Mock
+    private CachedBluetoothDevice mCachedBluetoothDeviceR;
 
     private Context mContext;
     private PreferenceScreen mScreen;
@@ -117,6 +126,7 @@
     private List<BluetoothDevice> mProfileConnectedDevices;
     private List<BluetoothDevice> mHearingAidActiveDevices;
     private List<BluetoothDevice> mLeAudioActiveDevices;
+    private Collection<CachedBluetoothDevice> mCachedDevices;
 
     @Before
     public void setUp() {
@@ -131,6 +141,7 @@
 
         when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
         when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
+        when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
         when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile);
         when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
         when(mLocalBluetoothProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile);
@@ -138,6 +149,11 @@
         mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
         mBluetoothAdapter = mBluetoothManager.getAdapter();
 
+        mCachedDevices = new ArrayList<>();
+        mCachedDevices.add(mCachedBluetoothDeviceL);
+        mCachedDevices.add(mCachedBluetoothDeviceR);
+        when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
+
         mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
         when(mBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_1);
         when(mBluetoothDevice.getAlias()).thenReturn(TEST_DEVICE_NAME_1);
@@ -480,6 +496,7 @@
     public void updateState_leAudioDeviceActive_shouldSetActivatedDeviceName() {
         mAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
         mShadowAudioManager.setOutputDevice(DEVICE_OUT_BLE_HEADSET);
+        when(mCachedBluetoothDeviceL.getDevice()).thenReturn(mBluetoothDevice);
         when(mBluetoothDevice.getName()).thenReturn(TEST_LE_AUDIO_DEVICE_NAME_1);
         when(mBluetoothDevice.getAlias()).thenReturn(TEST_LE_AUDIO_DEVICE_NAME_1);
         mProfileConnectedDevices.clear();
diff --git a/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
index 036d58c..5a92a08 100644
--- a/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/sound/MediaOutputPreferenceControllerTest.java
@@ -56,6 +56,8 @@
 import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
 import com.android.settingslib.bluetooth.A2dpProfile;
 import com.android.settingslib.bluetooth.BluetoothEventManager;
+import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
 import com.android.settingslib.bluetooth.HearingAidProfile;
 import com.android.settingslib.bluetooth.LeAudioProfile;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
@@ -77,6 +79,7 @@
 import org.robolectric.shadows.ShadowPackageManager;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
@@ -118,6 +121,12 @@
     private MediaSessionManager mMediaSessionManager;
     @Mock
     private MediaController mMediaController;
+    @Mock
+    private CachedBluetoothDeviceManager mCachedDeviceManager;
+    @Mock
+    private CachedBluetoothDevice mCachedBluetoothDeviceL;
+    @Mock
+    private CachedBluetoothDevice mCachedBluetoothDeviceR;
 
     private Context mContext;
     private PreferenceScreen mScreen;
@@ -142,6 +151,7 @@
     private ApplicationInfo mAppInfo;
     private PackageInfo mPackageInfo;
     private PackageStats mPackageStats;
+    private Collection<CachedBluetoothDevice> mCachedDevices;
 
     @Before
     public void setUp() {
@@ -173,6 +183,7 @@
 
         when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
         when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
+        when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
         when(mLocalBluetoothProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile);
         when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
         when(mLocalBluetoothProfileManager.getLeAudioProfile()).thenReturn(mLeAudioProfile);
@@ -180,6 +191,11 @@
         mBluetoothManager = mContext.getSystemService(BluetoothManager.class);
         mBluetoothAdapter = mBluetoothManager.getAdapter();
 
+        mCachedDevices = new ArrayList<>();
+        mCachedDevices.add(mCachedBluetoothDeviceL);
+        mCachedDevices.add(mCachedBluetoothDeviceR);
+        when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
+
         mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
         when(mBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_1);
         when(mBluetoothDevice.getAlias()).thenReturn(TEST_DEVICE_NAME_1);
@@ -280,6 +296,8 @@
     public void updateState_withActiveLeAudioDevice_setActivatedDeviceName() {
         mShadowAudioManager.setOutputDevice(DEVICE_OUT_BLE_HEADSET);
         mAudioManager.setMode(AudioManager.MODE_NORMAL);
+        when(mCachedBluetoothDeviceL.getDevice()).thenReturn(mBluetoothDevice);
+        when(mCachedBluetoothDeviceR.getDevice()).thenReturn(mSecondBluetoothDevice);
         when(mBluetoothDevice.getAlias()).thenReturn(TEST_LE_AUDIO_DEVICE_NAME_1);
         mProfileConnectedDevices.clear();
         mProfileConnectedDevices.add(mBluetoothDevice);