自学内容网 自学内容网

Android 各个版本授予应用信息权限及单次弹窗确认权限

依次添加需要的权限,进行默认打开应用信息的权限开关;

以下是不同版本提供的不同的授权方法进行授权:

O版本:

/frameworks/base/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java

grantRuntimePermissionsLPw ()方法

    //*/ grant custom apk all permissions
            PackageParser.Package customApk = getPackageLPr("com.nrpptt.application");
            grantRuntimePermissionsLPw(customApk, STORAGE_PERMISSIONS, userId);
            grantRuntimePermissionsLPw(customApk, CAMERA_PERMISSIONS, userId);
            grantRuntimePermissionsLPw(customApk, MICROPHONE_PERMISSIONS, userId);
            grantRuntimePermissionsLPw(customApk, CONTACTS_PERMISSIONS, userId);
            grantRuntimePermissionsLPw(customApk, LOCATION_PERMISSIONS, userId);
        grantRuntimePermissionsLPw(customApk, PHONE_PERMISSIONS, userId);
        //*/

P版本:

/frameworks/base/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java

grantRuntimePermissions()方法

   //*/allow soundrecorder permissions
         grantRuntimePermissions(getSystemPackage("com.android.soundrecorder");, STORAGE_PERMISSIONS, userId);
         grantRuntimePermissions(getSystemPackage("com.android.soundrecorder");, MICROPHONE_PERMISSIONS, userId);

grantRuntimePermissions(getSystemPackage("com.android.soundrecorder");, CAMERA_PERMISSIONS, userId);

...................................
     //*/

Q版本:

/frameworks/base/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java

grantPermissionsToSystemPackage()方法

//*/

grantPermissionsToSystemPackage("com.veclink.vecsipsimple", userId,
                        CONTACTS_PERMISSIONS, MICROPHONE_PERMISSIONS,
                        PHONE_PERMISSIONS, SMS_PERMISSIONS, CAMERA_PERMISSIONS,
                        STORAGE_PERMISSIONS,ALWAYS_LOCATION_PERMISSIONS);

        //*/


        //*/add permision
        grantPermissionsToSystemPackage("com.iflytek.inputmethod", userId,
ALWAYS_LOCATION_PERMISSIONS,PHONE_PERMISSIONS,CONTACTS_PERMISSIONS,SMS_PERMISSIONS,MICROPHONE_PERMISSIONS,STORAGE_PERMISSIONS,CAMERA_PERMISSIONS);      
        //*/
        //*/add permision
        grantPermissionsToSystemPackage("com.shenyaocn.android.usbcamera", userId,
ALWAYS_LOCATION_PERMISSIONS,PHONE_PERMISSIONS,CONTACTS_PERMISSIONS,SMS_PERMISSIONS,MICROPHONE_PERMISSIONS,STORAGE_PERMISSIONS,CAMERA_PERMISSIONS);      
        //*/

R版本:

/frameworks/base/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java

grantPermissionsToPackage()方法

grantPermissionsToSystemPackage()方法

//*/

grantPermissionsToPackage(pm, "com.veclink.vecsipsimple", userId, false, true,
                CAMERA_PERMISSIONS, ALWAYS_LOCATION_PERMISSIONS, MICROPHONE_PERMISSIONS,
                STORAGE_PERMISSIONS, PHONE_PERMISSIONS, SMS_PERMISSIONS);
        //*/

//*/

grantPermissionsToSystemPackage(pm, "com.corget", userId,
ALWAYS_LOCATION_PERMISSIONS,PHONE_PERMISSIONS,CONTACTS_PERMISSIONS,SMS_PERMISSIONS,MICROPHONE_PERMISSIONS,STORAGE_PERMISSIONS,CAMERA_PERMISSIONS);      
        //*/

S版本:

/frameworks/base/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java

grantPermissionsToSystemPackage()


    private void grantDefaultSystemHandlerPermissions(PackageManagerWrapper pm, int userId) {
        Log.i(TAG, "Granting permissions to default platform handlers for user " + userId);

//*/grant all permissions in appinfo or single dialog : NOTIFICATION_PERMISSIONS
        grantPermissionsToSystemPackage(pm,"com.iflytek.speechcloud", userId,
ALWAYS_LOCATION_PERMISSIONS,PHONE_PERMISSIONS,CONTACTS_PERMISSIONS,SMS_PERMISSIONS,MICROPHONE_PERMISSIONS,STORAGE_PERMISSIONS,CAMERA_PERMISSIONS,CALENDAR_PERMISSIONS,SENSORS_PERMISSIONS,NEARBY_DEVICES_PERMISSIONS);
        //*/

 

T版本:

/frameworks/base/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java

grantPermissionsToSystemPackage()方法

 //*/add permision
        grantPermissionsToSystemPackage(pm,"com.shli.interphone", userId,
ALWAYS_LOCATION_PERMISSIONS,PHONE_PERMISSIONS,CONTACTS_PERMISSIONS,SMS_PERMISSIONS,MICROPHONE_PERMISSIONS,STORAGE_PERMISSIONS,CAMERA_PERMISSIONS
,NEARBY_DEVICES_PERMISSIONS,CALENDAR_PERMISSIONS,NOTIFICATION_PERMISSIONS,SENSORS_PERMISSIONS);
        //*/
        //*/add permision
        grantPermissionsToSystemPackage(pm,"cn.com.ctsi.android.ctchat", userId,
ALWAYS_LOCATION_PERMISSIONS,PHONE_PERMISSIONS,CONTACTS_PERMISSIONS,SMS_PERMISSIONS,MICROPHONE_PERMISSIONS,STORAGE_PERMISSIONS,CAMERA_PERMISSIONS
,NEARBY_DEVICES_PERMISSIONS,CALENDAR_PERMISSIONS,NOTIFICATION_PERMISSIONS,SENSORS_PERMISSIONS);
        //*/ 


原文地址:https://blog.csdn.net/qq_46687516/article/details/143641903

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!