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

Commit 40bbf3b9 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi
Browse files

Use DeviceProtos to get flag file paths

Instead of the hardcoded paths we can use the global constants
for the proto file paths, and get all APEXes with flags from the
same class as well

Bug: 301491148
Test: build + boot
Flag: EXEMPT flagging support change
Change-Id: I685daec3cc1070472157fb40ba30c72a2a80d4b8
parent 666c6eb4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -426,6 +426,7 @@ java_defaults {
        "modules-utils-expresslog",
        "perfetto_trace_javastream_protos_jarjar",
        "libaconfig_java_proto_nano",
        "aconfig_device_paths_java",
    ],
}

+6 −8
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.internal.pm.pkg.component;

import static com.android.internal.pm.pkg.parsing.ParsingUtils.ANDROID_RES_NAMESPACE;

import android.aconfig.DeviceProtos;
import android.aconfig.nano.Aconfig;
import android.aconfig.nano.Aconfig.parsed_flag;
import android.aconfig.nano.Aconfig.parsed_flags;
@@ -40,7 +41,7 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;
import java.util.Arrays;
import java.util.Map;

/**
@@ -54,12 +55,6 @@ import java.util.Map;
public class AconfigFlags {
    private static final String LOG_TAG = "AconfigFlags";

    private static final List<String> sTextProtoFilesOnDevice = List.of(
            "/system/etc/aconfig_flags.pb",
            "/system_ext/etc/aconfig_flags.pb",
            "/product/etc/aconfig_flags.pb",
            "/vendor/etc/aconfig_flags.pb");

    public enum Permission {
        READ_WRITE,
        READ_ONLY
@@ -73,7 +68,10 @@ public class AconfigFlags {
            Slog.v(LOG_TAG, "Feature disabled, skipped all loading");
            return;
        }
        for (String fileName : sTextProtoFilesOnDevice) {
        final var defaultFlagProtoFiles =
                (Process.myUid() == Process.SYSTEM_UID) ? DeviceProtos.parsedFlagsProtoPaths()
                        : Arrays.asList(DeviceProtos.PATHS);
        for (String fileName : defaultFlagProtoFiles) {
            try (var inputStream = new FileInputStream(fileName)) {
                loadAconfigDefaultValues(inputStream.readAllBytes());
            } catch (IOException e) {