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

Commit 875ed5bb authored by Haijie Hong's avatar Haijie Hong Committed by Android (Google) Code Review
Browse files

Merge "Use default icon if icon uri is not available" into main

parents ec61998b c3f45211
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))