From d2c86ff9107db04ac578aaa0efceb424366234a2 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Wed, 2 Jan 2019 10:47:39 -0800 Subject: [PATCH] Make health storage HAL lazy Make health storage HAL run only when needed. Bug: 115675262 Test: Flash crosshatch, ensure android.hardware.health.storage@1.0-service is not running. Enable debug logging in vold. Run 'adb shell sm idle-maint run' and check logs to ensure vold runs "Start Dev GC on HAL" Change-Id: I4bd48b5bb1b3ae7e1f4ccaff2042f1331e4cd76d --- .../default/android.hardware.health.storage@1.0-service.rc | 2 ++ health/storage/1.0/default/service.cpp | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/health/storage/1.0/default/android.hardware.health.storage@1.0-service.rc b/health/storage/1.0/default/android.hardware.health.storage@1.0-service.rc index c6a142528b..d5e1a296de 100644 --- a/health/storage/1.0/default/android.hardware.health.storage@1.0-service.rc +++ b/health/storage/1.0/default/android.hardware.health.storage@1.0-service.rc @@ -1,5 +1,7 @@ service vendor.health-storage-hal-1-0 /vendor/bin/hw/android.hardware.health.storage@1.0-service interface android.hardware.health.storage@1.0::IStorage default + oneshot + disabled class hal user system group system diff --git a/health/storage/1.0/default/service.cpp b/health/storage/1.0/default/service.cpp index a945033839..f4296f1976 100644 --- a/health/storage/1.0/default/service.cpp +++ b/health/storage/1.0/default/service.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include "Storage.h" @@ -23,6 +24,7 @@ using android::status_t; using android::UNKNOWN_ERROR; using android::hardware::configureRpcThreadpool; using android::hardware::joinRpcThreadpool; +using android::hardware::LazyServiceRegistrar; using android::hardware::health::storage::V1_0::IStorage; using android::hardware::health::storage::V1_0::implementation::Storage; @@ -30,7 +32,8 @@ int main() { configureRpcThreadpool(1, true); sp service = new Storage(); - status_t result = service->registerAsService(); + LazyServiceRegistrar registrar; + status_t result = registrar.registerService(service); if (result != OK) { return result;