OSDN Git Service

Merge "Add ROLLBACK_RESISTANCE tag to key usage" into sc-dev am: 8f19fd90e3 am: 7c5c6...
[android-x86/system-vold.git] / MoveStorage.cpp
index 9b806ec..54e28a9 100644 (file)
@@ -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>
 
@@ -70,9 +70,7 @@ static bool pushBackContents(const std::string& path, std::vector<std::string>&
     bool found = false;
     struct dirent* ent;
     while ((ent = readdir(dirp.get())) != NULL) {
-        if ((!strcmp(ent->d_name, ".")) || (!strcmp(ent->d_name, ".."))) {
-            continue;
-        }
+        if (IsDotOrDotDot(*ent)) continue;
         auto subdir = path + "/" + ent->d_name;
         found |= pushBackContents(subdir, cmd, searchLevels - 1);
     }
@@ -258,7 +256,10 @@ 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};
+    auto wl = android::wakelock::WakeLock::tryGet(kWakeLock);
+    if (!wl.has_value()) {
+        return;
+    }
 
     android::os::PersistableBundle extras;
     status_t res = moveStorageInternal(from, to, listener);