安卓root有什么用,Android--手機root獲取與判斷應用是否獲取

 2023-10-08 阅读 26 评论 0

摘要:版權聲明:本文為博主原創文章,轉載請標明出處。 https://blog.csdn.net/chaoyu168/article/details/81075850 import android.util.Log;import java.io.DataOutputStream; import java.io.File;/** * 判斷手機是否ROOT */ public class isRoot{public static i
版權聲明:本文為博主原創文章,轉載請標明出處。 https://blog.csdn.net/chaoyu168/article/details/81075850
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();}}}
}

?

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/130497.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息