Notice
Recent Posts
Recent Comments
반응형
오늘도 공부
루팅폰 확인하기 본문
반응형
루팅폰에 system/sd 폴더는 퍼미션이 r/w로 되어있다는 것에 착안 거기에 파일을 생성하고 생성이
제대로 되면 루팅폰이라는걸 판단하는 코드
Process p;
try {
// Preform su to get root privledges
p = Runtime.getRuntime().exec("su");
// Attempt to write a file to a root-only
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("echo \"Do I have root?\" >/system/sd/temporary.txt\n");
// Close the terminal
os.writeBytes("exit\n");
os.flush();
try {
p.waitFor();
if (p.exitValue() != 255) {
// TODO Code to run on success
toastMessage("root");
}
else {
// TODO Code to run on unsuccessful
toastMessage("not root");
}
} catch (InterruptedException e) {
// TODO Code to run in interrupted exception
toastMessage("not root");
}
} catch (IOException e) {
// TODO Code to run in input/output exception
toastMessage("not root");
}
반응형
'Android > Tip&Tech' 카테고리의 다른 글
| android editext textarea처럼 만들기 (0) | 2011.06.28 |
|---|---|
| android 퍼미션 종류별 정리 (2) | 2011.06.24 |
| camera intent 관련 flag 팁 (0) | 2011.06.21 |
| android Badge 참고사항(카운트) (0) | 2011.06.20 |
| [팁] Android에서 SAX를 이용한 Parsing 방법 (0) | 2011.06.20 |
