From f74fde197586486ce88445d2eb0db89a084c3722 Mon Sep 17 00:00:00 2001 From: Tnze Date: Mon, 29 Aug 2022 20:18:50 +0800 Subject: [PATCH] Use HwLight.type as the key of mLightsByType There are two paths to consider: - HIDL HAL: We always set hwLight.id == hwLight.type == (byte)i; - AIDL HAL: hwLight.id may be not equals to hwLight.type; This patch use hwLight.type as the key of mLightsByType. Change-Id: I5c8c4df4bb2d6bda44bdd62d2b9ac7d9cb674d3f Signed-off-by: Tnze --- .../core/java/com/android/server/lights/LightsService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java index 91f14de040fe4..6c8ba1609f500 100644 --- a/services/core/java/com/android/server/lights/LightsService.java +++ b/services/core/java/com/android/server/lights/LightsService.java @@ -465,9 +465,10 @@ public class LightsService extends SystemService { } for (int i = mLightsById.size() - 1; i >= 0; i--) { - final int type = mLightsById.keyAt(i); + LightImpl light = mLightsById.valueAt(i); + final int type = light.mHwLight.type; if (0 <= type && type < mLightsByType.length) { - mLightsByType[type] = mLightsById.valueAt(i); + mLightsByType[type] = light; } } }