diff options
author | Kai <kwangsudo@google.com> | 2018-06-28 17:24:12 -0700 |
---|---|---|
committer | Kai <kwangsudo@google.com> | 2018-07-02 10:29:20 -0700 |
commit | 79b6cfa5d5104bb9817919251ce94ecfd2993411 (patch) | |
tree | 408e9a32985519d6c08909c48411725f65c89cd5 /service/src/com/android | |
parent | 1ab32b66ef7467e536df727b0b9419dd31556a8e (diff) | |
download | Car-79b6cfa5d5104bb9817919251ce94ecfd2993411.tar.gz |
Send global type property event in register
Send global type properties' events sunch as AC_ON, Night_Mode
when we are registering.
Bug: 110899894, 109817929
Test: Test in OWL and Mojave
Change-Id: If713a18b33361466ab2e7499db48732ff57eb255
Diffstat (limited to 'service/src/com/android')
-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() { |