diff options
author | Kai Wang <kwangsudo@google.com> | 2018-07-10 17:18:13 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-07-10 17:18:13 +0000 |
commit | f26773ed52ce972b3abf0b46b5ff1c7c3e23e29f (patch) | |
tree | ab8b0675c2999e10a4de504d74d374531d221c6b | |
parent | bec3d91a12302ecc4d37c49c995a11588bc6cebc (diff) | |
parent | 79b6cfa5d5104bb9817919251ce94ecfd2993411 (diff) | |
download | Car-f26773ed52ce972b3abf0b46b5ff1c7c3e23e29f.tar.gz |
Merge "Send global type property event in register" into pi-dev
-rw-r--r-- | service/src/com/android/car/CarPropertyService.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/service/src/com/android/car/CarPropertyService.java b/service/src/com/android/car/CarPropertyService.java index 68c4b8cbcb..785e59810c 100644 --- a/service/src/com/android/car/CarPropertyService.java +++ b/service/src/com/android/car/CarPropertyService.java @@ -159,6 +159,9 @@ public class CarPropertyService extends ICarProperty.Stub if (DBG) { Log.d(TAG, "registerListener: propId=0x" + toHexString(propId) + " rate=" + rate); } + if (mConfigs == null) { + mConfigs = mHal.getPropertyList(); + } if (mConfigs.get(propId) == null) { // Do not attempt to register an invalid propId Log.e(TAG, "registerListener: propId is not in config list: " + propId); @@ -197,14 +200,20 @@ public class CarPropertyService extends ICarProperty.Stub mHal.subscribeProperty(propId, rate); } } - // Send the latest value(s) to the registering listener only List<CarPropertyEvent> events = new LinkedList<CarPropertyEvent>(); - for (int areaId : mConfigs.get(propId).getAreaIds()) { - CarPropertyValue value = mHal.getProperty(propId, areaId); + if (mConfigs.get(propId).isGlobalProperty()) { + CarPropertyValue value = mHal.getProperty(propId, 0); CarPropertyEvent event = new CarPropertyEvent( CarPropertyEvent.PROPERTY_EVENT_PROPERTY_CHANGE, value); events.add(event); + } else { + for (int areaId : mConfigs.get(propId).getAreaIds()) { + CarPropertyValue value = mHal.getProperty(propId, areaId); + CarPropertyEvent event = new CarPropertyEvent( + CarPropertyEvent.PROPERTY_EVENT_PROPERTY_CHANGE, value); + events.add(event); + } } try { listener.onEvent(events); @@ -276,6 +285,7 @@ public class CarPropertyService extends ICarProperty.Stub /** * Return the list of properties that the caller may access. + * Should be called before get/setProperty(). */ @Override public List<CarPropertyConfig> getPropertyList() { |