Created
October 25, 2018 15:48
-
-
Save Drjacky/6f5ffe00e7f0259b52a20a7ae4c81940 to your computer and use it in GitHub Desktop.
grantSignaturePermission method in PackageManagerService java file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean grantSignaturePermission(String perm, PackageParser.Package pkg, | |
BasePermission bp, HashSet<String> origPermissions) { | |
boolean allowed; | |
allowed = (compareSignatures( | |
bp.packageSetting.signatures.mSignatures, pkg.mSignatures) | |
== PackageManager.SIGNATURE_MATCH) | |
|| (compareSignatures(mPlatformPackage.mSignatures, pkg.mSignatures) | |
== PackageManager.SIGNATURE_MATCH); | |
if (!allowed && (bp.protectionLevel | |
& PermissionInfo.PROTECTION_FLAG_SYSTEM) != 0) { | |
if (isSystemApp(pkg)) { | |
// For updated system applications, a system permission | |
// is granted only if it had been defined by the original application. | |
if (isUpdatedSystemApp(pkg)) { | |
final PackageSetting sysPs = mSettings | |
.getDisabledSystemPkgLPr(pkg.packageName); | |
final GrantedPermissions origGp = sysPs.sharedUser != null | |
? sysPs.sharedUser : sysPs; | |
if (origGp.grantedPermissions.contains(perm)) { | |
// If the original was granted this permission, we take | |
// that grant decision as read and propagate it to the | |
// update. | |
allowed = true; | |
} else { | |
// The system apk may have been updated with an older | |
// version of the one on the data partition, but which | |
// granted a new system permission that it didn't have | |
// before. In this case we do want to allow the app to | |
// now get the new permission if the ancestral apk is | |
// privileged to get it. | |
if (sysPs.pkg != null && sysPs.isPrivileged()) { | |
for (int j=0; | |
j<sysPs.pkg.requestedPermissions.size(); j++) { | |
if (perm.equals( | |
sysPs.pkg.requestedPermissions.get(j))) { | |
allowed = true; | |
break; | |
} | |
} | |
} | |
} | |
} else { | |
allowed = isPrivilegedApp(pkg); | |
} | |
} | |
} | |
//LINE 5634 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | |
// HERE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment