summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai2018-07-20 16:25:34 -0500
committerKai2018-07-20 16:29:06 -0500
commit579b5d3e96e115834220c0927bf390baff036924 (patch)
tree4df9b1cd2762089df93ae25dfce0116b8cb0a7b5
parentf26773ed52ce972b3abf0b46b5ff1c7c3e23e29f (diff)
downloadplatform-packages-services-car-579b5d3e96e115834220c0927bf390baff036924.tar.gz
platform-packages-services-car-579b5d3e96e115834220c0927bf390baff036924.tar.xz
platform-packages-services-car-579b5d3e96e115834220c0927bf390baff036924.zip
Cache CarPropertyConfigs in CarPropertyService
Cache CarPropertyConfigs in init(). Bug:111694943 Test: build and logcat Change-Id: I66713cf7accf4b12279d809a2d77e2e2e69e93d7
-rw-r--r--service/src/com/android/car/CarPropertyService.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/service/src/com/android/car/CarPropertyService.java b/service/src/com/android/car/CarPropertyService.java
index 785e5981..a01d4b87 100644
--- a/service/src/com/android/car/CarPropertyService.java
+++ b/service/src/com/android/car/CarPropertyService.java
@@ -137,6 +137,13 @@ public class CarPropertyService extends ICarProperty.Stub
137 137
138 @Override 138 @Override
139 public void init() { 139 public void init() {
140 if (mConfigs == null) {
141 // Cache the configs list to avoid subsequent binder calls
142 mConfigs = mHal.getPropertyList();
143 if (DBG) {
144 Log.d(TAG, "cache CarPropertyConfigs " + mConfigs.size());
145 }
146 }
140 } 147 }
141 148
142 @Override 149 @Override
@@ -159,9 +166,6 @@ public class CarPropertyService extends ICarProperty.Stub
159 if (DBG) { 166 if (DBG) {
160 Log.d(TAG, "registerListener: propId=0x" + toHexString(propId) + " rate=" + rate); 167 Log.d(TAG, "registerListener: propId=0x" + toHexString(propId) + " rate=" + rate);
161 } 168 }
162 if (mConfigs == null) {
163 mConfigs = mHal.getPropertyList();
164 }
165 if (mConfigs.get(propId) == null) { 169 if (mConfigs.get(propId) == null) {
166 // Do not attempt to register an invalid propId 170 // Do not attempt to register an invalid propId
167 Log.e(TAG, "registerListener: propId is not in config list: " + propId); 171 Log.e(TAG, "registerListener: propId is not in config list: " + propId);
@@ -285,15 +289,10 @@ public class CarPropertyService extends ICarProperty.Stub
285 289
286 /** 290 /**
287 * Return the list of properties that the caller may access. 291 * Return the list of properties that the caller may access.
288 * Should be called before get/setProperty().
289 */ 292 */
290 @Override 293 @Override
291 public List<CarPropertyConfig> getPropertyList() { 294 public List<CarPropertyConfig> getPropertyList() {
292 List<CarPropertyConfig> returnList = new ArrayList<CarPropertyConfig>(); 295 List<CarPropertyConfig> returnList = new ArrayList<CarPropertyConfig>();
293 if (mConfigs == null) {
294 // Cache the configs list to avoid subsequent binder calls
295 mConfigs = mHal.getPropertyList();
296 }
297 for (CarPropertyConfig c : mConfigs.values()) { 296 for (CarPropertyConfig c : mConfigs.values()) {
298 if (ICarImpl.hasPermission(mContext, mHal.getReadPermission(c.getPropertyId()))) { 297 if (ICarImpl.hasPermission(mContext, mHal.getReadPermission(c.getPropertyId()))) {
299 // Only add properties the list if the process has permissions to read it 298 // Only add properties the list if the process has permissions to read it