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

Commit 0469e1b6 authored by Jack He's avatar Jack He Committed by Automerger Merge Worker
Browse files

Merge "bt: Use group id to select color for icon" am: 3aa1e300 am:...

Merge "bt: Use group id to select color for icon" am: 3aa1e300 am: ee6eb4af am: 3b2192b2 am: fb1ef2d2 am: 5ed2a4c7

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



Change-Id: I0b270d0e882d4d31edbc49486ca172b9b3a11329
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e6aa9dc9 5ed2a4c7
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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();

+1 −2
Original line number Diff line number Diff line
@@ -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() {