나는 초보자입니다 stackoverflow 그래서 나는 코멘트를 추가 할 수 없습니다. 루팅 된 안드로이드에 명령을 구현하고 결과를 얻을
나는이 페이지를 보았다Read command output inside su process
를 나는이 대답을 시도하고 괜찮 :
Process p = Runtime.getRuntime().exec(new String[]{"su", "-c", "system/bin/sh"});
DataOutputStream stdin = new DataOutputStream(p.getOutputStream());
//from here all commands are executed with su permissions
stdin.writeBytes("ls /data\n"); // \n executes the command
InputStream stdout = p.getInputStream();
byte[] buffer = new byte[BUFF_LEN];
int read;
String out = new String();
//read method will wait forever if there is nothing in the stream
//so we need to read it in another way than while((read=stdout.read(buffer))>0)
while(true){
read = stdout.read(buffer);
out += new String(buffer, 0, read);
if(read<BUFF_LEN){
//we have read everything
break;
}
}
//do something with the output
하지만 쉘의 명령에 시도 할 때 응답은 같은 명령이었다.
내가이 명령을 넣어 :
stdin.writeBytes("echo AT+CQI?\n");
대답했다 :
AT+CQI?
내가 쓴 : 대답은
stdin.writeBytes("echo ATinkd\n");
이었다
ATinkd
,
이것은 "bla..bla..bla .."의 의미입니다. 즉 안드로이드 시스템이이 명령을 명령으로 인식하지 못한다는 뜻입니다.
신체에 조언이나 해결책이 있는지 궁금합니다.
[V.250] (http://www.itu.int/rec/T-REC-V.250-200307-I/en)은 AT 명령 줄에'\ r' 및 '\ n'이 아닙니다. – hlovdal