Loading tools/aconfig/aconfig_device_paths/Android.bp +5 −3 Original line number Diff line number Diff line Loading @@ -39,8 +39,8 @@ rust_library { genrule { name: "libaconfig_java_device_paths_src", srcs: ["src/DevicePathsTemplate.java"], out: ["DevicePaths.java"], srcs: ["src/DeviceProtosTemplate.java"], out: ["DeviceProtos.java"], tool_files: ["partition_aconfig_flags_paths.txt"], cmd: "sed -e '/TEMPLATE/{r$(location partition_aconfig_flags_paths.txt)' -e 'd}' $(in) > $(out)", } Loading @@ -48,5 +48,7 @@ genrule { java_library { name: "aconfig_device_paths_java", srcs: [":libaconfig_java_device_paths_src"], sdk_version: "core_current", static_libs: [ "libaconfig_java_proto_nano", ], } tools/aconfig/aconfig_device_paths/src/DevicePathsTemplate.java→tools/aconfig/aconfig_device_paths/src/DeviceProtosTemplate.java +30 −2 Original line number Diff line number Diff line Loading @@ -15,7 +15,12 @@ */ package android.aconfig; import android.aconfig.nano.Aconfig.parsed_flag; import android.aconfig.nano.Aconfig.parsed_flags; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading @@ -23,7 +28,7 @@ import java.util.List; /** * @hide */ public class DevicePaths { public class DeviceProtos { static final String[] PATHS = { TEMPLATE }; Loading @@ -31,12 +36,35 @@ public class DevicePaths { private static final String APEX_DIR = "/apex"; private static final String APEX_ACONFIG_PATH_SUFFIX = "/etc/aconfig_flags.pb"; /** * Returns a list of all on-device aconfig protos. * * May throw an exception if the protos can't be read at the call site. For * example, some of the protos are in the apex/ partition, which is mounted * somewhat late in the boot process. * * @throws IOException if we can't read one of the protos yet * @return a list of all on-device aconfig protos */ public static List<parsed_flag> loadAndParseFlagProtos() throws IOException { ArrayList<parsed_flag> result = new ArrayList(); for (String path : parsedFlagsProtoPaths()) { FileInputStream inputStream = new FileInputStream(path); parsed_flags parsedFlags = parsed_flags.parseFrom(inputStream.readAllBytes()); for (parsed_flag flag : parsedFlags.parsedFlag) { result.add(flag); } } return result; } /** * Returns the list of all on-device aconfig protos paths. * @hide */ public static List<String> parsedFlagsProtoPaths() { private static List<String> parsedFlagsProtoPaths() { ArrayList<String> paths = new ArrayList(Arrays.asList(PATHS)); File apexDirectory = new File(APEX_DIR); Loading Loading
tools/aconfig/aconfig_device_paths/Android.bp +5 −3 Original line number Diff line number Diff line Loading @@ -39,8 +39,8 @@ rust_library { genrule { name: "libaconfig_java_device_paths_src", srcs: ["src/DevicePathsTemplate.java"], out: ["DevicePaths.java"], srcs: ["src/DeviceProtosTemplate.java"], out: ["DeviceProtos.java"], tool_files: ["partition_aconfig_flags_paths.txt"], cmd: "sed -e '/TEMPLATE/{r$(location partition_aconfig_flags_paths.txt)' -e 'd}' $(in) > $(out)", } Loading @@ -48,5 +48,7 @@ genrule { java_library { name: "aconfig_device_paths_java", srcs: [":libaconfig_java_device_paths_src"], sdk_version: "core_current", static_libs: [ "libaconfig_java_proto_nano", ], }
tools/aconfig/aconfig_device_paths/src/DevicePathsTemplate.java→tools/aconfig/aconfig_device_paths/src/DeviceProtosTemplate.java +30 −2 Original line number Diff line number Diff line Loading @@ -15,7 +15,12 @@ */ package android.aconfig; import android.aconfig.nano.Aconfig.parsed_flag; import android.aconfig.nano.Aconfig.parsed_flags; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; Loading @@ -23,7 +28,7 @@ import java.util.List; /** * @hide */ public class DevicePaths { public class DeviceProtos { static final String[] PATHS = { TEMPLATE }; Loading @@ -31,12 +36,35 @@ public class DevicePaths { private static final String APEX_DIR = "/apex"; private static final String APEX_ACONFIG_PATH_SUFFIX = "/etc/aconfig_flags.pb"; /** * Returns a list of all on-device aconfig protos. * * May throw an exception if the protos can't be read at the call site. For * example, some of the protos are in the apex/ partition, which is mounted * somewhat late in the boot process. * * @throws IOException if we can't read one of the protos yet * @return a list of all on-device aconfig protos */ public static List<parsed_flag> loadAndParseFlagProtos() throws IOException { ArrayList<parsed_flag> result = new ArrayList(); for (String path : parsedFlagsProtoPaths()) { FileInputStream inputStream = new FileInputStream(path); parsed_flags parsedFlags = parsed_flags.parseFrom(inputStream.readAllBytes()); for (parsed_flag flag : parsedFlags.parsedFlag) { result.add(flag); } } return result; } /** * Returns the list of all on-device aconfig protos paths. * @hide */ public static List<String> parsedFlagsProtoPaths() { private static List<String> parsedFlagsProtoPaths() { ArrayList<String> paths = new ArrayList(Arrays.asList(PATHS)); File apexDirectory = new File(APEX_DIR); Loading