Commit graph

9330 commits

Author SHA1 Message Date
Ted Bauer
8e7cfad672 Read from new storage in C++ aconfig codegen
Read from the new aconfig storage backing in C++ aconfig codegen, for
READ_ONLY flags. Log if there is a match with the legacy storage, or a
mismatch, or a failure.

Only enabled if instrumentation is enabled, which will be enabled by a
build flag in a follow-up CL.

Test: m && cargo t
Bug: 328444881
Change-Id: I691dfad8860d8f917e93c5d56dac19f8791de943
2024-04-26 18:45:31 +00:00
Jeff DeCew
cfd7b0df36 Merge "Generate CustomFeatureFlags" into main 2024-04-26 18:39:43 +00:00
Jared Duke
8782e1e858 Use a version script for libaconfig_storage_read_api_cc
Restrict the set of exported symbols to those in the aconfig_storage
namespace by way of a version script. This shrinks the shared lib size
by ~75%, from ~800KB to <200KB.

Bug: 336657207
Test: m
Change-Id: I56044fe667a713cf1d94f96c992f379a5725850f
2024-04-26 17:43:14 +00:00
Mårten Kongstad
18ff19a563 check-flagged-apis: parse classes
Teach check-flagged-apis to parse classes, including inner classes.

Bug: 334870672
Test: atest --host check-flagged-apis-test
Change-Id: I17f65d3af55a20a1920b47f4c47fd0e92f9fa852
2024-04-26 05:58:41 +02:00
Mårten Kongstad
04e4564f49 check-flagged-apis: add missing requireNotNull
Bug: 334870672
Test: atest --host check-flagged-apis-test
Change-Id: Ibffafb504240c82d525105d4678983b30b70592d
2024-04-26 05:39:03 +02:00
Ben Fennema
cd6de1bc7f Allow boot_variable_file to be read from input_target_files
If boot_variable_file is not found locally, look for it inside
input_target_files.

Bug: 335732867
Test: generate OTA with file in target-files.zip and verify metadata
Change-Id: I2e61f50850e82a3795f2e0e1aefcaf2329a8cfb1
2024-04-25 17:11:13 +00:00
Ted Bauer
966e558e9f Merge "Prune unnecessary symbols from read API" into main 2024-04-25 16:59:05 +00:00
Ted Bauer
ad07bd54f6 Prune unnecessary symbols from read API
Bug: 328444881
Test: m
Change-Id: I3b730a6c3390a5d116d467f15f17e74a9096961d
2024-04-25 15:51:15 +00:00
Dennis Shen
fe5065705c aconfig: update aconfig storage write api and test update
Simplify storage write api so that we don't need the storage records pb
file.

Bug: b/312444587
Test: atest -c
Change-Id: I7e336b1d7766983364715dae15786b91b0c0743f
2024-04-25 13:40:07 +00:00
Fabián Cañas
c1f344e980 Add * support products and modules
Passing "*" to --products is equivalent to passing the all_named_producs
build variable

Passing "*" to --modules passes the contents of
PRODUCT_OUT/all_modules.txt

The total length of the text of all_modules can easily exceed the
maximum argument size for the OS. The proper solution is likely to call
getconf ARG_MAX, then concatenate the command to be executed to check
against the limit. Instead, the modules are processed in batches of 40k
modules. As long as module names don't get extremely long, this should
keep us under the ARG_MAX limit. In testing, using --modules "*" gets
split into two batches.

Test: build/make/tools/whichgit --modules "*"
Test: build/make/tools/whichgit --modules "*" --unused
Test: build/make/tools/whichgit --modules "*" --products "*"

Existing use-cases should remain unchanged:

TEST: build/make/tools/whichgit --modules framework
Change-Id: Ifa947daea2d439df0145e6def92637b67a8b5d22
2024-04-24 21:23:58 +00:00
Jeff DeCew
c3bc24f33b Generate CustomFeatureFlags
* Creates a new general-purpose CustomFeatureFlags class
* Simplifies FakeFeatureFlagsImpl to be based on that
* This allows teams to fake FeatureFlags without having to make changes per flag.
* This allows SetFlagsRule to inject an instance of FeatureFlags that would detect if a flag has been read.

Bug: 336768870
Flag: none
Test: presubmit
Change-Id: Id3c2530d484fa5584c46d11381fcfc0ab294f33f

NOTE FOR REVIEWERS - original patch and result patch are not identical.
PLEASE REVIEW CAREFULLY.
Diffs between the patches:
     "CustomFeatureFlags.java",
> +        include_str!("../../templates/CustomFeatureFlags.java.template"),
> +    )?;
> +    template.add_template(
> -    ["Flags.java", "FeatureFlags.java", "FeatureFlagsImpl.java", "FakeFeatureFlagsImpl.java"]
> -        .iter()
> -        .map(|file| {
> -            Ok(OutputFile {
> -                contents: template.render(file, &context)?.into(),
> -                path: path.join(file),
> -            })
> -        })
> -        .collect::<Result<Vec<OutputFile>>>()
> +    [
> +        "Flags.java",
> +        "FeatureFlags.java",
> +        "FeatureFlagsImpl.java",
> +        "CustomFeatureFlags.java",
> +        "FakeFeatureFlagsImpl.java",
> +    ]
> +    .iter()
> +    .map(|file| {
> +        Ok(OutputFile { contents: template.render(file, &context)?.into(), path: path.join(file) })
> +    })
> +    .collect::<Result<Vec<OutputFile>>>()
> -    const EXPECTED_FAKEFEATUREFLAGSIMPL_CONTENT: &str = r#"
> +    const EXPECTED_CUSTOMFEATUREFLAGS_CONTENT: &str = r#"
> +
> -    import java.util.HashMap;
> -    import java.util.Map;
> +    import java.util.List;
> +    import java.util.function.BiPredicate;
> +    import java.util.function.Predicate;
> +
> -    public class FakeFeatureFlagsImpl implements FeatureFlags {
> -        public FakeFeatureFlagsImpl() {
> -            resetAll();
> +    public class CustomFeatureFlags implements FeatureFlags {
> +
> +        private BiPredicate<String, Predicate<FeatureFlags>> mGetValueImpl;
> +
> +        public CustomFeatureFlags(BiPredicate<String, Predicate<FeatureFlags>> getValueImpl) {
> +            mGetValueImpl = getValueImpl;
> +
> -            return getValue(Flags.FLAG_DISABLED_RO);
> +            return getValue(Flags.FLAG_DISABLED_RO,
> +                    FeatureFlags::disabledRo);
> -            return getValue(Flags.FLAG_DISABLED_RW);
> +            return getValue(Flags.FLAG_DISABLED_RW,
> +                FeatureFlags::disabledRw);
> -            return getValue(Flags.FLAG_DISABLED_RW_EXPORTED);
> +            return getValue(Flags.FLAG_DISABLED_RW_EXPORTED,
> +                FeatureFlags::disabledRwExported);
> -            return getValue(Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE);
> +            return getValue(Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE,
> +                FeatureFlags::disabledRwInOtherNamespace);
> -            return getValue(Flags.FLAG_ENABLED_FIXED_RO);
> +            return getValue(Flags.FLAG_ENABLED_FIXED_RO,
> +                FeatureFlags::enabledFixedRo);
> -            return getValue(Flags.FLAG_ENABLED_FIXED_RO_EXPORTED);
> +            return getValue(Flags.FLAG_ENABLED_FIXED_RO_EXPORTED,
> +                FeatureFlags::enabledFixedRoExported);
> -            return getValue(Flags.FLAG_ENABLED_RO);
> +            return getValue(Flags.FLAG_ENABLED_RO,
> +                FeatureFlags::enabledRo);
> -            return getValue(Flags.FLAG_ENABLED_RO_EXPORTED);
> +            return getValue(Flags.FLAG_ENABLED_RO_EXPORTED,
> +                FeatureFlags::enabledRoExported);
> -            return getValue(Flags.FLAG_ENABLED_RW);
> +            return getValue(Flags.FLAG_ENABLED_RW,
> +                FeatureFlags::enabledRw);
> -        public void setFlag(String flagName, boolean value) {
> -            if (!this.mFlagMap.containsKey(flagName)) {
> -                throw new IllegalArgumentException("no such flag " + flagName);
> -            }
> -            this.mFlagMap.put(flagName, value);
> -        }
> -        public void resetAll() {
> -            for (Map.Entry entry : mFlagMap.entrySet()) {
> -                entry.setValue(null);
> -            }
> -        }
> +
> +
> -        private boolean getValue(String flagName) {
> -            Boolean value = this.mFlagMap.get(flagName);
> -            if (value == null) {
> -                throw new IllegalArgumentException(flagName + " is not set");
> -            }
> -            return value;
> +
> +        protected boolean getValue(String flagName, Predicate<FeatureFlags> getter) {
> +            return mGetValueImpl.test(flagName, getter);
> -        private Map<String, Boolean> mFlagMap = new HashMap<>(
> -            Map.ofEntries(
> -                Map.entry(Flags.FLAG_DISABLED_RO, false),
> -                Map.entry(Flags.FLAG_DISABLED_RW, false),
> -                Map.entry(Flags.FLAG_DISABLED_RW_EXPORTED, false),
> -                Map.entry(Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE, false),
> -                Map.entry(Flags.FLAG_ENABLED_FIXED_RO, false),
> -                Map.entry(Flags.FLAG_ENABLED_FIXED_RO_EXPORTED, false),
> -                Map.entry(Flags.FLAG_ENABLED_RO, false),
> -                Map.entry(Flags.FLAG_ENABLED_RO_EXPORTED, false),
> -                Map.entry(Flags.FLAG_ENABLED_RW, false)
> -            )
> -        );
> +
> +        public List<String> getFlagNames() {
> +            return Arrays.asList(
> +                Flags.FLAG_DISABLED_RO,
> +                Flags.FLAG_DISABLED_RW,
> +                Flags.FLAG_DISABLED_RW_EXPORTED,
> +                Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE,
> +                Flags.FLAG_ENABLED_FIXED_RO,
> +                Flags.FLAG_ENABLED_FIXED_RO_EXPORTED,
> +                Flags.FLAG_ENABLED_RO,
> +                Flags.FLAG_ENABLED_RO_EXPORTED,
> +                Flags.FLAG_ENABLED_RW
> +            );
> +        }
> +
> +    const EXPECTED_FAKEFEATUREFLAGSIMPL_CONTENT: &str = r#"
> +    package com.android.aconfig.test;
> +
> +    import java.util.HashMap;
> +    import java.util.Map;
> +    import java.util.function.Predicate;
> +
> +    /** @hide */
> +    public class FakeFeatureFlagsImpl extends CustomFeatureFlags {
> +        private Map<String, Boolean> mFlagMap = new HashMap<>();
> +
> +        public FakeFeatureFlagsImpl() {
> +            super(null);
> +            // Initialize the map with null values
> +            for (String flagName : getFlagNames()) {
> +                mFlagMap.put(flagName, null);
> +            }
> +        }
> +
> +        @Override
> +        protected boolean getValue(String flagName, Predicate<FeatureFlags> getter) {
> +            Boolean value = this.mFlagMap.get(flagName);
> +            if (value == null) {
> +                throw new IllegalArgumentException(flagName + " is not set");
> +            }
> +            return value;
> +        }
> +
> +        public void setFlag(String flagName, boolean value) {
> +            if (!this.mFlagMap.containsKey(flagName)) {
> +                throw new IllegalArgumentException("no such flag " + flagName);
> +            }
> +            this.mFlagMap.put(flagName, value);
> +        }
> +
> +        public void resetAll() {
> +            for (Map.Entry entry : mFlagMap.entrySet()) {
> +                entry.setValue(null);
> +            }
> +        }
> +    }
> +    "#;
> +
> +                "com/android/aconfig/test/CustomFeatureFlags.java",
> +                EXPECTED_CUSTOMFEATUREFLAGS_CONTENT,
> +            ),
> +            (
> -        let expect_fake_feature_flags_impl_content = r#"
> +        let expect_custom_feature_flags_content = r#"
> +
> -        import java.util.HashMap;
> -        import java.util.Map;
> +        import java.util.List;
> +        import java.util.function.BiPredicate;
> +        import java.util.function.Predicate;
> +
> -        public class FakeFeatureFlagsImpl implements FeatureFlags {
> -            public FakeFeatureFlagsImpl() {
> -                resetAll();
> +        public class CustomFeatureFlags implements FeatureFlags {
> +
> +            private BiPredicate<String, Predicate<FeatureFlags>> mGetValueImpl;
> +
> +            public CustomFeatureFlags(BiPredicate<String, Predicate<FeatureFlags>> getValueImpl) {
> +                mGetValueImpl = getValueImpl;
> +
> -                return getValue(Flags.FLAG_DISABLED_RW_EXPORTED);
> +                return getValue(Flags.FLAG_DISABLED_RW_EXPORTED,
> +                    FeatureFlags::disabledRwExported);
> -                return getValue(Flags.FLAG_ENABLED_FIXED_RO_EXPORTED);
> +                return getValue(Flags.FLAG_ENABLED_FIXED_RO_EXPORTED,
> +                    FeatureFlags::enabledFixedRoExported);
> -                return getValue(Flags.FLAG_ENABLED_RO_EXPORTED);
> +                return getValue(Flags.FLAG_ENABLED_RO_EXPORTED,
> +                    FeatureFlags::enabledRoExported);
> -            public void setFlag(String flagName, boolean value) {
> -                if (!this.mFlagMap.containsKey(flagName)) {
> -                    throw new IllegalArgumentException("no such flag " + flagName);
> -                }
> -                this.mFlagMap.put(flagName, value);
> +
> +            protected boolean getValue(String flagName, Predicate<FeatureFlags> getter) {
> +                return mGetValueImpl.test(flagName, getter);
> -            public void resetAll() {
> -                for (Map.Entry entry : mFlagMap.entrySet()) {
> -                    entry.setValue(null);
> -                }
> +
> +            public List<String> getFlagNames() {
> +                return Arrays.asList(
> +                    Flags.FLAG_DISABLED_RW_EXPORTED,
> +                    Flags.FLAG_ENABLED_FIXED_RO_EXPORTED,
> +                    Flags.FLAG_ENABLED_RO_EXPORTED
> +                );
> -            private boolean getValue(String flagName) {
> -                Boolean value = this.mFlagMap.get(flagName);
> -                if (value == null) {
> -                    throw new IllegalArgumentException(flagName + " is not set");
> -                }
> -                return value;
> -            }
> -            private Map<String, Boolean> mFlagMap = new HashMap<>(
> -                Map.ofEntries(
> -                    Map.entry(Flags.FLAG_DISABLED_RW_EXPORTED, false),
> -                    Map.entry(Flags.FLAG_ENABLED_FIXED_RO_EXPORTED, false),
> -                    Map.entry(Flags.FLAG_ENABLED_RO_EXPORTED, false)
> -                )
> -            );
> +
> +                "com/android/aconfig/test/CustomFeatureFlags.java",
> +                expect_custom_feature_flags_content,
> +            ),
> +            (
> -                expect_fake_feature_flags_impl_content,
> +                EXPECTED_FAKEFEATUREFLAGSIMPL_CONTENT,
> +                "com/android/aconfig/test/CustomFeatureFlags.java",
> +                EXPECTED_CUSTOMFEATUREFLAGS_CONTENT,
> +            ),
> +            (
> -        let expect_fakefeatureflags_content = r#"
> +        let expect_customfeatureflags_content = r#"
> +
> -        import java.util.HashMap;
> -        import java.util.Map;
> +        import java.util.List;
> +        import java.util.function.BiPredicate;
> +        import java.util.function.Predicate;
> +
> -        public class FakeFeatureFlagsImpl implements FeatureFlags {
> -            public FakeFeatureFlagsImpl() {
> -                resetAll();
> +        public class CustomFeatureFlags implements FeatureFlags {
> +
> +            private BiPredicate<String, Predicate<FeatureFlags>> mGetValueImpl;
> +
> +            public CustomFeatureFlags(BiPredicate<String, Predicate<FeatureFlags>> getValueImpl) {
> +                mGetValueImpl = getValueImpl;
> +
> -                return getValue(Flags.FLAG_DISABLED_RO);
> +                return getValue(Flags.FLAG_DISABLED_RO,
> +                        FeatureFlags::disabledRo);
> -                return getValue(Flags.FLAG_DISABLED_RW);
> +                return getValue(Flags.FLAG_DISABLED_RW,
> +                    FeatureFlags::disabledRw);
> -                return getValue(Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE);
> +                return getValue(Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE,
> +                    FeatureFlags::disabledRwInOtherNamespace);
> -                return getValue(Flags.FLAG_ENABLED_FIXED_RO);
> +                return getValue(Flags.FLAG_ENABLED_FIXED_RO,
> +                    FeatureFlags::enabledFixedRo);
> -                return getValue(Flags.FLAG_ENABLED_RO);
> +                return getValue(Flags.FLAG_ENABLED_RO,
> +                    FeatureFlags::enabledRo);
> -                return getValue(Flags.FLAG_ENABLED_RW);
> +                return getValue(Flags.FLAG_ENABLED_RW,
> +                    FeatureFlags::enabledRw);
> -            public void setFlag(String flagName, boolean value) {
> -                if (!this.mFlagMap.containsKey(flagName)) {
> -                    throw new IllegalArgumentException("no such flag " + flagName);
> -                }
> -                this.mFlagMap.put(flagName, value);
> -            }
> -            public void resetAll() {
> -                for (Map.Entry entry : mFlagMap.entrySet()) {
> -                    entry.setValue(null);
> -                }
> -            }
> +
> +
> -            private boolean getValue(String flagName) {
> -                Boolean value = this.mFlagMap.get(flagName);
> -                if (value == null) {
> -                    throw new IllegalArgumentException(flagName + " is not set");
> -                }
> -                return value;
> +
> +            protected boolean getValue(String flagName, Predicate<FeatureFlags> getter) {
> +                return mGetValueImpl.test(flagName, getter);
> -            private Map<String, Boolean> mFlagMap = new HashMap<>(
> -                Map.ofEntries(
> -                    Map.entry(Flags.FLAG_DISABLED_RO, false),
> -                    Map.entry(Flags.FLAG_DISABLED_RW, false),
> -                    Map.entry(Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE, false),
> -                    Map.entry(Flags.FLAG_ENABLED_FIXED_RO, false),
> -                    Map.entry(Flags.FLAG_ENABLED_RO, false),
> -                    Map.entry(Flags.FLAG_ENABLED_RW, false)
> -                )
> -            );
> +
> +            public List<String> getFlagNames() {
> +                return Arrays.asList(
> +                    Flags.FLAG_DISABLED_RO,
> +                    Flags.FLAG_DISABLED_RW,
> +                    Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE,
> +                    Flags.FLAG_ENABLED_FIXED_RO,
> +                    Flags.FLAG_ENABLED_RO,
> +                    Flags.FLAG_ENABLED_RW
> +                );
> +            }
> +
> +
> -            ("com/android/aconfig/test/FakeFeatureFlagsImpl.java", expect_fakefeatureflags_content),
> +            ("com/android/aconfig/test/CustomFeatureFlags.java", expect_customfeatureflags_content),
> +            (
> +                "com/android/aconfig/test/FakeFeatureFlagsImpl.java",
> +                EXPECTED_FAKEFEATUREFLAGSIMPL_CONTENT,
> +            ),
> --- /dev/null
> +++ tools/aconfig/aconfig/templates/CustomFeatureFlags.java.template
> +package {package_name};
> +
> +{{ if not library_exported- }}
> +// TODO(b/303773055): Remove the annotation after access issue is resolved.
> +import android.compat.annotation.UnsupportedAppUsage;
> +{{ -endif }}
> +import java.util.Arrays;
> +import java.util.HashSet;
> +import java.util.List;
> +import java.util.Set;
> +import java.util.function.BiPredicate;
> +import java.util.function.Predicate;
> +
> +/** @hide */
> +public class CustomFeatureFlags implements FeatureFlags \{
> +
> +    private BiPredicate<String, Predicate<FeatureFlags>> mGetValueImpl;
> +
> +    public CustomFeatureFlags(BiPredicate<String, Predicate<FeatureFlags>> getValueImpl) \{
> +        mGetValueImpl = getValueImpl;
> +    }
> +
> +{{ -for item in flag_elements}}
> +    @Override
> +{{ if not library_exported }}    @UnsupportedAppUsage{{ -endif }}
> +    public boolean {item.method_name}() \{
> +        return getValue(Flags.FLAG_{item.flag_name_constant_suffix},
> +            FeatureFlags::{item.method_name});
> +    }
> +{{ endfor }}
> +
> +{{ -if not library_exported }}
> +    public boolean isFlagReadOnlyOptimized(String flagName) \{
> +        if (mReadOnlyFlagsSet.contains(flagName) &&
> +            isOptimizationEnabled()) \{
> +                return true;
> +        }
> +        return false;
> +    }
> +
> +    @com.android.aconfig.annotations.AssumeTrueForR8
> +    private boolean isOptimizationEnabled() \{
> +        return false;
> +    }
> +{{ -endif }}
> +
> +    protected boolean getValue(String flagName, Predicate<FeatureFlags> getter) \{
> +        return mGetValueImpl.test(flagName, getter);
> +    }
> +
> +    public List<String> getFlagNames() \{
> +        return Arrays.asList(
> +            {{ -for item in flag_elements }}
> +            Flags.FLAG_{item.flag_name_constant_suffix}
> +            {{ -if not @last }},{{ endif }}
> +            {{ -endfor }}
> +        );
> +    }
> +
> +    private Set<String> mReadOnlyFlagsSet = new HashSet<>(
> +        Arrays.asList(
> +            {{ -for item in flag_elements }}
> +            {{ -if not item.is_read_write }}
> +            Flags.FLAG_{item.flag_name_constant_suffix},
> +            {{ -endif }}
> +            {{ -endfor }}
> +            ""{# The empty string here is to resolve the ending comma #}
> +        )
> +    );
> +}
> --- tools/aconfig/aconfig/templates/FakeFeatureFlagsImpl.java.template
> +++ tools/aconfig/aconfig/templates/FakeFeatureFlagsImpl.java.template
> -{{ if not library_exported- }}
> -// TODO(b/303773055): Remove the annotation after access issue is resolved.
> -import android.compat.annotation.UnsupportedAppUsage;
> -{{ -endif }}
> -import java.util.Arrays;
> +
> -import java.util.HashSet;
> -import java.util.Set;
> +import java.util.function.Predicate;
> -public class FakeFeatureFlagsImpl implements FeatureFlags \{
> +public class FakeFeatureFlagsImpl extends CustomFeatureFlags \{
> +    private Map<String, Boolean> mFlagMap = new HashMap<>();
> +
> -        resetAll();
> +        super(null);
> +        // Initialize the map with null values
> +        for (String flagName : getFlagNames()) \{
> +            mFlagMap.put(flagName, null);
> +        }
> -{{ for item in flag_elements}}
> -{{ if not library_exported }}    @UnsupportedAppUsage{{ -endif }}
> -    public boolean {item.method_name}() \{
> -        return getValue(Flags.FLAG_{item.flag_name_constant_suffix});
> +    protected boolean getValue(String flagName, Predicate<FeatureFlags> getter) \{
> +        Boolean value = this.mFlagMap.get(flagName);
> +        if (value == null) \{
> +            throw new IllegalArgumentException(flagName + " is not set");
> +        }
> +        return value;
> -{{ endfor}}
> +
> -{{ if not library_exported }}
> -    public boolean isFlagReadOnlyOptimized(String flagName) \{
> -        if (mReadOnlyFlagsSet.contains(flagName) &&
> -            isOptimizationEnabled()) \{
> -                return true;
> -        }
> -        return false;
> -    }
> -
> -    @com.android.aconfig.annotations.AssumeTrueForR8
> -    private boolean isOptimizationEnabled() \{
> -        return false;
> -    }
> -{{ -endif }}
> -    private boolean getValue(String flagName) \{
> -        Boolean value = this.mFlagMap.get(flagName);
> -        if (value == null) \{
> -            throw new IllegalArgumentException(flagName + " is not set");
> -        }
> -        return value;
> -    }
> -
> -
> -    private Map<String, Boolean> mFlagMap = new HashMap<>(
> -        Map.ofEntries(
> -            {{ -for item in flag_elements }}
> -            Map.entry(Flags.FLAG_{item.flag_name_constant_suffix}, false)
> -            {{ -if not @last }},{{ endif }}
> -            {{ -endfor }}
> -        )
> -    );
> -
> -    private Set<String> mReadOnlyFlagsSet = new HashSet<>(
> -        Arrays.asList(
> -            {{ -for item in flag_elements }}
> -            {{ -if not item.is_read_write }}
> -            Flags.FLAG_{item.flag_name_constant_suffix},
> -            {{ -endif }}
> -            {{ -endfor }}
> -            ""{# The empty string here is to resolve the ending comma #}
> -        )
> -    );

Original patch:
 diff --git a/tools/aconfig/aconfig/src/codegen/java.rs b/tools/aconfig/aconfig/src/codegen/java.rs
old mode 100644
new mode 100644
--- a/tools/aconfig/aconfig/src/codegen/java.rs
+++ b/tools/aconfig/aconfig/src/codegen/java.rs
@@ -63,21 +63,28 @@
         "FeatureFlags.java",
         include_str!("../../templates/FeatureFlags.java.template"),
     )?;
+    template.add_template(
+        "CustomFeatureFlags.java",
+        include_str!("../../templates/CustomFeatureFlags.java.template"),
+    )?;
     template.add_template(
         "FakeFeatureFlagsImpl.java",
         include_str!("../../templates/FakeFeatureFlagsImpl.java.template"),
     )?;
 
     let path: PathBuf = package.split('.').collect();
-    ["Flags.java", "FeatureFlags.java", "FeatureFlagsImpl.java", "FakeFeatureFlagsImpl.java"]
-        .iter()
-        .map(|file| {
-            Ok(OutputFile {
-                contents: template.render(file, &context)?.into(),
-                path: path.join(file),
-            })
-        })
-        .co
[[[Original patch trimmed due to size. Decoded string size: 26318. Decoded string SHA1: 7db34b7baf0a0bbaa1cff48b6ccab9c65408e743.]]]

Result patch:
 diff --git a/tools/aconfig/aconfig/src/codegen/java.rs b/tools/aconfig/aconfig/src/codegen/java.rs
index 18a4be5..9abc892 100644
--- a/tools/aconfig/aconfig/src/codegen/java.rs
+++ b/tools/aconfig/aconfig/src/codegen/java.rs
@@ -64,20 +64,27 @@
         include_str!("../../templates/FeatureFlags.java.template"),
     )?;
     template.add_template(
+        "CustomFeatureFlags.java",
+        include_str!("../../templates/CustomFeatureFlags.java.template"),
+    )?;
+    template.add_template(
         "FakeFeatureFlagsImpl.java",
         include_str!("../../templates/FakeFeatureFlagsImpl.java.template"),
     )?;
 
     let path: PathBuf = package.split('.').collect();
-    ["Flags.java", "FeatureFlags.java", "FeatureFlagsImpl.java", "FakeFeatureFlagsImpl.java"]
-        .iter()
-        .map(|file| {
-            Ok(OutputFile {
-                contents: template.render(file, &context)?.into(),
-                path: path.join(file),
-            })
-        })
-        .collect::<Result<Vec<OutputFile>>>
[[[Result patch trimmed due to size. Decoded string size: 26308. Decoded string SHA1: bb07ee948a630a6bc4cfbbf2a8df178f3e6d3103.]]]

Change-Id: I94184633303b9d76f7943451fb3b2c93d071ec1c
2024-04-24 14:43:27 +00:00
Fabián Cañas
e0c74fbdd6 Merge "Add --unused parameter to whichgit" into main 2024-04-24 13:11:08 +00:00
Fabián Cañas
97ea68aea6 Add --unused parameter to whichgit
The --unused parameter inverts the output of whichgit, reporting which
git projects are not used for a given build target.

Test: build/make/tools/whichgit --unused
Test: build/make/tools/whichgit --unused --modules framework

Existing use-cases should remain unchanged:

Test: build/make/tools/whichgit --modules framework
Change-Id: Ia4e55a5cb0331d522fed76821fe813ef98c25a67
2024-04-23 21:28:29 -04:00
Michael Wright
c55d79b7c7 Make check-flagged-apis executable
Occasionally sourcing the script would close my overall shell when it
hit an error. By having it just be an executable script, this prevents
it from impacting a user's normal shell environment and can depend on it
always being bash, rather than whatever shell people happen to be using.

Bug: 334870672
Test: tools/check-flagged-apis/check-flagged-apis.sh
Change-Id: Ic46cb4fefdea8d51be018d4f7a92b0d9ca7e57b3
2024-04-24 01:05:49 +02:00
Ted Bauer
171944d88a Merge "Update aconfig storage deps for CPP codegen" into main 2024-04-23 22:56:50 +00:00
Treehugger Robot
6974bbf7ee Merge "Update sdk finalizer to change soong instead of bazel" into main 2024-04-23 20:26:05 +00:00
Dennis Shen
59274f816c Merge "aconfig: remove cache filtering by container" into main 2024-04-23 20:17:35 +00:00
Michael Merg
c9d54b0877 Merge "Set enforce SOONG_GEN_COMPDB=1 when running soong for ide_query" into main 2024-04-23 19:59:04 +00:00
Jihoon Kang
ed37595aaf Update sdk finalizer to change soong instead of bazel
Update the map in soong instead of that in bazel

Bug: 315353489
Test: manual
Merged-In: I3a51be1119109d2a6cf3959bdc8a48192872580f
Change-Id: Ia61a17be4a7d85c00d2e9758ea2409019d451dfd
2024-04-23 19:53:46 +00:00
Dennis Shen
67e44dd2c3 Merge "aconfig: update flag info storage file" into main 2024-04-23 18:08:13 +00:00
Ted Bauer
8d20d51bf8 Update aconfig storage deps for CPP codegen
Bug: 328444881
Test: m AconfigDemoActivity
Change-Id: I12d746d3270dce39533e1afd213343e232044161
2024-04-23 18:07:40 +00:00
Dennis Shen
1ebcd017ae aconfig: remove cache filtering by container
No need for cache filtering based on container anymore. This is now
performed by build system automatically. The caches feed into storage
generation command are automatically filtered based on owning
container.

Bug: b/312444587
Test: atest aconfig.test
Change-Id: I44f3ac03d50b77a191a82ff7ed4d02766012492d
2024-04-19 21:44:32 +00:00
Treehugger Robot
563a2f62c5 Merge "fixup! Support generating partial OTAs from extracted target_files" into main 2024-04-19 16:19:32 +00:00
Michael Wright
2d3e50527d Merge changes I8b5e2642,I0520ab0f into main
* changes:
  check-flagged-apis: add script to run tool on actual data
  check-flagged-apis: simplify unit test dependencies
2024-04-19 15:25:22 +00:00
Dennis Shen
6f4c692948 aconfig: update flag info storage file
previously we store three bits per flag: is sticky, is read write, has
override. so when a local override arrives, is sticky bit as well has
override bit are set to true. this becomes problematic when the local
override is removed. we are not sure if we should remove has override
bit as well (server override could still be in place).

therefore restructuring the flag info for each flag into new three bits:
is read write, has server override and has local override. so now server
override and local override bits are independent from each other.

Bug: b/312444587
Test: atest -c
Change-Id: I03b2bb7312480773236c95f2b39f2589fee41924
2024-04-18 21:22:49 +00:00
Chirayu Desai
c8edf8af33 fixup! Support generating partial OTAs from extracted target_files
Test: Sign crosshatch
Change-Id: I6728da3a3a50ee24a35581af7e6ead3e13c5ff1d
2024-04-19 02:49:17 +05:30
Ted Bauer
206d44aff5 aflags: read protos from all containers
Create one library for reading protos from all containers, instead of
having numerous libraries perform the same logic. For Java, we will
create a similar library reusing the same
partition_aconfig_flags_paths.txt.

Bug: 324436145
Test: adb shell aflags list # Confirm that various containers appear
Change-Id: I924e281a50f9a609e1c07c03267eebe3dce52752
2024-04-18 14:38:41 +00:00
Mårten Kongstad
76460bd770 check-flagged-apis: add script to run tool on actual data
Add a script to make it easier to check-flagged-apis for the public APIs
and the three flavours of @FlaggedApi.

Bug: 334870672
Test: lunch sdk-next-eng && source check-flagged-apis.sh
Change-Id: I8b5e2642ade84560c5c61ae49d8c0dcdedb841ca
2024-04-18 16:13:52 +02:00
Michael Merg
75d934f261 Set enforce SOONG_GEN_COMPDB=1 when running soong for ide_query
Change-Id: I125a82fb07285bf53e9a6d591dee69d85ee82050
2024-04-18 12:06:31 +00:00
Mårten Kongstad
7cc217459a check-flagged-apis: simplify unit test dependencies
Replace the current unit test runner DeviceJUnit4ClassRunner with JUnit4
and replace the (larger) dependency tradefed with the (smaller)
dependency junit.

This has no impact other than minimizing the unit test static_libs.

Bug: 334870672
Test: atest --host check-flagged-apis-test
Change-Id: I0520ab0feeea5ea2ed15905136ba2647f86162cb
2024-04-18 10:25:33 +02:00
Dennis Shen
e6b424ad4a Merge "aconfig: add support for local override" into main 2024-04-17 19:07:56 +00:00
Mårten Kongstad
9238a3ab76 check-flagged-apis: create list of @FlaggedApi errors
Teach check-flagged-apis to cross-check the data from its three input
sources. This allows the tool to detect

  - @FlaggedApi references to non-existent flags
  - @FlaggedApi APIs present in the build artifacts even though the flag
    is disabled
  - @FlaggedApi APIs not present in the build artifacts even though the
    flag is enabled

By passing in different sources, the tool can detect these errors for
any of the API surfaces (public, @SystemApi(MODULE_LIBRARIES), etc).

Note: the tool assumes that a disabled flag means that the @FlaggedApi
should not be present in the build output. This is currently true, but
won't be once metalava starts reverting @FlaggedApis to their previous
SDK snapshot.

Bug: 334870672
Test: atest --host check-flagged-apis-test
Test: check-flagged-apis --api-signature out/target/product/mainline_x86/obj/ETC/frameworks-base-api-current.txt_intermediates/frameworks-base-api-current.txt --flag-values out/soong/.intermediates/all_aconfig_declarations.pb --api-versions out/dist/data/api-versions.xml
Change-Id: I790234865f831af7d45895def14d1d6740365622
2024-04-17 16:40:03 +02:00
Mårten Kongstad
b673d3bb7d check-flagged-apis: parse API versions XML
Teach check-flagged-apis to parse API versions XML; this represents the
APIs after metalava has processed the source and kept APIs as is, or
reverted them to the previous SDK snapshot, according to their
@FlaggedApi flags.

As with the API signature parser, limit support to fields to keep things
simple; support for classes and methods will be added in later CLs.

Note: `m sdk dist` will generate an API versions XML file.

Bug: 334870672
Test: atest --host check-flagged-apis-test
Test: check-flagged-apis --api-signature out/target/product/mainline_x86/obj/ETC/frameworks-base-api-current.txt_intermediates/frameworks-base-api-current.txt --flag-values out/soong/.intermediates/all_aconfig_declarations.pb --api-versions out/dist/data/api-versions.xml
Change-Id: I779a0d0cdb8a50536d3fc8d517fa38ba4b0dcd1c
2024-04-17 15:27:48 +02:00
Mårten Kongstad
387ff6cfe8 check-flagged-apis: parse flag names and values
Teach check-flagged-apis to parse the parsed_flags protobuf generated by
aconfig.

Note: `m all_aconfig_declarations` generates a protobuf file that
contains all info about all flags.

Bug: 334870672
Test: atest --host check-flagged-apis-test
Test: check-flagged-apis --api-signature out/target/product/mainline_x86/obj/ETC/frameworks-base-api-current.txt_intermediates/frameworks-base-api-current.txt --flag-values out/soong/.intermediates/all_aconfig_declarations.pb
Change-Id: I397b32ae2a373b429ef6ce22e0a06a0f15202b91
2024-04-17 15:27:48 +02:00
Mårten Kongstad
20de405dd5 check-flagged-apis: parse API signature files
Teach check-flagged-apis to extract flagged APIs from API signature files.

To keep things simple, only consider fields for now: support for classes
and methods will be added in a later CL.

Note: `m frameworks-base-api-current.txt` will generate an API signature
file that includes both the platform and mainline APIs.

Bug: 334870672
Test: atest --host check-flagged-apis-test
Test: check-flagged-apis --api-signature out/target/product/mainline_x86/obj/ETC/frameworks-base-api-current.txt_intermediates/frameworks-base-api-current.txt
Change-Id: Ic244b896672569f44af793796189b34c1f9d0c36
2024-04-17 15:27:48 +02:00
Mårten Kongstad
f242ec8989 check-flagged-apis: add unit test infrastructure
Add scaffolding for unit tests.

Bug: 334870672
Test: atest --host check-flagged-apis-test
Change-Id: I5ccf2a6424c19e739923379cdc41c359388484da
2024-04-17 15:27:45 +02:00
Dennis Shen
9f236037a2 aconfig: add support for local override
1, add a new field in storage metadata proto, for each container, there
is a local override file.

2, update write api to expose the api to map a writable file given the
specific path. the cannonical api will require a storage metadata proto,
and then find the right file path and map it.

3, minor update to make the proto lib cc_library instead of
cc_library_static

Bug: b/312444587
Test: atest -c
Change-Id: Iaf0aff44c1ca3ad4bffc5e06bb99bb276b9069c5
2024-04-17 12:25:11 +00:00
Mårten Kongstad
dc3fc2e0bc check-flagged-apis: add Flag value class
Add a value class to represent Flag names. We could use plain Strings
but having a dedicated class (with no overhead compared to String) makes
the intent of the code much clearer.

Bug: 334870672
Test: m check-flagged-apis && check-flagged-apis
Change-Id: Icdd4fb97d3fd49e507b7559504ea173a3dc52dea
2024-04-17 09:54:53 +02:00
Mårten Kongstad
e0179976cd check-flagged-apis: add Symbol value class
check-flagged-apis will read contents from various sources, which use
different formats to represent the same piece information (e.g.
"class#field" or "<class><field>").

Introduce a Symbol value class to represent any API (i.e. a class, field
or method) in a unified format.

Bug: 334870672
Test: m check-flagged-apis && check-flagged-apis
Change-Id: Id9404294a87b23a9d43e5e13ce39ea5a92608e33
2024-04-17 09:54:53 +02:00
Mårten Kongstad
4feb33fefc Merge "check-flagged-apis: add support for command line options" into main 2024-04-17 05:52:09 +00:00
Mårten Kongstad
e2ec38c51b Merge "check-flagged-apis: add new CLI to verify @FlaggedApi APIs" into main 2024-04-17 05:51:48 +00:00
Daniel Zheng
2fc519a568 Merge "ota_from_target_files: read correct api level" into main 2024-04-16 19:32:37 +00:00
Daniel Zheng
dc411eda4c ota_from_target_files: read correct api level
ro.product.first_api_level looks like the value we actually want to read
to since it inherits from $PRODUCT_SHIPPING_API_LEVEL. Other variables
we attempted to look at were giving other values (e.g 202504 for pixel
watch)

Bug: 331202590
Test: th
Change-Id: Ied3da247cba45611132db6c9e3cdefb447891f96
2024-04-16 12:32:05 -07:00
Mårten Kongstad
acfeb11d86 check-flagged-apis: add support for command line options
Use clikt as the command line options parser library.

Bug: 334870672
Test: m check-flagged-apis && check-flagged-apis
Change-Id: I7c406456b00e29293294dcdbef411d2543a1e8d5
2024-04-16 10:32:17 +02:00
Mårten Kongstad
9008724b50 check-flagged-apis: add new CLI to verify @FlaggedApi APIs
Add a new CLI to verify that the build artifacts contain the right set
of @FlaggedApi APIs, based on the value of the corresponding aconfig
flag.

This CLI will act as an end-to-end test of Soong and metalava.

This CL only adds the project scaffolding; later CLs will add the
implementation.

Bug: 334870672
Test: m check-flagged-apis && check-flagged-apis
Change-Id: Ib00653f2a549217da2b0058867c711f35efd5760
2024-04-16 10:32:17 +02:00
Treehugger Robot
8b1e29ae7e Merge "Make output of MakeVbmeta consistent" into main 2024-04-15 22:27:36 +00:00
Ted Bauer
8f9ca8075f Merge "aconfig: switch read api lib to cc_library" into main 2024-04-15 17:22:00 +00:00
Kelvin Zhang
1d9b3daad2 Make output of MakeVbmeta consistent
The order of items in `partitions` map is non-deterministic. To make
sure that builds are hermetic, sort the map before use.

Test: th
Bug: 332550989
Change-Id: I76c7037ef9f03904899339813819fcf985a7c893
2024-04-15 09:45:03 -07:00
Dennis Shen
36661d4cd0 aconfig: switch read api lib to cc_library
Bug: b/321077378
Test: atest -c
Change-Id: I8d64396797b01a8ce2f4bee165596701940836e4
2024-04-12 21:21:44 +00:00
Dennis Shen
7d642b10df Merge "aconfig: add write api cpp test to presubmit" into main 2024-04-12 18:26:55 +00:00
Dennis Shen
e8fa42f45a aconfig: add write api cpp test to presubmit
Bug: b/321077378
Test atest -c

Change-Id: Ib04280f25eb6c4de6ff1523579e6ac96a868ff1d
2024-04-12 16:57:28 +00:00
Dennis Shen
f17dbcd8b7 aconfig: update flag info query api
Currently flag info query api is called get_boolean_flag_attribute, in
this change, we switched it over to a flag value type generic
implementation get_flag_attribute. So in the future we want to add more flag value types, this api can stay the same.

Bug: b/312444587
Test: atest -c
Change-Id: I2b272f3fa3cb1d0edc8b77a44bf37752ffe95925
2024-04-12 16:28:10 +00:00
Nariyasu Heseri
5ffefcc642 Ensure insertion order of Python dict
Add keys to the dict `partitions` in serial to have a deterministic
insertion order.
This guarantees the generated vbmeta.img is always the same on the same
input, fixing image consistency issues.

Reference:
https://android-review.googlesource.com/c/platform/build/+/2585397

Bug: 332550989
Test: Generate vbmeta several times, confirm identical result.
Change-Id: I39da5844045f497fdc89e6477a7e32ddacb70764
2024-04-12 07:57:37 +00:00
Dennis Shen
d74941b42d aconfig: create flag info file write c api
Bug: b/312444587
Test: atest -c
Change-Id: I310e1ed727ced454bec2016afe48f7a29561fac3
2024-04-11 20:23:22 +00:00
Dennis Shen
4647c0e1f0 aconfig: create flag info file write rust api
Bug: b/312444587
Test: atest aconfig_storage_write_api.test; atest
aconfig_storage_write_api.test.rust

Change-Id: Icbedc78ae78b2c7590539f008521c507c2b3df5b
2024-04-11 20:23:00 +00:00
Dennis Shen
d22eee50fa Merge changes from topic "index_instead_of_offset" into main
* changes:
  aconfig: update storage write api
  aconfig: update storage read api
  aconfig: update storage file creation to allow storage files to store flag index instead of byte offset
  aconfig: update storage file to store flag index instead of file byte offset
2024-04-10 18:53:43 +00:00
Daniel Zheng
e836a3a2e4 Merge "zstd negative compression support" into main 2024-04-10 17:56:45 +00:00
Daniel Zheng
d919100382 zstd negative compression support
supporting negative compression levels in ota_from_target_files in the
format of zstd,-$compression_level

Test: ota_from_target_files
Change-Id: If2ca592829f10e7a0226cb41680cb47223d17c71
2024-04-10 10:54:51 -07:00
Dennis Shen
0efe47967b aconfig: update storage write api
Now we are storing flag index instead of flag byte offset in storage
files, need to update storage write api accordingly.

Bug: b/321077378
Test: atest -c
Change-Id: I67e55287a242df0af1925ede886f8c087d343c1f
2024-04-10 16:40:06 +00:00
Dennis Shen
b18227e8d8 aconfig: update storage read api
With the update to store flag index instead of flag byte offset in
storage file. We need to update flag read api accordingly.

Bug: b/321077378
Test: atest -c
Change-Id: Iccbf939fc5b7fe0ce0f2c33f7e3aa403c268120a
2024-04-10 16:39:21 +00:00
Dennis Shen
a8ba164422 aconfig: update storage file creation to allow storage files to store
flag index instead of byte offset

Bug: b/321077378
Test: atest -c
Change-Id: I2fbfa09ac880c172fd8e47866d9ec1449718e0b6
2024-04-10 16:37:23 +00:00
Dennis Shen
702408ecbb aconfig: update storage file to store flag index instead of file byte offset
Previously, in package.map, we store the byte offset of the first flag
in a flag package in a flag value file. In flag.map, we store the within
package flag byte offset. Once we know the total offset, we can locate
the flag in the flag value file. However, this offset may not work for
flag info file. Currently we only have boolean flags. Each boolean flag
value and info takes up 1 byte in flag value and flag info file. So the
byte offsets are the same. But in the future, when we add a new flag
value type, or add more contents to flag info file. Then the byte offset
for flag value file and flag info file may not be same.

Instead, we should store index rather than offset. The package map
should store the index of the first flag in this package. The flag map
stores the within package index. Then flag value read api and flag info
read api can then infer the byte offset independently.

Bug: b/321077378
Test: atest -c
Change-Id: Iad89776d5369715ba2d8faaea18261ac3271f13b
2024-04-10 16:36:46 +00:00
Dennis Shen
9fa78d373c aconfig: return stored flag type enum as a part of flag offset info
Bug: b/321077378
Test: atest -c
Change-Id: I25bad6b226de570eedfef4b450e09be2ac75c5eb
2024-04-10 15:14:14 +00:00
Dennis Shen
ccfb4c284f Merge changes from topic "flag_info_read_api" into main
* changes:
  aconfig: add flag info read c api
  aconfig: add flag info read rust api
2024-04-10 14:33:36 +00:00
Dennis Shen
cf7f5375be Merge "aconfig: add flag info field to proto" into main 2024-04-09 13:26:57 +00:00
Treehugger Robot
cfec7d0f7b Merge changes I1a5615e9,I01a673e7 into main
* changes:
  Remove dependency on non-AB modules
  Make build_image output consistent for partitions w/o build.prop
2024-04-08 19:57:56 +00:00
Kelvin Zhang
7a17cfd81a Remove dependency on non-AB modules
imgdiff is scheduled for removal.

Test: th
Bug: 324360816
Change-Id: I1a5615e9f5f776c16269ac8780187f97edba16f2
2024-04-08 11:08:14 -07:00
Dennis Shen
58ada6f972 aconfig: add flag info read c api
Bug: b/321077378
Test: atest aconfig_storage_read_api.test.cpp
Change-Id: If6c258429b8d8ccc872cac9f72cb533cf454ecbd
2024-04-07 20:36:25 +00:00
Dennis Shen
2ac7a4c2bd aconfig: add flag info read rust api
Bug: b/321077378
Test: atest aconfig_storage_read_api.test; atest
aconfig_storage_read_api.test.rust

Change-Id: I382ac0145c5d91827952b3ddb01cabefd1539854
2024-04-07 20:34:28 +00:00
Dennis Shen
eff5363e2d aconfig: add flag info field to proto
Bug: b/321077378
Test: m
Change-Id: I1b974f83ea49e8d4b19b3392cb7feab3d4b3fcdc
2024-04-05 16:40:43 +00:00
Dennis Shen
acfb82cf73 Merge "aconfig: move create flag info file api to aconfig_storage_write_api" into main 2024-04-05 13:59:45 +00:00
Dennis Shen
455dc608f3 aconfig: move create flag info file api to aconfig_storage_write_api
rust_ffi_static right now will export excessive symbols, this lead to a
duplication of symbols when aconfig links against both
libaconfig_storage_file_cc and libaconfig_storage_read_api_cc. This is
because aconfig_storage_read_api crate depends on aconfig_storage_file
crate. To solve this problem, move create flag info file api to
aconfig_storage_write_api crate which is parallel to
aconfig_storage_read_api crate.

Bug: b/321077378
Test: atest aconfig_storage_file.test; atest
aconfig_storage_read_api.test; atest aconfig_storage_write_api.test

Change-Id: Ibbb50193a2da82d52ccbb4087c8e3fb9f320805f
2024-04-04 21:39:04 +00:00
Zhi Dou
bc71cd03b9 aconfig: remove @com.android.aconfig.annotations.AconfigFlagAccessor from the
exported mode

The exported mode library will be dropped into google3, and there isn't
the library for this annotation.

Test: atest aconfig.test
Bug: n/a
Change-Id: I318d1c0faf232b22f42587b8ea2f976173c8554a
2024-04-04 20:21:50 +00:00
Dennis Shen
83066f6dc0 Merge "aconfig: add create_flag_info cc api" into main 2024-04-04 18:26:12 +00:00
Zhi Dou
93937ac342 Merge "aconfig: prototype AconfigFlagAccessor" into main 2024-04-03 19:17:15 +00:00
Dennis Shen
cf3042db77 Merge "aconfig: add api to create flag info file based on package map and flag map file" into main 2024-04-03 18:31:08 +00:00
Dennis Shen
2922ca9019 aconfig: add create_flag_info cc api
Bug: b/321077378
Test: atest aconfig_storage_file.test
Change-Id: I1d48311cade178f0b047a5b4d4f81c6dac4362c8
2024-04-03 18:09:39 +00:00
Treehugger Robot
6b1292065f Merge "aflags: add aflags.test to presubmit runs" into main 2024-04-03 15:45:35 +00:00
Mårten Kongstad
bf1b2ba6b2 Finalization: update OWNERS
Add new folks working on finalization, remove folks no longer working on
it.

Also, sort the entires alphabetically.

Bug: 323940469
Test: N/A
Change-Id: Ib8f6c3f485a06e3d1269e4142317174ae7ac276b
2024-04-03 17:20:42 +02:00
Ted Bauer
fb358d6a89 aflags: add aflags.test to presubmit runs
Bug: 326062088
Test: m # Also, confirm aflags.test runs in this CL
Change-Id: Ie7a1a7625163503e43d5b67d0e50554cd2a9e4cd
2024-04-03 14:02:51 +00:00
Zhi Dou
ddfd2f4889 aconfig: prototype AconfigFlagAccessor
Bug: n/a
Test: atest aconfig.test
Ignore-AOSP-First: need to submit with annotation change. will cherry pick to aosp.
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:c65c7c7f577f4140ff5632ce87a26dc98a75b8dc)
Merged-In: I62ea458c05fb61973705346c4313535f9b2291be
Change-Id: I62ea458c05fb61973705346c4313535f9b2291be
2024-04-03 13:31:57 +00:00
Dennis Shen
bb9912e551 aconfig: add api to create flag info file based on package map and flag
map file

Bug: b/321077378
Test: atest aconfig_storage_file.test
Change-Id: I957e231bc11db856a8c6753771eaafea2f168352
2024-04-02 21:39:51 +00:00
Dennis Shen
7d12daf9b4 aconfig: add flag type information to list flag api
Bug: b/321077378
Test: atest aconfig_storage_file.test
Change-Id: I1880e9aa441c423c3225a0ef86c6edde096d7ba3
2024-04-02 17:51:21 +00:00
Dennis Shen
9c7a000d6f Merge "aconfig: enable tests in presubmits" into main 2024-04-02 17:51:09 +00:00
Dennis Shen
d740c50331 Merge "aconfig: test updates" into main 2024-04-02 17:51:00 +00:00
Wei Li
20e7d0fe3d Merge "Add some comments to the field "third_party.identifier.type" in METADATA files." into main 2024-04-02 16:57:39 +00:00
Kelvin Zhang
4dc089971b Make build_image output consistent for partitions w/o build.prop
Bug: 331405669
Change-Id: I01a673e7c842a5042d85f079e29c680c4d7b589c
2024-04-02 09:05:08 -07:00
Dennis Shen
467d22f2a8 aconfig: enable tests in presubmits
Bug: b/321077378
Test: atest each test
Change-Id: Id8a47605c5642a9459d16c8414adc8590fd4c46d
2024-04-02 13:47:42 +00:00
Dennis Shen
3e4c33c1bc aconfig: test updates
Previously, three seperate crates create their own test baseline which
are nearly identical. This is inconvinent when updating the baselines.
All three locations needs to be touched. This cl merges functions to
create test storage file base struct into aconfig_storage_file crate

Bug: b/321077378
Test: atest aconfig.test
Change-Id: Ic97437f856763347a11de8b449592292014bcce3
2024-04-02 13:01:26 +00:00
Wei Li
dd020a1762 Add some comments to the field "third_party.identifier.type" in METADATA files.
Bug: 332409257
Test: CIs
Change-Id: I7db2e12e0f780003f94544177812cc3fabe2968c
2024-04-01 17:19:40 -07:00
Dennis Shen
cd381f5d64 Merge "aconfig: use an enum to represetn flag type" into main 2024-04-01 20:15:03 +00:00
Daniel Zheng
7187b548e6 Merge "Full ota v3 compatibilty check" into main 2024-04-01 19:08:30 +00:00
Daniel Zheng
2826b1a2d3 Full ota v3 compatibilty check
Check that device is shipped supporting v3 in order to enable it.
Otherwise fallback.

Bug: 331202590
Test: th
Change-Id: I218fbaa6a044420af39be70b055da5ffbfced158
2024-04-01 12:08:01 -07:00
Dennis Shen
93d11b7bc4 aconfig: use an enum to represetn flag type
Flag type is encoded as a u16 in flag table file. Previously we are
assinging value of 1 for flag type to indicate that they are all boolean
flags. In this change, we formalize the flag type designation with an
enum.

ReadWriteBoolean -> 0
ReadOnlyBoolean -> 1
FixedReadOnlyBoolean -> 2

Bug: b/321077378
Test: atest aconfg.test; atest aconfig_storage_file.test
Change-Id: I114818435b44f1e82a611f0509787993a5a8e70e
2024-04-01 18:30:06 +00:00
Dennis Shen
88899887c0 Merge "aconfig: syntax update, as_bytes to into_bytes to be more appropriate" into main 2024-04-01 17:33:46 +00:00
Lucas Henneman
83162dfcec Merge "TEST_MAPPING: fix TODO syntax" into main 2024-04-01 17:07:17 +00:00
Dennis Shen
87fc7cecd2 aconfig: syntax update, as_bytes to into_bytes to be more appropriate
Bug: b/321077378
Test: atest aconfig_storage_file.test; atest aconfig.test
Change-Id: I124387db54cd322bcce557a27c27e1b6a8c0f465
2024-04-01 15:19:13 +00:00
Dennis Shen
abf5ea2f46 Merge "aconfig_storage_file: add flag_info definition" into main 2024-04-01 14:20:34 +00:00
Lucas Henneman
6e7137c556 TEST_MAPPING: fix TODO syntax
These two TODO tags were improperly formatted, which means automation
will not alert anyone if the ticket is closed.

Bug: 327420679
Test: git diff
Change-Id: I99c8215fe3e24cdf3fa7be517291964cc5eb1ecf
Signed-off-by: Lucas Henneman <henneman@google.com>
2024-04-01 13:21:30 +00:00
Ted Bauer
6d4db66026 aflags: add new storage mode
Add a mode that lets the user use the new aconfig storage.

Bug: 324436145
Test: adb shell aflags list --use-new-storage
Change-Id: I97d7a229a64c6ef1aea844281298ce5449b02570
2024-03-29 16:57:42 +00:00
Ted Bauer
9b7185ca9c Merge "aconfig: make APIs apex available" into main 2024-03-28 23:33:32 +00:00
Dennis Shen
76163aaa38 aconfig_storage_file: add flag_info definition
Flag info file is another memory mapped file to store the file
information such as if current flag has been staged or not, is it sticky
and etc. This file will be created by aconfig storage daemon during
container initialization.

Bug: b/321077378
Test: atest aconfig_storage_file.test
Change-Id: I8f70e04c74b5770f89dbe981d9f03c787ea5eeed
2024-03-28 17:22:01 +00:00
Ted Bauer
e30efac744 aconfig: make APIs apex available
We need the aconfig APIs to be available on every mainline module, so
set the min_sdk_version as low as possible.

Bug: 328444881
Test: m
Change-Id: I02e569d510a30f4809d4a82f7630326b0b30f263
2024-03-28 13:46:18 +00:00
Treehugger Robot
efb09e77d3 Merge "Revert^2 "Migrate buildinfo.sh script into Soong"" into main 2024-03-28 02:59:51 +00:00
Charisee
58708f5d7b Update needed for Rust v1.77.0
error: this `let...else` may be rewritten with the `?` operator
   --> build/make/tools/aconfig/aconfig/src/commands.rs:320:5
    |
320 | /     let Some(package) = parsed_flags.first().map(|pf| pf.package()) else {
321 | |         return None;
322 | |     };
    | |______^ help: replace it with: `let package = parsed_flags.first().map(|pf| pf.package())?;`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ques
tion_mark
    = note: `-D clippy::question-mark` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::question_mark)]`

error: this `let...else` may be rewritten with the `?` operator
   --> build/make/tools/aconfig/aconfig/src/commands.rs:330:5
    |
330 | /     let Some(container) = parsed_flags.parsed_flag.first().map(|pf| pf.container()) else {
331 | |         return None;
332 | |     };
    | |______^ help: replace it with: `let container = parsed_flags.parsed_flag.first().map(|pf| pf.cont
ainer())?;`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ques
tion_mark

error: aborting due to 2 previous errors


Bug: 330185853
Test: ./test_compiler.py --prebuilt-path dist/rust-dev.tar.xz  --target aosp_cf_x86_64_phone --image
Change-Id: I00e22fc75137e8bd6fe28a8c20f8a1c3bbe711fd
2024-03-27 19:53:24 +00:00
Inseob Kim
06d22319d2 Revert^2 "Migrate buildinfo.sh script into Soong"
This reverts commit 54101665ee.

Reason for revert: Fixed build breakage

Bug: 322090587
Change-Id: I065a187bf5863cbb381b4f3308aae7b7200ffa6d
Test: compare build.prop before and after
Test: build multiple times and see build.prop isn't rebuilt
2024-03-27 05:19:56 +00:00
Gina Ko
813b17dd5c Merge "Revert "Migrate buildinfo.sh script into Soong"" into main 2024-03-26 22:46:48 +00:00
Gina Ko
54101665ee Revert "Migrate buildinfo.sh script into Soong"
Revert submission 3004875-buildinfo_prop_soong

Reason for revert: DroidMonitor-triggered revert due to breakage b/331462869

Reverted changes: /q/submissionid:3004875-buildinfo_prop_soong

Bug: 331462869
Change-Id: I02b125f10aaba538998dfe3a503ed2021405e8ae
2024-03-26 22:45:44 +00:00
Treehugger Robot
e1df94c841 Merge "releasetools: Resolve symlinks in IsEntryOtaPackage()" into main 2024-03-26 16:55:57 +00:00
Inseob Kim
1e13e587f5 Merge "Migrate buildinfo.sh script into Soong" into main 2024-03-26 08:06:06 +00:00
Treehugger Robot
decb8f4d1b Merge "Add apk_name information in error message" into main 2024-03-25 22:30:31 +00:00
Spandan Das
198dcf91ca Add apk_name information in error message
Logging the apk_name will improve debugging process if
`GetMinSdkVersion` returns an exception.

Test: None
Change-Id: I3ddf602d92701dcaaa4821fe42a76a870a721a11
2024-03-25 21:24:33 +00:00
LuK1337
fc51de4553
releasetools: Resolve symlinks in IsEntryOtaPackage()
Test: Sign target files package where
      SYSTEM/product/media/bootanimation-dark.zip is a symlink to
      bootanimation.zip.
Change-Id: I4648c3c39c094cb090cbe337c566c3e9ad894691
2024-03-24 21:18:17 +01:00
Daniel Zheng
4a80c5403d fallback to v2 on s build
In the case that a vendor is on s build (which doesn't have snapuserd),
and is takinga  v3 -> v3 upgrade, we want to fallback to v2 vabc ota.

Test: th
Change-Id: Iba259b139b9b423ac77d82e14a113cf35fbfea64
2024-03-22 12:02:54 -07:00
Dennis Shen
12d3417708 Merge "aconfig: update aconfig_storage_read_api" into main 2024-03-22 12:49:04 +00:00
Daniel Zheng
02393ee106 Revert "allow command line override"
This reverts commit f3d476ed40.

Reason for revert: b/330767621

Change-Id: Ia0b8ec3f177ae74c03d7cb4e568e44149b125617
2024-03-21 21:08:22 +00:00
Daniel Zheng
f3d476ed40 allow command line override
Allow override for vabc_cow version if specified from the command line.
If OPTIONS.vabc_cow_version is already defined, then we don't want to
modify this value since it was defined by --vabc_compression_param=

Test: th
Change-Id: I57b8129faf5caf9de1dc8ad96e7570214a9f3313
2024-03-21 10:47:51 -07:00
Inseob Kim
6a35810856 Migrate buildinfo.sh script into Soong
To build system.img in Soong, we need all artifacts including
build.prop. This fully migrates buildinfo.prop file into Soong as a
first step to build build.prop on Soong.

Bug: 322090587
Test: compare build.prop before and after
Test: build multiple times and see build.prop isn't rebuilt
Change-Id: I0d5aab21a825cfe22f97a6834209f9df196625d9
2024-03-21 17:18:59 +09:00
Dennis Shen
bb13bbb086 aconfig: update aconfig_storage_read_api
Previously we are ensuring that the public rust api to get mapped file
is safe as we are ensuring that the file being mapped has a permission
of 444. However, a file permission of 444 is not possible due to build
system needs to make file 644 while creating img files. Thus need to make the rust api to get mapped file unsafe.

In reality, this should have no impact. Because, even though the storage
files have a file permission of 644, they are on a RO partition like
system. So the files are not writable anyway. This is true for all the
containers (platform partitions and mainline modules) we know so far.

Bug: b/321077378
Test: atest aconfig_storage_read_api.test; atest
aconfig_storage_read_api.test.rust; atest
aconfig_storage_read_api.test.cpp

Change-Id: I643fe191e697a524e2303a32750f04c268f408fd
2024-03-21 01:44:02 +00:00
Kelvin Zhang
0669b8eac2 Fix typo
Test: th
Bug: 329678555
Change-Id: I952c19f93484dad9e273afe1cd45a043a36a34ee
2024-03-20 13:58:15 -07:00
Treehugger Robot
64134135c7 Merge "aconfig: update pb file location" into main 2024-03-20 17:46:35 +00:00
Dennis Shen
5e909adbc8 aconfig: update pb file location
We have moved the storage records metadata pb file to the boot dir.

Bug: b/321077378
Test: atest aconfig_storage_read_api.test
Change-Id: Ic5bd89052e311ec5b1993ba1779d49be8451caa2
2024-03-20 16:38:09 +00:00
Michael Merg
d8880abbdf Write ide_qeury results to stdout
All other output will be written to stderr.

Change-Id: Iefbd8292bb136e4723d5c168e4508ae183585c7c
2024-03-20 11:06:17 +00:00
Daniel Zheng
0b7a685573 create_brick_ota: fix nonetype bug
If devkeys are present, we don't need to specify a serialno. In this
case we should conditionally add serial no to our metadata

Test: create_brick_ota
Change-Id: I9c93aa0f9ec5752693a9ddde5b76be4c12d6fc3b
2024-03-19 12:29:13 -07:00
Kadir Çetinkaya
f6e76b6566 Merge "Make sure ninja keeps going after errors" into main 2024-03-18 07:36:16 +00:00
Treehugger Robot
6c63da3ce7 Merge "aconfig: c++ read api to return an android::base::Result and cargo fmt" into main 2024-03-15 14:16:27 +00:00
Kadir Çetinkaya
874e12be43 Make sure ninja keeps going after errors
Language services builds are usually executed in a non-building state of the codebase as the user is actively editing the code.

This change ensures we can build as many dependencies as possible for language services by ninja.

Note that this doesn't change the error-limit for soong itself, i.e. we can still fail-early if we encounter errors while generating ninja files.

Change-Id: I594e2ae4591d2e75db082486f28f705833ceb4a8
2024-03-15 07:27:30 +00:00
Tomasz Wasilczyk
4045ae7871 Remove SignApk output limitation of 2GiB
Bug: 302112430
Test: build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_x86_64 TARGET_RELEASE=trunk_staging CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS="art external/aac external/boringssl external/conscrypt external/cpu_features external/dlmalloc external/fdlibm external/libaom external/libavc external/libcxx external/libfuse external/libgav1 external/libgsm external/libhevc external/libmpeg2 external/libopus external/libtextclassifier external/libvpx external/libxaac external/oj-libjdwp external/sonivox external/speex external/tremolo external/vixl frameworks/av frameworks/base/media libcore libnativehelper packages/modules/Bluetooth packages/modules/Connectivity packages/modules/DnsResolver packages/modules/ExtServices packages/modules/NetworkStack packages/modules/NeuralNetworks packages/modules/SdkExtensions packages/modules/StatsD packages/providers/MediaProvider system/core/base system/core/libcutils system/core/libstats system/media/audio_utils system/netd/resolv" com.android.art.testing
      apksigner verify --in $OUT/../generic_x86_64/system/apex/com.android.art.testing.apex --print-certs -v --min-sdk-version 23
Change-Id: Id31eae0f221dd7ef333bd12aeef591463e1c931a
2024-03-14 14:57:04 -07:00
Dennis Shen
435fe14146 aconfig: c++ read api to return an android::base::Result and cargo fmt
Bug: b/312444587
Test: atest aconfig_storage_read_api.test.rust; atest
aconfig_storage_write_api.test.cpp

Change-Id: I6beb6e8d43b6f5418476101a929374e97832e27f
2024-03-14 19:25:07 +00:00
Dennis Shen
aa0287641e Merge "aconfig_storage: create aconfig storage c++ flag value write api" into main 2024-03-14 19:21:38 +00:00
Treehugger Robot
4e5aa5d0f5 Merge "Remove fs_get_stats." into main 2024-03-14 17:13:26 +00:00
Dennis Shen
1fdb6cc456 aconfig_storage: create aconfig storage c++ flag value write api
Bug: b/312444587
Test: atest aconfig_storage_write_api.test.cpp
Change-Id: Ib08575b7e6ca23141ebbf739bf604a66da472dc2
2024-03-14 16:06:03 +00:00
Elliott Hughes
b904c27e12 Remove fs_get_stats.
This was only used by the tarball-building support that was removed
in 2019.

Test: treehugger
Change-Id: I719364699d426d21010c3ab913d12f15128f2538
2024-03-14 15:32:24 +00:00
Dennis Shen
7c30411d3d Merge changes from topic "read_api" into main
* changes:
  aconfig: update aconfig_storage_read_api c++ lib
  aconfig: update aconfig_storage_read_api
2024-03-14 14:43:12 +00:00
Treehugger Robot
be19783c7a Merge "Replace some ByteBuffers with DataSource" into main 2024-03-13 23:57:51 +00:00
Tomasz Wasilczyk
4b114c29ec Replace some ByteBuffers with DataSource
This avoids ByteArray 2GiB limit in a few places, but requires more
changes to SignApk to fully support large archives.

Bug: 302112430
Test: build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_x86_64 TARGET_RELEASE=trunk_staging CLANG_COVERAGE=true NATIVE_COVERAGE_PATHS="art external/aac external/boringssl external/conscrypt external/cpu_features external/dlmalloc external/fdlibm external/libaom external/libavc external/libcxx external/libfuse external/libgav1 external/libgsm external/libhevc external/libmpeg2 external/libopus external/libtextclassifier external/libvpx external/libxaac external/oj-libjdwp external/sonivox external/speex external/tremolo external/vixl frameworks/av frameworks/base/media libcore libnativehelper packages/modules/Bluetooth packages/modules/Connectivity packages/modules/DnsResolver packages/modules/ExtServices packages/modules/NetworkStack packages/modules/NeuralNetworks packages/modules/SdkExtensions packages/modules/StatsD packages/providers/MediaProvider system/core/base system/core/libcutils system/core/libstats system/media/audio_utils system/netd/resolv" com.android.art.testing
Change-Id: Ie7fc0bbce9ef43b6331143703ac5568cf1b2186a
2024-03-13 21:43:13 +00:00
Dennis Shen
808bf915a8 aconfig: update aconfig_storage_read_api c++ lib
Now the read api lib no longer owns the memory mapped file. The rust lib
aconfig_storage_read_api api to get memory mapped file just returns an
Mmap rust struct. However cxx does not support Mmap data type, so we
cannot export the api to get memory mapped file from rust to c++. This
means we have to implement c++ apis to get memory mapped files.

This change is basically implementing c++ api to get memory mapped files,
mirroring the rust implementation. In addition, the integration test is
also updated to lock down the new c++ api implementation.

Bug: b/321077378
Test: atest aconfig_storage_read_api.test.cpp
Change-Id: I5e93a220cdd05cc0e5b0eb441284ac3e9dc34da7
2024-03-13 20:29:13 +00:00
Dennis Shen
71f9303dc0 aconfig: update aconfig_storage_read_api
Right now, aconfig_storage_read_api rust lib would own mapped files. So
individual flag lib does not need to. The original intent is that all
these flag lib can dynamically link against this lib. So say we have
different variants of flag lib for one flag package, there is just one
unique memory mapped file. In addition, the exposed rust apis hides the
memory mapped files. So when exporting these apis to c++/java, we don't
have to implement memory mapping in c++/java flag read api lib.

However, this design has its own downside. The biggest being that these
memory mapped files are stored in a mutable static hash map. For rust,
it must be protected by a mutex lock. The real effect on the lock is
mostly minimal as it immediately unlocks when the clone of memory
mapping is returned. But still we could get more performance out of it
in exchange of having more c++/java side implementation of mapping
files. (Note, apis that interpret mapped files are still exported by
Rust, so no c++/java implementation needed).

In this change, aconfig_storage_read_api give away its ownership of
memory mapped file in its api to get memory mapped file. The memory
mapped file is supposed to be owned by generated flag lib. By doing so,
no more mutex lock is needed. Also, since each flag lib has one flag
package, which maps to a single owning container. The flag lib can have
the memory mapped files as non mutable static variables. So no mutex
lock penalty on flag lib side.

Bug: b/321077378
Test: atest aconfig_storage_read_api.test; atest
aconfig_storage_read_api.test.rust

Change-Id: I29060bae90db6f7d296252ed73f7e312143f4b7e
2024-03-13 18:10:19 +00:00
Treehugger Robot
c7704f1650 Merge "aflags: show staged values for each flag." into main 2024-03-13 17:01:14 +00:00
Ted Bauer
46d758bd49 aflags: show staged values for each flag.
Lines now have a new column, and look like this:

com.android.example.flag1 enabled -            server read-write system
com.android.example.flag2 enabled (->disabled) server read-write system

The dash represents no change on boot, the (->value) represents a change
to value on the next boot.

Test: adb shell device_config put staged multitasking*com.android.wm.shell.enable_taskbar_navbar_unification true && adb shell aflags list | grep navbar_unification
Bug: 324436145
Change-Id: I022460bc69fcb2ccd9c6db8f060fcbd0337d1ea6
2024-03-13 14:46:31 +00:00
Dennis Shen
c89032cd2f Merge "aconfig: update aconfig_storage_file crate unit test to lockdown file size" into main 2024-03-13 13:10:18 +00:00
Seungjae Yoo
933d07a1b3 Merge "Add unit test for parsing avb info" into main 2024-03-13 01:39:42 +00:00
Dennis Shen
7176a4fdfa aconfig: update aconfig_storage_file crate unit test to lockdown file
size

Bug: b/321077378
m: atest aconfig_storage_file.test
Change-Id: Ic5e7e7a9fd7ac53bb1207a13acc0c992fe0afd2d
2024-03-12 22:40:53 +00:00
Dennis Shen
1d9f0dd291 aconfig: add rust integration test for aconfig_storage_write_api
Bug: b/312444587
Test: atest aconfig_storage_write_api.test.rust
Change-Id: I05f992ea93a19507ad865e97315c128473841a33
2024-03-12 19:09:04 +00:00
Dennis Shen
ee18b35565 Merge "aconfig: add storage file type into storage file serialization" into main 2024-03-12 14:38:50 +00:00
Treehugger Robot
1986c86bb2 Merge "aflags: make flag storage error message more user-friendly" into main 2024-03-12 13:20:21 +00:00
Dennis Shen
e9b9573def aconfig: add storage file type into storage file serialization
1, add storage file type into storage files serialization
2, update aconfig_storage_read_api integration tests to not rely on
soong to produce read only storage files. Instead, have the test process
create temp read only storage file copies.

Bug: b/312444587
Test: atest aconfig.test; atest.aconfig_storage_file.test
Change-Id: I1607fb000b48e8acffc966b16a5136578911ab3e
2024-03-12 12:43:31 +00:00
Treehugger Robot
672af9523b Merge "aconfig: create aconfig_storage_write_api crate" into main 2024-03-12 04:12:20 +00:00
Dennis Shen
7e5fca5898 aconfig: create aconfig_storage_write_api crate
aconfig_storage_write_api crate is the lib to be used by aconfig storage
daemon to update flag value at a given offset.

Note that mmap api is unsafe from memmap2 crate. This is due to the
possibility of other code write to the file after mmaping the file into
memory. Therefore the api to write to storage value file is also marked
as unsafe. In reality, the persistent storage value file is protected by
SELinux policy to allow write access only to aconfig storage daemon. In
addition, aconfig storage daemon is single threaded. So at any time,
only one thread is writing to a storage file, and only thru the mmapped
file in memory (not thru direct file write). So it would safe for
storage daemon to call this api.

Bug: b/312444587
Test: m libaconfig_storage_write_api; atest
aconfig_storage_write_api.test

Change-Id: I93cffea0d94e4c40e711d809418c0b18b6d9bfe1
2024-03-11 14:26:38 +00:00
Ted Bauer
e52434aa18 aflags: make flag storage error message more user-friendly
Bug: 328577149
Test: adb shell stop && sleep 10 && adb shell aflags list
Change-Id: Idb28c93f883b72031cf3e1ff4e8d396c4df708e2
2024-03-11 14:12:58 +00:00