diff options
author | Ruslan Tkhakokhov <rthakohov@google.com> | 2019-06-21 10:31:11 +0000 |
---|---|---|
committer | Ruslan Tkhakokhov <rthakohov@google.com> | 2019-06-21 10:33:30 +0000 |
commit | a37c01756f5a31369941361b0105a6853661e9f3 (patch) | |
tree | 8ce46906d0b492ae475bf69fde9b482f76c39cc6 | |
parent | 242130f3f8180baef35649f350ca737d0b0c6ae3 (diff) | |
download | vold-a37c01756f5a31369941361b0105a6853661e9f3.tar.gz |
Merged-In Revert "vold: use RAII wake locks"
This reverts commit 242130f3f8180baef35649f350ca737d0b0c6ae3.
Reason for revert: breaks the build
Change-Id: Ide809a114b2a04538f3ba4ed8af934bf326e54f3
-rw-r--r-- | Benchmark.cpp | 4 | ||||
-rw-r--r-- | IdleMaint.cpp | 11 | ||||
-rw-r--r-- | MoveStorage.cpp | 4 | ||||
-rw-r--r-- | cryptfs.cpp | 12 |
4 files changed, 24 insertions, 7 deletions
diff --git a/Benchmark.cpp b/Benchmark.cpp index 9548956f..b0a3b856 100644 --- a/Benchmark.cpp +++ b/Benchmark.cpp @@ -181,7 +181,7 @@ static status_t benchmarkInternal(const std::string& rootPath, void Benchmark(const std::string& path, const android::sp<android::os::IVoldTaskListener>& listener) { std::lock_guard<std::mutex> lock(kBenchmarkLock); - android::power::WakeLock wl{kWakeLock}; + acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock); PerformanceBoost boost; android::os::PersistableBundle extras; @@ -190,6 +190,8 @@ void Benchmark(const std::string& path, if (listener) { listener->onFinished(res, extras); } + + release_wake_lock(kWakeLock); } } // namespace vold diff --git a/IdleMaint.cpp b/IdleMaint.cpp index 164986c7..a2d0f91a 100644 --- a/IdleMaint.cpp +++ b/IdleMaint.cpp @@ -145,7 +145,7 @@ static void addFromFstab(std::list<std::string>* paths, PathTypes path_type) { } void Trim(const android::sp<android::os::IVoldTaskListener>& listener) { - android::power::WakeLock wl{kWakeLock}; + acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock); // Collect both fstab and vold volumes std::list<std::string> paths; @@ -195,6 +195,7 @@ void Trim(const android::sp<android::os::IVoldTaskListener>& listener) { listener->onFinished(0, extras); } + release_wake_lock(kWakeLock); } static bool waitForGc(const std::list<std::string>& paths) { @@ -369,7 +370,7 @@ int RunIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener) { LOG(DEBUG) << "idle maintenance started"; - android::power::WakeLock wl{kWakeLock}; + acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock); std::list<std::string> paths; addFromFstab(&paths, PathTypes::kBlkDevice); @@ -399,11 +400,13 @@ int RunIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener) { LOG(DEBUG) << "idle maintenance completed"; + release_wake_lock(kWakeLock); + return android::OK; } int AbortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener) { - android::power::WakeLock wl{kWakeLock}; + acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock); std::unique_lock<std::mutex> lk(cv_m); if (idle_maint_stat != IdleMaintStats::kStopped) { @@ -421,6 +424,8 @@ int AbortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener) listener->onFinished(0, extras); } + release_wake_lock(kWakeLock); + LOG(DEBUG) << "idle maintenance stopped"; return android::OK; diff --git a/MoveStorage.cpp b/MoveStorage.cpp index 9b806ec4..79a47ae1 100644 --- a/MoveStorage.cpp +++ b/MoveStorage.cpp @@ -258,13 +258,15 @@ fail: void MoveStorage(const std::shared_ptr<VolumeBase>& from, const std::shared_ptr<VolumeBase>& to, const android::sp<android::os::IVoldTaskListener>& listener) { - android::power::WakeLock wl{kWakeLock}; + acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock); android::os::PersistableBundle extras; status_t res = moveStorageInternal(from, to, listener); if (listener) { listener->onFinished(res, extras); } + + release_wake_lock(kWakeLock); } } // namespace vold diff --git a/cryptfs.cpp b/cryptfs.cpp index 7d59b2d5..c5d0307a 100644 --- a/cryptfs.cpp +++ b/cryptfs.cpp @@ -2007,7 +2007,6 @@ int cryptfs_enable_internal(int crypt_type, const char* passwd, int no_ui) { off64_t previously_encrypted_upto = 0; bool rebootEncryption = false; bool onlyCreateHeader = false; - std::unique_ptr<android::power::WakeLock> wakeLock = nullptr; if (get_crypt_ftr_and_key(&crypt_ftr) == 0) { if (crypt_ftr.flags & CRYPT_ENCRYPTION_IN_PROGRESS) { @@ -2074,7 +2073,7 @@ int cryptfs_enable_internal(int crypt_type, const char* passwd, int no_ui) { * wants to keep the screen on, it can grab a full wakelock. */ snprintf(lockid, sizeof(lockid), "enablecrypto%d", (int)getpid()); - wakeLock = std::make_unique<android::power::WakeLock>(lockid); + acquire_wake_lock(PARTIAL_WAKE_LOCK, lockid); /* The init files are setup to stop the class main and late start when * vold sets trigger_shutdown_framework. @@ -2255,6 +2254,7 @@ int cryptfs_enable_internal(int crypt_type, const char* passwd, int no_ui) { /* default encryption - continue first boot sequence */ property_set("ro.crypto.state", "encrypted"); property_set("ro.crypto.type", "block"); + release_wake_lock(lockid); if (rebootEncryption && crypt_ftr.crypt_type != CRYPT_TYPE_DEFAULT) { // Bring up cryptkeeper that will check the password and set it property_set("vold.decrypt", "trigger_shutdown_framework"); @@ -2291,6 +2291,7 @@ int cryptfs_enable_internal(int crypt_type, const char* passwd, int no_ui) { } else { /* set property to trigger dialog */ property_set("vold.encrypt_progress", "error_partially_encrypted"); + release_wake_lock(lockid); } return -1; } @@ -2300,10 +2301,14 @@ int cryptfs_enable_internal(int crypt_type, const char* passwd, int no_ui) { * Set the property and return. Hope the framework can deal with it. */ property_set("vold.encrypt_progress", "error_reboot_failed"); + release_wake_lock(lockid); return rc; error_unencrypted: property_set("vold.encrypt_progress", "error_not_encrypted"); + if (lockid[0]) { + release_wake_lock(lockid); + } return -1; error_shutting_down: @@ -2318,6 +2323,9 @@ error_shutting_down: /* shouldn't get here */ property_set("vold.encrypt_progress", "error_shutting_down"); + if (lockid[0]) { + release_wake_lock(lockid); + } return -1; } |