aconfig: allow dots in package fields
Allow package fields to include dots.
Update the generated code based on the package name: if the package name
is com.android.example:
- java: package com.android.example; ...
- C++: namespace com::android::example { ... }
- Rust: mod com { mod android { mod example { ... } } }
Also, update examples to use dots in the package fields.
Also, remove unnecessary #include from the auto-generated C++ code: the
header should not include itself.
Bug: 285000854
Test: atest aconfig.test
Change-Id: I8a5352e25c64c34dee0725202a1b7c9957819de8
diff --git a/tools/aconfig/src/aconfig.rs b/tools/aconfig/src/aconfig.rs
index 42762e2..696e154 100644
--- a/tools/aconfig/src/aconfig.rs
+++ b/tools/aconfig/src/aconfig.rs
@@ -244,7 +244,7 @@
#[test]
fn test_package_try_from_text_proto() {
let expected = FlagDeclarations {
- package: "ns".to_owned(),
+ package: "com.example".to_owned(),
flags: vec![
FlagDeclaration { name: "a".to_owned(), description: "A".to_owned() },
FlagDeclaration { name: "b".to_owned(), description: "B".to_owned() },
@@ -252,7 +252,7 @@
};
let s = r#"
- package: "ns"
+ package: "com.example"
flag {
name: "a"
description: "A"
@@ -270,14 +270,14 @@
#[test]
fn test_flag_declaration_try_from_text_proto_list() {
let expected = FlagValue {
- package: "ns".to_owned(),
+ package: "com.example".to_owned(),
name: "1234".to_owned(),
state: FlagState::Enabled,
permission: Permission::ReadOnly,
};
let s = r#"
- package: "ns"
+ package: "com.example"
name: "1234"
state: ENABLED
permission: READ_ONLY