Cache CarPropertyConfigs in CarPropertyService

Cache CarPropertyConfigs in init().

Bug:111694943
Test: build and logcat
Change-Id: I66713cf7accf4b12279d809a2d77e2e2e69e93d7
diff --git a/service/src/com/android/car/CarPropertyService.java b/service/src/com/android/car/CarPropertyService.java
index 785e598..a01d4b8 100644
--- a/service/src/com/android/car/CarPropertyService.java
+++ b/service/src/com/android/car/CarPropertyService.java
@@ -137,6 +137,13 @@
 
     @Override
     public void init() {
+        if (mConfigs == null) {
+            // Cache the configs list to avoid subsequent binder calls
+            mConfigs = mHal.getPropertyList();
+            if (DBG) {
+                Log.d(TAG, "cache CarPropertyConfigs " + mConfigs.size());
+            }
+        }
     }
 
     @Override
@@ -159,9 +166,6 @@
         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);
@@ -285,15 +289,10 @@
 
     /**
      * Return the list of properties that the caller may access.
-     * Should be called before get/setProperty().
      */
     @Override
     public List<CarPropertyConfig> getPropertyList() {
         List<CarPropertyConfig> returnList = new ArrayList<CarPropertyConfig>();
-        if (mConfigs == null) {
-            // Cache the configs list to avoid subsequent binder calls
-            mConfigs = mHal.getPropertyList();
-        }
         for (CarPropertyConfig c : mConfigs.values()) {
             if (ICarImpl.hasPermission(mContext, mHal.getReadPermission(c.getPropertyId()))) {
                 // Only add properties the list if the process has permissions to read it