add sleep and print commands.
This commit is contained in:
parent
a9483087a0
commit
60d7ee07ba
44
commands.c
44
commands.c
@ -797,6 +797,44 @@ cmd_restore_rom(const char *name, void *cookie, int argc, const char *argv[],
|
||||
return do_nandroid_restore(argv[0]);
|
||||
}
|
||||
|
||||
static int
|
||||
cmd_sleep(const char *name, void *cookie, int argc, const char *argv[],
|
||||
PermissionRequestList *permissions)
|
||||
{
|
||||
UNUSED(cookie);
|
||||
CHECK_WORDS();
|
||||
|
||||
if (argc != 1) {
|
||||
LOGE("Command %s requires exactly one argument\n", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int seconds = atoi(argv[0]);
|
||||
sleep(seconds);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
cmd_print(const char *name, void *cookie, int argc, const char *argv[],
|
||||
PermissionRequestList *permissions)
|
||||
{
|
||||
UNUSED(cookie);
|
||||
CHECK_WORDS();
|
||||
|
||||
char message[1024];
|
||||
message[0] = NULL;
|
||||
int i;
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
strcat(message, argv[i]);
|
||||
strcat(message, " ");
|
||||
}
|
||||
strcat(message, "\n");
|
||||
|
||||
ui_print(message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function definitions
|
||||
@ -1167,6 +1205,12 @@ register_update_commands(RecoveryCommandContext *ctx)
|
||||
ret = registerCommand("restore_rom", CMD_ARGS_WORDS, cmd_restore_rom, (void *)ctx);
|
||||
if (ret < 0) return ret;
|
||||
|
||||
ret = registerCommand("sleep", CMD_ARGS_WORDS, cmd_sleep, (void *)ctx);
|
||||
if (ret < 0) return ret;
|
||||
|
||||
ret = registerCommand("print", CMD_ARGS_WORDS, cmd_print, (void *)ctx);
|
||||
if (ret < 0) return ret;
|
||||
|
||||
/*
|
||||
* Functions
|
||||
*/
|
||||
|
@ -327,6 +327,11 @@ system(const char *command)
|
||||
|
||||
int do_nandroid_backup(char* backup_name)
|
||||
{
|
||||
if (ensure_root_path_mounted("SDCARD:") != 0) {
|
||||
LOGE ("Can't mount /sdcard\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char cmd[PATH_MAX];
|
||||
if (NULL == backup_name)
|
||||
backup_name = "";
|
||||
@ -344,6 +349,11 @@ int do_nandroid_backup(char* backup_name)
|
||||
|
||||
int do_nandroid_restore(char* backup_path)
|
||||
{
|
||||
if (ensure_root_path_mounted("SDCARD:") != 0) {
|
||||
LOGE ("Can't mount /sdcard\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char* command[PATH_MAX];
|
||||
sprintf(command, "nandroid-mobile.sh restore %s", backup_path);
|
||||
ui_print("Performing restore...\n");
|
||||
@ -359,11 +369,6 @@ int do_nandroid_restore(char* backup_path)
|
||||
|
||||
void show_nandroid_restore_menu()
|
||||
{
|
||||
if (ensure_root_path_mounted("SDCARD:") != 0) {
|
||||
LOGE ("Can't mount /sdcard\n");
|
||||
return;
|
||||
}
|
||||
|
||||
static char* headers[] = { "Choose an image to restore",
|
||||
"",
|
||||
NULL
|
||||
|
Loading…
Reference in New Issue
Block a user