Merge "vdc: print the failed command with failure status." am: b8d17384c5
am: 880deb6add
Change-Id: Ib680ab944a6e197e4afd3f4e2d36dcd345cbf9c8
This commit is contained in:
commit
faad076163
1 changed files with 24 additions and 22 deletions
46
vdc.cpp
46
vdc.cpp
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/parseint.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <binder/IServiceManager.h>
|
||||
#include <binder/Status.h>
|
||||
|
@ -55,9 +56,10 @@ static android::sp<android::IBinder> getServiceAggressive() {
|
|||
return res;
|
||||
}
|
||||
|
||||
static void checkStatus(android::binder::Status status) {
|
||||
static void checkStatus(std::vector<std::string>& cmd, android::binder::Status status) {
|
||||
if (status.isOk()) return;
|
||||
LOG(ERROR) << "Failed: " << status.toString8().string();
|
||||
std::string command = ::android::base::Join(cmd, " ");
|
||||
LOG(ERROR) << "Command: " << command << " Failed: " << status.toString8().string();
|
||||
exit(ENOTTY);
|
||||
}
|
||||
|
||||
|
@ -88,63 +90,63 @@ int main(int argc, char** argv) {
|
|||
auto vold = android::interface_cast<android::os::IVold>(binder);
|
||||
|
||||
if (args[0] == "cryptfs" && args[1] == "enablefilecrypto") {
|
||||
checkStatus(vold->fbeEnable());
|
||||
checkStatus(args, vold->fbeEnable());
|
||||
} else if (args[0] == "cryptfs" && args[1] == "init_user0") {
|
||||
checkStatus(vold->initUser0());
|
||||
checkStatus(args, vold->initUser0());
|
||||
} else if (args[0] == "cryptfs" && args[1] == "enablecrypto") {
|
||||
int passwordType = android::os::IVold::PASSWORD_TYPE_DEFAULT;
|
||||
int encryptionFlags = android::os::IVold::ENCRYPTION_FLAG_NO_UI;
|
||||
checkStatus(vold->fdeEnable(passwordType, "", encryptionFlags));
|
||||
checkStatus(args, vold->fdeEnable(passwordType, "", encryptionFlags));
|
||||
} else if (args[0] == "cryptfs" && args[1] == "mountdefaultencrypted") {
|
||||
checkStatus(vold->mountDefaultEncrypted());
|
||||
checkStatus(args, vold->mountDefaultEncrypted());
|
||||
} else if (args[0] == "volume" && args[1] == "shutdown") {
|
||||
checkStatus(vold->shutdown());
|
||||
checkStatus(args, vold->shutdown());
|
||||
} else if (args[0] == "cryptfs" && args[1] == "checkEncryption" && args.size() == 3) {
|
||||
checkStatus(vold->checkEncryption(args[2]));
|
||||
checkStatus(args, vold->checkEncryption(args[2]));
|
||||
} else if (args[0] == "cryptfs" && args[1] == "mountFstab" && args.size() == 3) {
|
||||
checkStatus(vold->mountFstab(args[2]));
|
||||
checkStatus(args, vold->mountFstab(args[2]));
|
||||
} else if (args[0] == "cryptfs" && args[1] == "encryptFstab" && args.size() == 3) {
|
||||
checkStatus(vold->encryptFstab(args[2]));
|
||||
checkStatus(args, vold->encryptFstab(args[2]));
|
||||
} else if (args[0] == "checkpoint" && args[1] == "supportsCheckpoint" && args.size() == 2) {
|
||||
bool supported = false;
|
||||
checkStatus(vold->supportsCheckpoint(&supported));
|
||||
checkStatus(args, vold->supportsCheckpoint(&supported));
|
||||
return supported ? 1 : 0;
|
||||
} else if (args[0] == "checkpoint" && args[1] == "supportsBlockCheckpoint" && args.size() == 2) {
|
||||
bool supported = false;
|
||||
checkStatus(vold->supportsBlockCheckpoint(&supported));
|
||||
checkStatus(args, vold->supportsBlockCheckpoint(&supported));
|
||||
return supported ? 1 : 0;
|
||||
} else if (args[0] == "checkpoint" && args[1] == "supportsFileCheckpoint" && args.size() == 2) {
|
||||
bool supported = false;
|
||||
checkStatus(vold->supportsFileCheckpoint(&supported));
|
||||
checkStatus(args, vold->supportsFileCheckpoint(&supported));
|
||||
return supported ? 1 : 0;
|
||||
} else if (args[0] == "checkpoint" && args[1] == "startCheckpoint" && args.size() == 3) {
|
||||
int retry;
|
||||
if (!android::base::ParseInt(args[2], &retry)) exit(EINVAL);
|
||||
checkStatus(vold->startCheckpoint(retry));
|
||||
checkStatus(args, vold->startCheckpoint(retry));
|
||||
} else if (args[0] == "checkpoint" && args[1] == "needsCheckpoint" && args.size() == 2) {
|
||||
bool enabled = false;
|
||||
checkStatus(vold->needsCheckpoint(&enabled));
|
||||
checkStatus(args, vold->needsCheckpoint(&enabled));
|
||||
return enabled ? 1 : 0;
|
||||
} else if (args[0] == "checkpoint" && args[1] == "needsRollback" && args.size() == 2) {
|
||||
bool enabled = false;
|
||||
checkStatus(vold->needsRollback(&enabled));
|
||||
checkStatus(args, vold->needsRollback(&enabled));
|
||||
return enabled ? 1 : 0;
|
||||
} else if (args[0] == "checkpoint" && args[1] == "commitChanges" && args.size() == 2) {
|
||||
checkStatus(vold->commitChanges());
|
||||
checkStatus(args, vold->commitChanges());
|
||||
} else if (args[0] == "checkpoint" && args[1] == "prepareCheckpoint" && args.size() == 2) {
|
||||
checkStatus(vold->prepareCheckpoint());
|
||||
checkStatus(args, vold->prepareCheckpoint());
|
||||
} else if (args[0] == "checkpoint" && args[1] == "restoreCheckpoint" && args.size() == 3) {
|
||||
checkStatus(vold->restoreCheckpoint(args[2]));
|
||||
checkStatus(args, vold->restoreCheckpoint(args[2]));
|
||||
} else if (args[0] == "checkpoint" && args[1] == "restoreCheckpointPart" && args.size() == 4) {
|
||||
int count;
|
||||
if (!android::base::ParseInt(args[3], &count)) exit(EINVAL);
|
||||
checkStatus(vold->restoreCheckpointPart(args[2], count));
|
||||
checkStatus(args, vold->restoreCheckpointPart(args[2], count));
|
||||
} else if (args[0] == "checkpoint" && args[1] == "markBootAttempt" && args.size() == 2) {
|
||||
checkStatus(vold->markBootAttempt());
|
||||
checkStatus(args, vold->markBootAttempt());
|
||||
} else if (args[0] == "checkpoint" && args[1] == "abortChanges" && args.size() == 4) {
|
||||
int retry;
|
||||
if (!android::base::ParseInt(args[2], &retry)) exit(EINVAL);
|
||||
checkStatus(vold->abortChanges(args[2], retry != 0));
|
||||
checkStatus(args, vold->abortChanges(args[2], retry != 0));
|
||||
} else {
|
||||
LOG(ERROR) << "Raw commands are no longer supported";
|
||||
exit(EINVAL);
|
||||
|
|
Loading…
Reference in a new issue