forked from Android500/AndroidLua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell_cmd.c
More file actions
39 lines (29 loc) · 992 Bytes
/
Copy pathshell_cmd.c
File metadata and controls
39 lines (29 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// Created by Administrator on 2018/1/17.
//
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "shell_cmd.h"
#include "androidlib.h"
int input_text(char *content){
int length = sizeof(CMD_INPUT_TEXT) + sizeof(content) + sizeof(USER);
char *cmd = malloc(sizeof(char) * length);
sprintf(cmd, "%s%s %s", CMD_INPUT_TEXT, content, USER);
LOGE("%s:%s", __FUNCTION__, cmd);
return system(cmd);
}
int run_app(char *action){
int length = sizeof(CMD_RUN_APP) + sizeof(action) + sizeof(USER);
char *cmd = malloc(sizeof(char) * length);
sprintf(cmd, "%s %s %s", CMD_RUN_APP, USER, action);
LOGE("%s:%s", __FUNCTION__, cmd);
return system(cmd);
}
int kill_app(char *packageName){
int length = sizeof(CMD_FORCE_STOP) + sizeof(packageName) + sizeof(USER);
char *cmd = malloc(sizeof(char) * length);
sprintf(cmd, "%s %s %s", CMD_FORCE_STOP, USER, packageName);
LOGE("%s:%s", __FUNCTION__, cmd);
return system(cmd);
}