Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3f45211 authored by Haijie Hong's avatar Haijie Hong
Browse files

Use default icon if icon uri is not available

Test: atest AdvancedBluetoothDetailsHeaderControllerTest
Flag: EXEMPT minor fix
Bug: 361715910
Change-Id: I66340ac1c6e5e59d25b306d5460e776c5b7c8f50
parent 03f75258
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -311,6 +311,8 @@ public class BluetoothUtils {
                } catch (SecurityException e) {
                    Log.e(TAG, "Failed to get permission for: " + iconUri, e);
                }
            } else {
                return new Pair<>(context.getDrawable(R.drawable.ic_earbuds_advanced), pair.second);
            }
        }

+17 −0
Original line number Diff line number Diff line
@@ -233,6 +233,23 @@ public class BluetoothUtilsTest {
                .isInstanceOf(AdaptiveIcon.class);
    }

    @Test
    public void getBtDrawableWithDescription_untetheredHeadset_returnUntetheredIcon() {
        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
                .thenReturn("true".getBytes());
        when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
        when(mCachedBluetoothDevice.getAddress()).thenReturn("1f:aa:bb");
        Drawable icon = mock(Drawable.class);
        when(mContext.getDrawable(com.android.settingslib.R.drawable.ic_earbuds_advanced))
                .thenReturn(icon);

        assertThat(
                BluetoothUtils.getBtDrawableWithDescription(
                        mContext, mCachedBluetoothDevice)
                        .first)
                .isSameInstanceAs(icon);
    }

    @Test
    public void getStringMetaData_hasMetaData_getCorrectMetaData() {
        when(mBluetoothDevice.getMetadata(BluetoothDevice.METADATA_UNTETHERED_LEFT_ICON))