Inseob Kim | 320628f | 2024-06-18 11:09:12 +0900 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Copyright (C) 2024 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | """A tool for generating {partition}/build.prop""" |
| 18 | |
| 19 | import argparse |
| 20 | import contextlib |
| 21 | import json |
Justin Yun | e5b7376 | 2024-07-03 13:34:29 +0900 | [diff] [blame] | 22 | import os |
Inseob Kim | 320628f | 2024-06-18 11:09:12 +0900 | [diff] [blame] | 23 | import subprocess |
| 24 | import sys |
| 25 | |
Justin Yun | e5b7376 | 2024-07-03 13:34:29 +0900 | [diff] [blame] | 26 | TEST_KEY_DIR = "build/make/target/product/security" |
| 27 | |
Inseob Kim | 320628f | 2024-06-18 11:09:12 +0900 | [diff] [blame] | 28 | def get_build_variant(product_config): |
| 29 | if product_config["Eng"]: |
| 30 | return "eng" |
| 31 | elif product_config["Debuggable"]: |
| 32 | return "userdebug" |
| 33 | else: |
| 34 | return "user" |
| 35 | |
| 36 | def get_build_flavor(product_config): |
| 37 | build_flavor = product_config["DeviceProduct"] + "-" + get_build_variant(product_config) |
| 38 | if "address" in product_config.get("SanitizeDevice", []) and "_asan" not in build_flavor: |
| 39 | build_flavor += "_asan" |
| 40 | return build_flavor |
| 41 | |
| 42 | def get_build_keys(product_config): |
| 43 | default_cert = product_config.get("DefaultAppCertificate", "") |
| 44 | if default_cert == "" or default_cert == os.path.join(TEST_KEY_DIR, "testKey"): |
| 45 | return "test-keys" |
| 46 | return "dev-keys" |
| 47 | |
| 48 | def parse_args(): |
| 49 | """Parse commandline arguments.""" |
| 50 | parser = argparse.ArgumentParser() |
| 51 | parser.add_argument("--build-fingerprint-file", required=True, type=argparse.FileType("r")) |
| 52 | parser.add_argument("--build-hostname-file", required=True, type=argparse.FileType("r")) |
| 53 | parser.add_argument("--build-number-file", required=True, type=argparse.FileType("r")) |
| 54 | parser.add_argument("--build-thumbprint-file", type=argparse.FileType("r")) |
| 55 | parser.add_argument("--build-username", required=True) |
| 56 | parser.add_argument("--date-file", required=True, type=argparse.FileType("r")) |
| 57 | parser.add_argument("--platform-preview-sdk-fingerprint-file", required=True, type=argparse.FileType("r")) |
| 58 | parser.add_argument("--prop-files", action="append", type=argparse.FileType("r"), default=[]) |
| 59 | parser.add_argument("--product-config", required=True, type=argparse.FileType("r")) |
| 60 | parser.add_argument("--partition", required=True) |
| 61 | parser.add_argument("--build-broken-dup-sysprop", action="store_true", default=False) |
| 62 | |
| 63 | parser.add_argument("--out", required=True, type=argparse.FileType("w")) |
| 64 | |
| 65 | args = parser.parse_args() |
| 66 | |
| 67 | # post process parse_args requiring manual handling |
| 68 | args.config = json.load(args.product_config) |
| 69 | config = args.config |
| 70 | |
| 71 | config["BuildFlavor"] = get_build_flavor(config) |
| 72 | config["BuildKeys"] = get_build_keys(config) |
| 73 | config["BuildVariant"] = get_build_variant(config) |
| 74 | |
| 75 | config["BuildFingerprint"] = args.build_fingerprint_file.read().strip() |
| 76 | config["BuildHostname"] = args.build_hostname_file.read().strip() |
| 77 | config["BuildNumber"] = args.build_number_file.read().strip() |
| 78 | config["BuildUsername"] = args.build_username |
Inseob Kim | 66c3cba | 2024-06-25 19:09:12 +0900 | [diff] [blame] | 79 | |
| 80 | build_version_tags_list = config["BuildVersionTags"] |
Inseob Kim | 320628f | 2024-06-18 11:09:12 +0900 | [diff] [blame] | 81 | if config["BuildType"] == "debug": |
Inseob Kim | 66c3cba | 2024-06-25 19:09:12 +0900 | [diff] [blame] | 82 | build_version_tags_list.append("debug") |
| 83 | build_version_tags_list.append(config["BuildKeys"]) |
| 84 | build_version_tags = ",".join(sorted(set(build_version_tags_list))) |
| 85 | config["BuildVersionTags"] = build_version_tags |
Inseob Kim | 320628f | 2024-06-18 11:09:12 +0900 | [diff] [blame] | 86 | |
| 87 | raw_date = args.date_file.read().strip() |
| 88 | config["Date"] = subprocess.check_output(["date", "-d", f"@{raw_date}"], text=True).strip() |
| 89 | config["DateUtc"] = subprocess.check_output(["date", "-d", f"@{raw_date}", "+%s"], text=True).strip() |
| 90 | |
| 91 | # build_desc is human readable strings that describe this build. This has the same info as the |
| 92 | # build fingerprint. |
| 93 | # e.g. "aosp_cf_x86_64_phone-userdebug VanillaIceCream MAIN eng.20240319.143939 test-keys" |
| 94 | config["BuildDesc"] = f"{config['DeviceProduct']}-{config['BuildVariant']} " \ |
| 95 | f"{config['Platform_version_name']} {config['BuildId']} " \ |
| 96 | f"{config['BuildNumber']} {config['BuildVersionTags']}" |
| 97 | |
| 98 | config["PlatformPreviewSdkFingerprint"] = args.platform_preview_sdk_fingerprint_file.read().strip() |
| 99 | |
| 100 | if args.build_thumbprint_file: |
| 101 | config["BuildThumbprint"] = args.build_thumbprint_file.read().strip() |
| 102 | |
| 103 | append_additional_system_props(args) |
| 104 | append_additional_vendor_props(args) |
| 105 | append_additional_product_props(args) |
| 106 | |
| 107 | return args |
| 108 | |
| 109 | def generate_common_build_props(args): |
| 110 | print("####################################") |
| 111 | print("# from generate_common_build_props") |
| 112 | print("# These properties identify this partition image.") |
| 113 | print("####################################") |
| 114 | |
| 115 | config = args.config |
| 116 | partition = args.partition |
| 117 | |
| 118 | if partition == "system": |
| 119 | print(f"ro.product.{partition}.brand={config['SystemBrand']}") |
| 120 | print(f"ro.product.{partition}.device={config['SystemDevice']}") |
| 121 | print(f"ro.product.{partition}.manufacturer={config['SystemManufacturer']}") |
| 122 | print(f"ro.product.{partition}.model={config['SystemModel']}") |
| 123 | print(f"ro.product.{partition}.name={config['SystemName']}") |
| 124 | else: |
| 125 | print(f"ro.product.{partition}.brand={config['ProductBrand']}") |
| 126 | print(f"ro.product.{partition}.device={config['DeviceName']}") |
| 127 | print(f"ro.product.{partition}.manufacturer={config['ProductManufacturer']}") |
| 128 | print(f"ro.product.{partition}.model={config['ProductModel']}") |
| 129 | print(f"ro.product.{partition}.name={config['DeviceProduct']}") |
| 130 | |
| 131 | if partition != "system": |
| 132 | if config["ModelForAttestation"]: |
| 133 | print(f"ro.product.model_for_attestation={config['ModelForAttestation']}") |
| 134 | if config["BrandForAttestation"]: |
| 135 | print(f"ro.product.brand_for_attestation={config['BrandForAttestation']}") |
| 136 | if config["NameForAttestation"]: |
| 137 | print(f"ro.product.name_for_attestation={config['NameForAttestation']}") |
| 138 | if config["DeviceForAttestation"]: |
| 139 | print(f"ro.product.device_for_attestation={config['DeviceForAttestation']}") |
| 140 | if config["ManufacturerForAttestation"]: |
| 141 | print(f"ro.product.manufacturer_for_attestation={config['ManufacturerForAttestation']}") |
| 142 | |
| 143 | if config["ZygoteForce64"]: |
| 144 | if partition == "vendor": |
| 145 | print(f"ro.{partition}.product.cpu.abilist={config['DeviceAbiList64']}") |
| 146 | print(f"ro.{partition}.product.cpu.abilist32=") |
| 147 | print(f"ro.{partition}.product.cpu.abilist64={config['DeviceAbiList64']}") |
| 148 | else: |
| 149 | if partition == "system" or partition == "vendor" or partition == "odm": |
| 150 | print(f"ro.{partition}.product.cpu.abilist={config['DeviceAbiList']}") |
| 151 | print(f"ro.{partition}.product.cpu.abilist32={config['DeviceAbiList32']}") |
| 152 | print(f"ro.{partition}.product.cpu.abilist64={config['DeviceAbiList64']}") |
| 153 | |
| 154 | print(f"ro.{partition}.build.date={config['Date']}") |
| 155 | print(f"ro.{partition}.build.date.utc={config['DateUtc']}") |
| 156 | # Allow optional assignments for ARC forward-declarations (b/249168657) |
| 157 | # TODO: Remove any tag-related inconsistencies once the goals from |
| 158 | # go/arc-android-sigprop-changes have been achieved. |
| 159 | print(f"ro.{partition}.build.fingerprint?={config['BuildFingerprint']}") |
| 160 | print(f"ro.{partition}.build.id?={config['BuildId']}") |
| 161 | print(f"ro.{partition}.build.tags?={config['BuildVersionTags']}") |
| 162 | print(f"ro.{partition}.build.type={config['BuildVariant']}") |
| 163 | print(f"ro.{partition}.build.version.incremental={config['BuildNumber']}") |
| 164 | print(f"ro.{partition}.build.version.release={config['Platform_version_last_stable']}") |
| 165 | print(f"ro.{partition}.build.version.release_or_codename={config['Platform_version_name']}") |
| 166 | print(f"ro.{partition}.build.version.sdk={config['Platform_sdk_version']}") |
| 167 | |
| 168 | def generate_build_info(args): |
| 169 | print() |
| 170 | print("####################################") |
| 171 | print("# from gen_build_prop.py:generate_build_info") |
| 172 | print("####################################") |
| 173 | print("# begin build properties") |
| 174 | |
| 175 | config = args.config |
| 176 | build_flags = config["BuildFlags"] |
| 177 | |
| 178 | # The ro.build.id will be set dynamically by init, by appending the unique vbmeta digest. |
| 179 | if config["BoardUseVbmetaDigestInFingerprint"]: |
| 180 | print(f"ro.build.legacy.id={config['BuildId']}") |
| 181 | else: |
| 182 | print(f"ro.build.id?={config['BuildId']}") |
| 183 | |
| 184 | # ro.build.display.id is shown under Settings -> About Phone |
| 185 | if config["BuildVariant"] == "user": |
| 186 | # User builds should show: |
| 187 | # release build number or branch.buld_number non-release builds |
| 188 | |
| 189 | # Dev. branches should have DISPLAY_BUILD_NUMBER set |
| 190 | if config["DisplayBuildNumber"]: |
Inseob Kim | 5c333a9 | 2024-07-19 09:25:38 +0900 | [diff] [blame^] | 191 | print(f"ro.build.display.id?={config['BuildId']}.{config['BuildNumber']} {config['BuildKeys']}") |
Inseob Kim | 320628f | 2024-06-18 11:09:12 +0900 | [diff] [blame] | 192 | else: |
| 193 | print(f"ro.build.display.id?={config['BuildId']} {config['BuildKeys']}") |
| 194 | else: |
| 195 | # Non-user builds should show detailed build information (See build desc above) |
| 196 | print(f"ro.build.display.id?={config['BuildDesc']}") |
| 197 | print(f"ro.build.version.incremental={config['BuildNumber']}") |
| 198 | print(f"ro.build.version.sdk={config['Platform_sdk_version']}") |
| 199 | print(f"ro.build.version.preview_sdk={config['Platform_preview_sdk_version']}") |
| 200 | print(f"ro.build.version.preview_sdk_fingerprint={config['PlatformPreviewSdkFingerprint']}") |
| 201 | print(f"ro.build.version.codename={config['Platform_sdk_codename']}") |
| 202 | print(f"ro.build.version.all_codenames={','.join(config['Platform_version_active_codenames'])}") |
| 203 | print(f"ro.build.version.known_codenames={config['Platform_version_known_codenames']}") |
| 204 | print(f"ro.build.version.release={config['Platform_version_last_stable']}") |
| 205 | print(f"ro.build.version.release_or_codename={config['Platform_version_name']}") |
| 206 | print(f"ro.build.version.release_or_preview_display={config['Platform_display_version_name']}") |
| 207 | print(f"ro.build.version.security_patch={config['Platform_security_patch']}") |
| 208 | print(f"ro.build.version.base_os={config['Platform_base_os']}") |
| 209 | print(f"ro.build.version.min_supported_target_sdk={build_flags['RELEASE_PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION']}") |
| 210 | print(f"ro.build.date={config['Date']}") |
| 211 | print(f"ro.build.date.utc={config['DateUtc']}") |
| 212 | print(f"ro.build.type={config['BuildVariant']}") |
| 213 | print(f"ro.build.user={config['BuildUsername']}") |
| 214 | print(f"ro.build.host={config['BuildHostname']}") |
| 215 | # TODO: Remove any tag-related optional property declarations once the goals |
| 216 | # from go/arc-android-sigprop-changes have been achieved. |
| 217 | print(f"ro.build.tags?={config['BuildVersionTags']}") |
| 218 | # ro.build.flavor are used only by the test harness to distinguish builds. |
| 219 | # Only add _asan for a sanitized build if it isn't already a part of the |
| 220 | # flavor (via a dedicated lunch config for example). |
| 221 | print(f"ro.build.flavor={config['BuildFlavor']}") |
| 222 | |
| 223 | # These values are deprecated, use "ro.product.cpu.abilist" |
| 224 | # instead (see below). |
| 225 | print(f"# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete,") |
| 226 | print(f"# use ro.product.cpu.abilist instead.") |
| 227 | print(f"ro.product.cpu.abi={config['DeviceAbi'][0]}") |
| 228 | if len(config["DeviceAbi"]) > 1: |
| 229 | print(f"ro.product.cpu.abi2={config['DeviceAbi'][1]}") |
| 230 | |
| 231 | if config["ProductLocales"]: |
| 232 | print(f"ro.product.locale={config['ProductLocales'][0]}") |
| 233 | print(f"ro.wifi.channels={' '.join(config['ProductDefaultWifiChannels'])}") |
| 234 | |
| 235 | print(f"# ro.build.product is obsolete; use ro.product.device") |
| 236 | print(f"ro.build.product={config['DeviceName']}") |
| 237 | |
| 238 | print(f"# Do not try to parse description or thumbprint") |
| 239 | print(f"ro.build.description?={config['BuildDesc']}") |
| 240 | if "build_thumbprint" in config: |
| 241 | print(f"ro.build.thumbprint={config['BuildThumbprint']}") |
| 242 | |
| 243 | print(f"# end build properties") |
| 244 | |
| 245 | def write_properties_from_file(file): |
| 246 | print() |
| 247 | print("####################################") |
| 248 | print(f"# from {file.name}") |
| 249 | print("####################################") |
| 250 | print(file.read(), end="") |
| 251 | |
| 252 | def write_properties_from_variable(name, props, build_broken_dup_sysprop): |
| 253 | print() |
| 254 | print("####################################") |
| 255 | print(f"# from variable {name}") |
| 256 | print("####################################") |
| 257 | |
| 258 | # Implement the legacy behavior when BUILD_BROKEN_DUP_SYSPROP is on. |
| 259 | # Optional assignments are all converted to normal assignments and |
| 260 | # when their duplicates the first one wins. |
| 261 | if build_broken_dup_sysprop: |
| 262 | processed_props = [] |
| 263 | seen_props = set() |
| 264 | for line in props: |
| 265 | line = line.replace("?=", "=") |
| 266 | key, value = line.split("=", 1) |
| 267 | if key in seen_props: |
| 268 | continue |
| 269 | seen_props.add(key) |
| 270 | processed_props.append(line) |
| 271 | props = processed_props |
| 272 | |
| 273 | for line in props: |
| 274 | print(line) |
| 275 | |
| 276 | def append_additional_system_props(args): |
| 277 | props = [] |
| 278 | |
| 279 | config = args.config |
| 280 | |
| 281 | # Add the product-defined properties to the build properties. |
| 282 | if config["PropertySplitEnabled"] or config["VendorImageFileSystemType"]: |
| 283 | if "PRODUCT_PROPERTY_OVERRIDES" in config: |
| 284 | props += config["PRODUCT_PROPERTY_OVERRIDES"] |
| 285 | |
| 286 | props.append(f"ro.treble.enabled={'true' if config['FullTreble'] else 'false'}") |
| 287 | # Set ro.llndk.api_level to show the maximum vendor API level that the LLNDK |
| 288 | # in the system partition supports. |
| 289 | if config["VendorApiLevel"]: |
| 290 | props.append(f"ro.llndk.api_level={config['VendorApiLevel']}") |
| 291 | |
| 292 | # Sets ro.actionable_compatible_property.enabled to know on runtime whether |
| 293 | # the allowed list of actionable compatible properties is enabled or not. |
| 294 | props.append("ro.actionable_compatible_property.enabled=true") |
| 295 | |
| 296 | # Enable core platform API violation warnings on userdebug and eng builds. |
| 297 | if config["BuildVariant"] != "user": |
| 298 | props.append("persist.debug.dalvik.vm.core_platform_api_policy=just-warn") |
| 299 | |
| 300 | # Define ro.sanitize.<name> properties for all global sanitizers. |
| 301 | for sanitize_target in config["SanitizeDevice"]: |
| 302 | props.append(f"ro.sanitize.{sanitize_target}=true") |
| 303 | |
| 304 | # Sets the default value of ro.postinstall.fstab.prefix to /system. |
| 305 | # Device board config should override the value to /product when needed by: |
| 306 | # |
| 307 | # PRODUCT_PRODUCT_PROPERTIES += ro.postinstall.fstab.prefix=/product |
| 308 | # |
| 309 | # It then uses ${ro.postinstall.fstab.prefix}/etc/fstab.postinstall to |
| 310 | # mount system_other partition. |
| 311 | props.append("ro.postinstall.fstab.prefix=/system") |
| 312 | |
| 313 | enable_target_debugging = True |
| 314 | if config["BuildVariant"] == "user" or config["BuildVariant"] == "userdebug": |
| 315 | # Target is secure in user builds. |
| 316 | props.append("ro.secure=1") |
| 317 | props.append("security.perf_harden=1") |
| 318 | |
| 319 | if config["BuildVariant"] == "user": |
| 320 | # Disable debugging in plain user builds. |
| 321 | props.append("ro.adb.secure=1") |
| 322 | enable_target_debugging = False |
| 323 | |
| 324 | # Disallow mock locations by default for user builds |
| 325 | props.append("ro.allow.mock.location=0") |
| 326 | else: |
| 327 | # Turn on checkjni for non-user builds. |
| 328 | props.append("ro.kernel.android.checkjni=1") |
| 329 | # Set device insecure for non-user builds. |
| 330 | props.append("ro.secure=0") |
| 331 | # Allow mock locations by default for non user builds |
| 332 | props.append("ro.allow.mock.location=1") |
| 333 | |
| 334 | if enable_target_debugging: |
| 335 | # Enable Dalvik lock contention logging. |
| 336 | props.append("dalvik.vm.lockprof.threshold=500") |
| 337 | |
| 338 | # Target is more debuggable and adbd is on by default |
| 339 | props.append("ro.debuggable=1") |
| 340 | else: |
| 341 | # Target is less debuggable and adbd is off by default |
| 342 | props.append("ro.debuggable=0") |
| 343 | |
| 344 | if config["BuildVariant"] == "eng": |
| 345 | if "ro.setupwizard.mode=ENABLED" in props: |
| 346 | # Don't require the setup wizard on eng builds |
| 347 | props = list(filter(lambda x: not x.startswith("ro.setupwizard.mode="), props)) |
| 348 | props.append("ro.setupwizard.mode=OPTIONAL") |
| 349 | |
| 350 | if not config["SdkBuild"]: |
| 351 | # To speedup startup of non-preopted builds, don't verify or compile the boot image. |
| 352 | props.append("dalvik.vm.image-dex2oat-filter=extract") |
| 353 | # b/323566535 |
| 354 | props.append("init.svc_debug.no_fatal.zygote=true") |
| 355 | |
| 356 | if config["SdkBuild"]: |
| 357 | props.append("xmpp.auto-presence=true") |
| 358 | props.append("ro.config.nocheckin=yes") |
| 359 | |
| 360 | props.append("net.bt.name=Android") |
| 361 | |
| 362 | # This property is set by flashing debug boot image, so default to false. |
| 363 | props.append("ro.force.debuggable=0") |
| 364 | |
| 365 | config["ADDITIONAL_SYSTEM_PROPERTIES"] = props |
| 366 | |
| 367 | def append_additional_vendor_props(args): |
| 368 | props = [] |
| 369 | |
| 370 | config = args.config |
| 371 | build_flags = config["BuildFlags"] |
| 372 | |
| 373 | # Add cpu properties for bionic and ART. |
| 374 | props.append(f"ro.bionic.arch={config['DeviceArch']}") |
| 375 | props.append(f"ro.bionic.cpu_variant={config['DeviceCpuVariantRuntime']}") |
| 376 | props.append(f"ro.bionic.2nd_arch={config['DeviceSecondaryArch']}") |
| 377 | props.append(f"ro.bionic.2nd_cpu_variant={config['DeviceSecondaryCpuVariantRuntime']}") |
| 378 | |
| 379 | props.append(f"persist.sys.dalvik.vm.lib.2=libart.so") |
| 380 | props.append(f"dalvik.vm.isa.{config['DeviceArch']}.variant={config['Dex2oatTargetCpuVariantRuntime']}") |
| 381 | if config["Dex2oatTargetInstructionSetFeatures"]: |
| 382 | props.append(f"dalvik.vm.isa.{config['DeviceArch']}.features={config['Dex2oatTargetInstructionSetFeatures']}") |
| 383 | |
| 384 | if config["DeviceSecondaryArch"]: |
| 385 | props.append(f"dalvik.vm.isa.{config['DeviceSecondaryArch']}.variant={config['SecondaryDex2oatCpuVariantRuntime']}") |
| 386 | if config["SecondaryDex2oatInstructionSetFeatures"]: |
| 387 | props.append(f"dalvik.vm.isa.{config['DeviceSecondaryArch']}.features={config['SecondaryDex2oatInstructionSetFeatures']}") |
| 388 | |
| 389 | # Although these variables are prefixed with TARGET_RECOVERY_, they are also needed under charger |
| 390 | # mode (via libminui). |
| 391 | if config["RecoveryDefaultRotation"]: |
| 392 | props.append(f"ro.minui.default_rotation={config['RecoveryDefaultRotation']}") |
| 393 | |
| 394 | if config["RecoveryOverscanPercent"]: |
| 395 | props.append(f"ro.minui.overscan_percent={config['RecoveryOverscanPercent']}") |
| 396 | |
| 397 | if config["RecoveryPixelFormat"]: |
| 398 | props.append(f"ro.minui.pixel_format={config['RecoveryPixelFormat']}") |
| 399 | |
| 400 | if "UseDynamicPartitions" in config: |
| 401 | props.append(f"ro.boot.dynamic_partitions={'true' if config['UseDynamicPartitions'] else 'false'}") |
| 402 | |
| 403 | if "RetrofitDynamicPartitions" in config: |
| 404 | props.append(f"ro.boot.dynamic_partitions_retrofit={'true' if config['RetrofitDynamicPartitions'] else 'false'}") |
| 405 | |
| 406 | if config["ShippingApiLevel"]: |
| 407 | props.append(f"ro.product.first_api_level={config['ShippingApiLevel']}") |
| 408 | |
| 409 | if config["ShippingVendorApiLevel"]: |
| 410 | props.append(f"ro.vendor.api_level={config['ShippingVendorApiLevel']}") |
| 411 | |
| 412 | if config["BuildVariant"] != "user" and config["BuildDebugfsRestrictionsEnabled"]: |
| 413 | props.append(f"ro.product.debugfs_restrictions.enabled=true") |
| 414 | |
| 415 | # Vendors with GRF must define BOARD_SHIPPING_API_LEVEL for the vendor API level. |
| 416 | # This must not be defined for the non-GRF devices. |
| 417 | # The values of the GRF properties will be verified by post_process_props.py |
| 418 | if config["BoardShippingApiLevel"]: |
| 419 | props.append(f"ro.board.first_api_level={config['ProductShippingApiLevel']}") |
| 420 | |
| 421 | # Build system set BOARD_API_LEVEL to show the api level of the vendor API surface. |
| 422 | # This must not be altered outside of build system. |
| 423 | if config["VendorApiLevel"]: |
| 424 | props.append(f"ro.board.api_level={config['VendorApiLevel']}") |
| 425 | |
| 426 | # RELEASE_BOARD_API_LEVEL_FROZEN is true when the vendor API surface is frozen. |
| 427 | if build_flags["RELEASE_BOARD_API_LEVEL_FROZEN"]: |
| 428 | props.append(f"ro.board.api_frozen=true") |
| 429 | |
| 430 | # Set build prop. This prop is read by ota_from_target_files when generating OTA, |
| 431 | # to decide if VABC should be disabled. |
| 432 | if config["DontUseVabcOta"]: |
| 433 | props.append(f"ro.vendor.build.dont_use_vabc=true") |
| 434 | |
| 435 | # Set the flag in vendor. So VTS would know if the new fingerprint format is in use when |
| 436 | # the system images are replaced by GSI. |
| 437 | if config["BoardUseVbmetaDigestInFingerprint"]: |
| 438 | props.append(f"ro.vendor.build.fingerprint_has_digest=1") |
| 439 | |
| 440 | props.append(f"ro.vendor.build.security_patch={config['VendorSecurityPatch']}") |
| 441 | props.append(f"ro.product.board={config['BootloaderBoardName']}") |
| 442 | props.append(f"ro.board.platform={config['BoardPlatform']}") |
| 443 | props.append(f"ro.hwui.use_vulkan={'true' if config['UsesVulkan'] else 'false'}") |
| 444 | |
| 445 | if config["ScreenDensity"]: |
| 446 | props.append(f"ro.sf.lcd_density={config['ScreenDensity']}") |
| 447 | |
| 448 | if "AbOtaUpdater" in config: |
| 449 | props.append(f"ro.build.ab_update={'true' if config['AbOtaUpdater'] else 'false'}") |
| 450 | if config["AbOtaUpdater"]: |
| 451 | props.append(f"ro.vendor.build.ab_ota_partitions={config['AbOtaPartitions']}") |
| 452 | |
| 453 | config["ADDITIONAL_VENDOR_PROPERTIES"] = props |
| 454 | |
| 455 | def append_additional_product_props(args): |
| 456 | props = [] |
| 457 | |
| 458 | config = args.config |
| 459 | |
| 460 | # Add the system server compiler filter if they are specified for the product. |
| 461 | if config["SystemServerCompilerFilter"]: |
| 462 | props.append(f"dalvik.vm.systemservercompilerfilter={config['SystemServerCompilerFilter']}") |
| 463 | |
| 464 | # Add the 16K developer args if it is defined for the product. |
| 465 | props.append(f"ro.product.build.16k_page.enabled={'true' if config['Product16KDeveloperOption'] else 'false'}") |
| 466 | |
| 467 | props.append(f"ro.build.characteristics={config['AAPTCharacteristics']}") |
| 468 | |
| 469 | if "AbOtaUpdater" in config and config["AbOtaUpdater"]: |
| 470 | props.append(f"ro.product.ab_ota_partitions={config['AbOtaPartitions']}") |
| 471 | |
| 472 | # Set this property for VTS to skip large page size tests on unsupported devices. |
| 473 | props.append(f"ro.product.cpu.pagesize.max={config['DeviceMaxPageSizeSupported']}") |
| 474 | |
| 475 | if config["NoBionicPageSizeMacro"]: |
| 476 | props.append(f"ro.product.build.no_bionic_page_size_macro=true") |
| 477 | |
| 478 | # If the value is "default", it will be mangled by post_process_props.py. |
| 479 | props.append(f"ro.dalvik.vm.enable_uffd_gc={config['EnableUffdGc']}") |
| 480 | |
| 481 | config["ADDITIONAL_PRODUCT_PROPERTIES"] = props |
| 482 | |
| 483 | def build_system_prop(args): |
| 484 | config = args.config |
| 485 | |
| 486 | # Order matters here. When there are duplicates, the last one wins. |
| 487 | # TODO(b/117892318): don't allow duplicates so that the ordering doesn't matter |
| 488 | variables = [ |
| 489 | "ADDITIONAL_SYSTEM_PROPERTIES", |
| 490 | "PRODUCT_SYSTEM_PROPERTIES", |
| 491 | # TODO(b/117892318): deprecate this |
| 492 | "PRODUCT_SYSTEM_DEFAULT_PROPERTIES", |
| 493 | ] |
| 494 | |
| 495 | if not config["PropertySplitEnabled"]: |
| 496 | variables += [ |
| 497 | "ADDITIONAL_VENDOR_PROPERTIES", |
| 498 | "PRODUCT_VENDOR_PROPERTIES", |
| 499 | ] |
| 500 | |
| 501 | build_prop(args, gen_build_info=True, gen_common_build_props=True, variables=variables) |
| 502 | |
| 503 | ''' |
| 504 | def build_vendor_prop(args): |
| 505 | config = args.config |
| 506 | |
| 507 | # Order matters here. When there are duplicates, the last one wins. |
| 508 | # TODO(b/117892318): don't allow duplicates so that the ordering doesn't matter |
| 509 | variables = [] |
| 510 | if config["PropertySplitEnabled"]: |
| 511 | variables += [ |
| 512 | "ADDITIONAL_VENDOR_PROPERTIES", |
| 513 | "PRODUCT_VENDOR_PROPERTIES", |
| 514 | # TODO(b/117892318): deprecate this |
| 515 | "PRODUCT_DEFAULT_PROPERTY_OVERRIDES", |
| 516 | "PRODUCT_PROPERTY_OVERRIDES", |
| 517 | ] |
| 518 | |
| 519 | build_prop(args, gen_build_info=False, gen_common_build_props=True, variables=variables) |
| 520 | |
| 521 | def build_product_prop(args): |
| 522 | config = args.config |
| 523 | |
| 524 | # Order matters here. When there are duplicates, the last one wins. |
| 525 | # TODO(b/117892318): don't allow duplicates so that the ordering doesn't matter |
| 526 | variables = [ |
| 527 | "ADDITIONAL_PRODUCT_PROPERTIES", |
| 528 | "PRODUCT_PRODUCT_PROPERTIES", |
| 529 | ] |
| 530 | build_prop(args, gen_build_info=False, gen_common_build_props=True, variables=variables) |
| 531 | ''' |
| 532 | |
| 533 | def build_prop(args, gen_build_info, gen_common_build_props, variables): |
| 534 | config = args.config |
| 535 | |
| 536 | if gen_common_build_props: |
| 537 | generate_common_build_props(args) |
| 538 | |
| 539 | if gen_build_info: |
| 540 | generate_build_info(args) |
| 541 | |
| 542 | for prop_file in args.prop_files: |
| 543 | write_properties_from_file(prop_file) |
| 544 | |
| 545 | for variable in variables: |
| 546 | if variable in config: |
| 547 | write_properties_from_variable(variable, config[variable], args.build_broken_dup_sysprop) |
| 548 | |
| 549 | def main(): |
| 550 | args = parse_args() |
| 551 | |
| 552 | with contextlib.redirect_stdout(args.out): |
| 553 | if args.partition == "system": |
| 554 | build_system_prop(args) |
| 555 | ''' |
| 556 | elif args.partition == "vendor": |
| 557 | build_vendor_prop(args) |
| 558 | elif args.partition == "product": |
| 559 | build_product_prop(args) |
| 560 | ''' |
| 561 | else: |
| 562 | sys.exit(f"not supported partition {args.partition}") |
| 563 | |
| 564 | if __name__ == "__main__": |
| 565 | main() |