summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2017-11-20 11:36:51 -0800
committerYifan Hong <elsk@google.com>2017-11-20 11:53:26 -0800
commit7a4b75659088fe2fa2723bb3cddc07301b9c62bc (patch)
treee077acfa2ac91594a71900841c219ff9db46c2b7
parent21796bf03171bef7b2c46cd81b24cba1f7ae97e0 (diff)
downloadlibhidl-7a4b75659088fe2fa2723bb3cddc07301b9c62bc.tar.gz
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
-rw-r--r--transport/HidlTransportSupport.cpp11
-rw-r--r--transport/include/hidl/HidlTransportSupport.h3
2 files changed, 14 insertions, 0 deletions
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 @@ bool setMinSchedulerPolicy(const sp<::android::hidl::base::V1_0::IBase>& service
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 @@ bool interfacesEqual(sp<ILeft> left, sp<IRight> right) {
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: