您的当前位置:首页正文

android 权限问题分析

2024-11-13 来源:个人技术集锦
publicstaticboolean runRootCommand(String command){ 

      Process process =null; 

      DataOutputStream os =null; 

      try{ 

           process =Runtime.getRuntime().exec("su"); 

           os =newDataOutputStream(process.getOutputStream()); 

           os.writeBytes(command+"\n"); 

           os.writeBytes("exit\n"); 

          os.flush(); 

           process.waitFor(); 

      }catch(Exception e){ 

          Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: "+e.getMessage()); 

          return false; 

      }finally{ 

          try{ 

              if(os !=null){ 

                      os.close(); 

                    } 

                    process.destroy(); 

                    }catch(Exception e){ 

                      // nothing 

                    } 

            }returntrue; 

          } 

      } 

 

转载于:https://www.cnblogs.com/sunfb/p/3927204.html

Top