diff options
author | Steven Moreland <smoreland@google.com> | 2019-10-02 17:00:44 -0700 |
---|---|---|
committer | Steven Moreland <smoreland@google.com> | 2019-10-02 17:01:40 -0700 |
commit | 1f4d49f896c82b61718f6adbfe5241f69e613dfd (patch) | |
tree | 0c82ffd65c9a6295d3cabcd1303ae42fabb785b1 /dumpstate | |
parent | 772fb53999dbba193b8333eb51812cb1a19bd74a (diff) |
dumpstate example: use new lazy hal mechanism
hwservicemanager will now shutdown the service when it is not in use.
This puts less restrictions on clients.
Bug: N/A
Test: build only (this is an example implementation not used on any
device)
Change-Id: I4641e727f6e4c3ca5d97d53a66b3cc0fee6f12f3
Diffstat (limited to 'dumpstate')
-rw-r--r-- | dumpstate/1.0/default/DumpstateDevice.cpp | 5 | ||||
-rw-r--r-- | dumpstate/1.0/default/service.cpp | 12 |
2 files changed, 8 insertions, 9 deletions
diff --git a/dumpstate/1.0/default/DumpstateDevice.cpp b/dumpstate/1.0/default/DumpstateDevice.cpp index 25d92b0acd..c57bf43dbf 100644 --- a/dumpstate/1.0/default/DumpstateDevice.cpp +++ b/dumpstate/1.0/default/DumpstateDevice.cpp @@ -37,11 +37,6 @@ Return<void> DumpstateDevice::dumpstateBoard(const hidl_handle& handle) { // NOTE: this is just an example on how to use the DumpstateUtil.h functions to implement // this interface. - // Exit when dump is completed since this is a lazy HAL. - addPostCommandTask([]() { - exit(0); - }); - if (handle == nullptr || handle->numFds < 1) { ALOGE("no FDs\n"); return Void(); diff --git a/dumpstate/1.0/default/service.cpp b/dumpstate/1.0/default/service.cpp index 4f276b7d40..76c72b5b25 100644 --- a/dumpstate/1.0/default/service.cpp +++ b/dumpstate/1.0/default/service.cpp @@ -15,22 +15,26 @@ */ #define LOG_TAG "android.hardware.dumpstate@1.0-service" +#include <hidl/HidlLazyUtils.h> #include <hidl/HidlSupport.h> #include <hidl/HidlTransportSupport.h> #include "DumpstateDevice.h" +using ::android::OK; +using ::android::sp; using ::android::hardware::configureRpcThreadpool; +using ::android::hardware::joinRpcThreadpool; +using ::android::hardware::LazyServiceRegistrar; using ::android::hardware::dumpstate::V1_0::IDumpstateDevice; using ::android::hardware::dumpstate::V1_0::implementation::DumpstateDevice; -using ::android::hardware::joinRpcThreadpool; -using ::android::OK; -using ::android::sp; int main(int /* argc */, char* /* argv */ []) { sp<IDumpstateDevice> dumpstate = new DumpstateDevice; configureRpcThreadpool(1, true /* will join */); - if (dumpstate->registerAsService() != OK) { + + auto registrar = LazyServiceRegistrar::getInstance(); + if (registrar.registerService(dumpstate) != OK) { ALOGE("Could not register service."); return 1; } |