import android.util.Log;import java.io.DataOutputStream;
import java.io.File;/** * 判斷手機是否ROOT */
public class isRoot{public static int root() {int root = 0;try { if ((!new File("/system/bin/su").exists()) && (!new File("/system/xbin/su").exists())) { root = 0;} else { root = 1;} } catch (Exception e) { } return root; }/**** 判斷應用是否有root權限*/public static synchronized boolean getRootAhth(){Process process = null;DataOutputStream os = null;try{process = Runtime.getRuntime().exec("su");os = new DataOutputStream(process.getOutputStream());os.writeBytes("exit\n");os.flush();int exitValue = process.waitFor();if (exitValue == 0){return true;} else{return false;}} 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){e.printStackTrace();}}}
}
?
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态