diff options
5 files changed, 232 insertions, 40 deletions
diff --git a/ravenwood/Android.bp b/ravenwood/Android.bp index 4731cfbfc935..0c2ce8dcb698 100644 --- a/ravenwood/Android.bp +++ b/ravenwood/Android.bp @@ -376,6 +376,7 @@ filegroup { ":ravenwood-empty-res", ":framework-platform-compat-config", ":services-platform-compat-config", + "texts/ravenwood-build.prop", ], device_first_srcs: [ ":apex_icu.dat", diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java index 91778579ab28..c5a9c7b28ad3 100644 --- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java +++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java @@ -22,7 +22,6 @@ import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_INST_R import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_RESOURCE_APK; import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERBOSE_LOGGING; import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERSION_JAVA_SYSPROP; -import static com.android.ravenwood.common.RavenwoodCommonUtils.getRavenwoodRuntimePath; import static org.junit.Assert.assertThrows; import static org.mockito.ArgumentMatchers.any; @@ -90,8 +89,6 @@ public class RavenwoodRuntimeEnvironmentController { private static final String LIBRAVENWOOD_INITIALIZER_NAME = "ravenwood_initializer"; private static final String RAVENWOOD_NATIVE_SYSPROP_NAME = "ravenwood_sysprop"; private static final String RAVENWOOD_NATIVE_RUNTIME_NAME = "ravenwood_runtime"; - private static final String RAVENWOOD_BUILD_PROP = - getRavenwoodRuntimePath() + "ravenwood-data/build.prop"; /** * When enabled, attempt to dump all thread stacks just before we hit the @@ -204,7 +201,7 @@ public class RavenwoodRuntimeEnvironmentController { System.load(RavenwoodCommonUtils.getJniLibraryPath(RAVENWOOD_NATIVE_RUNTIME_NAME)); // Do the basic set up for the android sysprops. - RavenwoodSystemProperties.initialize(RAVENWOOD_BUILD_PROP); + RavenwoodSystemProperties.initialize(); setSystemProperties(null); // Do this after loading RAVENWOOD_NATIVE_RUNTIME_NAME (which backs Os.setenv()), diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java index 9bc45bee1775..3e4619f55c6d 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java @@ -16,21 +16,30 @@ package android.platform.test.ravenwood; -import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_SYSPROP; +import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERBOSE_LOGGING; +import static com.android.ravenwood.common.RavenwoodCommonUtils.getRavenwoodRuntimePath; -import com.android.ravenwood.common.RavenwoodCommonUtils; +import android.util.Log; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; public class RavenwoodSystemProperties { private static final String TAG = "RavenwoodSystemProperties"; + /** We pull in propeties from this file. */ + private static final String RAVENWOOD_BUILD_PROP = "ravenwood-data/ravenwood-build.prop"; + + /** This is the actual build.prop we use to build the device (contents depends on lunch). */ + private static final String DEVICE_BUILD_PROP = "ravenwood-data/build.prop"; + + /** The default values. */ private static final Map<String, String> sDefaultValues = new HashMap<>(); private static final String[] PARTITIONS = { @@ -43,52 +52,54 @@ public class RavenwoodSystemProperties { "vendor_dlkm", }; - /** - * More info about property file loading: system/core/init/property_service.cpp - * In the following logic, the only partition we would need to consider is "system", - * since we only read from system-build.prop - */ - static void initialize(String propFile) { - // Load all properties from build.prop + private static Map<String, String> readProperties(String propFile) { + // Use an ordered map just for cleaner dump log. + final Map<String, String> ret = new LinkedHashMap<>(); try { Files.readAllLines(Path.of(propFile)).stream() .map(String::trim) .filter(s -> !s.startsWith("#")) .map(s -> s.split("\\s*=\\s*", 2)) .filter(a -> a.length == 2) - .forEach(a -> sDefaultValues.put(a[0], a[1])); + .forEach(a -> ret.put(a[0], a[1])); } catch (IOException e) { throw new RuntimeException(e); } + return ret; + } - // If ro.product.${name} is not set, derive from ro.product.${partition}.${name} - // If ro.product.cpu.abilist* is not set, derive from ro.${partition}.product.cpu.abilist* - for (var entry : Set.copyOf(sDefaultValues.entrySet())) { - final String key; - if (entry.getKey().startsWith("ro.product.system.")) { - var name = entry.getKey().substring(18); - key = "ro.product." + name; - - } else if (entry.getKey().startsWith("ro.system.product.cpu.abilist")) { - var name = entry.getKey().substring(22); - key = "ro.product.cpu." + name; + /** + * Load default sysprops from {@link #RAVENWOOD_BUILD_PROP}. We also pull in + * certain properties from the acutual device's build.prop {@link #DEVICE_BUILD_PROP} too. + * + * More info about property file loading: system/core/init/property_service.cpp + * In the following logic, the only partition we would need to consider is "system", + * since we only read from system-build.prop + */ + static void initialize() { + var path = getRavenwoodRuntimePath(); + var ravenwoodProps = readProperties(path + RAVENWOOD_BUILD_PROP); + var deviceProps = readProperties(path + DEVICE_BUILD_PROP); + + Log.i(TAG, "Default system properties:"); + ravenwoodProps.forEach((key, origValue) -> { + final String value; + + // If a value starts with "$$$", then this is a reference to the device-side value. + if (origValue.startsWith("$$$")) { + var deviceKey = origValue.substring(3); + var deviceValue = deviceProps.get(deviceKey); + if (deviceValue == null) { + throw new RuntimeException("Failed to initialize system properties. Key '" + + deviceKey + "' doesn't exist in the device side build.prop"); + } + value = deviceValue; } else { - continue; - } - if (!sDefaultValues.containsKey(key)) { - sDefaultValues.put(key, entry.getValue()); + value = origValue; } - } - - // Some other custom values - sDefaultValues.put("ro.board.first_api_level", "1"); - sDefaultValues.put("ro.product.first_api_level", "1"); - sDefaultValues.put("ro.soc.manufacturer", "Android"); - sDefaultValues.put("ro.soc.model", "Ravenwood"); - sDefaultValues.put(RAVENWOOD_SYSPROP, "1"); - - // Log all values - sDefaultValues.forEach((key, value) -> RavenwoodCommonUtils.log(TAG, key + "=" + value)); + Log.i(TAG, key + "=" + value); + sDefaultValues.put(key, value); + }); // Copy ro.product.* and ro.build.* to all partitions, just in case // We don't want to log these because these are just a lot of duplicate values @@ -104,6 +115,13 @@ public class RavenwoodSystemProperties { } } } + if (RAVENWOOD_VERBOSE_LOGGING) { + // Dump all properties for local debugging. + Log.v(TAG, "All system properties:"); + for (var key : sDefaultValues.keySet().stream().sorted().toList()) { + Log.v(TAG, "" + key + "=" + sDefaultValues.get(key)); + } + } } private volatile boolean mIsImmutable; diff --git a/ravenwood/texts/build.prop-sample-cuttlefish b/ravenwood/texts/build.prop-sample-cuttlefish new file mode 100644 index 000000000000..f78b727f5779 --- /dev/null +++ b/ravenwood/texts/build.prop-sample-cuttlefish @@ -0,0 +1,132 @@ +# This is file is generated with `aosp_cf_x86_64_phone-trunk_staging-eng` on 2024-11-06. +# We have this file here only as a reference. We don't actually use this file anywhere. + +#################################### +# from generate_common_build_props +# These properties identify this partition image. +#################################### +ro.product.system.brand=Android +ro.product.system.device=generic +ro.product.system.manufacturer=Android +ro.product.system.model=mainline +ro.product.system.name=mainline +ro.system.product.cpu.abilist=x86_64,x86,arm64-v8a,armeabi-v7a,armeabi +ro.system.product.cpu.abilist32=x86,armeabi-v7a,armeabi +ro.system.product.cpu.abilist64=x86_64,arm64-v8a +ro.system.build.date=Tue Nov 5 13:25:43 PST 2024 +ro.system.build.date.utc=1730841943 +ro.system.build.fingerprint=generic/aosp_cf_x86_64_phone/vsoc_x86_64:Baklava/MAIN/eng.omakot:eng/test-keys +ro.system.build.id=MAIN +ro.system.build.tags=test-keys +ro.system.build.type=eng +ro.system.build.version.incremental=eng.omakot +ro.system.build.version.release=15 +ro.system.build.version.release_or_codename=Baklava +ro.system.build.version.sdk=35 +#################################### +# from gen_build_prop.py:generate_build_info +#################################### +# begin build properties +ro.build.legacy.id=MAIN +ro.build.display.id=aosp_cf_x86_64_phone-eng Baklava MAIN eng.omakot test-keys +ro.build.version.incremental=eng.omakot +ro.build.version.sdk=35 +ro.build.version.preview_sdk=1 +ro.build.version.preview_sdk_fingerprint=2ef06129940d459014cf4dede3950d71 +ro.build.version.codename=Baklava +ro.build.version.all_codenames=Baklava +ro.build.version.known_codenames=Base,Base11,Cupcake,Donut,Eclair,Eclair01,EclairMr1,Froyo,Gingerbread,GingerbreadMr1,Honeycomb,HoneycombMr1,HoneycombMr2,IceCreamSandwich,IceCreamSandwichMr1,JellyBean,JellyBeanMr1,JellyBeanMr2,Kitkat,KitkatWatch,Lollipop,LollipopMr1,M,N,NMr1,O,OMr1,P,Q,R,S,Sv2,Tiramisu,UpsideDownCake,VanillaIceCream,Baklava +ro.build.version.release=15 +ro.build.version.release_or_codename=Baklava +ro.build.version.release_or_preview_display=Baklava +ro.build.version.security_patch=2024-08-05 +ro.build.version.base_os= +ro.build.version.min_supported_target_sdk=28 +ro.build.date=Tue Nov 5 13:25:43 PST 2024 +ro.build.date.utc=1730841943 +ro.build.type=eng +ro.build.user=omakoto +ro.build.host=omakoto-ct1.c.googlers.com +ro.build.tags=test-keys +ro.build.flavor=aosp_cf_x86_64_phone-eng +# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete, +# use ro.product.cpu.abilist instead. +ro.product.cpu.abi=x86_64 +ro.product.locale=en-US +ro.wifi.channels= +# ro.build.product is obsolete; use ro.product.device +ro.build.product=vsoc_x86_64 +# Do not try to parse description or thumbprint +ro.build.description=aosp_cf_x86_64_phone-eng Baklava MAIN eng.omakot test-keys +# end build properties +#################################### +# from variable ADDITIONAL_SYSTEM_PROPERTIES +#################################### +ro.treble.enabled=true +ro.llndk.api_level=202504 +ro.actionable_compatible_property.enabled=true +persist.debug.dalvik.vm.core_platform_api_policy=just-warn +ro.postinstall.fstab.prefix=/system +ro.kernel.android.checkjni=1 +ro.secure=0 +ro.allow.mock.location=1 +dalvik.vm.lockprof.threshold=500 +ro.debuggable=1 +dalvik.vm.image-dex2oat-filter=extract +init.svc_debug.no_fatal.zygote=true +net.bt.name=Android +ro.force.debuggable=0 +#################################### +# from variable PRODUCT_SYSTEM_PROPERTIES +#################################### +debug.atrace.tags.enableflags=0 +persist.traced.enable=1 +dalvik.vm.image-dex2oat-Xms=64m +dalvik.vm.image-dex2oat-Xmx=64m +dalvik.vm.dex2oat-Xms=64m +dalvik.vm.dex2oat-Xmx=512m +dalvik.vm.usejit=true +dalvik.vm.dexopt.secondary=true +dalvik.vm.dexopt.thermal-cutoff=2 +dalvik.vm.appimageformat=lz4 +ro.dalvik.vm.native.bridge=0 +pm.dexopt.post-boot=verify +pm.dexopt.first-boot=verify +pm.dexopt.boot-after-ota=verify +pm.dexopt.boot-after-mainline-update=verify +pm.dexopt.install=speed-profile +pm.dexopt.install-fast=skip +pm.dexopt.install-bulk=speed-profile +pm.dexopt.install-bulk-secondary=verify +pm.dexopt.install-bulk-downgraded=verify +pm.dexopt.install-bulk-secondary-downgraded=verify +pm.dexopt.bg-dexopt=speed-profile +pm.dexopt.ab-ota=speed-profile +pm.dexopt.inactive=verify +pm.dexopt.cmdline=verify +pm.dexopt.shared=speed +dalvik.vm.disable-art-service-dexopt=true +dalvik.vm.disable-odrefresh=true +dalvik.vm.dex2oat-resolve-startup-strings=true +dalvik.vm.dex2oat-max-image-block-size=524288 +dalvik.vm.minidebuginfo=true +dalvik.vm.dex2oat-minidebuginfo=true +dalvik.vm.madvise.vdexfile.size=104857600 +dalvik.vm.madvise.odexfile.size=104857600 +dalvik.vm.madvise.artfile.size=4294967295 +dalvik.vm.usap_pool_enabled=false +dalvik.vm.usap_refill_threshold=1 +dalvik.vm.usap_pool_size_max=3 +dalvik.vm.usap_pool_size_min=1 +dalvik.vm.usap_pool_refill_delay_ms=3000 +dalvik.vm.useartservice=true +dalvik.vm.enable_pr_dexopt=true +ro.cp_system_other_odex=1 +ro.apex.updatable=true +ro.launcher.depth.widget=0 +#################################### +# from variable PRODUCT_SYSTEM_DEFAULT_PROPERTIES +#################################### +# Auto-added by post_process_props.py +persist.sys.usb.config=adb +# end of file diff --git a/ravenwood/texts/ravenwood-build.prop b/ravenwood/texts/ravenwood-build.prop new file mode 100644 index 000000000000..93a18cffec50 --- /dev/null +++ b/ravenwood/texts/ravenwood-build.prop @@ -0,0 +1,44 @@ +# This file contains system properties used on ravenwood. + +ro.is_on_ravenwood=1 + +ro.board.first_api_level=1 +ro.product.first_api_level=1 +ro.soc.manufacturer=Android +ro.soc.model=Ravenwood +ro.debuggable=1 + +# The ones starting with "ro.product" or "ro.bild" will be copied to all "partitions" too. +# See RavenwoodSystemProperties. +ro.product.brand=Android +ro.product.device=Ravenwood +ro.product.manufacturer=Android +ro.product.model=Ravenwood +ro.product.name=Ravenwood +ro.product.cpu.abilist=x86_64 +ro.product.cpu.abilist32= +ro.product.cpu.abilist64=x86_64 + +ro.build.date=Thu Jan 01 00:00:00 GMT 2024 +ro.build.date.utc=1704092400 +ro.build.id=MAIN +ro.build.tags=dev-keys +ro.build.type=userdebug +ro.build.version.incremental=userdebug.ravenwood.20240101 + +# These are what we used to use on Ravenwood, copied here as a reference. +#ro.build.version.codename=REL +#ro.build.version.all_codenames=REL +#ro.build.version.known_codenames=REL +#ro.build.version.release=14 +#ro.build.version.release_or_codename=VanillaIceCream +#ro.build.version.sdk=34 + +# We pull in the following values from the real build.prop file. +ro.build.version.codename=$$$ro.build.version.codename +ro.build.version.all_codenames=$$$ro.build.version.codename +ro.build.version.known_codenames=$$$ro.build.version.codename +ro.build.version.release=$$$ro.build.version.release +ro.build.version.release_or_codename=$$$ro.build.version.release_or_codename +ro.build.version.release_or_preview_display=$$$ro.build.version.release_or_preview_display +ro.build.version.sdk=$$$ro.build.version.sdk |