Merge "bt: Use group id to select color for icon" into udc-dev am: b98f79e575

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23083998

Change-Id: Iac5ab45c989292681bcc22c4dc8d15b85cc0c033
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Michał Narajowski
2023-05-09 10:52:50 +00:00
committed by Automerger Merge Worker
2 changed files with 11 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import android.annotation.SuppressLint;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothCsipSetCoordinator;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
@@ -174,14 +175,21 @@ public class BluetoothUtils {
resources, ((BitmapDrawable) pair.first).getBitmap()), pair.second);
}
int hashCode;
if ((cachedDevice.getGroupId() != BluetoothCsipSetCoordinator.GROUP_ID_INVALID)) {
hashCode = new Integer(cachedDevice.getGroupId()).hashCode();
} else {
hashCode = cachedDevice.getAddress().hashCode();
}
return new Pair<>(buildBtRainbowDrawable(context,
pair.first, cachedDevice.getAddress().hashCode()), pair.second);
pair.first, hashCode), pair.second);
}
/**
* Build Bluetooth device icon with rainbow
*/
public static Drawable buildBtRainbowDrawable(Context context, Drawable drawable,
private static Drawable buildBtRainbowDrawable(Context context, Drawable drawable,
int hashCode) {
final Resources resources = context.getResources();

View File

@@ -1548,8 +1548,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
refresh();
}
return new Pair<>(BluetoothUtils.buildBtRainbowDrawable(
mContext, pair.first, getAddress().hashCode()), pair.second);
return BluetoothUtils.getBtRainbowDrawableWithDescription(mContext, this);
}
void releaseLruCache() {