Use getPidIfSharable() in autogen C++/Java.
C++: calls into android::hardware::details::
getPidIfSharable() and let libhidl decide whether
PID should be shared in getDebugInfo().
Java: calls into android.os.HidlSupport.getPidIfSharable()
that calls into C++ equivalent.
Bug: 68430495
Fixes: 68992575
Test: lshal
Change-Id: Iad6099368a5feaae1eed63bcee52a437444ab63e
diff --git a/Interface.cpp b/Interface.cpp
index 3d9786f..ac13f9f 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -389,8 +389,7 @@
[](auto &out) {
out << "_hidl_cb(";
out.block([&] {
- out << "::android::hardware::details::debuggable()"
- << "? getpid() : -1 /* pid */,\n"
+ out << "::android::hardware::details::getPidIfSharable(),\n"
<< "::android::hardware::details::debuggable()"
<< "? reinterpret_cast<uint64_t>(this) : 0 /* ptr */,\n"
<< sArch << "\n";
@@ -404,10 +403,9 @@
const Type &refInfo = method->results().front()->type();
out << refInfo.getJavaType(false /* forInitializer */) << " info = new "
<< refInfo.getJavaType(true /* forInitializer */) << "();\n"
- // TODO(b/34777099): PID for java.
- << "info.pid = -1;\n"
+ << "info.pid = android.os.HidlSupport.getPidIfSharable();\n"
<< "info.ptr = 0;\n"
- << "info.arch = android.hidl.base.V1_0.DebugInfo.Architecture.UNKNOWN;"
+ << "info.arch = android.hidl.base.V1_0.DebugInfo.Architecture.UNKNOWN;\n"
<< "return info;";
} } } /* javaImpl */
);