storaged: storaged_t replace initHealthService with init.
storaged_t has more fields that depend on the health service;
they should be initialized in the new init() function.
Test: storaged unit tests
Change-Id: I70d41e5d0a0ef20c39c41c7539a284937bd21ad5
diff --git a/storaged/include/storaged.h b/storaged/include/storaged.h
index 6bf6c9c..1017512 100644
--- a/storaged/include/storaged.h
+++ b/storaged/include/storaged.h
@@ -96,8 +96,11 @@
return string("/data/misc_ce/") + to_string(user_id) +
"/storaged/storaged.proto";
}
-public:
+ void init_health_service();
+
+ public:
storaged_t(void);
+ void init(void);
void event(void);
void event_checked(void);
void pause(void) {
@@ -130,7 +133,6 @@
void add_user_ce(userid_t user_id);
void remove_user_ce(userid_t user_id);
- void init_health_service();
virtual ::android::hardware::Return<void> healthInfoChanged(
const ::android::hardware::health::V1_0::HealthInfo& info);
void serviceDied(uint64_t cookie, const wp<::android::hidl::base::V1_0::IBase>& who);
diff --git a/storaged/main.cpp b/storaged/main.cpp
index c1b1329..b3f1281 100644
--- a/storaged/main.cpp
+++ b/storaged/main.cpp
@@ -51,7 +51,7 @@
void* storaged_main(void* /* unused */) {
storaged_sp = new storaged_t();
- storaged_sp->init_health_service();
+ storaged_sp->init();
storaged_sp->report_storage_info();
LOG_TO(SYSTEM, INFO) << "storaged: Start";
diff --git a/storaged/storaged.cpp b/storaged/storaged.cpp
index ef41b57..7086887 100644
--- a/storaged/storaged.cpp
+++ b/storaged/storaged.cpp
@@ -84,6 +84,10 @@
return android::hardware::Void();
}
+void storaged_t::init() {
+ init_health_service();
+}
+
void storaged_t::init_health_service() {
if (!mUidm.enabled())
return;