summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Wang2018-07-10 12:18:13 -0500
committerAndroid (Google) Code Review2018-07-10 12:18:13 -0500
commitf26773ed52ce972b3abf0b46b5ff1c7c3e23e29f (patch)
treeab8b0675c2999e10a4de504d74d374531d221c6b
parentbec3d91a12302ecc4d37c49c995a11588bc6cebc (diff)
parent79b6cfa5d5104bb9817919251ce94ecfd2993411 (diff)
downloadplatform-packages-services-car-f26773ed52ce972b3abf0b46b5ff1c7c3e23e29f.tar.gz
platform-packages-services-car-f26773ed52ce972b3abf0b46b5ff1c7c3e23e29f.tar.xz
platform-packages-services-car-f26773ed52ce972b3abf0b46b5ff1c7c3e23e29f.zip
Merge "Send global type property event in register" into pi-dev
-rw-r--r--service/src/com/android/car/CarPropertyService.java16
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 68c4b8cb..785e5981 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
159 if (DBG) { 159 if (DBG) {
160 Log.d(TAG, "registerListener: propId=0x" + toHexString(propId) + " rate=" + rate); 160 Log.d(TAG, "registerListener: propId=0x" + toHexString(propId) + " rate=" + rate);
161 } 161 }
162 if (mConfigs == null) {
163 mConfigs = mHal.getPropertyList();
164 }
162 if (mConfigs.get(propId) == null) { 165 if (mConfigs.get(propId) == null) {
163 // Do not attempt to register an invalid propId 166 // Do not attempt to register an invalid propId
164 Log.e(TAG, "registerListener: propId is not in config list: " + propId); 167 Log.e(TAG, "registerListener: propId is not in config list: " + propId);
@@ -197,14 +200,20 @@ public class CarPropertyService extends ICarProperty.Stub
197 mHal.subscribeProperty(propId, rate); 200 mHal.subscribeProperty(propId, rate);
198 } 201 }
199 } 202 }
200
201 // Send the latest value(s) to the registering listener only 203 // Send the latest value(s) to the registering listener only
202 List<CarPropertyEvent> events = new LinkedList<CarPropertyEvent>(); 204 List<CarPropertyEvent> events = new LinkedList<CarPropertyEvent>();
203 for (int areaId : mConfigs.get(propId).getAreaIds()) { 205 if (mConfigs.get(propId).isGlobalProperty()) {
204 CarPropertyValue value = mHal.getProperty(propId, areaId); 206 CarPropertyValue value = mHal.getProperty(propId, 0);
205 CarPropertyEvent event = new CarPropertyEvent( 207 CarPropertyEvent event = new CarPropertyEvent(
206 CarPropertyEvent.PROPERTY_EVENT_PROPERTY_CHANGE, value); 208 CarPropertyEvent.PROPERTY_EVENT_PROPERTY_CHANGE, value);
207 events.add(event); 209 events.add(event);
210 } else {
211 for (int areaId : mConfigs.get(propId).getAreaIds()) {
212 CarPropertyValue value = mHal.getProperty(propId, areaId);
213 CarPropertyEvent event = new CarPropertyEvent(
214 CarPropertyEvent.PROPERTY_EVENT_PROPERTY_CHANGE, value);
215 events.add(event);
216 }
208 } 217 }
209 try { 218 try {
210 listener.onEvent(events); 219 listener.onEvent(events);
@@ -276,6 +285,7 @@ public class CarPropertyService extends ICarProperty.Stub
276 285
277 /** 286 /**
278 * Return the list of properties that the caller may access. 287 * Return the list of properties that the caller may access.
288 * Should be called before get/setProperty().
279 */ 289 */
280 @Override 290 @Override
281 public List<CarPropertyConfig> getPropertyList() { 291 public List<CarPropertyConfig> getPropertyList() {