Java Code Examples for android.content.pm.PermissionInfo#PROTECTION_FLAG_PRIVILEGED

The following examples show how to use android.content.pm.PermissionInfo#PROTECTION_FLAG_PRIVILEGED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BroadcastQueue.java    From AndroidComponentPlugin with Apache License 2.0 7 votes vote down vote up
/**
 * Return true if all given permissions are signature-only perms.
 */
final boolean isSignaturePerm(String[] perms) {
    if (perms == null) {
        return false;
    }
    IPackageManager pm = AppGlobals.getPackageManager();
    for (int i = perms.length-1; i >= 0; i--) {
        try {
            PermissionInfo pi = pm.getPermissionInfo(perms[i], "android", 0);
            if ((pi.protectionLevel & (PermissionInfo.PROTECTION_MASK_BASE
                    | PermissionInfo.PROTECTION_FLAG_PRIVILEGED))
                    != PermissionInfo.PROTECTION_SIGNATURE) {
                // If this a signature permission and NOT allowed for privileged apps, it
                // is okay...  otherwise, nope!
                return false;
            }
        } catch (RemoteException e) {
            return false;
        }
    }
    return true;
}
 
Example 2
Source File: BroadcastQueue.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Return true if all given permissions are signature-only perms.
 */
final boolean isSignaturePerm(String[] perms) {
    if (perms == null) {
        return false;
    }
    IPackageManager pm = AppGlobals.getPackageManager();
    for (int i = perms.length-1; i >= 0; i--) {
        try {
            PermissionInfo pi = pm.getPermissionInfo(perms[i], "android", 0);
            if ((pi.protectionLevel & (PermissionInfo.PROTECTION_MASK_BASE
                    | PermissionInfo.PROTECTION_FLAG_PRIVILEGED))
                    != PermissionInfo.PROTECTION_SIGNATURE) {
                // If this a signature permission and NOT allowed for privileged apps, it
                // is okay...  otherwise, nope!
                return false;
            }
        } catch (RemoteException e) {
            return false;
        }
    }
    return true;
}
 
Example 3
Source File: BasePermission.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public boolean isPrivileged() {
    return (protectionLevel & PermissionInfo.PROTECTION_FLAG_PRIVILEGED) != 0;
}