clang-format the rest of the files

Apply clang-format to fix the remaining files not fixed by
change I23cde3f0bbcac13bef555d13514e922c79d5ad48

Test: Format-only changes; treehugger suffices.
Change-Id: I1bfd5c8d68d298596875d5edae26cdfe27c03489
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index 999df94..a99f75d 100644
--- a/VoldNativeService.cpp
+++ b/VoldNativeService.cpp
@@ -24,9 +24,9 @@
 #include "Process.h"
 #include "VolumeManager.h"
 
-#include "cryptfs.h"
 #include "Ext4Crypt.h"
 #include "MetadataCrypt.h"
+#include "cryptfs.h"
 
 #include <fstream>
 #include <thread>
@@ -83,11 +83,11 @@
     uid_t uid;
 
     if (checkCallingPermission(String16(permission), reinterpret_cast<int32_t*>(&pid),
-            reinterpret_cast<int32_t*>(&uid))) {
+                               reinterpret_cast<int32_t*>(&uid))) {
         return ok();
     } else {
         return exception(binder::Status::EX_SECURITY,
-                StringPrintf("UID %d / PID %d lacks permission %s", uid, pid, permission));
+                         StringPrintf("UID %d / PID %d lacks permission %s", uid, pid, permission));
     }
 }
 
@@ -97,7 +97,7 @@
         return ok();
     } else {
         return exception(binder::Status::EX_SECURITY,
-                StringPrintf("UID %d is not expected UID %d", uid, expectedUid));
+                         StringPrintf("UID %d is not expected UID %d", uid, expectedUid));
     }
 }
 
@@ -108,7 +108,7 @@
     for (const char& c : id) {
         if (!std::isalnum(c) && c != ':' && c != ',') {
             return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
-                    StringPrintf("ID %s is malformed", id.c_str()));
+                             StringPrintf("ID %s is malformed", id.c_str()));
         }
     }
     return ok();
@@ -120,16 +120,16 @@
     }
     if (path[0] != '/') {
         return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
-                StringPrintf("Path %s is relative", path.c_str()));
+                         StringPrintf("Path %s is relative", path.c_str()));
     }
     if ((path + '/').find("/../") != std::string::npos) {
         return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
-                StringPrintf("Path %s is shady", path.c_str()));
+                         StringPrintf("Path %s is shady", path.c_str()));
     }
     for (const char& c : path) {
         if (c == '\0' || c == '\n') {
             return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
-                    StringPrintf("Path %s is malformed", path.c_str()));
+                             StringPrintf("Path %s is malformed", path.c_str()));
         }
     }
     return ok();
@@ -140,7 +140,7 @@
     for (const char& c : hex) {
         if (!std::isxdigit(c) && c != ':' && c != '-') {
             return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
-                    StringPrintf("Hex %s is malformed", hex.c_str()));
+                             StringPrintf("Hex %s is malformed", hex.c_str()));
         }
     }
     return ok();
@@ -168,12 +168,12 @@
             continue;
         }
         return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
-                StringPrintf("Bad package character %c in %s", c, packageName.c_str()));
+                         StringPrintf("Bad package character %c in %s", c, packageName.c_str()));
     }
 
     if (front) {
         return exception(binder::Status::EX_ILLEGAL_ARGUMENT,
-                StringPrintf("Missing separator in %s", packageName.c_str()));
+                         StringPrintf("Missing separator in %s", packageName.c_str()));
     }
 
     return ok();
@@ -209,67 +209,75 @@
     return ok();
 }
 
-#define ENFORCE_UID(uid) {                                  \
-    binder::Status status = checkUid((uid));                \
-    if (!status.isOk()) {                                   \
-        return status;                                      \
-    }                                                       \
-}
+#define ENFORCE_UID(uid)                         \
+    {                                            \
+        binder::Status status = checkUid((uid)); \
+        if (!status.isOk()) {                    \
+            return status;                       \
+        }                                        \
+    }
 
-#define CHECK_ARGUMENT_ID(id) {                             \
-    binder::Status status = checkArgumentId((id));          \
-    if (!status.isOk()) {                                   \
-        return status;                                      \
-    }                                                       \
-}
+#define CHECK_ARGUMENT_ID(id)                          \
+    {                                                  \
+        binder::Status status = checkArgumentId((id)); \
+        if (!status.isOk()) {                          \
+            return status;                             \
+        }                                              \
+    }
 
-#define CHECK_ARGUMENT_PATH(path) {                         \
-    binder::Status status = checkArgumentPath((path));      \
-    if (!status.isOk()) {                                   \
-        return status;                                      \
-    }                                                       \
-}
+#define CHECK_ARGUMENT_PATH(path)                          \
+    {                                                      \
+        binder::Status status = checkArgumentPath((path)); \
+        if (!status.isOk()) {                              \
+            return status;                                 \
+        }                                                  \
+    }
 
-#define CHECK_ARGUMENT_HEX(hex) {                           \
-    binder::Status status = checkArgumentHex((hex));        \
-    if (!status.isOk()) {                                   \
-        return status;                                      \
-    }                                                       \
-}
+#define CHECK_ARGUMENT_HEX(hex)                          \
+    {                                                    \
+        binder::Status status = checkArgumentHex((hex)); \
+        if (!status.isOk()) {                            \
+            return status;                               \
+        }                                                \
+    }
 
-#define CHECK_ARGUMENT_PACKAGE_NAMES(packageNames) {                        \
-    binder::Status status = checkArgumentPackageNames((packageNames));      \
-    if (!status.isOk()) {                                                   \
-        return status;                                                      \
-    }                                                                       \
-}
+#define CHECK_ARGUMENT_PACKAGE_NAMES(packageNames)                         \
+    {                                                                      \
+        binder::Status status = checkArgumentPackageNames((packageNames)); \
+        if (!status.isOk()) {                                              \
+            return status;                                                 \
+        }                                                                  \
+    }
 
-#define CHECK_ARGUMENT_SANDBOX_IDS(sandboxIds) {                            \
-    binder::Status status = checkArgumentSandboxIds((sandboxIds));          \
-    if (!status.isOk()) {                                                   \
-        return status;                                                      \
-    }                                                                       \
-}
+#define CHECK_ARGUMENT_SANDBOX_IDS(sandboxIds)                         \
+    {                                                                  \
+        binder::Status status = checkArgumentSandboxIds((sandboxIds)); \
+        if (!status.isOk()) {                                          \
+            return status;                                             \
+        }                                                              \
+    }
 
-#define CHECK_ARGUMENT_PACKAGE_NAME(packageName) {                          \
-    binder::Status status = checkArgumentPackageName((packageName));        \
-    if (!status.isOk()) {                                                   \
-        return status;                                                      \
-    }                                                                       \
-}
+#define CHECK_ARGUMENT_PACKAGE_NAME(packageName)                         \
+    {                                                                    \
+        binder::Status status = checkArgumentPackageName((packageName)); \
+        if (!status.isOk()) {                                            \
+            return status;                                               \
+        }                                                                \
+    }
 
-#define CHECK_ARGUMENT_SANDBOX_ID(sandboxId) {                              \
-    binder::Status status = checkArgumentSandboxId((sandboxId));            \
-    if (!status.isOk()) {                                                   \
-        return status;                                                      \
-    }                                                                       \
-}
+#define CHECK_ARGUMENT_SANDBOX_ID(sandboxId)                         \
+    {                                                                \
+        binder::Status status = checkArgumentSandboxId((sandboxId)); \
+        if (!status.isOk()) {                                        \
+            return status;                                           \
+        }                                                            \
+    }
 
-#define ACQUIRE_LOCK \
+#define ACQUIRE_LOCK                                                        \
     std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getLock()); \
     ATRACE_CALL();
 
-#define ACQUIRE_CRYPT_LOCK \
+#define ACQUIRE_CRYPT_LOCK                                                       \
     std::lock_guard<std::mutex> lock(VolumeManager::Instance()->getCryptLock()); \
     ATRACE_CALL();
 
@@ -287,7 +295,7 @@
     return android::OK;
 }
 
-status_t VoldNativeService::dump(int fd, const Vector<String16> & /* args */) {
+status_t VoldNativeService::dump(int fd, const Vector<String16>& /* args */) {
     auto out = std::fstream(StringPrintf("/proc/self/fd/%d", fd));
     const binder::Status dump_permission = checkPermission(kDump);
     if (!dump_permission.isOk()) {
@@ -302,7 +310,7 @@
 }
 
 binder::Status VoldNativeService::setListener(
-        const android::sp<android::os::IVoldListener>& listener) {
+    const android::sp<android::os::IVoldListener>& listener) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_LOCK;
 
@@ -314,12 +322,8 @@
     ENFORCE_UID(AID_SYSTEM);
 
     // Simply acquire/release each lock for watchdog
-    {
-        ACQUIRE_LOCK;
-    }
-    {
-        ACQUIRE_CRYPT_LOCK;
-    }
+    { ACQUIRE_LOCK; }
+    { ACQUIRE_CRYPT_LOCK; }
 
     return ok();
 }
@@ -353,7 +357,7 @@
 }
 
 binder::Status VoldNativeService::onUserStarted(int32_t userId,
-        const std::vector<std::string>& packageNames) {
+                                                const std::vector<std::string>& packageNames) {
     ENFORCE_UID(AID_SYSTEM);
     CHECK_ARGUMENT_PACKAGE_NAMES(packageNames);
     ACQUIRE_LOCK;
@@ -369,7 +373,7 @@
 }
 
 binder::Status VoldNativeService::addAppIds(const std::vector<std::string>& packageNames,
-        const std::vector<int32_t>& appIds) {
+                                            const std::vector<int32_t>& appIds) {
     ENFORCE_UID(AID_SYSTEM);
     CHECK_ARGUMENT_PACKAGE_NAMES(packageNames);
     ACQUIRE_LOCK;
@@ -378,7 +382,7 @@
 }
 
 binder::Status VoldNativeService::addSandboxIds(const std::vector<int32_t>& appIds,
-        const std::vector<std::string>& sandboxIds) {
+                                                const std::vector<std::string>& sandboxIds) {
     ENFORCE_UID(AID_SYSTEM);
     CHECK_ARGUMENT_SANDBOX_IDS(sandboxIds);
     ACQUIRE_LOCK;
@@ -394,7 +398,7 @@
 }
 
 binder::Status VoldNativeService::partition(const std::string& diskId, int32_t partitionType,
-        int32_t ratio) {
+                                            int32_t ratio) {
     ENFORCE_UID(AID_SYSTEM);
     CHECK_ARGUMENT_ID(diskId);
     ACQUIRE_LOCK;
@@ -404,15 +408,19 @@
         return error("Failed to find disk " + diskId);
     }
     switch (partitionType) {
-    case PARTITION_TYPE_PUBLIC: return translate(disk->partitionPublic());
-    case PARTITION_TYPE_PRIVATE: return translate(disk->partitionPrivate());
-    case PARTITION_TYPE_MIXED: return translate(disk->partitionMixed(ratio));
-    default: return error("Unknown type " + std::to_string(partitionType));
+        case PARTITION_TYPE_PUBLIC:
+            return translate(disk->partitionPublic());
+        case PARTITION_TYPE_PRIVATE:
+            return translate(disk->partitionPrivate());
+        case PARTITION_TYPE_MIXED:
+            return translate(disk->partitionMixed(ratio));
+        default:
+            return error("Unknown type " + std::to_string(partitionType));
     }
 }
 
 binder::Status VoldNativeService::forgetPartition(const std::string& partGuid,
-        const std::string& fsUuid) {
+                                                  const std::string& fsUuid) {
     ENFORCE_UID(AID_SYSTEM);
     CHECK_ARGUMENT_HEX(partGuid);
     CHECK_ARGUMENT_HEX(fsUuid);
@@ -422,7 +430,7 @@
 }
 
 binder::Status VoldNativeService::mount(const std::string& volId, int32_t mountFlags,
-        int32_t mountUserId) {
+                                        int32_t mountUserId) {
     ENFORCE_UID(AID_SYSTEM);
     CHECK_ARGUMENT_ID(volId);
     ACQUIRE_LOCK;
@@ -498,9 +506,7 @@
     auto status = pathForVolId(volId, &path);
     if (!status.isOk()) return status;
 
-    std::thread([=]() {
-        android::vold::Benchmark(path, listener);
-    }).detach();
+    std::thread([=]() { android::vold::Benchmark(path, listener); }).detach();
     return ok();
 }
 
@@ -515,8 +521,9 @@
     return translate(android::vold::CheckEncryption(path));
 }
 
-binder::Status VoldNativeService::moveStorage(const std::string& fromVolId,
-        const std::string& toVolId, const android::sp<android::os::IVoldTaskListener>& listener) {
+binder::Status VoldNativeService::moveStorage(
+    const std::string& fromVolId, const std::string& toVolId,
+    const android::sp<android::os::IVoldTaskListener>& listener) {
     ENFORCE_UID(AID_SYSTEM);
     CHECK_ARGUMENT_ID(fromVolId);
     CHECK_ARGUMENT_ID(toVolId);
@@ -530,9 +537,7 @@
         return error("Failed to find volume " + toVolId);
     }
 
-    std::thread([=]() {
-        android::vold::MoveStorage(fromVol, toVol, listener);
-    }).detach();
+    std::thread([=]() { android::vold::MoveStorage(fromVol, toVol, listener); }).detach();
     return ok();
 }
 
@@ -542,11 +547,20 @@
 
     std::string tmp;
     switch (remountMode) {
-    case REMOUNT_MODE_NONE: tmp = "none"; break;
-    case REMOUNT_MODE_DEFAULT: tmp = "default"; break;
-    case REMOUNT_MODE_READ: tmp = "read"; break;
-    case REMOUNT_MODE_WRITE: tmp = "write"; break;
-    default: return error("Unknown mode " + std::to_string(remountMode));
+        case REMOUNT_MODE_NONE:
+            tmp = "none";
+            break;
+        case REMOUNT_MODE_DEFAULT:
+            tmp = "default";
+            break;
+        case REMOUNT_MODE_READ:
+            tmp = "read";
+            break;
+        case REMOUNT_MODE_WRITE:
+            tmp = "write";
+            break;
+        default:
+            return error("Unknown mode " + std::to_string(remountMode));
     }
     return translate(VolumeManager::Instance()->remountUid(uid, tmp));
 }
@@ -560,14 +574,15 @@
 }
 
 binder::Status VoldNativeService::createObb(const std::string& sourcePath,
-        const std::string& sourceKey, int32_t ownerGid, std::string* _aidl_return) {
+                                            const std::string& sourceKey, int32_t ownerGid,
+                                            std::string* _aidl_return) {
     ENFORCE_UID(AID_SYSTEM);
     CHECK_ARGUMENT_PATH(sourcePath);
     CHECK_ARGUMENT_HEX(sourceKey);
     ACQUIRE_LOCK;
 
     return translate(
-            VolumeManager::Instance()->createObb(sourcePath, sourceKey, ownerGid, _aidl_return));
+        VolumeManager::Instance()->createObb(sourcePath, sourceKey, ownerGid, _aidl_return));
 }
 
 binder::Status VoldNativeService::destroyObb(const std::string& volId) {
@@ -578,41 +593,35 @@
     return translate(VolumeManager::Instance()->destroyObb(volId));
 }
 
-binder::Status VoldNativeService::fstrim(int32_t fstrimFlags,
-        const android::sp<android::os::IVoldTaskListener>& listener) {
+binder::Status VoldNativeService::fstrim(
+    int32_t fstrimFlags, const android::sp<android::os::IVoldTaskListener>& listener) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_LOCK;
 
-    std::thread([=]() {
-        android::vold::Trim(listener);
-    }).detach();
+    std::thread([=]() { android::vold::Trim(listener); }).detach();
     return ok();
 }
 
 binder::Status VoldNativeService::runIdleMaint(
-        const android::sp<android::os::IVoldTaskListener>& listener) {
+    const android::sp<android::os::IVoldTaskListener>& listener) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_LOCK;
 
-    std::thread([=]() {
-        android::vold::RunIdleMaint(listener);
-    }).detach();
+    std::thread([=]() { android::vold::RunIdleMaint(listener); }).detach();
     return ok();
 }
 
 binder::Status VoldNativeService::abortIdleMaint(
-        const android::sp<android::os::IVoldTaskListener>& listener) {
+    const android::sp<android::os::IVoldTaskListener>& listener) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_LOCK;
 
-    std::thread([=]() {
-        android::vold::AbortIdleMaint(listener);
-    }).detach();
+    std::thread([=]() { android::vold::AbortIdleMaint(listener); }).detach();
     return ok();
 }
 
 binder::Status VoldNativeService::mountAppFuse(int32_t uid, int32_t pid, int32_t mountId,
-        android::base::unique_fd* _aidl_return) {
+                                               android::base::unique_fd* _aidl_return) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_LOCK;
 
@@ -652,7 +661,7 @@
 }
 
 static int fdeEnableInternal(int32_t passwordType, const std::string& password,
-        int32_t encryptionFlags) {
+                             int32_t encryptionFlags) {
     bool noUi = (encryptionFlags & VoldNativeService::ENCRYPTION_FLAG_NO_UI) != 0;
 
     for (int tries = 0; tries < 2; ++tries) {
@@ -673,8 +682,8 @@
     return -1;
 }
 
-binder::Status VoldNativeService::fdeEnable(int32_t passwordType,
-        const std::string& password, int32_t encryptionFlags) {
+binder::Status VoldNativeService::fdeEnable(int32_t passwordType, const std::string& password,
+                                            int32_t encryptionFlags) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_CRYPT_LOCK;
 
@@ -692,7 +701,7 @@
 }
 
 binder::Status VoldNativeService::fdeChangePassword(int32_t passwordType,
-        const std::string& password) {
+                                                    const std::string& password) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_CRYPT_LOCK;
 
@@ -706,8 +715,7 @@
     return translate(cryptfs_verify_passwd(password.c_str()));
 }
 
-binder::Status VoldNativeService::fdeGetField(const std::string& key,
-        std::string* _aidl_return) {
+binder::Status VoldNativeService::fdeGetField(const std::string& key, std::string* _aidl_return) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_CRYPT_LOCK;
 
@@ -720,8 +728,7 @@
     }
 }
 
-binder::Status VoldNativeService::fdeSetField(const std::string& key,
-        const std::string& value) {
+binder::Status VoldNativeService::fdeSetField(const std::string& key, const std::string& value) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_CRYPT_LOCK;
 
@@ -803,8 +810,7 @@
     return translateBool(e4crypt_mount_metadata_encrypted(mountPoint, true));
 }
 
-binder::Status VoldNativeService::createUserKey(int32_t userId, int32_t userSerial,
-        bool ephemeral) {
+binder::Status VoldNativeService::createUserKey(int32_t userId, int32_t userSerial, bool ephemeral) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_CRYPT_LOCK;
 
@@ -819,7 +825,8 @@
 }
 
 binder::Status VoldNativeService::addUserKeyAuth(int32_t userId, int32_t userSerial,
-        const std::string& token, const std::string& secret) {
+                                                 const std::string& token,
+                                                 const std::string& secret) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_CRYPT_LOCK;
 
@@ -834,7 +841,8 @@
 }
 
 binder::Status VoldNativeService::unlockUserKey(int32_t userId, int32_t userSerial,
-        const std::string& token, const std::string& secret) {
+                                                const std::string& token,
+                                                const std::string& secret) {
     ENFORCE_UID(AID_SYSTEM);
     ACQUIRE_CRYPT_LOCK;
 
@@ -849,7 +857,8 @@
 }
 
 binder::Status VoldNativeService::prepareUserStorage(const std::unique_ptr<std::string>& uuid,
-        int32_t userId, int32_t userSerial, int32_t flags) {
+                                                     int32_t userId, int32_t userSerial,
+                                                     int32_t flags) {
     ENFORCE_UID(AID_SYSTEM);
     std::string empty_string = "";
     auto uuid_ = uuid ? *uuid : empty_string;
@@ -860,7 +869,7 @@
 }
 
 binder::Status VoldNativeService::destroyUserStorage(const std::unique_ptr<std::string>& uuid,
-        int32_t userId, int32_t flags) {
+                                                     int32_t userId, int32_t flags) {
     ENFORCE_UID(AID_SYSTEM);
     std::string empty_string = "";
     auto uuid_ = uuid ? *uuid : empty_string;
@@ -871,14 +880,16 @@
 }
 
 binder::Status VoldNativeService::mountExternalStorageForApp(const std::string& packageName,
-        int32_t appId, const std::string& sandboxId, int32_t userId) {
+                                                             int32_t appId,
+                                                             const std::string& sandboxId,
+                                                             int32_t userId) {
     ENFORCE_UID(AID_SYSTEM);
     CHECK_ARGUMENT_PACKAGE_NAME(packageName);
     CHECK_ARGUMENT_SANDBOX_ID(sandboxId);
     ACQUIRE_LOCK;
 
-    return translate(VolumeManager::Instance()->mountExternalStorageForApp(
-            packageName, appId, sandboxId, userId));
+    return translate(VolumeManager::Instance()->mountExternalStorageForApp(packageName, appId,
+                                                                           sandboxId, userId));
 }
 
 }  // namespace vold
diff --git a/VoldNativeService.h b/VoldNativeService.h
index d5de707..dacf712 100644
--- a/VoldNativeService.h
+++ b/VoldNativeService.h
@@ -26,10 +26,10 @@
 namespace vold {
 
 class VoldNativeService : public BinderService<VoldNativeService>, public os::BnVold {
-public:
+  public:
     static status_t start();
     static char const* getServiceName() { return "vold"; }
-    virtual status_t dump(int fd, const Vector<String16> &args) override;
+    virtual status_t dump(int fd, const Vector<String16>& args) override;
 
     binder::Status setListener(const android::sp<android::os::IVoldListener>& listener);
 
@@ -43,9 +43,9 @@
     binder::Status onUserStopped(int32_t userId);
 
     binder::Status addAppIds(const std::vector<std::string>& packageNames,
-            const std::vector<int32_t>& appIds);
+                             const std::vector<int32_t>& appIds);
     binder::Status addSandboxIds(const std::vector<int32_t>& appIds,
-            const std::vector<std::string>& sandboxIds);
+                                 const std::vector<std::string>& sandboxIds);
 
     binder::Status onSecureKeyguardStateChanged(bool isShowing);
 
@@ -56,38 +56,35 @@
     binder::Status unmount(const std::string& volId);
     binder::Status format(const std::string& volId, const std::string& fsType);
     binder::Status benchmark(const std::string& volId,
-            const android::sp<android::os::IVoldTaskListener>& listener);
+                             const android::sp<android::os::IVoldTaskListener>& listener);
     binder::Status checkEncryption(const std::string& volId);
 
     binder::Status moveStorage(const std::string& fromVolId, const std::string& toVolId,
-            const android::sp<android::os::IVoldTaskListener>& listener);
+                               const android::sp<android::os::IVoldTaskListener>& listener);
 
     binder::Status remountUid(int32_t uid, int32_t remountMode);
 
     binder::Status mkdirs(const std::string& path);
 
     binder::Status createObb(const std::string& sourcePath, const std::string& sourceKey,
-            int32_t ownerGid, std::string* _aidl_return);
+                             int32_t ownerGid, std::string* _aidl_return);
     binder::Status destroyObb(const std::string& volId);
 
     binder::Status fstrim(int32_t fstrimFlags,
-            const android::sp<android::os::IVoldTaskListener>& listener);
-    binder::Status runIdleMaint(
-            const android::sp<android::os::IVoldTaskListener>& listener);
-    binder::Status abortIdleMaint(
-            const android::sp<android::os::IVoldTaskListener>& listener);
+                          const android::sp<android::os::IVoldTaskListener>& listener);
+    binder::Status runIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener);
+    binder::Status abortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener);
 
     binder::Status mountAppFuse(int32_t uid, int32_t pid, int32_t mountId,
-            android::base::unique_fd* _aidl_return);
+                                android::base::unique_fd* _aidl_return);
     binder::Status unmountAppFuse(int32_t uid, int32_t pid, int32_t mountId);
 
     binder::Status fdeCheckPassword(const std::string& password);
     binder::Status fdeRestart();
     binder::Status fdeComplete(int32_t* _aidl_return);
-    binder::Status fdeEnable(int32_t passwordType,
-            const std::string& password, int32_t encryptionFlags);
-    binder::Status fdeChangePassword(int32_t passwordType,
-            const std::string& password);
+    binder::Status fdeEnable(int32_t passwordType, const std::string& password,
+                             int32_t encryptionFlags);
+    binder::Status fdeChangePassword(int32_t passwordType, const std::string& password);
     binder::Status fdeVerifyPassword(const std::string& password);
     binder::Status fdeGetField(const std::string& key, std::string* _aidl_return);
     binder::Status fdeSetField(const std::string& key, const std::string& value);
@@ -106,21 +103,21 @@
     binder::Status createUserKey(int32_t userId, int32_t userSerial, bool ephemeral);
     binder::Status destroyUserKey(int32_t userId);
 
-    binder::Status addUserKeyAuth(int32_t userId, int32_t userSerial,
-            const std::string& token, const std::string& secret);
+    binder::Status addUserKeyAuth(int32_t userId, int32_t userSerial, const std::string& token,
+                                  const std::string& secret);
     binder::Status fixateNewestUserKeyAuth(int32_t userId);
 
-    binder::Status unlockUserKey(int32_t userId, int32_t userSerial,
-            const std::string& token, const std::string& secret);
+    binder::Status unlockUserKey(int32_t userId, int32_t userSerial, const std::string& token,
+                                 const std::string& secret);
     binder::Status lockUserKey(int32_t userId);
 
-    binder::Status prepareUserStorage(const std::unique_ptr<std::string>& uuid,
-            int32_t userId, int32_t userSerial, int32_t flags);
-    binder::Status destroyUserStorage(const std::unique_ptr<std::string>& uuid,
-            int32_t userId, int32_t flags);
+    binder::Status prepareUserStorage(const std::unique_ptr<std::string>& uuid, int32_t userId,
+                                      int32_t userSerial, int32_t flags);
+    binder::Status destroyUserStorage(const std::unique_ptr<std::string>& uuid, int32_t userId,
+                                      int32_t flags);
 
     binder::Status mountExternalStorageForApp(const std::string& packageName, int32_t appId,
-            const std::string& sandboxId, int32_t userId);
+                                              const std::string& sandboxId, int32_t userId);
 };
 
 }  // namespace vold
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 260c2f0..efbcf41 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -26,8 +26,8 @@
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <sys/sysmacros.h>
+#include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
 
@@ -84,11 +84,10 @@
 static const unsigned int kMajorBlockExperimentalMin = 240;
 static const unsigned int kMajorBlockExperimentalMax = 254;
 
-VolumeManager *VolumeManager::sInstance = NULL;
+VolumeManager* VolumeManager::sInstance = NULL;
 
-VolumeManager *VolumeManager::Instance() {
-    if (!sInstance)
-        sInstance = new VolumeManager();
+VolumeManager* VolumeManager::Instance() {
+    if (!sInstance) sInstance = new VolumeManager();
     return sInstance;
 }
 
@@ -101,8 +100,7 @@
     mMntStorageCreated = false;
 }
 
-VolumeManager::~VolumeManager() {
-}
+VolumeManager::~VolumeManager() {}
 
 int VolumeManager::updateVirtualDisk() {
     ATRACE_NAME("VolumeManager::updateVirtualDisk");
@@ -123,8 +121,9 @@
                 return -1;
             }
 
-            auto disk = new android::vold::Disk("virtual", buf.st_rdev, "virtual",
-                    android::vold::Disk::Flags::kAdoptable | android::vold::Disk::Flags::kSd);
+            auto disk = new android::vold::Disk(
+                "virtual", buf.st_rdev, "virtual",
+                android::vold::Disk::Flags::kAdoptable | android::vold::Disk::Flags::kSd);
             mVirtualDisk = std::shared_ptr<android::vold::Disk>(disk);
             handleDiskAdded(mVirtualDisk);
         }
@@ -163,7 +162,7 @@
     // storage; the framework will decide if it should be mounted.
     CHECK(mInternalEmulated == nullptr);
     mInternalEmulated = std::shared_ptr<android::vold::VolumeBase>(
-            new android::vold::EmulatedVolume("/data/media"));
+        new android::vold::EmulatedVolume("/data/media"));
     mInternalEmulated->create();
 
     // Consider creating a virtual disk
@@ -179,17 +178,17 @@
     return 0;
 }
 
-void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
+void VolumeManager::handleBlockEvent(NetlinkEvent* evt) {
     std::lock_guard<std::mutex> lock(mLock);
 
     if (mDebug) {
         LOG(VERBOSE) << "----------------";
-        LOG(VERBOSE) << "handleBlockEvent with action " << (int) evt->getAction();
+        LOG(VERBOSE) << "handleBlockEvent with action " << (int)evt->getAction();
         evt->dump();
     }
 
-    std::string eventPath(evt->findParam("DEVPATH")?evt->findParam("DEVPATH"):"");
-    std::string devType(evt->findParam("DEVTYPE")?evt->findParam("DEVTYPE"):"");
+    std::string eventPath(evt->findParam("DEVPATH") ? evt->findParam("DEVPATH") : "");
+    std::string devType(evt->findParam("DEVTYPE") ? evt->findParam("DEVTYPE") : "");
 
     if (devType != "disk") return;
 
@@ -198,43 +197,42 @@
     dev_t device = makedev(major, minor);
 
     switch (evt->getAction()) {
-    case NetlinkEvent::Action::kAdd: {
-        for (const auto& source : mDiskSources) {
-            if (source->matches(eventPath)) {
-                // For now, assume that MMC and virtio-blk (the latter is
-                // emulator-specific; see Disk.cpp for details) devices are SD,
-                // and that everything else is USB
-                int flags = source->getFlags();
-                if (major == kMajorBlockMmc
-                    || (android::vold::IsRunningInEmulator()
-                    && major >= (int) kMajorBlockExperimentalMin
-                    && major <= (int) kMajorBlockExperimentalMax)) {
-                    flags |= android::vold::Disk::Flags::kSd;
-                } else {
-                    flags |= android::vold::Disk::Flags::kUsb;
-                }
+        case NetlinkEvent::Action::kAdd: {
+            for (const auto& source : mDiskSources) {
+                if (source->matches(eventPath)) {
+                    // For now, assume that MMC and virtio-blk (the latter is
+                    // emulator-specific; see Disk.cpp for details) devices are SD,
+                    // and that everything else is USB
+                    int flags = source->getFlags();
+                    if (major == kMajorBlockMmc || (android::vold::IsRunningInEmulator() &&
+                                                    major >= (int)kMajorBlockExperimentalMin &&
+                                                    major <= (int)kMajorBlockExperimentalMax)) {
+                        flags |= android::vold::Disk::Flags::kSd;
+                    } else {
+                        flags |= android::vold::Disk::Flags::kUsb;
+                    }
 
-                auto disk = new android::vold::Disk(eventPath, device,
-                        source->getNickname(), flags);
-                handleDiskAdded(std::shared_ptr<android::vold::Disk>(disk));
-                break;
+                    auto disk =
+                        new android::vold::Disk(eventPath, device, source->getNickname(), flags);
+                    handleDiskAdded(std::shared_ptr<android::vold::Disk>(disk));
+                    break;
+                }
             }
+            break;
         }
-        break;
-    }
-    case NetlinkEvent::Action::kChange: {
-        LOG(DEBUG) << "Disk at " << major << ":" << minor << " changed";
-        handleDiskChanged(device);
-        break;
-    }
-    case NetlinkEvent::Action::kRemove: {
-        handleDiskRemoved(device);
-        break;
-    }
-    default: {
-        LOG(WARNING) << "Unexpected block event action " << (int) evt->getAction();
-        break;
-    }
+        case NetlinkEvent::Action::kChange: {
+            LOG(DEBUG) << "Disk at " << major << ":" << minor << " changed";
+            handleDiskChanged(device);
+            break;
+        }
+        case NetlinkEvent::Action::kRemove: {
+            handleDiskRemoved(device);
+            break;
+        }
+        default: {
+            LOG(WARNING) << "Unexpected block event action " << (int)evt->getAction();
+            break;
+        }
     }
 }
 
@@ -243,7 +241,7 @@
     // until the user unlocks the device to actually touch it
     if (mSecureKeyguardShowing) {
         LOG(INFO) << "Found disk at " << disk->getEventPath()
-                << " but delaying scan due to secure keyguard";
+                  << " but delaying scan due to secure keyguard";
         mPendingDisks.push_back(disk);
     } else {
         disk->create();
@@ -318,8 +316,7 @@
     return nullptr;
 }
 
-void VolumeManager::listVolumes(android::vold::VolumeBase::Type type,
-        std::list<std::string>& list) {
+void VolumeManager::listVolumes(android::vold::VolumeBase::Type type, std::list<std::string>& list) {
     list.clear();
     for (const auto& disk : mDisks) {
         disk->listVolumes(type, list);
@@ -353,13 +350,13 @@
         PLOG(ERROR) << "fs_prepare_dir failed on " << mntTarget;
         return -errno;
     }
-    if (TEMP_FAILURE_RETRY(mount("/mnt/runtime/write", mntTarget.c_str(),
-            nullptr, MS_BIND | MS_REC, nullptr)) == -1) {
+    if (TEMP_FAILURE_RETRY(mount("/mnt/runtime/write", mntTarget.c_str(), nullptr, MS_BIND | MS_REC,
+                                 nullptr)) == -1) {
         PLOG(ERROR) << "Failed to mount /mnt/runtime/write at " << mntTarget;
         return -errno;
     }
-    if (TEMP_FAILURE_RETRY(mount(nullptr, mntTarget.c_str(),
-            nullptr, MS_REC | MS_SLAVE, nullptr)) == -1) {
+    if (TEMP_FAILURE_RETRY(
+            mount(nullptr, mntTarget.c_str(), nullptr, MS_REC | MS_SLAVE, nullptr)) == -1) {
         PLOG(ERROR) << "Failed to set MS_SLAVE at " << mntTarget;
         return -errno;
     }
@@ -416,10 +413,9 @@
 }
 
 int VolumeManager::mountSandboxesForPrimaryVol(userid_t userId,
-        const std::vector<std::string>& packageNames) {
+                                               const std::vector<std::string>& packageNames) {
     std::string primaryRoot(StringPrintf("/mnt/storage/%s", mPrimary->getLabel().c_str()));
-    bool isPrimaryEmulated =
-            (mPrimary->getType() == android::vold::VolumeBase::Type::kEmulated);
+    bool isPrimaryEmulated = (mPrimary->getType() == android::vold::VolumeBase::Type::kEmulated);
     if (isPrimaryEmulated) {
         StringAppendF(&primaryRoot, "/%d", userId);
         if (fs_prepare_dir(primaryRoot.c_str(), 0755, AID_ROOT, AID_ROOT) != 0) {
@@ -428,8 +424,8 @@
         }
     }
 
-    std::string sandboxRoot = prepareSubDirs(primaryRoot, "Android/sandbox/",
-            0700, AID_ROOT, AID_ROOT);
+    std::string sandboxRoot =
+        prepareSubDirs(primaryRoot, "Android/sandbox/", 0700, AID_ROOT, AID_ROOT);
     if (sandboxRoot.empty()) {
         return -errno;
     }
@@ -441,8 +437,7 @@
         return -errno;
     }
 
-    std::string dataRoot = prepareSubDirs(primaryRoot, "Android/data/",
-            0700, AID_ROOT, AID_ROOT);
+    std::string dataRoot = prepareSubDirs(primaryRoot, "Android/data/", 0700, AID_ROOT, AID_ROOT);
     if (dataRoot.empty()) {
         return -errno;
     }
@@ -481,29 +476,27 @@
         if (pkgDataSourceDir.empty()) {
             return -errno;
         }
-        std::string pkgDataTargetDir = preparePkgDataTarget(packageName, uid,
-                pkgSandboxSourceDir);
+        std::string pkgDataTargetDir = preparePkgDataTarget(packageName, uid, pkgSandboxSourceDir);
         if (pkgDataTargetDir.empty()) {
             return -errno;
         }
-        if (TEMP_FAILURE_RETRY(mount(pkgDataSourceDir.c_str(), pkgDataTargetDir.c_str(),
-                nullptr, MS_BIND | MS_REC, nullptr)) == -1) {
-            PLOG(ERROR) << "Failed to mount " << pkgDataSourceDir << " at "
-                        << pkgDataTargetDir;
+        if (TEMP_FAILURE_RETRY(mount(pkgDataSourceDir.c_str(), pkgDataTargetDir.c_str(), nullptr,
+                                     MS_BIND | MS_REC, nullptr)) == -1) {
+            PLOG(ERROR) << "Failed to mount " << pkgDataSourceDir << " at " << pkgDataTargetDir;
             return -errno;
         }
 
         // Already created [1] /mnt/storage/emulated/0/Android/sandbox/<sandboxId>
         // Create [2] /mnt/user/0/package/<packageName>/emulated/0
         // Mount [1] at [2]
-        std::string pkgSandboxTargetDir = prepareSandboxTarget(packageName, uid,
-                mPrimary->getLabel(), mntTargetRoot, isPrimaryEmulated);
+        std::string pkgSandboxTargetDir = prepareSandboxTarget(
+            packageName, uid, mPrimary->getLabel(), mntTargetRoot, isPrimaryEmulated);
         if (pkgSandboxTargetDir.empty()) {
             return -errno;
         }
 
         if (TEMP_FAILURE_RETRY(mount(pkgSandboxSourceDir.c_str(), pkgSandboxTargetDir.c_str(),
-                nullptr, MS_BIND | MS_REC, nullptr)) == -1) {
+                                     nullptr, MS_BIND | MS_REC, nullptr)) == -1) {
             PLOG(ERROR) << "Failed to mount " << pkgSandboxSourceDir << " at "
                         << pkgSandboxTargetDir;
             return -errno;
@@ -512,14 +505,14 @@
         // Create [1] /mnt/user/0/package/<packageName>/self/primary
         // Already created [2] /mnt/user/0/package/<packageName>/emulated/0
         // Mount [2] at [1]
-        std::string pkgPrimaryTargetDir = prepareSubDirs(
-                StringPrintf("%s/%s", mntTargetRoot.c_str(), packageName.c_str()),
-                "self/primary/", 0755, uid, uid);
+        std::string pkgPrimaryTargetDir =
+            prepareSubDirs(StringPrintf("%s/%s", mntTargetRoot.c_str(), packageName.c_str()),
+                           "self/primary/", 0755, uid, uid);
         if (pkgPrimaryTargetDir.empty()) {
             return -errno;
         }
         if (TEMP_FAILURE_RETRY(mount(pkgSandboxTargetDir.c_str(), pkgPrimaryTargetDir.c_str(),
-                nullptr, MS_BIND | MS_REC, nullptr)) == -1) {
+                                     nullptr, MS_BIND | MS_REC, nullptr)) == -1) {
             PLOG(ERROR) << "Failed to mount " << pkgSandboxTargetDir << " at "
                         << pkgPrimaryTargetDir;
             return -errno;
@@ -528,8 +521,8 @@
     return 0;
 }
 
-std::string VolumeManager::prepareSubDirs(const std::string& pathPrefix,
-        const std::string& subDirs, mode_t mode, uid_t uid, gid_t gid) {
+std::string VolumeManager::prepareSubDirs(const std::string& pathPrefix, const std::string& subDirs,
+                                          mode_t mode, uid_t uid, gid_t gid) {
     std::string path(pathPrefix);
     std::vector<std::string> subDirList = android::base::Split(subDirs, "/");
     for (size_t i = 0; i < subDirList.size(); ++i) {
@@ -547,7 +540,7 @@
 }
 
 std::string VolumeManager::prepareSandboxSource(uid_t uid, const std::string& sandboxId,
-        const std::string& sandboxRootDir) {
+                                                const std::string& sandboxRootDir) {
     std::string sandboxSourceDir(sandboxRootDir);
     if (android::base::StartsWith(sandboxId, "shared:")) {
         StringAppendF(&sandboxSourceDir, "/shared/%s", sandboxId.substr(7).c_str());
@@ -562,21 +555,21 @@
 }
 
 std::string VolumeManager::prepareSandboxTarget(const std::string& packageName, uid_t uid,
-        const std::string& volumeLabel, const std::string& mntTargetRootDir,
-        bool isUserDependent) {
+                                                const std::string& volumeLabel,
+                                                const std::string& mntTargetRootDir,
+                                                bool isUserDependent) {
     std::string segment;
     if (isUserDependent) {
-        segment = StringPrintf("%s/%s/%d/",
-                packageName.c_str(), volumeLabel.c_str(), multiuser_get_user_id(uid));
+        segment = StringPrintf("%s/%s/%d/", packageName.c_str(), volumeLabel.c_str(),
+                               multiuser_get_user_id(uid));
     } else {
-        segment = StringPrintf("%s/%s/",
-                packageName.c_str(), volumeLabel.c_str());
+        segment = StringPrintf("%s/%s/", packageName.c_str(), volumeLabel.c_str());
     }
     return prepareSubDirs(mntTargetRootDir, segment.c_str(), 0755, uid, uid);
 }
 
 std::string VolumeManager::preparePkgDataSource(const std::string& packageName, uid_t uid,
-        const std::string& dataRootDir) {
+                                                const std::string& dataRootDir) {
     std::string dataSourceDir = StringPrintf("%s/%s", dataRootDir.c_str(), packageName.c_str());
     if (fs_prepare_dir(dataSourceDir.c_str(), 0755, uid, uid) != 0) {
         PLOG(ERROR) << "fs_prepare_dir failed on " << dataSourceDir;
@@ -586,7 +579,7 @@
 }
 
 std::string VolumeManager::preparePkgDataTarget(const std::string& packageName, uid_t uid,
-        const std::string& pkgSandboxDir) {
+                                                const std::string& pkgSandboxDir) {
     std::string segment = StringPrintf("Android/data/%s/", packageName.c_str());
     return prepareSubDirs(pkgSandboxDir, segment.c_str(), 0755, uid, uid);
 }
@@ -622,7 +615,7 @@
 }
 
 int VolumeManager::addAppIds(const std::vector<std::string>& packageNames,
-        const std::vector<int32_t>& appIds) {
+                             const std::vector<int32_t>& appIds) {
     for (size_t i = 0; i < packageNames.size(); ++i) {
         mAppIds[packageNames[i]] = appIds[i];
     }
@@ -630,7 +623,7 @@
 }
 
 int VolumeManager::addSandboxIds(const std::vector<int32_t>& appIds,
-        const std::vector<std::string>& sandboxIds) {
+                                 const std::vector<std::string>& sandboxIds) {
     for (size_t i = 0; i < appIds.size(); ++i) {
         mSandboxIds[appIds[i]] = sandboxIds[i];
     }
@@ -638,7 +631,7 @@
 }
 
 int VolumeManager::mountExternalStorageForApp(const std::string& packageName, appid_t appId,
-        const std::string& sandboxId, userid_t userId) {
+                                              const std::string& sandboxId, userid_t userId) {
     if (!GetBoolProperty(kIsolatedStorage, false)) {
         return 0;
     } else if (mStartedUsers.find(userId) == mStartedUsers.end()) {
@@ -766,7 +759,7 @@
         }
 
         // We purposefully leave the namespace open across the fork
-        nsFd = openat(pidFd, "ns/mnt", O_RDONLY); // not O_CLOEXEC
+        nsFd = openat(pidFd, "ns/mnt", O_RDONLY);  // not O_CLOEXEC
         if (nsFd < 0) {
             PLOG(WARNING) << "Failed to open namespace for " << de->d_name;
             goto next;
@@ -791,26 +784,22 @@
                 // Sane default of no storage visible
                 _exit(0);
             }
-            if (TEMP_FAILURE_RETRY(mount(storageSource.c_str(), "/storage",
-                    NULL, MS_BIND | MS_REC, NULL)) == -1) {
-                PLOG(ERROR) << "Failed to mount " << storageSource << " for "
-                        << de->d_name;
+            if (TEMP_FAILURE_RETRY(
+                    mount(storageSource.c_str(), "/storage", NULL, MS_BIND | MS_REC, NULL)) == -1) {
+                PLOG(ERROR) << "Failed to mount " << storageSource << " for " << de->d_name;
                 _exit(1);
             }
-            if (TEMP_FAILURE_RETRY(mount(NULL, "/storage", NULL,
-                    MS_REC | MS_SLAVE, NULL)) == -1) {
-                PLOG(ERROR) << "Failed to set MS_SLAVE to /storage for "
-                        << de->d_name;
+            if (TEMP_FAILURE_RETRY(mount(NULL, "/storage", NULL, MS_REC | MS_SLAVE, NULL)) == -1) {
+                PLOG(ERROR) << "Failed to set MS_SLAVE to /storage for " << de->d_name;
                 _exit(1);
             }
 
             // Mount user-specific symlink helper into place
             userid_t user_id = multiuser_get_user_id(uid);
             std::string userSource(StringPrintf("/mnt/user/%d", user_id));
-            if (TEMP_FAILURE_RETRY(mount(userSource.c_str(), "/storage/self",
-                    NULL, MS_BIND, NULL)) == -1) {
-                PLOG(ERROR) << "Failed to mount " << userSource << " for "
-                        << de->d_name;
+            if (TEMP_FAILURE_RETRY(
+                    mount(userSource.c_str(), "/storage/self", NULL, MS_BIND, NULL)) == -1) {
+                PLOG(ERROR) << "Failed to mount " << userSource << " for " << de->d_name;
                 _exit(1);
             }
 
@@ -824,7 +813,7 @@
             TEMP_FAILURE_RETRY(waitpid(child, nullptr, 0));
         }
 
-next:
+    next:
         close(nsFd);
         close(pidFd);
     }
@@ -863,7 +852,7 @@
 // Can be called twice (sequentially) during shutdown. should be safe for that.
 int VolumeManager::shutdown() {
     if (mInternalEmulated == nullptr) {
-        return 0; // already shutdown
+        return 0;  // already shutdown
     }
     android::vold::sSleepOnUnmount = false;
     mInternalEmulated->destroy();
@@ -954,20 +943,18 @@
     android::vold::ForceUnmount(path);
 
     const auto opts = android::base::StringPrintf(
-            "fd=%i,"
-            "rootmode=40000,"
-            "default_permissions,"
-            "allow_other,"
-            "user_id=%d,group_id=%d,"
-            "context=\"u:object_r:app_fuse_file:s0\","
-            "fscontext=u:object_r:app_fusefs:s0",
-            device_fd,
-            uid,
-            uid);
+        "fd=%i,"
+        "rootmode=40000,"
+        "default_permissions,"
+        "allow_other,"
+        "user_id=%d,group_id=%d,"
+        "context=\"u:object_r:app_fuse_file:s0\","
+        "fscontext=u:object_r:app_fusefs:s0",
+        device_fd, uid, uid);
 
-    const int result = TEMP_FAILURE_RETRY(mount(
-            "/dev/fuse", path.c_str(), "fuse",
-            MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME, opts.c_str()));
+    const int result =
+        TEMP_FAILURE_RETRY(mount("/dev/fuse", path.c_str(), "fuse",
+                                 MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME, opts.c_str()));
     if (result != 0) {
         PLOG(ERROR) << "Failed to mount " << path;
         return -errno;
@@ -976,11 +963,8 @@
     return android::OK;
 }
 
-static android::status_t runCommandInNamespace(const std::string& command,
-                                               uid_t uid,
-                                               pid_t pid,
-                                               const std::string& path,
-                                               int device_fd) {
+static android::status_t runCommandInNamespace(const std::string& command, uid_t uid, pid_t pid,
+                                               const std::string& path, int device_fd) {
     if (DEBUG_APPFUSE) {
         LOG(DEBUG) << "Run app fuse command " << command << " for the path " << path
                    << " in namespace " << uid;
@@ -994,8 +978,7 @@
 
     // Obtains process file descriptor.
     const std::string pid_str = android::base::StringPrintf("%d", pid);
-    const unique_fd pid_fd(
-            openat(dir.get(), pid_str.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC));
+    const unique_fd pid_fd(openat(dir.get(), pid_str.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC));
     if (pid_fd.get() == -1) {
         PLOG(ERROR) << "Failed to open /proc/" << pid;
         return -errno;
@@ -1011,7 +994,7 @@
         }
         if (sb.st_uid != AID_SYSTEM) {
             LOG(ERROR) << "Only system can mount appfuse. UID expected=" << AID_SYSTEM
-                    << ", actual=" << sb.st_uid;
+                       << ", actual=" << sb.st_uid;
             return -EPERM;
         }
     }
@@ -1020,8 +1003,8 @@
     {
         std::string rootName;
         std::string pidName;
-        if (!android::vold::Readlinkat(dir.get(), "1/ns/mnt", &rootName)
-                || !android::vold::Readlinkat(pid_fd.get(), "ns/mnt", &pidName)) {
+        if (!android::vold::Readlinkat(dir.get(), "1/ns/mnt", &rootName) ||
+            !android::vold::Readlinkat(pid_fd.get(), "ns/mnt", &pidName)) {
             PLOG(ERROR) << "Failed to read namespaces";
             return -EPERM;
         }
@@ -1032,7 +1015,7 @@
     }
 
     // We purposefully leave the namespace open across the fork
-    unique_fd ns_fd(openat(pid_fd.get(), "ns/mnt", O_RDONLY)); // not O_CLOEXEC
+    unique_fd ns_fd(openat(pid_fd.get(), "ns/mnt", O_RDONLY));  // not O_CLOEXEC
     if (ns_fd.get() < 0) {
         PLOG(ERROR) << "Failed to open namespace for /proc/" << pid << "/ns/mnt";
         return -errno;
@@ -1050,8 +1033,8 @@
         } else if (command == "unmount") {
             // If it's just after all FD opened on mount point are closed, umount2 can fail with
             // EBUSY. To avoid the case, specify MNT_DETACH.
-            if (umount2(path.c_str(), UMOUNT_NOFOLLOW | MNT_DETACH) != 0 &&
-                    errno != EINVAL && errno != ENOENT) {
+            if (umount2(path.c_str(), UMOUNT_NOFOLLOW | MNT_DETACH) != 0 && errno != EINVAL &&
+                errno != ENOENT) {
                 PLOG(ERROR) << "Failed to unmount directory.";
                 _exit(-errno);
             }
@@ -1078,11 +1061,11 @@
 }
 
 int VolumeManager::createObb(const std::string& sourcePath, const std::string& sourceKey,
-        int32_t ownerGid, std::string* outVolId) {
+                             int32_t ownerGid, std::string* outVolId) {
     int id = mNextObbId++;
 
     auto vol = std::shared_ptr<android::vold::VolumeBase>(
-            new android::vold::ObbVolume(id, sourcePath, sourceKey, ownerGid));
+        new android::vold::ObbVolume(id, sourcePath, sourceKey, ownerGid));
     vol->create();
 
     mObbVolumes.push_back(vol);
@@ -1104,7 +1087,7 @@
 }
 
 int VolumeManager::mountAppFuse(uid_t uid, pid_t pid, int mountId,
-        android::base::unique_fd* device_fd) {
+                                android::base::unique_fd* device_fd) {
     std::string name = std::to_string(mountId);
 
     // Check mount point name.
@@ -1122,7 +1105,7 @@
     }
 
     // Open device FD.
-    device_fd->reset(open("/dev/fuse", O_RDWR)); // not O_CLOEXEC
+    device_fd->reset(open("/dev/fuse", O_RDWR));  // not O_CLOEXEC
     if (device_fd->get() == -1) {
         PLOG(ERROR) << "Failed to open /dev/fuse";
         return -1;
diff --git a/VolumeManager.h b/VolumeManager.h
index 38355fc..492770e 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -17,8 +17,8 @@
 #ifndef ANDROID_VOLD_VOLUME_MANAGER_H
 #define ANDROID_VOLD_VOLUME_MANAGER_H
 
-#include <pthread.h>
 #include <fnmatch.h>
+#include <pthread.h>
 #include <stdlib.h>
 
 #include <list>
@@ -29,9 +29,9 @@
 
 #include <android-base/unique_fd.h>
 #include <cutils/multiuser.h>
+#include <sysutils/NetlinkEvent.h>
 #include <utils/List.h>
 #include <utils/Timers.h>
-#include <sysutils/NetlinkEvent.h>
 
 #include "android/os/IVoldListener.h"
 
@@ -41,12 +41,12 @@
 #define DEBUG_APPFUSE 0
 
 class VolumeManager {
-private:
-    static VolumeManager *sInstance;
+  private:
+    static VolumeManager* sInstance;
 
-    bool                   mDebug;
+    bool mDebug;
 
-public:
+  public:
     virtual ~VolumeManager();
 
     // TODO: pipe all requests through VM to avoid exposing this lock
@@ -59,13 +59,12 @@
     int start();
     int stop();
 
-    void handleBlockEvent(NetlinkEvent *evt);
+    void handleBlockEvent(NetlinkEvent* evt);
 
     class DiskSource {
-    public:
-        DiskSource(const std::string& sysPattern, const std::string& nickname, int flags) :
-                mSysPattern(sysPattern), mNickname(nickname), mFlags(flags) {
-        }
+      public:
+        DiskSource(const std::string& sysPattern, const std::string& nickname, int flags)
+            : mSysPattern(sysPattern), mNickname(nickname), mFlags(flags) {}
 
         bool matches(const std::string& sysPath) {
             return !fnmatch(mSysPattern.c_str(), sysPath.c_str(), 0);
@@ -74,7 +73,7 @@
         const std::string& getNickname() { return mNickname; }
         int getFlags() { return mFlags; }
 
-    private:
+      private:
         std::string mSysPattern;
         std::string mNickname;
         int mFlags;
@@ -96,9 +95,9 @@
 
     int addAppIds(const std::vector<std::string>& packageNames, const std::vector<int32_t>& appIds);
     int addSandboxIds(const std::vector<int32_t>& appIds,
-            const std::vector<std::string>& sandboxIds);
+                      const std::vector<std::string>& sandboxIds);
     int mountExternalStorageForApp(const std::string& packageName, appid_t appId,
-            const std::string& sandboxId, userid_t userId);
+                                   const std::string& sandboxId, userid_t userId);
 
     int onSecureKeyguardStateChanged(bool isShowing);
 
@@ -116,7 +115,7 @@
     int updateVirtualDisk();
     int setDebug(bool enable);
 
-    static VolumeManager *Instance();
+    static VolumeManager* Instance();
 
     /*
      * Ensure that all directories along given path exist, creating parent
@@ -128,30 +127,30 @@
     int mkdirs(const std::string& path);
 
     int createObb(const std::string& path, const std::string& key, int32_t ownerGid,
-            std::string* outVolId);
+                  std::string* outVolId);
     int destroyObb(const std::string& volId);
 
     int mountAppFuse(uid_t uid, pid_t pid, int mountId, android::base::unique_fd* device_fd);
     int unmountAppFuse(uid_t uid, pid_t pid, int mountId);
 
-private:
+  private:
     VolumeManager();
     void readInitialState();
 
     int linkPrimary(userid_t userId, const std::vector<std::string>& packageNames);
 
     std::string prepareSandboxSource(uid_t uid, const std::string& sandboxId,
-            const std::string& sandboxRootDir);
+                                     const std::string& sandboxRootDir);
     std::string prepareSandboxTarget(const std::string& packageName, uid_t uid,
-            const std::string& volumeLabel, const std::string& mntTargetRootDir, bool isUserDependent);
+                                     const std::string& volumeLabel,
+                                     const std::string& mntTargetRootDir, bool isUserDependent);
     std::string preparePkgDataSource(const std::string& packageName, uid_t uid,
-            const std::string& dataRootDir);
+                                     const std::string& dataRootDir);
     std::string preparePkgDataTarget(const std::string& packageName, uid_t uid,
-            const std::string& pkgSandboxDir);
-    int mountSandboxesForPrimaryVol(userid_t userId,
-            const std::vector<std::string>& packageNames);
+                                     const std::string& pkgSandboxDir);
+    int mountSandboxesForPrimaryVol(userid_t userId, const std::vector<std::string>& packageNames);
     std::string prepareSubDirs(const std::string& pathPrefix, const std::string& subDirs,
-            mode_t mode, uid_t uid, gid_t gid);
+                               mode_t mode, uid_t uid, gid_t gid);
 
     void handleDiskAdded(const std::shared_ptr<android::vold::Disk>& disk);
     void handleDiskChanged(dev_t device);
diff --git a/binder/android/os/IVold.aidl b/binder/android/os/IVold.aidl
index cff1baa..fce8aad 100644
--- a/binder/android/os/IVold.aidl
+++ b/binder/android/os/IVold.aidl
@@ -47,14 +47,14 @@
     void checkEncryption(@utf8InCpp String volId);
 
     void moveStorage(@utf8InCpp String fromVolId, @utf8InCpp String toVolId,
-            IVoldTaskListener listener);
+                     IVoldTaskListener listener);
 
     void remountUid(int uid, int remountMode);
 
     void mkdirs(@utf8InCpp String path);
 
-    @utf8InCpp String createObb(@utf8InCpp String sourcePath,
-            @utf8InCpp String sourceKey, int ownerGid);
+    @utf8InCpp String createObb(@utf8InCpp String sourcePath, @utf8InCpp String sourceKey,
+                                int ownerGid);
     void destroyObb(@utf8InCpp String volId);
 
     void fstrim(int fstrimFlags, IVoldTaskListener listener);
@@ -87,17 +87,20 @@
     void createUserKey(int userId, int userSerial, boolean ephemeral);
     void destroyUserKey(int userId);
 
-    void addUserKeyAuth(int userId, int userSerial, @utf8InCpp String token, @utf8InCpp String secret);
+    void addUserKeyAuth(int userId, int userSerial, @utf8InCpp String token,
+                        @utf8InCpp String secret);
     void fixateNewestUserKeyAuth(int userId);
 
-    void unlockUserKey(int userId, int userSerial, @utf8InCpp String token, @utf8InCpp String secret);
+    void unlockUserKey(int userId, int userSerial, @utf8InCpp String token,
+                       @utf8InCpp String secret);
     void lockUserKey(int userId);
 
-    void prepareUserStorage(@nullable @utf8InCpp String uuid, int userId, int userSerial, int storageFlags);
+    void prepareUserStorage(@nullable @utf8InCpp String uuid, int userId, int userSerial,
+                            int storageFlags);
     void destroyUserStorage(@nullable @utf8InCpp String uuid, int userId, int storageFlags);
 
-    void mountExternalStorageForApp(in @utf8InCpp String packageName,
-            int appId, in @utf8InCpp String sandboxId, int userId);
+    void mountExternalStorageForApp(in @utf8InCpp String packageName, int appId,
+                                    in @utf8InCpp String sandboxId, int userId);
 
     const int ENCRYPTION_FLAG_NO_UI = 4;
 
diff --git a/model/EmulatedVolume.cpp b/model/EmulatedVolume.cpp
index 25ea602..19074af 100644
--- a/model/EmulatedVolume.cpp
+++ b/model/EmulatedVolume.cpp
@@ -27,8 +27,8 @@
 #include <stdlib.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <sys/sysmacros.h>
+#include <sys/types.h>
 #include <sys/wait.h>
 
 using android::base::StringPrintf;
@@ -38,22 +38,21 @@
 
 static const char* kFusePath = "/system/bin/sdcard";
 
-EmulatedVolume::EmulatedVolume(const std::string& rawPath) :
-        VolumeBase(Type::kEmulated), mFusePid(0) {
+EmulatedVolume::EmulatedVolume(const std::string& rawPath)
+    : VolumeBase(Type::kEmulated), mFusePid(0) {
     setId("emulated");
     mRawPath = rawPath;
     mLabel = "emulated";
 }
 
-EmulatedVolume::EmulatedVolume(const std::string& rawPath, dev_t device,
-        const std::string& fsUuid) : VolumeBase(Type::kEmulated), mFusePid(0) {
+EmulatedVolume::EmulatedVolume(const std::string& rawPath, dev_t device, const std::string& fsUuid)
+    : VolumeBase(Type::kEmulated), mFusePid(0) {
     setId(StringPrintf("emulated:%u,%u", major(device), minor(device)));
     mRawPath = rawPath;
     mLabel = fsUuid;
 }
 
-EmulatedVolume::~EmulatedVolume() {
-}
+EmulatedVolume::~EmulatedVolume() {}
 
 status_t EmulatedVolume::doMount() {
     // We could have migrated storage to an adopted private volume, so always
@@ -72,8 +71,8 @@
     setLabel(label);
 
     if (fs_prepare_dir(mFuseDefault.c_str(), 0700, AID_ROOT, AID_ROOT) ||
-            fs_prepare_dir(mFuseRead.c_str(), 0700, AID_ROOT, AID_ROOT) ||
-            fs_prepare_dir(mFuseWrite.c_str(), 0700, AID_ROOT, AID_ROOT)) {
+        fs_prepare_dir(mFuseRead.c_str(), 0700, AID_ROOT, AID_ROOT) ||
+        fs_prepare_dir(mFuseWrite.c_str(), 0700, AID_ROOT, AID_ROOT)) {
         PLOG(ERROR) << getId() << " failed to create mount points";
         return -errno;
     }
@@ -81,6 +80,7 @@
     dev_t before = GetDevice(mFuseWrite);
 
     if (!(mFusePid = fork())) {
+        // clang-format off
         if (execl(kFusePath, kFusePath,
                 "-u", "1023", // AID_MEDIA_RW
                 "-g", "1023", // AID_MEDIA_RW
@@ -91,6 +91,7 @@
                 mRawPath.c_str(),
                 label.c_str(),
                 NULL)) {
+            // clang-format on
             PLOG(ERROR) << "Failed to exec";
         }
 
@@ -106,7 +107,7 @@
     nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
     while (before == GetDevice(mFuseWrite)) {
         LOG(VERBOSE) << "Waiting for FUSE to spin up...";
-        usleep(50000); // 50ms
+        usleep(50000);  // 50ms
 
         nsecs_t now = systemTime(SYSTEM_TIME_BOOTTIME);
         if (nanoseconds_to_milliseconds(now - start) > 5000) {
diff --git a/model/PublicVolume.cpp b/model/PublicVolume.cpp
index 4076e73..9b48f82 100644
--- a/model/PublicVolume.cpp
+++ b/model/PublicVolume.cpp
@@ -20,8 +20,8 @@
 #include "fs/Exfat.h"
 #include "fs/Vfat.h"
 
-#include <android-base/stringprintf.h>
 #include <android-base/logging.h>
+#include <android-base/stringprintf.h>
 #include <cutils/fs.h>
 #include <private/android_filesystem_config.h>
 #include <utils/Timers.h>
@@ -30,8 +30,8 @@
 #include <stdlib.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
-#include <sys/types.h>
 #include <sys/sysmacros.h>
+#include <sys/types.h>
 #include <sys/wait.h>
 
 using android::base::StringPrintf;
@@ -43,14 +43,12 @@
 
 static const char* kAsecPath = "/mnt/secure/asec";
 
-PublicVolume::PublicVolume(dev_t device) :
-        VolumeBase(Type::kPublic), mDevice(device), mFusePid(0) {
+PublicVolume::PublicVolume(dev_t device) : VolumeBase(Type::kPublic), mDevice(device), mFusePid(0) {
     setId(StringPrintf("public:%u,%u", major(device), minor(device)));
     mDevPath = StringPrintf("/dev/block/vold/%s", getId().c_str());
 }
 
-PublicVolume::~PublicVolume() {
-}
+PublicVolume::~PublicVolume() {}
 
 status_t PublicVolume::readMetadata() {
     status_t res = ReadMetadataUntrusted(mDevPath, &mFsType, &mFsUuid, &mFsLabel);
@@ -66,8 +64,7 @@
     std::string securePath(mRawPath + "/.android_secure");
 
     // Recover legacy secure path
-    if (!access(legacyPath.c_str(), R_OK | X_OK)
-            && access(securePath.c_str(), R_OK | X_OK)) {
+    if (!access(legacyPath.c_str(), R_OK | X_OK) && access(securePath.c_str(), R_OK | X_OK)) {
         if (rename(legacyPath.c_str(), securePath.c_str())) {
             PLOG(WARNING) << getId() << " failed to rename legacy ASEC dir";
         }
@@ -159,8 +156,8 @@
     }
 
     if (fs_prepare_dir(mFuseDefault.c_str(), 0700, AID_ROOT, AID_ROOT) ||
-            fs_prepare_dir(mFuseRead.c_str(), 0700, AID_ROOT, AID_ROOT) ||
-            fs_prepare_dir(mFuseWrite.c_str(), 0700, AID_ROOT, AID_ROOT)) {
+        fs_prepare_dir(mFuseRead.c_str(), 0700, AID_ROOT, AID_ROOT) ||
+        fs_prepare_dir(mFuseWrite.c_str(), 0700, AID_ROOT, AID_ROOT)) {
         PLOG(ERROR) << getId() << " failed to create FUSE mount points";
         return -errno;
     }
@@ -169,6 +166,7 @@
 
     if (!(mFusePid = fork())) {
         if (getMountFlags() & MountFlags::kPrimary) {
+            // clang-format off
             if (execl(kFusePath, kFusePath,
                     "-u", "1023", // AID_MEDIA_RW
                     "-g", "1023", // AID_MEDIA_RW
@@ -177,9 +175,11 @@
                     mRawPath.c_str(),
                     stableName.c_str(),
                     NULL)) {
+                // clang-format on
                 PLOG(ERROR) << "Failed to exec";
             }
         } else {
+            // clang-format off
             if (execl(kFusePath, kFusePath,
                     "-u", "1023", // AID_MEDIA_RW
                     "-g", "1023", // AID_MEDIA_RW
@@ -187,6 +187,7 @@
                     mRawPath.c_str(),
                     stableName.c_str(),
                     NULL)) {
+                // clang-format on
                 PLOG(ERROR) << "Failed to exec";
             }
         }
@@ -203,7 +204,7 @@
     nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
     while (before == GetDevice(mFuseWrite)) {
         LOG(VERBOSE) << "Waiting for FUSE to spin up...";
-        usleep(50000); // 50ms
+        usleep(50000);  // 50ms
 
         nsecs_t now = systemTime(SYSTEM_TIME_BOOTTIME);
         if (nanoseconds_to_milliseconds(now - start) > 5000) {
diff --git a/model/VolumeBase.cpp b/model/VolumeBase.cpp
index cf3d54e..74bd874 100644
--- a/model/VolumeBase.cpp
+++ b/model/VolumeBase.cpp
@@ -14,12 +14,12 @@
  * limitations under the License.
  */
 
-#include "Utils.h"
 #include "VolumeBase.h"
+#include "Utils.h"
 #include "VolumeManager.h"
 
-#include <android-base/stringprintf.h>
 #include <android-base/logging.h>
+#include <android-base/stringprintf.h>
 
 #include <fcntl.h>
 #include <stdlib.h>
@@ -32,10 +32,13 @@
 namespace android {
 namespace vold {
 
-VolumeBase::VolumeBase(Type type) :
-        mType(type), mMountFlags(0), mMountUserId(-1), mCreated(false), mState(
-                State::kUnmounted), mSilent(false) {
-}
+VolumeBase::VolumeBase(Type type)
+    : mType(type),
+      mMountFlags(0),
+      mMountUserId(-1),
+      mCreated(false),
+      mState(State::kUnmounted),
+      mSilent(false) {}
 
 VolumeBase::~VolumeBase() {
     CHECK(!mCreated);
@@ -45,7 +48,9 @@
     mState = state;
 
     auto listener = getListener();
-    if (listener) listener->onVolumeStateChanged(getId(), static_cast<int32_t>(mState));
+    if (listener) {
+        listener->onVolumeStateChanged(getId(), static_cast<int32_t>(mState));
+    }
 }
 
 status_t VolumeBase::setDiskId(const std::string& diskId) {
@@ -131,7 +136,9 @@
     mInternalPath = internalPath;
 
     auto listener = getListener();
-    if (listener) listener->onVolumeInternalPathChanged(getId(), mInternalPath);
+    if (listener) {
+        listener->onVolumeInternalPathChanged(getId(), mInternalPath);
+    }
 
     return OK;
 }
@@ -178,8 +185,9 @@
     status_t res = doCreate();
 
     auto listener = getListener();
-    if (listener) listener->onVolumeCreated(getId(),
-            static_cast<int32_t>(mType), mDiskId, mPartGuid);
+    if (listener) {
+        listener->onVolumeCreated(getId(), static_cast<int32_t>(mType), mDiskId, mPartGuid);
+    }
 
     setState(State::kUnmounted);
     return res;
@@ -199,9 +207,10 @@
         setState(State::kRemoved);
     }
 
-
     auto listener = getListener();
-    if (listener) listener->onVolumeDestroyed(getId());
+    if (listener) {
+        listener->onVolumeDestroyed(getId());
+    }
 
     status_t res = doDestroy();
     mCreated = false;
@@ -238,8 +247,7 @@
     setState(State::kEjecting);
     for (const auto& vol : mVolumes) {
         if (vol->destroy()) {
-            LOG(WARNING) << getId() << " failed to destroy " << vol->getId()
-                    << " stacked above";
+            LOG(WARNING) << getId() << " failed to destroy " << vol->getId() << " stacked above";
         }
     }
     mVolumes.clear();
diff --git a/model/VolumeBase.h b/model/VolumeBase.h
index 2052c15..a75669e 100644
--- a/model/VolumeBase.h
+++ b/model/VolumeBase.h
@@ -17,8 +17,8 @@
 #ifndef ANDROID_VOLD_VOLUME_BASE_H
 #define ANDROID_VOLD_VOLUME_BASE_H
 
-#include "android/os/IVoldListener.h"
 #include "Utils.h"
+#include "android/os/IVoldListener.h"
 
 #include <cutils/multiuser.h>
 #include <utils/Errors.h>
@@ -45,7 +45,7 @@
  * volumes and removes any bind mounts before finally unmounting itself.
  */
 class VolumeBase {
-public:
+  public:
     virtual ~VolumeBase();
 
     enum class Type {
@@ -103,7 +103,7 @@
     status_t unmount();
     status_t format(const std::string& fsType);
 
-protected:
+  protected:
     explicit VolumeBase(Type type);
 
     virtual status_t doCreate();
@@ -119,7 +119,7 @@
 
     android::sp<android::os::IVoldListener> getListener();
 
-private:
+  private:
     /* ID that uniquely references volume while alive */
     std::string mId;
     /* ID that uniquely references parent disk while alive */