hidl_enum_iterator: deprecate w/ message am: 2f2c96367a
am: ec6fd8431c
Change-Id: Ie467c7d6bf0361988a1b29b6dfaca37d8dcf3207
diff --git a/transport/Android.bp b/transport/Android.bp
index 9216cd1..5b0c11c 100644
--- a/transport/Android.bp
+++ b/transport/Android.bp
@@ -78,20 +78,3 @@
},
},
}
-
-// deprecated/legacy (already removed in mainline Android)
-// use android-hidl-base-V1-0-java instead!
-java_library_static {
- name: "android.hidl.base-V1.0-java-static",
- no_framework_libs: true,
- defaults: ["hidl-java-module-defaults"],
- srcs: [":android.hidl.base-V1.0-java_gen_java"],
- libs: [
- "hwbinder",
- ],
- product_variables: {
- pdk: {
- enabled: false,
- },
- },
-}
\ No newline at end of file
diff --git a/transport/HidlTransportUtils.cpp b/transport/HidlTransportUtils.cpp
index eda9b8a..4e952eb 100644
--- a/transport/HidlTransportUtils.cpp
+++ b/transport/HidlTransportUtils.cpp
@@ -16,16 +16,25 @@
#include <hidl/HidlTransportUtils.h>
+#include <android/hidl/base/1.0/IBase.h>
+
namespace android {
namespace hardware {
namespace details {
-Return<bool> canCastInterface(::android::hidl::base::V1_0::IBase* interface,
- const char* castTo, bool emitError) {
+using ::android::hidl::base::V1_0::IBase;
+
+Return<bool> canCastInterface(IBase* interface, const char* castTo, bool emitError) {
if (interface == nullptr) {
return false;
}
+ // b/68217907
+ // Every HIDL interface is a base interface.
+ if (std::string(IBase::descriptor) == castTo) {
+ return true;
+ }
+
bool canCast = false;
auto chainRet = interface->interfaceChain([&](const hidl_vec<hidl_string> &types) {
for (size_t i = 0; i < types.size(); i++) {
@@ -46,7 +55,7 @@
return canCast;
}
-std::string getDescriptor(::android::hidl::base::V1_0::IBase* interface) {
+std::string getDescriptor(IBase* interface) {
std::string myDescriptor{};
auto ret = interface->interfaceDescriptor([&](const hidl_string &types) {
myDescriptor = types.c_str();
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index f11acab..01f83bd 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -101,29 +101,55 @@
return cmdline;
}
-void tryShortenProcessName(const std::string &packageName) {
+std::string packageWithoutVersion(const std::string& packageAndVersion) {
+ size_t at = packageAndVersion.find('@');
+ if (at == std::string::npos) return packageAndVersion;
+ return packageAndVersion.substr(0, at);
+}
+
+void tryShortenProcessName(const std::string& packageAndVersion) {
+ const static std::string kTasks = "/proc/self/task/";
+
+ // make sure that this binary name is in the same package
std::string processName = binaryName();
- if (!startsWith(processName, packageName)) {
+ // e.x. android.hardware.foo is this package
+ if (!startsWith(packageWithoutVersion(processName), packageWithoutVersion(packageAndVersion))) {
return;
}
- // e.x. android.hardware.module.foo@1.0 -> foo@1.0
- size_t lastDot = packageName.rfind('.');
- size_t secondDot = packageName.rfind('.', lastDot - 1);
+ // e.x. android.hardware.module.foo@1.2 -> foo@1.2
+ size_t lastDot = packageAndVersion.rfind('.');
+ if (lastDot == std::string::npos) return;
+ size_t secondDot = packageAndVersion.rfind('.', lastDot - 1);
+ if (secondDot == std::string::npos) return;
- if (secondDot == std::string::npos) {
- return;
+ std::string newName = processName.substr(secondDot + 1, std::string::npos);
+ ALOGI("Removing namespace from process name %s to %s.", processName.c_str(), newName.c_str());
+
+ std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(kTasks.c_str()), closedir);
+ if (dir == nullptr) return;
+
+ dirent* dp;
+ while ((dp = readdir(dir.get())) != nullptr) {
+ if (dp->d_type != DT_DIR) continue;
+ if (dp->d_name[0] == '.') continue;
+
+ std::fstream fs(kTasks + dp->d_name + "/comm");
+ if (!fs.is_open()) {
+ ALOGI("Could not rename process, failed read comm for %s.", dp->d_name);
+ continue;
+ }
+
+ std::string oldComm;
+ fs >> oldComm;
+
+ // don't rename if it already has an explicit name
+ if (startsWith(packageAndVersion, oldComm)) {
+ fs.seekg(0, fs.beg);
+ fs << newName;
+ }
}
-
- std::string newName = processName.substr(secondDot + 1,
- 16 /* TASK_COMM_LEN */ - 1);
- ALOGI("Removing namespace from process name %s to %s.",
- processName.c_str(), newName.c_str());
-
- int rc = pthread_setname_np(pthread_self(), newName.c_str());
- ALOGI_IF(rc != 0, "Removing namespace from process name %s failed.",
- processName.c_str());
}
namespace details {
diff --git a/transport/current.txt b/transport/current.txt
index 958d679..0251824 100644
--- a/transport/current.txt
+++ b/transport/current.txt
@@ -15,3 +15,7 @@
# HALs released in Android O-MR1
0b94dc876f749ed24a98f61c41d46ad75a27511163f1968a084213a33c684ef6 android.hidl.manager@1.1::IServiceManager
+
+# HALs released in Android P
+445da29052612c57db3a8504f6395814277dc3826ee0f166cc732031b35af496 android.hidl.memory.block@1.0::types
+2e19301ceb87fb0696cd8268fab9c41f95d23c7392d35bc575daaa6eb32807eb android.hidl.memory.token@1.0::IMemoryToken
diff --git a/vintfdata/manifest.xml b/vintfdata/manifest.xml
index 3fc2067..66f5bd0 100644
--- a/vintfdata/manifest.xml
+++ b/vintfdata/manifest.xml
@@ -80,6 +80,16 @@
<instance>vr</instance>
</interface>
</hal>
+ <hal>
+ <name>android.hardware.health</name>
+ <transport>hwbinder</transport>
+ <version>2.0</version>
+ <interface>
+ <name>IHealth</name>
+ <!-- The backup instance provided by healthd. -->
+ <instance>backup</instance>
+ </interface>
+ </hal>
<hal format="native">
<name>netutils-wrapper</name>
<!--
diff --git a/vintfdata/manifest_healthd_exclude.xml b/vintfdata/manifest_healthd_exclude.xml
new file mode 100644
index 0000000..b4060f0
--- /dev/null
+++ b/vintfdata/manifest_healthd_exclude.xml
@@ -0,0 +1,15 @@
+<!--
+ Include this file to DEVICE_FRAMEWORK_MANIFEST_FILE to disable
+ having an healthd on the device which is not needed if you have
+ an alternative implementation like the following:
+ (1) Device has android.hardware.health@2.0-service.override
+ (2) Device has android.hardware.health@2.0-service.<device>, which
+ contains the following:
+ overrides: ["healthd"]
+-->
+<manifest version="1.0" type="framework">
+ <hal format="hidl" override="true">
+ <name>android.hardware.health</name>
+ <transport>hwbinder</transport>
+ </hal>
+</manifest>