Merge "Allow properties to be derived from partition-specific properties"

This commit is contained in:
Steven Laver 2019-02-12 16:44:57 +00:00 committed by Gerrit Code Review
commit 0cf76f544b
3 changed files with 51 additions and 13 deletions

View File

@ -416,12 +416,8 @@ endif
$(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \
TARGET_DEVICE="$(TARGET_DEVICE)" \
PRODUCT_NAME="$(TARGET_PRODUCT)" \
PRODUCT_BRAND="$(PRODUCT_BRAND)" \
PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \
PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
PRODUCT_MODEL="$(PRODUCT_MODEL)" \
PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
BUILD_ID="$(BUILD_ID)" \
BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
@ -441,7 +437,6 @@ endif
PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \
PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION="$(PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION)" \
BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \
$(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT_FROM_FILE)") \
TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \

View File

@ -28,10 +28,6 @@ fi
if [ -n "$AB_OTA_UPDATER" ] ; then
echo "ro.build.ab_update=$AB_OTA_UPDATER"
fi
echo "ro.product.model=$PRODUCT_MODEL"
echo "ro.product.brand=$PRODUCT_BRAND"
echo "ro.product.name=$PRODUCT_NAME"
echo "ro.product.device=$TARGET_DEVICE"
# These values are deprecated, use "ro.product.cpu.abilist"
# instead (see below).
@ -45,7 +41,6 @@ echo "ro.product.cpu.abilist=$TARGET_CPU_ABI_LIST"
echo "ro.product.cpu.abilist32=$TARGET_CPU_ABI_LIST_32_BIT"
echo "ro.product.cpu.abilist64=$TARGET_CPU_ABI_LIST_64_BIT"
echo "ro.product.manufacturer=$PRODUCT_MANUFACTURER"
if [ -n "$PRODUCT_DEFAULT_LOCALE" ] ; then
echo "ro.product.locale=$PRODUCT_DEFAULT_LOCALE"
fi
@ -54,9 +49,8 @@ echo "ro.wifi.channels=$PRODUCT_DEFAULT_WIFI_CHANNELS"
echo "# ro.build.product is obsolete; use ro.product.device"
echo "ro.build.product=$TARGET_DEVICE"
echo "# Do not try to parse description, fingerprint, or thumbprint"
echo "# Do not try to parse description or thumbprint"
echo "ro.build.description=$PRIVATE_BUILD_DESC"
echo "ro.build.fingerprint=$BUILD_FINGERPRINT"
if [ -n "$BUILD_THUMBPRINT" ] ; then
echo "ro.build.thumbprint=$BUILD_THUMBPRINT"
fi

View File

@ -259,6 +259,12 @@ class BuildInfo(object):
device: The device name, which could come from OEM dicts if applicable.
"""
_RO_PRODUCT_RESOLVE_PROPS = ["ro.product.brand", "ro.product.device",
"ro.product.manufacturer", "ro.product.model",
"ro.product.name"]
_RO_PRODUCT_PROPS_DEFAULT_SOURCE_ORDER = ["product", "product_services",
"odm", "vendor", "system"]
def __init__(self, info_dict, oem_dicts):
"""Initializes a BuildInfo instance with the given dicts.
@ -325,11 +331,43 @@ class BuildInfo(object):
def GetBuildProp(self, prop):
"""Returns the inquired build property."""
if prop in BuildInfo._RO_PRODUCT_RESOLVE_PROPS:
return self._ResolveRoProductBuildProp(prop)
try:
return self.info_dict.get("build.prop", {})[prop]
except KeyError:
raise common.ExternalError("couldn't find %s in build.prop" % (prop,))
def _ResolveRoProductBuildProp(self, prop):
"""Resolves the inquired ro.product.* build property"""
prop_val = self.info_dict.get("build.prop", {}).get(prop)
if prop_val:
return prop_val
source_order_val = self.info_dict.get("build.prop", {}).get(
"ro.product.property_source_order")
if source_order_val:
source_order = source_order_val.split(",")
else:
source_order = BuildInfo._RO_PRODUCT_PROPS_DEFAULT_SOURCE_ORDER
# Check that all sources in ro.product.property_source_order are valid
if any([x not in BuildInfo._RO_PRODUCT_PROPS_DEFAULT_SOURCE_ORDER
for x in source_order]):
raise common.ExternalError(
"Invalid ro.product.property_source_order '{}'".format(source_order))
for source in source_order:
source_prop = prop.replace("ro.product", "ro.product.{}".format(source),
1)
prop_val = self.info_dict.get("{}.build.prop".format(source), {}).get(
source_prop)
if prop_val:
return prop_val
raise common.ExternalError("couldn't resolve {}".format(prop))
def GetVendorBuildProp(self, prop):
"""Returns the inquired vendor build property."""
try:
@ -345,7 +383,18 @@ class BuildInfo(object):
def CalculateFingerprint(self):
if self.oem_props is None:
return self.GetBuildProp("ro.build.fingerprint")
try:
return self.GetBuildProp("ro.build.fingerprint")
except common.ExternalError:
return "{}/{}/{}:{}/{}/{}:{}/{}".format(
self.GetBuildProp("ro.product.brand"),
self.GetBuildProp("ro.product.name"),
self.GetBuildProp("ro.product.device"),
self.GetBuildProp("ro.build.version.release"),
self.GetBuildProp("ro.build.id"),
self.GetBuildProp("ro.build.version.incremental"),
self.GetBuildProp("ro.build.type"),
self.GetBuildProp("ro.build.tags"))
return "%s/%s/%s:%s" % (
self.GetOemProperty("ro.product.brand"),
self.GetOemProperty("ro.product.name"),