HidlTransportSupport: add getPidIfSharable.

This function provides PID when it is "sharable" (i.e
on debug builds). Auto-generated IBase::getDebugInfo
uses this function (both in Java and C++) to provide
the PID.

Test: builds
Test: lshal works
Bug: 68430495
Bug: 68992575
Change-Id: I051e795bb01528341a5f061892902a9f305ad493
diff --git a/transport/HidlTransportSupport.cpp b/transport/HidlTransportSupport.cpp
index 9bb8148..1a9f195 100644
--- a/transport/HidlTransportSupport.cpp
+++ b/transport/HidlTransportSupport.cpp
@@ -53,5 +53,16 @@
     return true;
 }
 
+namespace details {
+int32_t getPidIfSharable() {
+#if LIBHIDL_TARGET_DEBUGGABLE
+    return getpid();
+#else
+    using android::hidl::manager::V1_0::IServiceManager;
+    return IServiceManager::PidConstant::NO_PID;
+#endif
+}
+}  // namespace details
+
 }  // namespace hardware
 }  // namespace android
diff --git a/transport/include/hidl/HidlTransportSupport.h b/transport/include/hidl/HidlTransportSupport.h
index 730727c..9123d6f 100644
--- a/transport/include/hidl/HidlTransportSupport.h
+++ b/transport/include/hidl/HidlTransportSupport.h
@@ -78,6 +78,9 @@
 
 namespace details {
 
+// Return PID on userdebug / eng builds and IServiceManager::PidConstant::NO_PID on user builds.
+int32_t getPidIfSharable();
+
 // cast the interface IParent to IChild.
 // Return nonnull if cast successful.
 // Return nullptr if: