vold: use RAII wake locks
Prevents wake lock leaks, e.g. b/133175847
Bug: 133175847
Test: boot blueline
Change-Id: Icda4c81e00a61adec6a12c61c329867fef284dc5
diff --git a/MoveStorage.cpp b/MoveStorage.cpp
index 79a47ae..2447cce 100644
--- a/MoveStorage.cpp
+++ b/MoveStorage.cpp
@@ -21,8 +21,8 @@
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
-#include <hardware_legacy/power.h>
#include <private/android_filesystem_config.h>
+#include <wakelock/wakelock.h>
#include <thread>
@@ -258,15 +258,13 @@
void MoveStorage(const std::shared_ptr<VolumeBase>& from, const std::shared_ptr<VolumeBase>& to,
const android::sp<android::os::IVoldTaskListener>& listener) {
- acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
+ android::wakelock::WakeLock wl{kWakeLock};
android::os::PersistableBundle extras;
status_t res = moveStorageInternal(from, to, listener);
if (listener) {
listener->onFinished(res, extras);
}
-
- release_wake_lock(kWakeLock);
}
} // namespace vold