给所有App添加sdcard权限

目录

前言

下面实验基于Android8.1源码,通过对Android源码的修改,让所有App都具备sdcard权限.

修改

在frameworks/base/core/java/android/content/pm/PackageParser.java文件中的函数parseBaseApkCommon的while ((type = parser.next()) != XmlPullParser.END_DOCUMENT循环上加入下面的代码.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
String addPermissionName = "android.permission.WRITE_EXTERNAL_STORAGE";
int luoIndex = pkg.requestedPermissions.indexOf(addPermissionName);
// if hasn't needPermission
if (luoIndex == -1){
pkg.requestedPermissions.add(addPermissionName.intern());
Slog.w("LuoHunPermissions","android.permission.WRITE_EXTERNAL_STORAGE" );
}

addPermissionName="android.permission.READ_EXTERNAL_STORAGE";
luoIndex = pkg.requestedPermissions.indexOf(addPermissionName);
if (luoIndex == -1){
pkg.requestedPermissions.add(addPermissionName.intern());
Slog.w("LuoHunPermissions","android.permission.WRITE_EXTERNAL_STORAGE" );
}

添加sdcard权限


相关内容

0%