解决方案 »

  1.   

    可以 但是需要linux系统有的需要root权限
      

  2.   

    在你的应用程序中执行->adb在终端执行的命令1. [代码][Java]代码     
    01
    这是方法,添加到你的应用程序中即可,比较简陋,呵呵!
    02
    public void execShell(String cmd){
    03
            try{ 
    04
                //权限设置
    05
                Process p = Runtime.getRuntime().exec("su"); 
    06
                //获取输出流
    07
                OutputStream outputStream = p.getOutputStream();
    08
                DataOutputStream dataOutputStream=new DataOutputStream(outputStream);
    09
                //将命令写入
    10
                dataOutputStream.writeBytes(cmd);
    11
                //提交命令
    12
                dataOutputStream.flush();
    13
                //关闭流操作
    14
                dataOutputStream.close();
    15
                outputStream.close();
    16
           } 
    17
           catch(Throwable t) 
    18
            { 
    19
                 t.printStackTrace(); 
    20
                }
    21
        }
    2. [代码]第二种方式     
    01
    public void execCommand(String command) throws IOException {
    02
        Runtime runtime = Runtime.getRuntime();
    03
        Process proc = runtime.exec(command);
    04
        try {
    05
            if (proc.waitFor() != 0) {
    06
                System.err.println("exit value = " + proc.exitValue());
    07
            }
    08
            BufferedReader in = new BufferedReader(new InputStreamReader(
    09
                    proc.getInputStream()));
    10
            StringBuffer stringBuffer = new StringBuffer();
    11
            String line = null;
    12
            while ((line = in.readLine()) != null) {
    13
                stringBuffer.append(line+" ");
    14
            }
    15
            System.out.println(stringBuffer.toString());
    16
     
    17
        } catch (InterruptedException e) {
    18
            System.err.println(e);
    19
        }finally{
    20
            try {
    21
                proc.destroy();
    22
            } catch (Exception e2) {
    23
            }
    24
        }
    25
    }
      

  3.   

    adb是pc上的,手机上要和adbd通讯了,adb仅仅是个通讯接口
      

  4.   

    为什么不用jni,在c里直接system(“cmd”)调用,或者用popen("")呢!!这个很简单
      

  5.   

    这样可以绕过权限吗?或者说你可以执行android 应用层权限不够的命令?比如pm -r install
      

  6.   

    adbd嗯,这个还真不知道,有时间研究一下。