From e3b6bf175c86415d682f093489705c011290ade6 Mon Sep 17 00:00:00 2001 From: Jaekyun Seok Date: Thu, 16 Feb 2017 13:48:30 +0900 Subject: [PATCH] Allow system configs to be read from vendor partition Soc vendors also want to add their own configs like odms do. Additionally they should be allowed to add their own app permission configs because they can install their own apps in /vendor/app. So Soc vendors should be able to add system configs around libs, features, permissions and apps. Additionally this CL modified codes to allow "privapp-permissions" only on system partition because we won't allow apps on the partner partitions to count as privileged. Test: building succeeded and tested on sailfish. Bug: 35369237 Change-Id: I7d84d6e351d9e7023931757082d9f661c5a9a80a --- core/java/com/android/server/SystemConfig.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/server/SystemConfig.java b/core/java/com/android/server/SystemConfig.java index 3d012bf24f7a5..67f9f8f49ee6c 100644 --- a/core/java/com/android/server/SystemConfig.java +++ b/core/java/com/android/server/SystemConfig.java @@ -59,6 +59,7 @@ public class SystemConfig { private static final int ALLOW_LIBS = 0x02; private static final int ALLOW_PERMISSIONS = 0x04; private static final int ALLOW_APP_CONFIGS = 0x08; + private static final int ALLOW_PRIVAPP_PERMISSIONS = 0x10; private static final int ALLOW_ALL = ~0; // Group-ids that are given to all packages as read from etc/permissions/*.xml. @@ -225,6 +226,13 @@ public class SystemConfig { // Read configuration from the old permissions dir readPermissions(Environment.buildPath( Environment.getRootDirectory(), "etc", "permissions"), ALLOW_ALL); + // Allow Vendor to customize system configs around libs, features, permissions and apps + int vendorPermissionFlag = ALLOW_LIBS | ALLOW_FEATURES | ALLOW_PERMISSIONS | + ALLOW_APP_CONFIGS; + readPermissions(Environment.buildPath( + Environment.getVendorDirectory(), "etc", "sysconfig"), vendorPermissionFlag); + readPermissions(Environment.buildPath( + Environment.getVendorDirectory(), "etc", "permissions"), vendorPermissionFlag); // Allow ODM to customize system configs around libs, features and apps int odmPermissionFlag = ALLOW_LIBS | ALLOW_FEATURES | ALLOW_APP_CONFIGS; readPermissions(Environment.buildPath( @@ -313,6 +321,7 @@ public class SystemConfig { boolean allowFeatures = (permissionFlag & ALLOW_FEATURES) != 0; boolean allowPermissions = (permissionFlag & ALLOW_PERMISSIONS) != 0; boolean allowAppConfigs = (permissionFlag & ALLOW_APP_CONFIGS) != 0; + boolean allowPrivappPermissions = (permissionFlag & ALLOW_PRIVAPP_PERMISSIONS) != 0; while (true) { XmlUtils.nextElement(parser); if (parser.getEventType() == XmlPullParser.END_DOCUMENT) { @@ -553,7 +562,7 @@ public class SystemConfig { associatedPkgs.add(pkgname); } XmlUtils.skipCurrentTag(parser); - } else if ("privapp-permissions".equals(name) && allowAppConfigs) { + } else if ("privapp-permissions".equals(name) && allowPrivappPermissions) { readPrivAppPermissions(parser); } else { XmlUtils.skipCurrentTag(parser);