Merge "Add CtsOsTestCases:android.os.cts.HwBinderTest to postsubmits" into main am: ef80b00872 am: e8c4b35a55

Original change: https://android-review.googlesource.com/c/platform/system/libhidl/+/3026003

Change-Id: I7f88cf20c8b997d1c47e84ce273d4d3d48ff7545
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index 8867f53..54bb8dc 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -71,7 +71,16 @@
 static constexpr bool kIsRecovery = false;
 #endif
 
-static void waitForHwServiceManager() {
+static bool isHwServiceManagerInstalled() {
+    return access("/system_ext/bin/hwservicemanager", F_OK) == 0 ||
+           access("/system/system_ext/bin/hwservicemanager", F_OK) == 0 ||
+           access("/system/bin/hwservicemanager", F_OK) == 0;
+}
+
+static bool waitForHwServiceManager() {
+    if (!isHwServiceManagerInstalled()) {
+        return false;
+    }
     // TODO(b/31559095): need bionic host so that we can use 'prop_info' returned
     // from WaitForProperty
 #ifdef __ANDROID__
@@ -80,10 +89,21 @@
     using std::literals::chrono_literals::operator""s;
 
     using android::base::WaitForProperty;
-    while (!WaitForProperty(kHwServicemanagerReadyProperty, "true", 1s)) {
+    while (true) {
+        if (base::GetBoolProperty("hwservicemanager.disabled", false)) {
+            return false;
+        }
+        if (WaitForProperty(kHwServicemanagerReadyProperty, "true", 1s)) {
+            return true;
+        }
         LOG(WARNING) << "Waited for hwservicemanager.ready for a second, waiting another...";
     }
 #endif  // __ANDROID__
+    return true;
+}
+
+bool isHidlSupported() {
+    return waitForHwServiceManager();
 }
 
 static std::string binaryName() {
@@ -211,31 +231,6 @@
            fqName == IServiceManager1_2::descriptor;
 }
 
-static bool isHwServiceManagerInstalled() {
-    return access("/system_ext/bin/hwservicemanager", F_OK) == 0 ||
-           access("/system/system_ext/bin/hwservicemanager", F_OK) == 0 ||
-           access("/system/bin/hwservicemanager", F_OK) == 0;
-}
-
-bool isHidlSupported() {
-    if (!isHwServiceManagerInstalled()) {
-        return false;
-    }
-#ifdef __ANDROID__
-    // TODO(b/218588089) remove this temporary support variable once Cuttlefish
-    // (the only current Android V launching device) no longer requires HIDL.
-    constexpr bool kTempHidlSupport = true;
-    static const char* kVendorApiProperty = "ro.vendor.api_level";
-    // HIDL and hwservicemanager are not supported in Android V+
-    return android::base::GetIntProperty(kVendorApiProperty, 0) < __ANDROID_API_V__ ||
-           kTempHidlSupport;
-#else
-    // No access to properties and no requirement for dropping HIDL support if
-    // this isn't Android
-    return true;
-#endif  // __ANDROID__
-}
-
 /*
  * A replacement for hwservicemanager when it is not installed on a device.
  *
@@ -397,20 +392,18 @@
             return gDefaultServiceManager;
         }
 
-        if (!isHidlSupported()) {
-            // hwservicemanager is not available on this device.
-            LOG(WARNING) << "hwservicemanager is not supported on the device.";
-            gDefaultServiceManager = sp<NoHwServiceManager>::make();
-            return gDefaultServiceManager;
-        }
-
         if (access("/dev/hwbinder", F_OK|R_OK|W_OK) != 0) {
             // HwBinder not available on this device or not accessible to
             // this process.
             return nullptr;
         }
 
-        waitForHwServiceManager();
+        if (!isHidlSupported()) {
+            // hwservicemanager is not available on this device.
+            LOG(WARNING) << "hwservicemanager is not supported on the device.";
+            gDefaultServiceManager = sp<NoHwServiceManager>::make();
+            return gDefaultServiceManager;
+        }
 
         while (gDefaultServiceManager == nullptr) {
             gDefaultServiceManager =
diff --git a/vintfdata/freeze.sh b/vintfdata/freeze.sh
index a624ee3..d14f36e 100755
--- a/vintfdata/freeze.sh
+++ b/vintfdata/freeze.sh
@@ -19,7 +19,7 @@
     return 1
   }
 
-  local modules_to_build=check-vintf-all
+  local modules_to_build="check-vintf-all vintffm"
   echo "Building ${modules_to_build}"
   "${ANDROID_BUILD_TOP}/build/soong/soong_ui.bash" --build-mode --all-modules --dir="$(pwd)" ${modules_to_build} || {
     echo "${modules_to_build} failed. Backwards compatibility might be broken."
diff --git a/vintfdata/frozen/202404.xml b/vintfdata/frozen/202404.xml
new file mode 100644
index 0000000..fa5e3ac
--- /dev/null
+++ b/vintfdata/frozen/202404.xml
@@ -0,0 +1,69 @@
+<compatibility-matrix version="8.0" type="device">
+    <hal format="aidl" optional="false">
+        <name>android.frameworks.cameraservice.service</name>
+        <version>2</version>
+        <interface>
+            <name>ICameraService</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="aidl" optional="false">
+        <name>android.frameworks.location.altitude</name>
+        <version>2</version>
+        <interface>
+            <name>IAltitudeService</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="aidl" optional="false">
+        <name>android.frameworks.sensorservice</name>
+        <interface>
+            <name>ISensorManager</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="aidl" optional="false">
+        <name>android.frameworks.stats</name>
+        <version>2</version>
+        <interface>
+            <name>IStats</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="aidl" optional="false">
+        <name>android.frameworks.vibrator</name>
+        <interface>
+            <name>IVibratorControlService</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="aidl" optional="false">
+        <name>android.hardware.media.c2</name>
+        <interface>
+            <name>IComponentStore</name>
+            <instance>software</instance>
+        </interface>
+    </hal>
+    <hal format="aidl" optional="false">
+        <name>android.system.keystore2</name>
+        <version>4</version>
+        <interface>
+            <name>IKeystoreService</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="aidl" optional="false">
+        <name>android.system.net.netd</name>
+        <interface>
+            <name>INetd</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="aidl" optional="false">
+        <name>android.system.suspend</name>
+        <interface>
+            <name>ISystemSuspend</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+</compatibility-matrix>