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
Merged-In: I1bfd5c8d68d298596875d5edae26cdfe27c03489
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index 81523c6..1a15304 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,45 +140,49 @@
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();
}
-#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 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();
@@ -196,7 +200,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()) {
@@ -211,7 +215,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;
@@ -223,12 +227,8 @@
ENFORCE_UID(AID_SYSTEM);
// Simply acquire/release each lock for watchdog
- {
- ACQUIRE_LOCK;
- }
- {
- ACQUIRE_CRYPT_LOCK;
- }
+ { ACQUIRE_LOCK; }
+ { ACQUIRE_CRYPT_LOCK; }
return ok();
}
@@ -283,7 +283,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;
@@ -293,15 +293,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);
@@ -311,7 +315,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;
@@ -387,9 +391,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();
}
@@ -404,8 +406,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);
@@ -419,9 +422,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();
}
@@ -431,11 +432,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));
}
@@ -449,14 +459,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) {
@@ -467,41 +478,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;
@@ -541,7 +546,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) {
@@ -562,8 +567,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;
@@ -581,7 +586,7 @@
}
binder::Status VoldNativeService::fdeChangePassword(int32_t passwordType,
- const std::string& password) {
+ const std::string& password) {
ENFORCE_UID(AID_SYSTEM);
ACQUIRE_CRYPT_LOCK;
@@ -595,8 +600,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;
@@ -609,8 +613,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;
@@ -692,8 +695,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;
@@ -708,7 +710,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;
@@ -723,7 +726,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;
@@ -738,7 +742,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;
@@ -749,7 +754,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;