Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab66cf11 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Enable aconfig_storage on Ravenwood

Design: go/ravenwood-aconfig-2025

Bug: 396458006
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh -s
Flag: EXEMPT host side change only
Change-Id: Ie31691456edd3209a5679e4c012bbb7ad1de67bf
parent 34ee9717
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import java.util.List;

/**
 * @hide
 *
 * Note this class does _not_ work on Ravenwood (yet). Contact g/ravenwood if you need it.
 */
public class DeviceProtos {
	public static final String[] PATHS = {
+38 −2
Original line number Diff line number Diff line
@@ -25,12 +25,44 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/** @hide */
/**
 * Utility class to load protobuf storage files.
 *
 * This class _does_ support Ravenwood.
 *
 * In order to avoid adding extra dependencies, this class doesn't use Ravenwood annotations
 * or RavenwoodHelper.java. Instead, we just hardcode relevant logic.
 *
 * @hide
 */
public class DeviceProtosTestUtil {
    public static final String[] PATHS = {
    private static final String[] PATHS_DEVICE = {
        TEMPLATE
    };

    /** Path to ravenwood runtime, or null on non-ravenwood environment. */
    private static final String RAVENWOOD_RUNTIME_PATH
            = System.getProperty("android.ravenwood.runtime_path");

    /** True if on ravenwood */
    private static final boolean ON_RAVENWOOD = RAVENWOOD_RUNTIME_PATH != null;

    private static String[] getPaths() {
        if (!ON_RAVENWOOD) {
            return PATHS_DEVICE;
        }
        return new String[] {
            RAVENWOOD_RUNTIME_PATH + "/aconfig/metadata/aconfig/etc/all_aconfig_declarations.pb"
        };
    }

    /**
     * Protobuf storage files. On the device side, this array contains multiple files, one
     * from each partition. On Ravenwood, this contains a single protobuf file containing all the
     * flags.
     */
    public static final String[] PATHS = getPaths();

    private static final String APEX_DIR = "/apex/";
    private static final String APEX_ACONFIG_PATH_SUFFIX = "/etc/aconfig_flags.pb";
    private static final String SYSTEM_APEX_DIR = "/system/apex";
@@ -67,6 +99,10 @@ public class DeviceProtosTestUtil {
    public static List<String> parsedFlagsProtoPaths() {
        ArrayList<String> paths = new ArrayList(Arrays.asList(PATHS));

        if (ON_RAVENWOOD) {
            return paths; // No apexes on Ravenwood.
        }

        File apexDirectory = new File(SYSTEM_APEX_DIR);
        if (!apexDirectory.isDirectory()) {
            return paths;
+6 −0
Original line number Diff line number Diff line
@@ -164,6 +164,9 @@ java_library {
    srcs: [
        "srcs/**/*.java",
    ],
    libs: [
        "ravenwood-annotations-lib",
    ],
    sdk_version: "core_current",
    min_sdk_version: "29",
    host_supported: true,
@@ -179,6 +182,9 @@ java_library {
    srcs: [
        "srcs/**/*.java",
    ],
    libs: [
        "ravenwood-annotations-lib",
    ],
    sdk_version: "none",
    system_modules: "core-all-system-modules",
    host_supported: true,
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ package android.aconfig.storage;
 * <p>This exception indicates a general problem with Aconfig Storage, such as an inability to read
 * or write data.
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class AconfigStorageException extends RuntimeException {

    /** Generic error code indicating an unspecified Aconfig Storage error. */
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Objects;

@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class ByteBufferReader {

    private ByteBuffer mByteBuffer;
Loading