HalDevManager: Cache the result of vendor hal support in init flow

There are two benefits
1. Reduce the counts of IPC call to query via service manager
2. Prevent from another thread will have chance to be blocked with
synchronized mLock during running iWifi.start().

Bug: 79163913
Bug: 80626882
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Change-Id: Ie6994bfe349a5f04cd1b83ab93e4fbf7de7a9554
diff --git a/service/java/com/android/server/wifi/HalDeviceManager.java b/service/java/com/android/server/wifi/HalDeviceManager.java
index 5bc52d4..a5e461e 100644
--- a/service/java/com/android/server/wifi/HalDeviceManager.java
+++ b/service/java/com/android/server/wifi/HalDeviceManager.java
@@ -76,6 +76,9 @@
 
     private final Clock mClock;
 
+    // cache the value for supporting vendor HAL or not
+    private boolean mIsVendorHalSupported = false;
+
     // public API
     public HalDeviceManager(Clock clock) {
         mClock = clock;
@@ -134,7 +137,7 @@
      * Returns whether the vendor HAL is supported on this device or not.
      */
     public boolean isSupported() {
-        return isSupportedInternal();
+        return mIsVendorHalSupported;
     }
 
     /**
@@ -611,7 +614,7 @@
 
     private void initializeInternal() {
         initIServiceManagerIfNecessary();
-        if (isSupportedInternal()) {
+        if (mIsVendorHalSupported) {
             initIWifiIfNecessary();
         }
     }
@@ -685,6 +688,9 @@
                     Log.wtf(TAG, "Exception while operating on IServiceManager: " + e);
                     mServiceManager = null;
                 }
+
+                // Cache the result for the supporting vendor hal or not
+                mIsVendorHalSupported = isSupportedInternal();
             }
         }
     }