Permission is not a changeable permission type

给你一囗甜甜゛ 提交于 2020-02-25 04:38:25

问题


Background: I was trying out the new Tiles and TileService and decided to recreate the USB Tethering tile from CyanogenMod. I used reflection to access Connectivity manager's methods.

Problem: One Such method is the isTetheringSupported() which causes java.lang.SecurityException: You either need MANAGE_USERS or CREATE_USERS permission to: query user

So I added the permissions to the manifest but every time I use pm grant it returns "Permission is not a changeable permission type"

According to this I should not get this error when signed with the debug key.

Question: How do I get those permissions?


回答1:


UPDATE: Via Xposed it is possible to hook into the PackageManger and remove the below check and then do pm grant... to successfully grant whatever permission. If someone sees this and needs help to do so comment below I'll help you out.

OLD ANSWER This code in the source

boolean isDevelopment =
            ((bp.protectionLevel&PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0);

doesn't check if your app is in development mode. It checks if the permission you are requesting has the protectionLevel attribute (set in manifest) set to development. And the permission you are trying to get seems not to have any elements declared in the manifest that could pass this check:

if (!isNormal && !isDangerous && !isDevelopment) {
        throw new SecurityException("Permission " + bp.name
                + " is not a changeable permission type");
    }

Just stumbled upon this with another permission. Seems there's sadly no way to get it.



来源:https://stackoverflow.com/questions/41174789/permission-is-not-a-changeable-permission-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!