IBase::getReferenceInfo -> getDebugInfo

Bug: 34777099
Bug: 34861460

Test: lshal
Test: NFC / light / audio with and without persistent.hal.binderized;
      run lshal to reflect this.

Change-Id: I70aebefcaf5ed92a3c31a7bf2406d610c4533258
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index 6be7254..de4519b 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -18,6 +18,13 @@
 
 #include <hidl/HidlBinderSupport.h>
 
+// C includes
+#include <unistd.h>
+
+// C++ includes
+#include <fstream>
+#include <sstream>
+
 #ifdef LIBHIDL_TARGET_DEBUGGABLE
 #include <android-base/logging.h>
 #endif
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index cdcfd0e..e3cbea4 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -198,7 +198,8 @@
                     vec.push_back({
                         .interfaceName = matchedName,
                         .instanceName = "",
-                        .refCount = -1,
+                        .pid = -1,
+                        .ptr = 0,
                     });
                 }
             }
diff --git a/transport/base/1.0/Android.mk b/transport/base/1.0/Android.mk
index cae969c..0d2ff24 100644
--- a/transport/base/1.0/Android.mk
+++ b/transport/base/1.0/Android.mk
@@ -13,9 +13,9 @@
 HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
 
 #
-# Build types.hal (ReferenceInfo)
+# Build types.hal (DebugInfo)
 #
-GEN := $(intermediates)/android/hidl/base/V1_0/ReferenceInfo.java
+GEN := $(intermediates)/android/hidl/base/V1_0/DebugInfo.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -24,7 +24,7 @@
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
         -Ljava \
         -randroid.hidl:system/libhidl/transport \
-        android.hidl.base@1.0::types.ReferenceInfo
+        android.hidl.base@1.0::types.DebugInfo
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
@@ -63,9 +63,9 @@
 HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
 
 #
-# Build types.hal (ReferenceInfo)
+# Build types.hal (DebugInfo)
 #
-GEN := $(intermediates)/android/hidl/base/V1_0/ReferenceInfo.java
+GEN := $(intermediates)/android/hidl/base/V1_0/DebugInfo.java
 $(GEN): $(HIDL)
 $(GEN): PRIVATE_HIDL := $(HIDL)
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
@@ -74,7 +74,7 @@
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
         -Ljava \
         -randroid.hidl:system/libhidl/transport \
-        android.hidl.base@1.0::types.ReferenceInfo
+        android.hidl.base@1.0::types.DebugInfo
 
 $(GEN): $(LOCAL_PATH)/types.hal
 	$(transform-generated-source)
diff --git a/transport/base/1.0/IBase.hal b/transport/base/1.0/IBase.hal
index 643ac6e..5d4d51a 100644
--- a/transport/base/1.0/IBase.hal
+++ b/transport/base/1.0/IBase.hal
@@ -95,9 +95,7 @@
 
     /*
      * Get debug information on references on this interface.
-     * @return info has the following information:
-     *         - refCount: -1 if not available; or
-     *                     ref count on the stub for remote binderized servers.
+     * @return info debugging information. See comments of DebugInfo.
      */
-    getReferenceInfo() generates (ReferenceInfo info);
+    getDebugInfo() generates (DebugInfo info);
 };
diff --git a/transport/base/1.0/types.hal b/transport/base/1.0/types.hal
index 0d47184..0f225d2 100644
--- a/transport/base/1.0/types.hal
+++ b/transport/base/1.0/types.hal
@@ -17,9 +17,10 @@
 package android.hidl.base@1.0;
 
 /*
- * The returned object for getReferenceInfo.
- * refCount: strong reference count on the stub object.
+ * The returned object for getDebugInfo.
+ * pid: pid of current process. -1 if not available.
  */
-struct ReferenceInfo {
-    int64_t refCount;
+struct DebugInfo {
+    int32_t pid;
+    uint64_t ptr;
 };
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index 120e818..fb0b1f0 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -17,6 +17,9 @@
 #ifndef ANDROID_HIDL_BINDER_SUPPORT_H
 #define ANDROID_HIDL_BINDER_SUPPORT_H
 
+#include <sys/types.h>
+
+#include <android/hidl/base/1.0/BnHwBase.h>
 #include <android/hidl/base/1.0/IBase.h>
 #include <hidl/HidlSupport.h>
 #include <hidl/HidlTransportUtils.h>
@@ -26,7 +29,6 @@
 #include <hwbinder/IPCThreadState.h>
 #include <hwbinder/Parcel.h>
 #include <hwbinder/ProcessState.h>
-#include <android/hidl/base/1.0/BnHwBase.h>
 // Defines functions for hidl_string, hidl_version, Status, hidl_vec, MQDescriptor,
 // etc. to interact with Parcel.
 
diff --git a/transport/manager/1.0/IServiceManager.hal b/transport/manager/1.0/IServiceManager.hal
index 10823ca..2eafed0 100644
--- a/transport/manager/1.0/IServiceManager.hal
+++ b/transport/manager/1.0/IServiceManager.hal
@@ -112,7 +112,9 @@
         string interfaceName;
         string instanceName;
         // negative values means N/A.
-        int64_t refCount;
+        int32_t pid;
+        // 0 means N/A.
+        uint64_t ptr;
     };
 
     /*