From d7827fdf5c1da36adae8d685957545a60c6be928 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Mon, 3 Dec 2018 10:27:01 -0800 Subject: [PATCH] SystemConfig: allow reading sku specific props Sometimes, very similar devices share the same exact images but use slightly different hardware. In this case, they distinguish themselves with skus like ro.boot.product.hardware.sku. This SKU is also used to distinguish between which HALs are exposed in the VINTF manifest. In this CL, we add the following locations to read from: odm/etc/sysconf/sku_${sku}/*.xml odm/etc/permissions/sku_${sku}/*.xml Only the configurations already available to be set from the ODM image can be set here. Bug: 119129238 Test: boot Test: manually use unavailable-feature from odm sku directory Change-Id: I465ac818e5c68f1118668f13b45940fd8fa0fa62 --- .../java/com/android/server/SystemConfig.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/java/com/android/server/SystemConfig.java b/core/java/com/android/server/SystemConfig.java index 45069ca1d3e28..a07c96ceba2e0 100644 --- a/core/java/com/android/server/SystemConfig.java +++ b/core/java/com/android/server/SystemConfig.java @@ -25,6 +25,7 @@ import android.content.pm.PackageManager; import android.os.Build; import android.os.Environment; import android.os.Process; +import android.os.SystemProperties; import android.os.storage.StorageManager; import android.text.TextUtils; import android.util.ArrayMap; @@ -67,6 +68,9 @@ public class SystemConfig { private static final int ALLOW_HIDDENAPI_WHITELISTING = 0x40; private static final int ALLOW_ALL = ~0; + // property for runtime configuration differentiation + private static final String SKU_PROPERTY = "ro.boot.product.hardware.sku"; + // Group-ids that are given to all packages as read from etc/permissions/*.xml. int[] mGlobalGids; @@ -312,6 +316,17 @@ public class SystemConfig { readPermissions(Environment.buildPath( Environment.getOdmDirectory(), "etc", "permissions"), odmPermissionFlag); + String skuProperty = SystemProperties.get(SKU_PROPERTY, ""); + if (!skuProperty.isEmpty()) { + String skuDir = "sku_" + skuProperty; + + readPermissions(Environment.buildPath( + Environment.getOdmDirectory(), "etc", "sysconfig", skuDir), odmPermissionFlag); + readPermissions(Environment.buildPath( + Environment.getOdmDirectory(), "etc", "permissions", skuDir), + odmPermissionFlag); + } + // Allow OEM to customize features and OEM permissions int oemPermissionFlag = ALLOW_FEATURES | ALLOW_OEM_PERMISSIONS; readPermissions(Environment.buildPath( @@ -342,6 +357,10 @@ public class SystemConfig { // Iterate over the files in the directory and scan .xml files File platformFile = null; for (File f : libraryDir.listFiles()) { + if (!f.isFile()) { + continue; + } + // We'll read platform.xml last if (f.getPath().endsWith("etc/permissions/platform.xml")) { platformFile = f;