Merge "Fix pixel buds icon is empty in output switcher" into rvc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
31534b741c
@@ -18,6 +18,7 @@ package com.android.settingslib.media;
|
|||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.media.MediaRoute2Info;
|
import android.media.MediaRoute2Info;
|
||||||
import android.media.MediaRouter2Manager;
|
import android.media.MediaRouter2Manager;
|
||||||
@@ -56,8 +57,9 @@ public class BluetoothMediaDevice extends MediaDevice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Drawable getIcon() {
|
public Drawable getIcon() {
|
||||||
final Drawable drawable = getIconWithoutBackground();
|
final Drawable drawable =
|
||||||
if (!isFastPairDevice()) {
|
BluetoothUtils.getBtDrawableWithDescription(mContext, mCachedDevice).first;
|
||||||
|
if (!(drawable instanceof BitmapDrawable)) {
|
||||||
setColorFilter(drawable);
|
setColorFilter(drawable);
|
||||||
}
|
}
|
||||||
return BluetoothUtils.buildAdvancedDrawable(mContext, drawable);
|
return BluetoothUtils.buildAdvancedDrawable(mContext, drawable);
|
||||||
@@ -65,9 +67,7 @@ public class BluetoothMediaDevice extends MediaDevice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Drawable getIconWithoutBackground() {
|
public Drawable getIconWithoutBackground() {
|
||||||
return isFastPairDevice()
|
return BluetoothUtils.getBtClassDrawableWithDescription(mContext, mCachedDevice).first;
|
||||||
? BluetoothUtils.getBtDrawableWithDescription(mContext, mCachedDevice).first
|
|
||||||
: mContext.getDrawable(R.drawable.ic_headphone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothProfile;
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
|
|
||||||
@@ -96,4 +97,17 @@ public class BluetoothMediaDeviceTest {
|
|||||||
|
|
||||||
assertThat(mBluetoothMediaDevice.isFastPairDevice()).isFalse();
|
assertThat(mBluetoothMediaDevice.isFastPairDevice()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getIcon_isNotFastPairDevice_drawableTypeIsNotBitmapDrawable() {
|
||||||
|
final BluetoothDevice bluetoothDevice = mock(BluetoothDevice.class);
|
||||||
|
when(mDevice.getDevice()).thenReturn(bluetoothDevice);
|
||||||
|
|
||||||
|
final String value = "False";
|
||||||
|
final byte[] bytes = value.getBytes();
|
||||||
|
when(bluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
|
||||||
|
.thenReturn(bytes);
|
||||||
|
|
||||||
|
assertThat(mBluetoothMediaDevice.getIcon() instanceof BitmapDrawable).isFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user