Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java +18 −5 Original line number Diff line number Diff line Loading @@ -101,6 +101,22 @@ public class BluetoothUtils { void onShowError(Context context, String name, int messageResId); } /** * @param context to access resources from * @param cachedDevice to get class from * @return pair containing the drawable and the description of the type of the device. The type * could either derived from metadata or CoD. */ public static Pair<Drawable, String> getDerivedBtClassDrawableWithDescription( Context context, CachedBluetoothDevice cachedDevice) { return BluetoothUtils.isAdvancedUntetheredDevice(cachedDevice.getDevice()) ? new Pair<>( getBluetoothDrawable( context, com.android.internal.R.drawable.ic_bt_headphones_a2dp), context.getString(R.string.bluetooth_talkback_headphone)) : BluetoothUtils.getBtClassDrawableWithDescription(context, cachedDevice); } /** * @param context to access resources from * @param cachedDevice to get class from Loading Loading @@ -731,9 +747,7 @@ public class BluetoothUtils { int broadcastId = broadcast.getLatestBroadcastId(); return !sourceList.isEmpty() && broadcastId != UNKNOWN_VALUE_PLACEHOLDER && sourceList.stream() .anyMatch( source -> isSourceMatched(source, broadcastId)); && sourceList.stream().anyMatch(source -> isSourceMatched(source, broadcastId)); } /** Checks the connectivity status based on the provided broadcast receive state. */ Loading Loading @@ -1030,8 +1044,7 @@ public class BluetoothUtils { cachedDevice.getAddress()); break; case BluetoothProfile.LE_AUDIO: if (audioDeviceCategory == AudioManager.AUDIO_DEVICE_CATEGORY_SPEAKER) { if (audioDeviceCategory == AudioManager.AUDIO_DEVICE_CATEGORY_SPEAKER) { saDevice = new AudioDeviceAttributes( AudioDeviceAttributes.ROLE_OUTPUT, Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java +33 −5 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.platform.test.flag.junit.SetFlagsRule; import android.provider.Settings; import android.util.Pair; import com.android.internal.R; import com.android.settingslib.widget.AdaptiveIcon; import com.google.common.collect.ImmutableList; Loading Loading @@ -117,6 +118,34 @@ public class BluetoothUtilsTest { when(mHearingAid.getProfileId()).thenReturn(BluetoothProfile.HEARING_AID); } @Test public void getDerivedBtClassDrawableWithDescription_isAdvancedUntetheredDevice_returnHeadset() { when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)) .thenReturn(BOOL_METADATA.getBytes()); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice); Pair<Drawable, String> pair = BluetoothUtils.getDerivedBtClassDrawableWithDescription( mContext, mCachedBluetoothDevice); verify(mContext).getDrawable(R.drawable.ic_bt_headphones_a2dp); } @Test public void getDerivedBtClassDrawableWithDescription_notAdvancedUntetheredDevice_returnPhone() { when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)) .thenReturn("false".getBytes()); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice); when(mCachedBluetoothDevice.getBtClass().getMajorDeviceClass()) .thenReturn(BluetoothClass.Device.Major.PHONE); Pair<Drawable, String> pair = BluetoothUtils.getDerivedBtClassDrawableWithDescription( mContext, mCachedBluetoothDevice); verify(mContext).getDrawable(R.drawable.ic_phone); } @Test public void getBtClassDrawableWithDescription_typePhone_returnPhoneDrawable() { when(mCachedBluetoothDevice.getBtClass().getMajorDeviceClass()) Loading Loading @@ -699,7 +728,6 @@ public class BluetoothUtilsTest { .isFalse(); } @Test public void isAvailableHearingDevice_isConnectedHearingAid_returnTure() { when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true); Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothUtils.java +18 −5 Original line number Diff line number Diff line Loading @@ -101,6 +101,22 @@ public class BluetoothUtils { void onShowError(Context context, String name, int messageResId); } /** * @param context to access resources from * @param cachedDevice to get class from * @return pair containing the drawable and the description of the type of the device. The type * could either derived from metadata or CoD. */ public static Pair<Drawable, String> getDerivedBtClassDrawableWithDescription( Context context, CachedBluetoothDevice cachedDevice) { return BluetoothUtils.isAdvancedUntetheredDevice(cachedDevice.getDevice()) ? new Pair<>( getBluetoothDrawable( context, com.android.internal.R.drawable.ic_bt_headphones_a2dp), context.getString(R.string.bluetooth_talkback_headphone)) : BluetoothUtils.getBtClassDrawableWithDescription(context, cachedDevice); } /** * @param context to access resources from * @param cachedDevice to get class from Loading Loading @@ -731,9 +747,7 @@ public class BluetoothUtils { int broadcastId = broadcast.getLatestBroadcastId(); return !sourceList.isEmpty() && broadcastId != UNKNOWN_VALUE_PLACEHOLDER && sourceList.stream() .anyMatch( source -> isSourceMatched(source, broadcastId)); && sourceList.stream().anyMatch(source -> isSourceMatched(source, broadcastId)); } /** Checks the connectivity status based on the provided broadcast receive state. */ Loading Loading @@ -1030,8 +1044,7 @@ public class BluetoothUtils { cachedDevice.getAddress()); break; case BluetoothProfile.LE_AUDIO: if (audioDeviceCategory == AudioManager.AUDIO_DEVICE_CATEGORY_SPEAKER) { if (audioDeviceCategory == AudioManager.AUDIO_DEVICE_CATEGORY_SPEAKER) { saDevice = new AudioDeviceAttributes( AudioDeviceAttributes.ROLE_OUTPUT, Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothUtilsTest.java +33 −5 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.platform.test.flag.junit.SetFlagsRule; import android.provider.Settings; import android.util.Pair; import com.android.internal.R; import com.android.settingslib.widget.AdaptiveIcon; import com.google.common.collect.ImmutableList; Loading Loading @@ -117,6 +118,34 @@ public class BluetoothUtilsTest { when(mHearingAid.getProfileId()).thenReturn(BluetoothProfile.HEARING_AID); } @Test public void getDerivedBtClassDrawableWithDescription_isAdvancedUntetheredDevice_returnHeadset() { when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)) .thenReturn(BOOL_METADATA.getBytes()); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice); Pair<Drawable, String> pair = BluetoothUtils.getDerivedBtClassDrawableWithDescription( mContext, mCachedBluetoothDevice); verify(mContext).getDrawable(R.drawable.ic_bt_headphones_a2dp); } @Test public void getDerivedBtClassDrawableWithDescription_notAdvancedUntetheredDevice_returnPhone() { when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET)) .thenReturn("false".getBytes()); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice); when(mCachedBluetoothDevice.getBtClass().getMajorDeviceClass()) .thenReturn(BluetoothClass.Device.Major.PHONE); Pair<Drawable, String> pair = BluetoothUtils.getDerivedBtClassDrawableWithDescription( mContext, mCachedBluetoothDevice); verify(mContext).getDrawable(R.drawable.ic_phone); } @Test public void getBtClassDrawableWithDescription_typePhone_returnPhoneDrawable() { when(mCachedBluetoothDevice.getBtClass().getMajorDeviceClass()) Loading Loading @@ -699,7 +728,6 @@ public class BluetoothUtilsTest { .isFalse(); } @Test public void isAvailableHearingDevice_isConnectedHearingAid_returnTure() { when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true); Loading