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"); 

解决方案 »

  1.   

    Log.e("Debug", "...Successfully to su");  
    Log.e("Debug", "Fails to su");  
      

  2.   

    应用安装到了系统中, logcat 看的.
      

  3.   


    Log.e("Debug", "Fails to su");
    前面加上
    e.printStackTrace();看一下具体出错提示
      

  4.   

    这些参数应如何写呢?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"; //***************************************************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
      

  5.   


    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";