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 <cjd001113@outlook.com>
This commit is contained in:
Tnze
2022-08-29 20:18:50 +08:00
committed by JunDao Tnze
parent 860bf12b8f
commit f74fde1975

View File

@@ -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;
}
}
}