diff options
author | Devin Moore <devinmoore@google.com> | 2023-11-27 17:54:09 +0000 |
---|---|---|
committer | Devin Moore <devinmoore@google.com> | 2023-11-28 01:01:57 +0000 |
commit | 523130f03f830fc1740f4a8e00e3f059bece4efc (patch) | |
tree | cdb52d34d3ea1b2550e3dedb69fc200ee2b99d3c | |
parent | 5777fdd3a736e0ad04d771b8870d8aba79db6105 (diff) | |
download | hwservicemanager-523130f03f830fc1740f4a8e00e3f059bece4efc.tar.gz |
Exit if HIDL isn't supported
hwservicemanager will set hwservicemanager.disabled property to get init
to shut it down without restarting it or kicking off any of the
onrestart actions.
Test: launch_cvd with isHidlSupported returning false
Bug: 218588089
Change-Id: I7745a1fbd1c3f8a5f65f88099c932a01733865fc
-rw-r--r-- | hwservicemanager.rc | 3 | ||||
-rw-r--r-- | service.cpp | 13 |
2 files changed, 16 insertions, 0 deletions
diff --git a/hwservicemanager.rc b/hwservicemanager.rc index 7ad492b..ce4db63 100644 --- a/hwservicemanager.rc +++ b/hwservicemanager.rc @@ -10,3 +10,6 @@ service hwservicemanager /system/system_ext/bin/hwservicemanager task_profiles ServiceCapacityLow HighPerformance class animation shutdown critical + +on property:hwservicemanager.disabled=true + stop hwservicemanager diff --git a/service.cpp b/service.cpp index 3fc1391..3766bc5 100644 --- a/service.cpp +++ b/service.cpp @@ -26,6 +26,7 @@ #include <cutils/properties.h> #include <hidl/HidlBinderSupport.h> #include <hidl/HidlTransportSupport.h> +#include <hidl/ServiceManagement.h> #include <hidl/Status.h> #include <hwbinder/IPCThreadState.h> #include <hwbinder/ProcessState.h> @@ -145,6 +146,18 @@ int main() { // TODO(b/36424585): make fatal ProcessState::self()->setCallRestriction(ProcessState::CallRestriction::ERROR_IF_NOT_ONEWAY); + if (!android::hardware::isHidlSupported()) { + ALOGI("HIDL is not supported on this device so hwservicemanager is not needed"); + int rc = property_set("hwservicemanager.disabled", "true"); + if (rc) { + LOG_ALWAYS_FATAL("Failed to set \"hwservicemanager.disabled\" (error %d).\"", rc); + } + // wait here for init to see the proprty and shut us down + while (true) { + ALOGW("Waiting on init to shut this process down."); + sleep(10); + } + } sp<ServiceManager> manager = new ServiceManager(); setRequestingSid(manager, true); |