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

Commit bc76a3d9 authored by Mårten Kongstad's avatar Mårten Kongstad
Browse files

aconfig: rename test flag `disabled_rw_2` -> `disabled_rw_in_other_namespace`

The flag `disabled_rw_2` is used to verify that aconfig can
auto-generate code for flags in different namespaces. Rename the flag to
`disabled_rw_in_other_namespace` to highlight that it belongs to a
different namespace than the other flags.

This CL is a semantic change only.

Bug: None
Test: atest aconfig.test
Change-Id: Ib82fdce0ca3f7cd56b9b3f80e44fe424a03a2ae4
parent 8fc7cf63
Loading
Loading
Loading
Loading
+25 −25
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ public:

    virtual bool disabled_rw() = 0;

    virtual bool disabled_rw_2() = 0;
    virtual bool disabled_rw_in_other_namespace() = 0;

    virtual bool enabled_fixed_ro() = 0;

@@ -184,8 +184,8 @@ inline bool disabled_rw() {
    return provider_->disabled_rw();
}

inline bool disabled_rw_2() {
    return provider_->disabled_rw_2();
inline bool disabled_rw_in_other_namespace() {
    return provider_->disabled_rw_in_other_namespace();
}

inline bool enabled_fixed_ro() {
@@ -209,7 +209,7 @@ bool com_android_aconfig_test_disabled_ro();

bool com_android_aconfig_test_disabled_rw();

bool com_android_aconfig_test_disabled_rw_2();
bool com_android_aconfig_test_disabled_rw_in_other_namespace();

bool com_android_aconfig_test_enabled_fixed_ro();

@@ -244,9 +244,9 @@ public:

    virtual void disabled_rw(bool val) = 0;

    virtual bool disabled_rw_2() = 0;
    virtual bool disabled_rw_in_other_namespace() = 0;

    virtual void disabled_rw_2(bool val) = 0;
    virtual void disabled_rw_in_other_namespace(bool val) = 0;

    virtual bool enabled_fixed_ro() = 0;

@@ -281,12 +281,12 @@ inline void disabled_rw(bool val) {
    provider_->disabled_rw(val);
}

inline bool disabled_rw_2() {
    return provider_->disabled_rw_2();
inline bool disabled_rw_in_other_namespace() {
    return provider_->disabled_rw_in_other_namespace();
}

inline void disabled_rw_2(bool val) {
    provider_->disabled_rw_2(val);
inline void disabled_rw_in_other_namespace(bool val) {
    provider_->disabled_rw_in_other_namespace(val);
}

inline bool enabled_fixed_ro() {
@@ -330,9 +330,9 @@ bool com_android_aconfig_test_disabled_rw();

void set_com_android_aconfig_test_disabled_rw(bool val);

bool com_android_aconfig_test_disabled_rw_2();
bool com_android_aconfig_test_disabled_rw_in_other_namespace();

void set_com_android_aconfig_test_disabled_rw_2(bool val);
void set_com_android_aconfig_test_disabled_rw_in_other_namespace(bool val);

bool com_android_aconfig_test_enabled_fixed_ro();

@@ -379,11 +379,11 @@ namespace com::android::aconfig::test {
                return cache_[0];
            }

            virtual bool disabled_rw_2() override {
            virtual bool disabled_rw_in_other_namespace() override {
                if (cache_[1] == -1) {
                    cache_[1] = server_configurable_flags::GetServerConfigurableFlag(
                        "aconfig_flags.other_namespace",
                        "com.android.aconfig.test.disabled_rw_2",
                        "com.android.aconfig.test.disabled_rw_in_other_namespace",
                        "false") == "true";
                }
                return cache_[1];
@@ -423,8 +423,8 @@ bool com_android_aconfig_test_disabled_rw() {
    return com::android::aconfig::test::disabled_rw();
}

bool com_android_aconfig_test_disabled_rw_2() {
    return com::android::aconfig::test::disabled_rw_2();
bool com_android_aconfig_test_disabled_rw_in_other_namespace() {
    return com::android::aconfig::test::disabled_rw_in_other_namespace();
}

bool com_android_aconfig_test_enabled_fixed_ro() {
@@ -487,20 +487,20 @@ namespace com::android::aconfig::test {
                overrides_["disabled_rw"] = val;
            }

            virtual bool disabled_rw_2() override {
                auto it = overrides_.find("disabled_rw_2");
            virtual bool disabled_rw_in_other_namespace() override {
                auto it = overrides_.find("disabled_rw_in_other_namespace");
                  if (it != overrides_.end()) {
                      return it->second;
                } else {
                  return server_configurable_flags::GetServerConfigurableFlag(
                      "aconfig_flags.other_namespace",
                      "com.android.aconfig.test.disabled_rw_2",
                      "com.android.aconfig.test.disabled_rw_in_other_namespace",
                      "false") == "true";
                }
            }

            virtual void disabled_rw_2(bool val) override {
                overrides_["disabled_rw_2"] = val;
            virtual void disabled_rw_in_other_namespace(bool val) override {
                overrides_["disabled_rw_in_other_namespace"] = val;
            }

            virtual bool enabled_fixed_ro() override {
@@ -572,13 +572,13 @@ void set_com_android_aconfig_test_disabled_rw(bool val) {
    com::android::aconfig::test::disabled_rw(val);
}

bool com_android_aconfig_test_disabled_rw_2() {
    return com::android::aconfig::test::disabled_rw_2();
bool com_android_aconfig_test_disabled_rw_in_other_namespace() {
    return com::android::aconfig::test::disabled_rw_in_other_namespace();
}


void set_com_android_aconfig_test_disabled_rw_2(bool val) {
    com::android::aconfig::test::disabled_rw_2(val);
void set_com_android_aconfig_test_disabled_rw_in_other_namespace(bool val) {
    com::android::aconfig::test::disabled_rw_in_other_namespace(val);
}


+13 −13
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ mod tests {
        @UnsupportedAppUsage
        boolean disabledRw();
        @UnsupportedAppUsage
        boolean disabledRw2();
        boolean disabledRwInOtherNamespace();
        @com.android.aconfig.annotations.AssumeTrueForR8
        @UnsupportedAppUsage
        boolean enabledFixedRo();
@@ -202,7 +202,7 @@ mod tests {
        /** @hide */
        public static final String FLAG_DISABLED_RW = "com.android.aconfig.test.disabled_rw";
        /** @hide */
        public static final String FLAG_DISABLED_RW_2 = "com.android.aconfig.test.disabled_rw_2";
        public static final String FLAG_DISABLED_RW_IN_OTHER_NAMESPACE = "com.android.aconfig.test.disabled_rw_in_other_namespace";
        /** @hide */
        public static final String FLAG_ENABLED_FIXED_RO = "com.android.aconfig.test.enabled_fixed_ro";
        /** @hide */
@@ -220,8 +220,8 @@ mod tests {
            return FEATURE_FLAGS.disabledRw();
        }
        @UnsupportedAppUsage
        public static boolean disabledRw2() {
            return FEATURE_FLAGS.disabledRw2();
        public static boolean disabledRwInOtherNamespace() {
            return FEATURE_FLAGS.disabledRwInOtherNamespace();
        }
        @com.android.aconfig.annotations.AssumeTrueForR8
        @UnsupportedAppUsage
@@ -262,8 +262,8 @@ mod tests {
        }
        @Override
        @UnsupportedAppUsage
        public boolean disabledRw2() {
            return getValue(Flags.FLAG_DISABLED_RW_2);
        public boolean disabledRwInOtherNamespace() {
            return getValue(Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE);
        }
        @Override
        @UnsupportedAppUsage
@@ -302,7 +302,7 @@ mod tests {
            Map.ofEntries(
                Map.entry(Flags.FLAG_DISABLED_RO, false),
                Map.entry(Flags.FLAG_DISABLED_RW, false),
                Map.entry(Flags.FLAG_DISABLED_RW_2, 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)
@@ -336,7 +336,7 @@ mod tests {
            private static boolean aconfig_test_is_cached = false;
            private static boolean other_namespace_is_cached = false;
            private static boolean disabledRw = false;
            private static boolean disabledRw2 = false;
            private static boolean disabledRwInOtherNamespace = false;
            private static boolean enabledRw = true;


@@ -363,8 +363,8 @@ mod tests {
            private void load_overrides_other_namespace() {
                try {
                    Properties properties = DeviceConfig.getProperties("other_namespace");
                    disabledRw2 =
                        properties.getBoolean("com.android.aconfig.test.disabled_rw_2", false);
                    disabledRwInOtherNamespace =
                        properties.getBoolean("com.android.aconfig.test.disabled_rw_in_other_namespace", false);
                } catch (NullPointerException e) {
                    throw new RuntimeException(
                        "Cannot read value from namespace other_namespace "
@@ -394,11 +394,11 @@ mod tests {
            }
            @Override
            @UnsupportedAppUsage
            public boolean disabledRw2() {
            public boolean disabledRwInOtherNamespace() {
                if (!other_namespace_is_cached) {
                    load_overrides_other_namespace();
                }
                return disabledRw2;
                return disabledRwInOtherNamespace;
            }
            @Override
            @UnsupportedAppUsage
@@ -489,7 +489,7 @@ mod tests {
            }
            @Override
            @UnsupportedAppUsage
            public boolean disabledRw2() {
            public boolean disabledRwInOtherNamespace() {
                throw new UnsupportedOperationException(
                    "Method is not implemented.");
            }
+22 −22
Original line number Diff line number Diff line
@@ -104,10 +104,10 @@ lazy_static::lazy_static! {
        "com.android.aconfig.test.disabled_rw",
        "false") == "true";

    /// flag value cache for disabled_rw_2
    static ref CACHED_disabled_rw_2: bool = flags_rust::GetServerConfigurableFlag(
    /// flag value cache for disabled_rw_in_other_namespace
    static ref CACHED_disabled_rw_in_other_namespace: bool = flags_rust::GetServerConfigurableFlag(
        "aconfig_flags.other_namespace",
        "com.android.aconfig.test.disabled_rw_2",
        "com.android.aconfig.test.disabled_rw_in_other_namespace",
        "false") == "true";

    /// flag value cache for enabled_rw
@@ -128,9 +128,9 @@ impl FlagProvider {
        *CACHED_disabled_rw
    }

    /// query flag disabled_rw_2
    pub fn disabled_rw_2(&self) -> bool {
        *CACHED_disabled_rw_2
    /// query flag disabled_rw_in_other_namespace
    pub fn disabled_rw_in_other_namespace(&self) -> bool {
        *CACHED_disabled_rw_in_other_namespace
    }

    /// query flag enabled_fixed_ro
@@ -164,10 +164,10 @@ pub fn disabled_rw() -> bool {
    PROVIDER.disabled_rw()
}

/// query flag disabled_rw_2
/// query flag disabled_rw_in_other_namespace
#[inline(always)]
pub fn disabled_rw_2() -> bool {
    PROVIDER.disabled_rw_2()
pub fn disabled_rw_in_other_namespace() -> bool {
    PROVIDER.disabled_rw_in_other_namespace()
}

/// query flag enabled_fixed_ro
@@ -228,19 +228,19 @@ impl FlagProvider {
        self.overrides.insert("disabled_rw", val);
    }

    /// query flag disabled_rw_2
    pub fn disabled_rw_2(&self) -> bool {
        self.overrides.get("disabled_rw_2").copied().unwrap_or(
    /// query flag disabled_rw_in_other_namespace
    pub fn disabled_rw_in_other_namespace(&self) -> bool {
        self.overrides.get("disabled_rw_in_other_namespace").copied().unwrap_or(
            flags_rust::GetServerConfigurableFlag(
                "aconfig_flags.other_namespace",
                "com.android.aconfig.test.disabled_rw_2",
                "com.android.aconfig.test.disabled_rw_in_other_namespace",
                "false") == "true"
        )
    }

    /// set flag disabled_rw_2
    pub fn set_disabled_rw_2(&mut self, val: bool) {
        self.overrides.insert("disabled_rw_2", val);
    /// set flag disabled_rw_in_other_namespace
    pub fn set_disabled_rw_in_other_namespace(&mut self, val: bool) {
        self.overrides.insert("disabled_rw_in_other_namespace", val);
    }

    /// query flag enabled_fixed_ro
@@ -317,16 +317,16 @@ pub fn set_disabled_rw(val: bool) {
    PROVIDER.lock().unwrap().set_disabled_rw(val);
}

/// query flag disabled_rw_2
/// query flag disabled_rw_in_other_namespace
#[inline(always)]
pub fn disabled_rw_2() -> bool {
    PROVIDER.lock().unwrap().disabled_rw_2()
pub fn disabled_rw_in_other_namespace() -> bool {
    PROVIDER.lock().unwrap().disabled_rw_in_other_namespace()
}

/// set flag disabled_rw_2
/// set flag disabled_rw_in_other_namespace
#[inline(always)]
pub fn set_disabled_rw_2(val: bool) {
    PROVIDER.lock().unwrap().set_disabled_rw_2(val);
pub fn set_disabled_rw_in_other_namespace(val: bool) {
    PROVIDER.lock().unwrap().set_disabled_rw_in_other_namespace(val);
}

/// query flag enabled_fixed_ro
+2 −2
Original line number Diff line number Diff line
@@ -433,7 +433,7 @@ mod tests {
        let input = parse_test_flags_as_input();
        let bytes = create_device_config_defaults(input).unwrap();
        let text = std::str::from_utf8(&bytes).unwrap();
        assert_eq!("aconfig_test:com.android.aconfig.test.disabled_rw=disabled\nother_namespace:com.android.aconfig.test.disabled_rw_2=disabled\naconfig_test:com.android.aconfig.test.enabled_rw=enabled\n", text);
        assert_eq!("aconfig_test:com.android.aconfig.test.disabled_rw=disabled\nother_namespace:com.android.aconfig.test.disabled_rw_in_other_namespace=disabled\naconfig_test:com.android.aconfig.test.enabled_rw=enabled\n", text);
    }

    #[test]
@@ -441,7 +441,7 @@ mod tests {
        let input = parse_test_flags_as_input();
        let bytes = create_device_config_sysprops(input).unwrap();
        let text = std::str::from_utf8(&bytes).unwrap();
        assert_eq!("persist.device_config.com.android.aconfig.test.disabled_rw=false\npersist.device_config.com.android.aconfig.test.disabled_rw_2=false\npersist.device_config.com.android.aconfig.test.enabled_rw=true\n", text);
        assert_eq!("persist.device_config.com.android.aconfig.test.disabled_rw=false\npersist.device_config.com.android.aconfig.test.disabled_rw_in_other_namespace=false\npersist.device_config.com.android.aconfig.test.enabled_rw=true\n", text);
    }

    #[test]
+2 −2
Original line number Diff line number Diff line
@@ -60,9 +60,9 @@ parsed_flag {
}
parsed_flag {
  package: "com.android.aconfig.test"
  name: "disabled_rw_2"
  name: "disabled_rw_in_other_namespace"
  namespace: "other_namespace"
  description: "This flag is DISABLED + READ_WRITE"
  description: "This flag is DISABLED + READ_WRITE, and is defined in another namespace"
  bug: "999"
  state: DISABLED
  permission: READ_WRITE
Loading