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

Commit 0bc82f87 authored by Angela Wang's avatar Angela Wang
Browse files

Refreshes the icon immediately after setHearingAidInfo() is called

If we know a device is hearing devices, we should refresh the icon
immediately.

Bug: 317737217
Test: atest BluetoothUtilsTest#getBtClassDrawableWithDescription_typeHearingAid_returnHearingAidDrawable
Change-Id: I9f3d3d822bc7783aa677e42d7999548c8f6c5ce3
parent b1e0f283
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -117,6 +117,12 @@ public class BluetoothUtils {
            }
        }

        if (cachedDevice.isHearingAidDevice()) {
            return new Pair<>(getBluetoothDrawable(context,
                    com.android.internal.R.drawable.ic_bt_hearing_aid),
                    context.getString(R.string.bluetooth_talkback_hearing_aids));
        }

        List<LocalBluetoothProfile> profiles = cachedDevice.getProfiles();
        int resId = 0;
        for (LocalBluetoothProfile profile : profiles) {
+1 −0
Original line number Diff line number Diff line
@@ -412,6 +412,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>

    public void setHearingAidInfo(HearingAidInfo hearingAidInfo) {
        mHearingAidInfo = hearingAidInfo;
        dispatchAttributesChanged();
    }

    public HearingAidInfo getHearingAidInfo() {
+9 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.settingslib.bluetooth;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -86,6 +87,14 @@ public class BluetoothUtilsTest {
        verify(mContext).getDrawable(com.android.internal.R.drawable.ic_bt_laptop);
    }

    @Test
    public void getBtClassDrawableWithDescription_typeHearingAid_returnHearingAidDrawable() {
        when(mCachedBluetoothDevice.isHearingAidDevice()).thenReturn(true);
        BluetoothUtils.getBtClassDrawableWithDescription(mContext, mCachedBluetoothDevice);

        verify(mContext).getDrawable(com.android.internal.R.drawable.ic_bt_hearing_aid);
    }

    @Test
    public void getBtRainbowDrawableWithDescription_normalHeadset_returnAdaptiveIcon() {
        when(mBluetoothDevice.getMetadata(