System package permission decls take precedence over 3rd party apps'

In particular, if a 3rd party app tries to define a permission that
turns out to be defined by system packages following an upgrade,
the system package gets ownership and grants are re-evaluated
on that basis.

Bug 11242510

(Cherry-pick backport to JB)

Change-Id: Iabf7b6280e6c6674a51af5624142bd19ea0750ed
This commit is contained in:
Christopher Tate
2013-11-05 12:28:10 -08:00
parent 427864188d
commit 50cbfd554f

View File

@@ -4179,6 +4179,18 @@ public class PackageManagerService extends IPackageManager.Stub {
permissionMap.put(p.info.name, bp);
}
if (bp.perm == null) {
if (bp.sourcePackage != null
&& !bp.sourcePackage.equals(p.info.packageName)) {
// If this is a permission that was formerly defined by a non-system
// app, but is now defined by a system app (following an upgrade),
// discard the previous declaration and consider the system's to be
// canonical.
if (isSystemApp(p.owner)) {
Slog.i(TAG, "New decl " + p.owner + " of permission "
+ p.info.name + " is system");
bp.sourcePackage = null;
}
}
if (bp.sourcePackage == null
|| bp.sourcePackage.equals(p.info.packageName)) {
BasePermission tree = findPermissionTreeLP(p.info.name);