Android权限的实现
1) 第一层:由应用设置,修改AndroidManifest.xml,形如:
<uses-permission android:name=”android.permission.INTERNET”/>
2) 第二层:框架层,权限对应组,frameworks/base/data/etc/platform.xml,形如:
<permission name=”android.permission.INTERNET”>
<group gid=inet” />
</permission>
3) 第三层:系统层,系统的权限,system/core/include/private/android_filesystem_config.h,形如:
#define AID_INET 3003 建立SOCKET的权限
……
{ “inet”, AID_INET, },
获取app uid、gid信息:
InputStream input = null; try { java.lang.Process process = Runtime.getRuntime().exec("id"); input = process.getInputStream(); byte[] bytes = new byte[1204]; int len; while ((len = (input.read(bytes))) > 0) { System.out.print(new String(bytes, 0, len)); } } catch (IOException e) { e.printStackTrace(); } finally { if (input != null) { try { input.close(); } catch (IOException e) { e.printStackTrace(); } } }/System.out: uid=10321(u0_a321) gid=10321(u0_a321) groups=1015(sdcard_rw),1028(sdcard_r),3003(inet),9997(everybody),50321(all_a321)