android java 成功获得root权限后(log信息可知), 执行adb shell命令时, 出错, 是什么地方的问题呢?
Runtime ex = Runtime.getRuntime();
String cmdBecomeSu = "su";
String script = "busybox chmod a+rw /dev/input/event1";
String script1 = "busybox sendevent /dev/input/event1 1 116 1";
String script2 = "busybox sendevent /dev/input/event1 0 0 0";
String script3 = "busybox sendevent /dev/input/event1 1 116 0";
String script4 = "busybox sendevent /dev/input/event1 0 0 0"; try{
java.lang.Process runsum = ex.exec(cmdBecomeSu);
int exitVal = 0;
final OutputStreamWriter out = new OutputStreamWriter(runsum.getOutputStream()); // Write the script to be executed
out.write(script); // Ensure that the last character is an "enter"
out.write("\n");
out.flush(); // Terminate the "su" process
out.write("exit\n");
out.flush(); exitVal = runsum.waitFor();
if (exitVal == 0) {
Log.e("Debug", "...Successfully to su");
} //*********************************************
out.write(script1); // Ensure that the last character is an "enter"
out.write("\n");
out.flush(); // Terminate the "su" process
out.write("exit\n");
out.flush();
//*********************************************
//*********************************************
out.write(script2); // Ensure that the last character is an "enter"
out.write("\n");
out.flush(); // Terminate the "su" process
out.write("exit\n");
out.flush();
//********************************************* //*********************************************
out.write(script3); // Ensure that the last character is an "enter"
out.write("\n");
out.flush(); // Terminate the "su" process
out.write("exit\n");
out.flush();
//********************************************* //*********************************************
out.write(script4); // Ensure that the last character is an "enter"
out.write("\n");
out.flush(); // Terminate the "su" process
out.write("exit\n");
out.flush();
//*********************************************
} catch ( Exception e){
Log.e("Debug", "Fails to su");
}
Runtime ex = Runtime.getRuntime();
String cmdBecomeSu = "su";
String script = "busybox chmod a+rw /dev/input/event1";
String script1 = "busybox sendevent /dev/input/event1 1 116 1";
String script2 = "busybox sendevent /dev/input/event1 0 0 0";
String script3 = "busybox sendevent /dev/input/event1 1 116 0";
String script4 = "busybox sendevent /dev/input/event1 0 0 0"; try{
java.lang.Process runsum = ex.exec(cmdBecomeSu);
int exitVal = 0;
final OutputStreamWriter out = new OutputStreamWriter(runsum.getOutputStream()); // Write the script to be executed
out.write(script); // Ensure that the last character is an "enter"
out.write("\n");
out.flush(); // Terminate the "su" process
out.write("exit\n");
out.flush(); exitVal = runsum.waitFor();
if (exitVal == 0) {
Log.e("Debug", "...Successfully to su");
} //*********************************************
out.write(script1); // Ensure that the last character is an "enter"
out.write("\n");
out.flush(); // Terminate the "su" process
out.write("exit\n");
out.flush();
//*********************************************
//*********************************************
out.write(script2); // Ensure that the last character is an "enter"
out.write("\n");
out.flush(); // Terminate the "su" process
out.write("exit\n");
out.flush();
//********************************************* //*********************************************
out.write(script3); // Ensure that the last character is an "enter"
out.write("\n");
out.flush(); // Terminate the "su" process
out.write("exit\n");
out.flush();
//********************************************* //*********************************************
out.write(script4); // Ensure that the last character is an "enter"
out.write("\n");
out.flush(); // Terminate the "su" process
out.write("exit\n");
out.flush();
//*********************************************
} catch ( Exception e){
Log.e("Debug", "Fails to su");
}
解决方案 »
- 用eclipse开发Android项目导出文件失败
- android rgb32如何转为rgb888
- 初学android,manifest.xml文件的xmlns
- 请教:如何获取连接端口
- 绘制 移动 图形,,
- AudioCommandThread::threadLoop中对应mLock.lock()的unlock的地方在哪里
- android数据库操作
- android hello world报错
- android 然后跳转activity 后返回保留原来的ListView数据
- 安卓虚拟机能直接跑java程序吗
- 你知道怎么导入 com.android.mms.R吗?
- android开发office文档阅读器(求思路)
Log.e("Debug", "Fails to su");
Log.e("Debug", "Fails to su");
前面加上
e.printStackTrace();看一下具体出错提示
String script2 = "busybox sendevent /dev/input/event1 0 0 0";
String script3 = "busybox sendevent /dev/input/event1 1 116 0";
String script4 = "busybox sendevent /dev/input/event1 0 0 0"; //***************************************************adb shell 下, 以下是可用的,
adb shell sendevent /dev/input/event1 1 116 1
adb shell sendevent /dev/input/event1 0 0 0
adb shell sendevent /dev/input/event1 1 116 0
adb shell sendevent /dev/input/event1 0 0 0
String script1 = "sendevent /dev/input/event1 1 116 1";
String script2 = "sendevent /dev/input/event1 0 0 0";
String script3 = "sendevent /dev/input/event1 1 116 0";
String script4 = "sendevent /dev/input/event1 0 0 0";