有没有办法用"rw"国旗。
我试图通过检查android设备文件中的可写分区和系统目录来检测设备是否有根。
提前感谢你的帮助:)。
我还能说什么呢
<标题>测试1File dir = new File("/system");
if(dir.canRead() && dir.canWrite()) {
System.out.println("Can read and write in this directory. (rw)");
} else if(dir.canRead()) {
System.out.println("Can read in this directory (r)");
} else if(dir.canWrite()) {
System.out.println("Can write in this directory (w).");
}
输出Can read in this directory (r)
$ mount | grep '/system'
/dev/block/platform/13540000.dwmmc0/by-name/SYSTEM /system ext4 ro,seclabel,relatime,norecovery 0 0
<标题>测试2 h1> 输出Can read and write in this directory. (rw)
$ mount | grep '/storage/emulated'
/data/media /storage/emulated sdcardfs rw,seclabel,nosuid,nodev,noexec,relatime,low_uid=1023,low_gid=1023,gid=9997,multi_user,mask=0007,reserved=20MB 0 0
标题>标题>