summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Cherry2018-01-11 18:26:10 -0600
committerTom Cherry2018-01-11 18:26:50 -0600
commit4094e5ee2eacc11ce7f062ceb9bb9df9028f492f (patch)
tree9ca0ae48fae032d74f79501f18bea7d2156f80a4 /property_service
parenteac86b0ea90f19f9a4116e9a1ca401f0959ceb03 (diff)
downloadplatform-system-core-4094e5ee2eacc11ce7f062ceb9bb9df9028f492f.tar.gz
platform-system-core-4094e5ee2eacc11ce7f062ceb9bb9df9028f492f.tar.xz
platform-system-core-4094e5ee2eacc11ce7f062ceb9bb9df9028f492f.zip
Rename property 'schema' to 'type'
Bug: 70858511 Test: boot Change-Id: I8e17596ddd8393f245c7e02ff72765c84d3bb208
Diffstat (limited to 'property_service')
-rw-r--r--property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h31
-rw-r--r--property_service/libpropertyinfoparser/property_info_parser.cpp52
-rw-r--r--property_service/libpropertyinfoserializer/include/property_info_serializer/property_info_serializer.h8
-rw-r--r--property_service/libpropertyinfoserializer/property_info_file.cpp4
-rw-r--r--property_service/libpropertyinfoserializer/property_info_serializer.cpp8
-rw-r--r--property_service/libpropertyinfoserializer/property_info_serializer_test.cpp231
-rw-r--r--property_service/libpropertyinfoserializer/trie_builder.cpp22
-rw-r--r--property_service/libpropertyinfoserializer/trie_builder.h31
-rw-r--r--property_service/libpropertyinfoserializer/trie_builder_test.cpp46
-rw-r--r--property_service/libpropertyinfoserializer/trie_serializer.cpp14
10 files changed, 222 insertions, 225 deletions
diff --git a/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h b/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h
index 2ee816124..054802197 100644
--- a/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h
+++ b/property_service/libpropertyinfoparser/include/property_info_parser/property_info_parser.h
@@ -32,8 +32,8 @@ struct PropertyEntry {
32 32
33 // This is the context match for this node_; ~0u if it doesn't correspond to any. 33 // This is the context match for this node_; ~0u if it doesn't correspond to any.
34 uint32_t context_index; 34 uint32_t context_index;
35 // This is the schema for this node_; ~0u if it doesn't correspond to any. 35 // This is the type for this node_; ~0u if it doesn't correspond to any.
36 uint32_t schema_index; 36 uint32_t type_index;
37}; 37};
38 38
39struct TrieNodeInternal { 39struct TrieNodeInternal {
@@ -61,7 +61,7 @@ struct PropertyInfoAreaHeader {
61 uint32_t minimum_supported_version; 61 uint32_t minimum_supported_version;
62 uint32_t size; 62 uint32_t size;
63 uint32_t contexts_offset; 63 uint32_t contexts_offset;
64 uint32_t schemas_offset; 64 uint32_t types_offset;
65 uint32_t root_offset; 65 uint32_t root_offset;
66}; 66};
67 67
@@ -103,7 +103,7 @@ class TrieNode {
103 } 103 }
104 104
105 uint32_t context_index() const { return node_property_entry()->context_index; } 105 uint32_t context_index() const { return node_property_entry()->context_index; }
106 uint32_t schema_index() const { return node_property_entry()->schema_index; } 106 uint32_t type_index() const { return node_property_entry()->type_index; }
107 107
108 uint32_t num_child_nodes() const { return trie_node_base_->num_child_nodes; } 108 uint32_t num_child_nodes() const { return trie_node_base_->num_child_nodes; }
109 TrieNode child_node(int n) const { 109 TrieNode child_node(int n) const {
@@ -143,12 +143,11 @@ class TrieNode {
143 143
144class PropertyInfoArea : private SerializedData { 144class PropertyInfoArea : private SerializedData {
145 public: 145 public:
146 void GetPropertyInfoIndexes(const char* name, uint32_t* context_index, 146 void GetPropertyInfoIndexes(const char* name, uint32_t* context_index, uint32_t* type_index) const;
147 uint32_t* schema_index) const; 147 void GetPropertyInfo(const char* property, const char** context, const char** type) const;
148 void GetPropertyInfo(const char* property, const char** context, const char** schema) const;
149 148
150 int FindContextIndex(const char* context) const; 149 int FindContextIndex(const char* context) const;
151 int FindSchemaIndex(const char* schema) const; 150 int FindTypeIndex(const char* type) const;
152 151
153 const char* context(uint32_t index) const { 152 const char* context(uint32_t index) const {
154 uint32_t context_array_size_offset = contexts_offset(); 153 uint32_t context_array_size_offset = contexts_offset();
@@ -156,10 +155,10 @@ class PropertyInfoArea : private SerializedData {
156 return data_base() + context_array[index]; 155 return data_base() + context_array[index];
157 } 156 }
158 157
159 const char* schema(uint32_t index) const { 158 const char* type(uint32_t index) const {
160 uint32_t schema_array_size_offset = schemas_offset(); 159 uint32_t type_array_size_offset = types_offset();
161 const uint32_t* schema_array = uint32_array(schema_array_size_offset + sizeof(uint32_t)); 160 const uint32_t* type_array = uint32_array(type_array_size_offset + sizeof(uint32_t));
162 return data_base() + schema_array[index]; 161 return data_base() + type_array[index];
163 } 162 }
164 163
165 uint32_t current_version() const { return header()->current_version; } 164 uint32_t current_version() const { return header()->current_version; }
@@ -168,21 +167,21 @@ class PropertyInfoArea : private SerializedData {
168 uint32_t size() const { return SerializedData::size(); } 167 uint32_t size() const { return SerializedData::size(); }
169 168
170 uint32_t num_contexts() const { return uint32_array(contexts_offset())[0]; } 169 uint32_t num_contexts() const { return uint32_array(contexts_offset())[0]; }
171 uint32_t num_schemas() const { return uint32_array(schemas_offset())[0]; } 170 uint32_t num_types() const { return uint32_array(types_offset())[0]; }
172 171
173 TrieNode root_node() const { return trie(header()->root_offset); } 172 TrieNode root_node() const { return trie(header()->root_offset); }
174 173
175 private: 174 private:
176 void CheckPrefixMatch(const char* remaining_name, const TrieNode& trie_node, 175 void CheckPrefixMatch(const char* remaining_name, const TrieNode& trie_node,
177 uint32_t* context_index, uint32_t* schema_index) const; 176 uint32_t* context_index, uint32_t* type_index) const;
178 177
179 const PropertyInfoAreaHeader* header() const { 178 const PropertyInfoAreaHeader* header() const {
180 return reinterpret_cast<const PropertyInfoAreaHeader*>(data_base()); 179 return reinterpret_cast<const PropertyInfoAreaHeader*>(data_base());
181 } 180 }
182 uint32_t contexts_offset() const { return header()->contexts_offset; } 181 uint32_t contexts_offset() const { return header()->contexts_offset; }
183 uint32_t contexts_array_offset() const { return contexts_offset() + sizeof(uint32_t); } 182 uint32_t contexts_array_offset() const { return contexts_offset() + sizeof(uint32_t); }
184 uint32_t schemas_offset() const { return header()->schemas_offset; } 183 uint32_t types_offset() const { return header()->types_offset; }
185 uint32_t schemas_array_offset() const { return schemas_offset() + sizeof(uint32_t); } 184 uint32_t types_array_offset() const { return types_offset() + sizeof(uint32_t); }
186 185
187 TrieNode trie(uint32_t offset) const { 186 TrieNode trie(uint32_t offset) const {
188 if (offset != 0 && offset > size()) return TrieNode(); 187 if (offset != 0 && offset > size()) return TrieNode();
diff --git a/property_service/libpropertyinfoparser/property_info_parser.cpp b/property_service/libpropertyinfoparser/property_info_parser.cpp
index a8f663624..489d81a67 100644
--- a/property_service/libpropertyinfoparser/property_info_parser.cpp
+++ b/property_service/libpropertyinfoparser/property_info_parser.cpp
@@ -56,12 +56,12 @@ int PropertyInfoArea::FindContextIndex(const char* context) const {
56 }); 56 });
57} 57}
58 58
59// Binary search the list of schemas to find the index of a given schema string. 59// Binary search the list of types to find the index of a given type string.
60// Only should be used for TrieSerializer to construct the Trie. 60// Only should be used for TrieSerializer to construct the Trie.
61int PropertyInfoArea::FindSchemaIndex(const char* schema) const { 61int PropertyInfoArea::FindTypeIndex(const char* type) const {
62 return Find(num_schemas(), [this, schema](auto array_offset) { 62 return Find(num_types(), [this, type](auto array_offset) {
63 auto string_offset = uint32_array(schemas_array_offset())[array_offset]; 63 auto string_offset = uint32_array(types_array_offset())[array_offset];
64 return strcmp(c_string(string_offset), schema); 64 return strcmp(c_string(string_offset), type);
65 }); 65 });
66} 66}
67 67
@@ -89,7 +89,7 @@ bool TrieNode::FindChildForString(const char* name, uint32_t namelen, TrieNode*
89} 89}
90 90
91void PropertyInfoArea::CheckPrefixMatch(const char* remaining_name, const TrieNode& trie_node, 91void PropertyInfoArea::CheckPrefixMatch(const char* remaining_name, const TrieNode& trie_node,
92 uint32_t* context_index, uint32_t* schema_index) const { 92 uint32_t* context_index, uint32_t* type_index) const {
93 const uint32_t remaining_name_size = strlen(remaining_name); 93 const uint32_t remaining_name_size = strlen(remaining_name);
94 for (uint32_t i = 0; i < trie_node.num_prefixes(); ++i) { 94 for (uint32_t i = 0; i < trie_node.num_prefixes(); ++i) {
95 auto prefix_len = trie_node.prefix(i)->namelen; 95 auto prefix_len = trie_node.prefix(i)->namelen;
@@ -99,8 +99,8 @@ void PropertyInfoArea::CheckPrefixMatch(const char* remaining_name, const TrieNo
99 if (trie_node.prefix(i)->context_index != ~0u) { 99 if (trie_node.prefix(i)->context_index != ~0u) {
100 *context_index = trie_node.prefix(i)->context_index; 100 *context_index = trie_node.prefix(i)->context_index;
101 } 101 }
102 if (trie_node.prefix(i)->schema_index != ~0u) { 102 if (trie_node.prefix(i)->type_index != ~0u) {
103 *schema_index = trie_node.prefix(i)->schema_index; 103 *type_index = trie_node.prefix(i)->type_index;
104 } 104 }
105 return; 105 return;
106 } 106 }
@@ -108,9 +108,9 @@ void PropertyInfoArea::CheckPrefixMatch(const char* remaining_name, const TrieNo
108} 108}
109 109
110void PropertyInfoArea::GetPropertyInfoIndexes(const char* name, uint32_t* context_index, 110void PropertyInfoArea::GetPropertyInfoIndexes(const char* name, uint32_t* context_index,
111 uint32_t* schema_index) const { 111 uint32_t* type_index) const {
112 uint32_t return_context_index = ~0u; 112 uint32_t return_context_index = ~0u;
113 uint32_t return_schema_index = ~0u; 113 uint32_t return_type_index = ~0u;
114 const char* remaining_name = name; 114 const char* remaining_name = name;
115 auto trie_node = root_node(); 115 auto trie_node = root_node();
116 while (true) { 116 while (true) {
@@ -120,13 +120,13 @@ void PropertyInfoArea::GetPropertyInfoIndexes(const char* name, uint32_t* contex
120 if (trie_node.context_index() != ~0u) { 120 if (trie_node.context_index() != ~0u) {
121 return_context_index = trie_node.context_index(); 121 return_context_index = trie_node.context_index();
122 } 122 }
123 if (trie_node.schema_index() != ~0u) { 123 if (trie_node.type_index() != ~0u) {
124 return_schema_index = trie_node.schema_index(); 124 return_type_index = trie_node.type_index();
125 } 125 }
126 126
127 // Check prefixes at this node. This comes after the node check since these prefixes are by 127 // Check prefixes at this node. This comes after the node check since these prefixes are by
128 // definition longer than the node itself. 128 // definition longer than the node itself.
129 CheckPrefixMatch(remaining_name, trie_node, &return_context_index, &return_schema_index); 129 CheckPrefixMatch(remaining_name, trie_node, &return_context_index, &return_type_index);
130 130
131 if (sep == nullptr) { 131 if (sep == nullptr) {
132 break; 132 break;
@@ -153,29 +153,29 @@ void PropertyInfoArea::GetPropertyInfoIndexes(const char* name, uint32_t* contex
153 *context_index = return_context_index; 153 *context_index = return_context_index;
154 } 154 }
155 } 155 }
156 if (schema_index != nullptr) { 156 if (type_index != nullptr) {
157 if (trie_node.exact_match(i)->schema_index != ~0u) { 157 if (trie_node.exact_match(i)->type_index != ~0u) {
158 *schema_index = trie_node.exact_match(i)->schema_index; 158 *type_index = trie_node.exact_match(i)->type_index;
159 } else { 159 } else {
160 *schema_index = return_schema_index; 160 *type_index = return_type_index;
161 } 161 }
162 } 162 }
163 return; 163 return;
164 } 164 }
165 } 165 }
166 // Check prefix matches for prefixes not deliminated with '.' 166 // Check prefix matches for prefixes not deliminated with '.'
167 CheckPrefixMatch(remaining_name, trie_node, &return_context_index, &return_schema_index); 167 CheckPrefixMatch(remaining_name, trie_node, &return_context_index, &return_type_index);
168 // Return previously found prefix match. 168 // Return previously found prefix match.
169 if (context_index != nullptr) *context_index = return_context_index; 169 if (context_index != nullptr) *context_index = return_context_index;
170 if (schema_index != nullptr) *schema_index = return_schema_index; 170 if (type_index != nullptr) *type_index = return_type_index;
171 return; 171 return;
172} 172}
173 173
174void PropertyInfoArea::GetPropertyInfo(const char* property, const char** context, 174void PropertyInfoArea::GetPropertyInfo(const char* property, const char** context,
175 const char** schema) const { 175 const char** type) const {
176 uint32_t context_index; 176 uint32_t context_index;
177 uint32_t schema_index; 177 uint32_t type_index;
178 GetPropertyInfoIndexes(property, &context_index, &schema_index); 178 GetPropertyInfoIndexes(property, &context_index, &type_index);
179 if (context != nullptr) { 179 if (context != nullptr) {
180 if (context_index == ~0u) { 180 if (context_index == ~0u) {
181 *context = nullptr; 181 *context = nullptr;
@@ -183,11 +183,11 @@ void PropertyInfoArea::GetPropertyInfo(const char* property, const char** contex
183 *context = this->context(context_index); 183 *context = this->context(context_index);
184 } 184 }
185 } 185 }
186 if (schema != nullptr) { 186 if (type != nullptr) {
187 if (schema_index == ~0u) { 187 if (type_index == ~0u) {
188 *schema = nullptr; 188 *type = nullptr;
189 } else { 189 } else {
190 *schema = this->schema(schema_index); 190 *type = this->type(type_index);
191 } 191 }
192 } 192 }
193} 193}
diff --git a/property_service/libpropertyinfoserializer/include/property_info_serializer/property_info_serializer.h b/property_service/libpropertyinfoserializer/include/property_info_serializer/property_info_serializer.h
index d2ec385d4..439813d12 100644
--- a/property_service/libpropertyinfoserializer/include/property_info_serializer/property_info_serializer.h
+++ b/property_service/libpropertyinfoserializer/include/property_info_serializer/property_info_serializer.h
@@ -26,19 +26,19 @@ namespace properties {
26struct PropertyInfoEntry { 26struct PropertyInfoEntry {
27 PropertyInfoEntry() {} 27 PropertyInfoEntry() {}
28 template <typename T, typename U, typename V> 28 template <typename T, typename U, typename V>
29 PropertyInfoEntry(T&& name, U&& context, V&& schema, bool exact_match) 29 PropertyInfoEntry(T&& name, U&& context, V&& type, bool exact_match)
30 : name(std::forward<T>(name)), 30 : name(std::forward<T>(name)),
31 context(std::forward<U>(context)), 31 context(std::forward<U>(context)),
32 schema(std::forward<V>(schema)), 32 type(std::forward<V>(type)),
33 exact_match(exact_match) {} 33 exact_match(exact_match) {}
34 std::string name; 34 std::string name;
35 std::string context; 35 std::string context;
36 std::string schema; 36 std::string type;
37 bool exact_match; 37 bool exact_match;
38}; 38};
39 39
40bool BuildTrie(const std::vector<PropertyInfoEntry>& property_info, 40bool BuildTrie(const std::vector<PropertyInfoEntry>& property_info,
41 const std::string& default_context, const std::string& default_schema, 41 const std::string& default_context, const std::string& default_type,
42 std::string* serialized_trie, std::string* error); 42 std::string* serialized_trie, std::string* error);
43 43
44void ParsePropertyInfoFile(const std::string& file_contents, 44void ParsePropertyInfoFile(const std::string& file_contents,
diff --git a/property_service/libpropertyinfoserializer/property_info_file.cpp b/property_service/libpropertyinfoserializer/property_info_file.cpp
index 702f219d8..bf96d88bf 100644
--- a/property_service/libpropertyinfoserializer/property_info_file.cpp
+++ b/property_service/libpropertyinfoserializer/property_info_file.cpp
@@ -28,9 +28,9 @@ bool ParsePropertyInfoLine(const std::string& line, PropertyInfoEntry* out, std:
28 28
29 // It is not an error to not find these, as older files will not contain them. 29 // It is not an error to not find these, as older files will not contain them.
30 auto exact_match = tokenizer.GetNext(); 30 auto exact_match = tokenizer.GetNext();
31 auto schema = tokenizer.GetRemaining(); 31 auto type = tokenizer.GetRemaining();
32 32
33 *out = {property, context, schema, exact_match == "exact"}; 33 *out = {property, context, type, exact_match == "exact"};
34 return true; 34 return true;
35} 35}
36 36
diff --git a/property_service/libpropertyinfoserializer/property_info_serializer.cpp b/property_service/libpropertyinfoserializer/property_info_serializer.cpp
index 656c96e33..803657ab8 100644
--- a/property_service/libpropertyinfoserializer/property_info_serializer.cpp
+++ b/property_service/libpropertyinfoserializer/property_info_serializer.cpp
@@ -27,13 +27,13 @@ namespace android {
27namespace properties { 27namespace properties {
28 28
29bool BuildTrie(const std::vector<PropertyInfoEntry>& property_info, 29bool BuildTrie(const std::vector<PropertyInfoEntry>& property_info,
30 const std::string& default_context, const std::string& default_schema, 30 const std::string& default_context, const std::string& default_type,
31 std::string* serialized_trie, std::string* error) { 31 std::string* serialized_trie, std::string* error) {
32 // Check that names are legal first 32 // Check that names are legal first
33 auto trie_builder = TrieBuilder(default_context, default_schema); 33 auto trie_builder = TrieBuilder(default_context, default_type);
34 34
35 for (const auto& [name, context, schema, is_exact] : property_info) { 35 for (const auto& [name, context, type, is_exact] : property_info) {
36 if (!trie_builder.AddToTrie(name, context, schema, is_exact, error)) { 36 if (!trie_builder.AddToTrie(name, context, type, is_exact, error)) {
37 return false; 37 return false;
38 } 38 }
39 } 39 }
diff --git a/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp b/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp
index 46c2d06ef..f4845505c 100644
--- a/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp
+++ b/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp
@@ -46,7 +46,7 @@ TEST(propertyinfoserializer, TrieNodeCheck) {
46 auto root_node = property_info_area->root_node(); 46 auto root_node = property_info_area->root_node();
47 EXPECT_STREQ("root", root_node.name()); 47 EXPECT_STREQ("root", root_node.name());
48 EXPECT_STREQ("default", property_info_area->context(root_node.context_index())); 48 EXPECT_STREQ("default", property_info_area->context(root_node.context_index()));
49 EXPECT_STREQ("default", property_info_area->schema(root_node.schema_index())); 49 EXPECT_STREQ("default", property_info_area->type(root_node.type_index()));
50 50
51 EXPECT_EQ(0U, root_node.num_prefixes()); 51 EXPECT_EQ(0U, root_node.num_prefixes());
52 EXPECT_EQ(0U, root_node.num_exact_matches()); 52 EXPECT_EQ(0U, root_node.num_exact_matches());
@@ -59,7 +59,7 @@ TEST(propertyinfoserializer, TrieNodeCheck) {
59 59
60 EXPECT_STREQ("test", test_node.name()); 60 EXPECT_STREQ("test", test_node.name());
61 EXPECT_STREQ("1st", property_info_area->context(test_node.context_index())); 61 EXPECT_STREQ("1st", property_info_area->context(test_node.context_index()));
62 EXPECT_STREQ("1st", property_info_area->schema(test_node.schema_index())); 62 EXPECT_STREQ("1st", property_info_area->type(test_node.type_index()));
63 63
64 EXPECT_EQ(0U, test_node.num_child_nodes()); 64 EXPECT_EQ(0U, test_node.num_child_nodes());
65 65
@@ -69,7 +69,7 @@ TEST(propertyinfoserializer, TrieNodeCheck) {
69 EXPECT_STREQ("test", serialized_trie.data() + prefix->name_offset); 69 EXPECT_STREQ("test", serialized_trie.data() + prefix->name_offset);
70 EXPECT_EQ(4U, prefix->namelen); 70 EXPECT_EQ(4U, prefix->namelen);
71 EXPECT_STREQ("2nd", property_info_area->context(prefix->context_index)); 71 EXPECT_STREQ("2nd", property_info_area->context(prefix->context_index));
72 EXPECT_STREQ("2nd", property_info_area->schema(prefix->schema_index)); 72 EXPECT_STREQ("2nd", property_info_area->type(prefix->type_index));
73 } 73 }
74 74
75 EXPECT_EQ(3U, test_node.num_exact_matches()); 75 EXPECT_EQ(3U, test_node.num_exact_matches());
@@ -85,9 +85,9 @@ TEST(propertyinfoserializer, TrieNodeCheck) {
85 EXPECT_STREQ("3rd", property_info_area->context(match2->context_index)); 85 EXPECT_STREQ("3rd", property_info_area->context(match2->context_index));
86 EXPECT_STREQ("3rd", property_info_area->context(match3->context_index)); 86 EXPECT_STREQ("3rd", property_info_area->context(match3->context_index));
87 87
88 EXPECT_STREQ("3rd", property_info_area->schema(match1->schema_index)); 88 EXPECT_STREQ("3rd", property_info_area->type(match1->type_index));
89 EXPECT_STREQ("3rd", property_info_area->schema(match2->schema_index)); 89 EXPECT_STREQ("3rd", property_info_area->type(match2->type_index));
90 EXPECT_STREQ("3rd", property_info_area->schema(match3->schema_index)); 90 EXPECT_STREQ("3rd", property_info_area->type(match3->type_index));
91 } 91 }
92 92
93 // Check the long string node 93 // Check the long string node
@@ -120,7 +120,7 @@ TEST(propertyinfoserializer, TrieNodeCheck) {
120 auto final_match = long_string_node.exact_match(0); 120 auto final_match = long_string_node.exact_match(0);
121 EXPECT_STREQ("string", serialized_trie.data() + final_match->name_offset); 121 EXPECT_STREQ("string", serialized_trie.data() + final_match->name_offset);
122 EXPECT_STREQ("4th", property_info_area->context(final_match->context_index)); 122 EXPECT_STREQ("4th", property_info_area->context(final_match->context_index));
123 EXPECT_STREQ("4th", property_info_area->schema(final_match->schema_index)); 123 EXPECT_STREQ("4th", property_info_area->type(final_match->type_index));
124} 124}
125 125
126TEST(propertyinfoserializer, GetPropertyInfo) { 126TEST(propertyinfoserializer, GetPropertyInfo) {
@@ -143,109 +143,109 @@ TEST(propertyinfoserializer, GetPropertyInfo) {
143 auto root_node = property_info_area->root_node(); 143 auto root_node = property_info_area->root_node();
144 EXPECT_STREQ("root", root_node.name()); 144 EXPECT_STREQ("root", root_node.name());
145 EXPECT_STREQ("default", property_info_area->context(root_node.context_index())); 145 EXPECT_STREQ("default", property_info_area->context(root_node.context_index()));
146 EXPECT_STREQ("default", property_info_area->schema(root_node.schema_index())); 146 EXPECT_STREQ("default", property_info_area->type(root_node.type_index()));
147 147
148 const char* context; 148 const char* context;
149 const char* schema; 149 const char* type;
150 property_info_area->GetPropertyInfo("abc", &context, &schema); 150 property_info_area->GetPropertyInfo("abc", &context, &type);
151 EXPECT_STREQ("default", context); 151 EXPECT_STREQ("default", context);
152 EXPECT_STREQ("default", schema); 152 EXPECT_STREQ("default", type);
153 property_info_area->GetPropertyInfo("abc.abc", &context, &schema); 153 property_info_area->GetPropertyInfo("abc.abc", &context, &type);
154 EXPECT_STREQ("default", context); 154 EXPECT_STREQ("default", context);
155 EXPECT_STREQ("default", schema); 155 EXPECT_STREQ("default", type);
156 property_info_area->GetPropertyInfo("123.abc", &context, &schema); 156 property_info_area->GetPropertyInfo("123.abc", &context, &type);
157 EXPECT_STREQ("default", context); 157 EXPECT_STREQ("default", context);
158 EXPECT_STREQ("default", schema); 158 EXPECT_STREQ("default", type);
159 159
160 property_info_area->GetPropertyInfo("test.a", &context, &schema); 160 property_info_area->GetPropertyInfo("test.a", &context, &type);
161 EXPECT_STREQ("1st", context); 161 EXPECT_STREQ("1st", context);
162 EXPECT_STREQ("1st", schema); 162 EXPECT_STREQ("1st", type);
163 property_info_area->GetPropertyInfo("test.b", &context, &schema); 163 property_info_area->GetPropertyInfo("test.b", &context, &type);
164 EXPECT_STREQ("1st", context); 164 EXPECT_STREQ("1st", context);
165 EXPECT_STREQ("1st", schema); 165 EXPECT_STREQ("1st", type);
166 property_info_area->GetPropertyInfo("test.c", &context, &schema); 166 property_info_area->GetPropertyInfo("test.c", &context, &type);
167 EXPECT_STREQ("1st", context); 167 EXPECT_STREQ("1st", context);
168 EXPECT_STREQ("1st", schema); 168 EXPECT_STREQ("1st", type);
169 169
170 property_info_area->GetPropertyInfo("test.test", &context, &schema); 170 property_info_area->GetPropertyInfo("test.test", &context, &type);
171 EXPECT_STREQ("5th", context); 171 EXPECT_STREQ("5th", context);
172 EXPECT_STREQ("5th", schema); 172 EXPECT_STREQ("5th", type);
173 property_info_area->GetPropertyInfo("test.testa", &context, &schema); 173 property_info_area->GetPropertyInfo("test.testa", &context, &type);
174 EXPECT_STREQ("2nd", context); 174 EXPECT_STREQ("2nd", context);
175 EXPECT_STREQ("2nd", schema); 175 EXPECT_STREQ("2nd", type);
176 property_info_area->GetPropertyInfo("test.testb", &context, &schema); 176 property_info_area->GetPropertyInfo("test.testb", &context, &type);
177 EXPECT_STREQ("2nd", context); 177 EXPECT_STREQ("2nd", context);
178 EXPECT_STREQ("2nd", schema); 178 EXPECT_STREQ("2nd", type);
179 property_info_area->GetPropertyInfo("test.testc", &context, &schema); 179 property_info_area->GetPropertyInfo("test.testc", &context, &type);
180 EXPECT_STREQ("2nd", context); 180 EXPECT_STREQ("2nd", context);
181 EXPECT_STREQ("2nd", schema); 181 EXPECT_STREQ("2nd", type);
182 182
183 property_info_area->GetPropertyInfo("test.test.a", &context, &schema); 183 property_info_area->GetPropertyInfo("test.test.a", &context, &type);
184 EXPECT_STREQ("2nd", context); 184 EXPECT_STREQ("2nd", context);
185 EXPECT_STREQ("2nd", schema); 185 EXPECT_STREQ("2nd", type);
186 property_info_area->GetPropertyInfo("test.test.b", &context, &schema); 186 property_info_area->GetPropertyInfo("test.test.b", &context, &type);
187 EXPECT_STREQ("2nd", context); 187 EXPECT_STREQ("2nd", context);
188 EXPECT_STREQ("2nd", schema); 188 EXPECT_STREQ("2nd", type);
189 property_info_area->GetPropertyInfo("test.test.c", &context, &schema); 189 property_info_area->GetPropertyInfo("test.test.c", &context, &type);
190 EXPECT_STREQ("2nd", context); 190 EXPECT_STREQ("2nd", context);
191 EXPECT_STREQ("2nd", schema); 191 EXPECT_STREQ("2nd", type);
192 192
193 property_info_area->GetPropertyInfo("test.test1", &context, &schema); 193 property_info_area->GetPropertyInfo("test.test1", &context, &type);
194 EXPECT_STREQ("3rd", context); 194 EXPECT_STREQ("3rd", context);
195 EXPECT_STREQ("3rd", schema); 195 EXPECT_STREQ("3rd", type);
196 property_info_area->GetPropertyInfo("test.test2", &context, &schema); 196 property_info_area->GetPropertyInfo("test.test2", &context, &type);
197 EXPECT_STREQ("7th", context); 197 EXPECT_STREQ("7th", context);
198 EXPECT_STREQ("7th", schema); 198 EXPECT_STREQ("7th", type);
199 property_info_area->GetPropertyInfo("test.test3", &context, &schema); 199 property_info_area->GetPropertyInfo("test.test3", &context, &type);
200 EXPECT_STREQ("3rd", context); 200 EXPECT_STREQ("3rd", context);
201 EXPECT_STREQ("3rd", schema); 201 EXPECT_STREQ("3rd", type);
202 202
203 property_info_area->GetPropertyInfo("test.test11", &context, &schema); 203 property_info_area->GetPropertyInfo("test.test11", &context, &type);
204 EXPECT_STREQ("2nd", context); 204 EXPECT_STREQ("2nd", context);
205 EXPECT_STREQ("2nd", schema); 205 EXPECT_STREQ("2nd", type);
206 property_info_area->GetPropertyInfo("test.test22", &context, &schema); 206 property_info_area->GetPropertyInfo("test.test22", &context, &type);
207 EXPECT_STREQ("2nd", context); 207 EXPECT_STREQ("2nd", context);
208 EXPECT_STREQ("2nd", schema); 208 EXPECT_STREQ("2nd", type);
209 property_info_area->GetPropertyInfo("test.test33", &context, &schema); 209 property_info_area->GetPropertyInfo("test.test33", &context, &type);
210 EXPECT_STREQ("2nd", context); 210 EXPECT_STREQ("2nd", context);
211 EXPECT_STREQ("2nd", schema); 211 EXPECT_STREQ("2nd", type);
212 212
213 property_info_area->GetPropertyInfo("this.is.a.long.string", &context, &schema); 213 property_info_area->GetPropertyInfo("this.is.a.long.string", &context, &type);
214 EXPECT_STREQ("4th", context); 214 EXPECT_STREQ("4th", context);
215 EXPECT_STREQ("4th", schema); 215 EXPECT_STREQ("4th", type);
216 216
217 property_info_area->GetPropertyInfo("this.is.a.long", &context, &schema); 217 property_info_area->GetPropertyInfo("this.is.a.long", &context, &type);
218 EXPECT_STREQ("default", context); 218 EXPECT_STREQ("default", context);
219 EXPECT_STREQ("default", schema); 219 EXPECT_STREQ("default", type);
220 property_info_area->GetPropertyInfo("this.is.a", &context, &schema); 220 property_info_area->GetPropertyInfo("this.is.a", &context, &type);
221 EXPECT_STREQ("default", context); 221 EXPECT_STREQ("default", context);
222 EXPECT_STREQ("default", schema); 222 EXPECT_STREQ("default", type);
223 property_info_area->GetPropertyInfo("this.is", &context, &schema); 223 property_info_area->GetPropertyInfo("this.is", &context, &type);
224 EXPECT_STREQ("default", context); 224 EXPECT_STREQ("default", context);
225 EXPECT_STREQ("default", schema); 225 EXPECT_STREQ("default", type);
226 property_info_area->GetPropertyInfo("this", &context, &schema); 226 property_info_area->GetPropertyInfo("this", &context, &type);
227 EXPECT_STREQ("default", context); 227 EXPECT_STREQ("default", context);
228 EXPECT_STREQ("default", schema); 228 EXPECT_STREQ("default", type);
229 229
230 property_info_area->GetPropertyInfo("test.test2.a", &context, &schema); 230 property_info_area->GetPropertyInfo("test.test2.a", &context, &type);
231 EXPECT_STREQ("6th", context); 231 EXPECT_STREQ("6th", context);
232 EXPECT_STREQ("6th", schema); 232 EXPECT_STREQ("6th", type);
233 233
234 property_info_area->GetPropertyInfo("testoneword", &context, &schema); 234 property_info_area->GetPropertyInfo("testoneword", &context, &type);
235 EXPECT_STREQ("8th", context); 235 EXPECT_STREQ("8th", context);
236 EXPECT_STREQ("8th", schema); 236 EXPECT_STREQ("8th", type);
237 237
238 property_info_area->GetPropertyInfo("testwordprefix", &context, &schema); 238 property_info_area->GetPropertyInfo("testwordprefix", &context, &type);
239 EXPECT_STREQ("9th", context); 239 EXPECT_STREQ("9th", context);
240 EXPECT_STREQ("9th", schema); 240 EXPECT_STREQ("9th", type);
241 241
242 property_info_area->GetPropertyInfo("testwordprefixblah", &context, &schema); 242 property_info_area->GetPropertyInfo("testwordprefixblah", &context, &type);
243 EXPECT_STREQ("9th", context); 243 EXPECT_STREQ("9th", context);
244 EXPECT_STREQ("9th", schema); 244 EXPECT_STREQ("9th", type);
245 245
246 property_info_area->GetPropertyInfo("testwordprefix.blah", &context, &schema); 246 property_info_area->GetPropertyInfo("testwordprefix.blah", &context, &type);
247 EXPECT_STREQ("9th", context); 247 EXPECT_STREQ("9th", context);
248 EXPECT_STREQ("9th", schema); 248 EXPECT_STREQ("9th", type);
249} 249}
250 250
251TEST(propertyinfoserializer, RealProperties) { 251TEST(propertyinfoserializer, RealProperties) {
@@ -777,35 +777,34 @@ TEST(propertyinfoserializer, GetPropertyInfo_prefix_without_dot) {
777 auto property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_trie.data()); 777 auto property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_trie.data());
778 778
779 const char* context; 779 const char* context;
780 const char* schema; 780 const char* type;
781 property_info_area->GetPropertyInfo("persist.radio", &context, &schema); 781 property_info_area->GetPropertyInfo("persist.radio", &context, &type);
782 EXPECT_STREQ("1st", context); 782 EXPECT_STREQ("1st", context);
783 EXPECT_STREQ("1st", schema); 783 EXPECT_STREQ("1st", type);
784 property_info_area->GetPropertyInfo("persist.radio.subproperty", &context, &schema); 784 property_info_area->GetPropertyInfo("persist.radio.subproperty", &context, &type);
785 EXPECT_STREQ("1st", context); 785 EXPECT_STREQ("1st", context);
786 EXPECT_STREQ("1st", schema); 786 EXPECT_STREQ("1st", type);
787 property_info_area->GetPropertyInfo("persist.radiowords", &context, &schema); 787 property_info_area->GetPropertyInfo("persist.radiowords", &context, &type);
788 EXPECT_STREQ("1st", context); 788 EXPECT_STREQ("1st", context);
789 EXPECT_STREQ("1st", schema); 789 EXPECT_STREQ("1st", type);
790 property_info_area->GetPropertyInfo("persist.radio.long.long.long.sub.property", &context, 790 property_info_area->GetPropertyInfo("persist.radio.long.long.long.sub.property", &context, &type);
791 &schema);
792 EXPECT_STREQ("1st", context); 791 EXPECT_STREQ("1st", context);
793 EXPECT_STREQ("1st", schema); 792 EXPECT_STREQ("1st", type);
794 property_info_area->GetPropertyInfo("persist.radio.something.else.here", &context, &schema); 793 property_info_area->GetPropertyInfo("persist.radio.something.else.here", &context, &type);
795 EXPECT_STREQ("2nd", context); 794 EXPECT_STREQ("2nd", context);
796 EXPECT_STREQ("2nd", schema); 795 EXPECT_STREQ("2nd", type);
797 property_info_area->GetPropertyInfo("persist.radio.something.else.here2", &context, &schema); 796 property_info_area->GetPropertyInfo("persist.radio.something.else.here2", &context, &type);
798 EXPECT_STREQ("2nd", context); 797 EXPECT_STREQ("2nd", context);
799 EXPECT_STREQ("2nd", schema); 798 EXPECT_STREQ("2nd", type);
800 property_info_area->GetPropertyInfo("persist.radio.something.else.here.after", &context, &schema); 799 property_info_area->GetPropertyInfo("persist.radio.something.else.here.after", &context, &type);
801 EXPECT_STREQ("2nd", context); 800 EXPECT_STREQ("2nd", context);
802 EXPECT_STREQ("2nd", schema); 801 EXPECT_STREQ("2nd", type);
803 property_info_area->GetPropertyInfo("persist.radio.something.else.nothere", &context, &schema); 802 property_info_area->GetPropertyInfo("persist.radio.something.else.nothere", &context, &type);
804 EXPECT_STREQ("1st", context); 803 EXPECT_STREQ("1st", context);
805 EXPECT_STREQ("1st", schema); 804 EXPECT_STREQ("1st", type);
806 property_info_area->GetPropertyInfo("persist.radio.something.else", &context, &schema); 805 property_info_area->GetPropertyInfo("persist.radio.something.else", &context, &type);
807 EXPECT_STREQ("1st", context); 806 EXPECT_STREQ("1st", context);
808 EXPECT_STREQ("1st", schema); 807 EXPECT_STREQ("1st", type);
809} 808}
810 809
811TEST(propertyinfoserializer, GetPropertyInfo_prefix_with_dot_vs_without) { 810TEST(propertyinfoserializer, GetPropertyInfo_prefix_with_dot_vs_without) {
@@ -823,28 +822,28 @@ TEST(propertyinfoserializer, GetPropertyInfo_prefix_with_dot_vs_without) {
823 auto property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_trie.data()); 822 auto property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_trie.data());
824 823
825 const char* context; 824 const char* context;
826 const char* schema; 825 const char* type;
827 property_info_area->GetPropertyInfo("persist.notradio", &context, &schema); 826 property_info_area->GetPropertyInfo("persist.notradio", &context, &type);
828 EXPECT_STREQ("1st", context); 827 EXPECT_STREQ("1st", context);
829 EXPECT_STREQ("1st", schema); 828 EXPECT_STREQ("1st", type);
830 property_info_area->GetPropertyInfo("persist.radio", &context, &schema); 829 property_info_area->GetPropertyInfo("persist.radio", &context, &type);
831 EXPECT_STREQ("2nd", context); 830 EXPECT_STREQ("2nd", context);
832 EXPECT_STREQ("2nd", schema); 831 EXPECT_STREQ("2nd", type);
833 property_info_area->GetPropertyInfo("persist.radio.subproperty", &context, &schema); 832 property_info_area->GetPropertyInfo("persist.radio.subproperty", &context, &type);
834 EXPECT_STREQ("2nd", context); 833 EXPECT_STREQ("2nd", context);
835 EXPECT_STREQ("2nd", schema); 834 EXPECT_STREQ("2nd", type);
836 property_info_area->GetPropertyInfo("persist.radiowords", &context, &schema); 835 property_info_area->GetPropertyInfo("persist.radiowords", &context, &type);
837 EXPECT_STREQ("2nd", context); 836 EXPECT_STREQ("2nd", context);
838 EXPECT_STREQ("2nd", schema); 837 EXPECT_STREQ("2nd", type);
839 property_info_area->GetPropertyInfo("persist.radio.long.property.prefix.match", &context, &schema); 838 property_info_area->GetPropertyInfo("persist.radio.long.property.prefix.match", &context, &type);
840 EXPECT_STREQ("2nd", context); 839 EXPECT_STREQ("2nd", context);
841 EXPECT_STREQ("2nd", schema); 840 EXPECT_STREQ("2nd", type);
842 property_info_area->GetPropertyInfo("persist.radio.long.property.exact.match", &context, &schema); 841 property_info_area->GetPropertyInfo("persist.radio.long.property.exact.match", &context, &type);
843 EXPECT_STREQ("3rd", context); 842 EXPECT_STREQ("3rd", context);
844 EXPECT_STREQ("3rd", schema); 843 EXPECT_STREQ("3rd", type);
845} 844}
846 845
847TEST(propertyinfoserializer, GetPropertyInfo_empty_context_and_schema) { 846TEST(propertyinfoserializer, GetPropertyInfo_empty_context_and_type) {
848 auto property_info = std::vector<PropertyInfoEntry>{ 847 auto property_info = std::vector<PropertyInfoEntry>{
849 {"persist.", "1st", "", false}, 848 {"persist.", "1st", "", false},
850 {"persist.dot_prefix.", "2nd", "", false}, 849 {"persist.dot_prefix.", "2nd", "", false},
@@ -862,28 +861,28 @@ TEST(propertyinfoserializer, GetPropertyInfo_empty_context_and_schema) {
862 auto property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_trie.data()); 861 auto property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_trie.data());
863 862
864 const char* context; 863 const char* context;
865 const char* schema; 864 const char* type;
866 property_info_area->GetPropertyInfo("notpersist.radio.something", &context, &schema); 865 property_info_area->GetPropertyInfo("notpersist.radio.something", &context, &type);
867 EXPECT_STREQ("default", context); 866 EXPECT_STREQ("default", context);
868 EXPECT_STREQ("default", schema); 867 EXPECT_STREQ("default", type);
869 property_info_area->GetPropertyInfo("persist.nomatch", &context, &schema); 868 property_info_area->GetPropertyInfo("persist.nomatch", &context, &type);
870 EXPECT_STREQ("1st", context); 869 EXPECT_STREQ("1st", context);
871 EXPECT_STREQ("default", schema); 870 EXPECT_STREQ("default", type);
872 property_info_area->GetPropertyInfo("persist.dot_prefix.something", &context, &schema); 871 property_info_area->GetPropertyInfo("persist.dot_prefix.something", &context, &type);
873 EXPECT_STREQ("2nd", context); 872 EXPECT_STREQ("2nd", context);
874 EXPECT_STREQ("default", schema); 873 EXPECT_STREQ("default", type);
875 property_info_area->GetPropertyInfo("persist.non_dot_prefix.something", &context, &schema); 874 property_info_area->GetPropertyInfo("persist.non_dot_prefix.something", &context, &type);
876 EXPECT_STREQ("3rd", context); 875 EXPECT_STREQ("3rd", context);
877 EXPECT_STREQ("default", schema); 876 EXPECT_STREQ("default", type);
878 property_info_area->GetPropertyInfo("persist.exact_match", &context, &schema); 877 property_info_area->GetPropertyInfo("persist.exact_match", &context, &type);
879 EXPECT_STREQ("1st", context); 878 EXPECT_STREQ("1st", context);
880 EXPECT_STREQ("default", schema); 879 EXPECT_STREQ("default", type);
881 property_info_area->GetPropertyInfo("persist.dot_prefix2.something", &context, &schema); 880 property_info_area->GetPropertyInfo("persist.dot_prefix2.something", &context, &type);
882 EXPECT_STREQ("1st", context); 881 EXPECT_STREQ("1st", context);
883 EXPECT_STREQ("4th", schema); 882 EXPECT_STREQ("4th", type);
884 property_info_area->GetPropertyInfo("persist.non_dot_prefix2.something", &context, &schema); 883 property_info_area->GetPropertyInfo("persist.non_dot_prefix2.something", &context, &type);
885 EXPECT_STREQ("1st", context); 884 EXPECT_STREQ("1st", context);
886 EXPECT_STREQ("5th", schema); 885 EXPECT_STREQ("5th", type);
887} 886}
888 887
889} // namespace properties 888} // namespace properties
diff --git a/property_service/libpropertyinfoserializer/trie_builder.cpp b/property_service/libpropertyinfoserializer/trie_builder.cpp
index feb753be7..8c5ce8495 100644
--- a/property_service/libpropertyinfoserializer/trie_builder.cpp
+++ b/property_service/libpropertyinfoserializer/trie_builder.cpp
@@ -23,23 +23,23 @@ using android::base::Split;
23namespace android { 23namespace android {
24namespace properties { 24namespace properties {
25 25
26TrieBuilder::TrieBuilder(const std::string& default_context, const std::string& default_schema) 26TrieBuilder::TrieBuilder(const std::string& default_context, const std::string& default_type)
27 : builder_root_("root") { 27 : builder_root_("root") {
28 auto* context_pointer = StringPointerFromContainer(default_context, &contexts_); 28 auto* context_pointer = StringPointerFromContainer(default_context, &contexts_);
29 builder_root_.set_context(context_pointer); 29 builder_root_.set_context(context_pointer);
30 auto* schema_pointer = StringPointerFromContainer(default_schema, &schemas_); 30 auto* type_pointer = StringPointerFromContainer(default_type, &types_);
31 builder_root_.set_schema(schema_pointer); 31 builder_root_.set_type(type_pointer);
32} 32}
33 33
34bool TrieBuilder::AddToTrie(const std::string& name, const std::string& context, 34bool TrieBuilder::AddToTrie(const std::string& name, const std::string& context,
35 const std::string& schema, bool exact, std::string* error) { 35 const std::string& type, bool exact, std::string* error) {
36 auto* context_pointer = StringPointerFromContainer(context, &contexts_); 36 auto* context_pointer = StringPointerFromContainer(context, &contexts_);
37 auto* schema_pointer = StringPointerFromContainer(schema, &schemas_); 37 auto* type_pointer = StringPointerFromContainer(type, &types_);
38 return AddToTrie(name, context_pointer, schema_pointer, exact, error); 38 return AddToTrie(name, context_pointer, type_pointer, exact, error);
39} 39}
40 40
41bool TrieBuilder::AddToTrie(const std::string& name, const std::string* context, 41bool TrieBuilder::AddToTrie(const std::string& name, const std::string* context,
42 const std::string* schema, bool exact, std::string* error) { 42 const std::string* type, bool exact, std::string* error) {
43 TrieBuilderNode* current_node = &builder_root_; 43 TrieBuilderNode* current_node = &builder_root_;
44 44
45 auto name_pieces = Split(name, "."); 45 auto name_pieces = Split(name, ".");
@@ -66,12 +66,12 @@ bool TrieBuilder::AddToTrie(const std::string& name, const std::string* context,
66 66
67 // Store our context based on what type of match it is. 67 // Store our context based on what type of match it is.
68 if (exact) { 68 if (exact) {
69 if (!current_node->AddExactMatchContext(name_pieces.front(), context, schema)) { 69 if (!current_node->AddExactMatchContext(name_pieces.front(), context, type)) {
70 *error = "Duplicate exact match detected for '" + name + "'"; 70 *error = "Duplicate exact match detected for '" + name + "'";
71 return false; 71 return false;
72 } 72 }
73 } else if (!ends_with_dot) { 73 } else if (!ends_with_dot) {
74 if (!current_node->AddPrefixContext(name_pieces.front(), context, schema)) { 74 if (!current_node->AddPrefixContext(name_pieces.front(), context, type)) {
75 *error = "Duplicate prefix match detected for '" + name + "'"; 75 *error = "Duplicate prefix match detected for '" + name + "'";
76 return false; 76 return false;
77 } 77 }
@@ -84,12 +84,12 @@ bool TrieBuilder::AddToTrie(const std::string& name, const std::string* context,
84 *error = "Unable to allocate Trie node"; 84 *error = "Unable to allocate Trie node";
85 return false; 85 return false;
86 } 86 }
87 if (child->context() != nullptr || child->schema() != nullptr) { 87 if (child->context() != nullptr || child->type() != nullptr) {
88 *error = "Duplicate prefix match detected for '" + name + "'"; 88 *error = "Duplicate prefix match detected for '" + name + "'";
89 return false; 89 return false;
90 } 90 }
91 child->set_context(context); 91 child->set_context(context);
92 child->set_schema(schema); 92 child->set_type(type);
93 } 93 }
94 return true; 94 return true;
95} 95}
diff --git a/property_service/libpropertyinfoserializer/trie_builder.h b/property_service/libpropertyinfoserializer/trie_builder.h
index f928e764f..b971589fe 100644
--- a/property_service/libpropertyinfoserializer/trie_builder.h
+++ b/property_service/libpropertyinfoserializer/trie_builder.h
@@ -26,13 +26,12 @@ namespace android {
26namespace properties { 26namespace properties {
27 27
28struct PropertyEntryBuilder { 28struct PropertyEntryBuilder {
29 PropertyEntryBuilder() : context(nullptr), schema(nullptr) {} 29 PropertyEntryBuilder() : context(nullptr), type(nullptr) {}
30 PropertyEntryBuilder(const std::string& name, const std::string* context, 30 PropertyEntryBuilder(const std::string& name, const std::string* context, const std::string* type)
31 const std::string* schema) 31 : name(name), context(context), type(type) {}
32 : name(name), context(context), schema(schema) {}
33 std::string name; 32 std::string name;
34 const std::string* context; 33 const std::string* context;
35 const std::string* schema; 34 const std::string* type;
36}; 35};
37 36
38class TrieBuilderNode { 37class TrieBuilderNode {
@@ -56,33 +55,33 @@ class TrieBuilderNode {
56 TrieBuilderNode* AddChild(const std::string& name) { return &children_.emplace_back(name); } 55 TrieBuilderNode* AddChild(const std::string& name) { return &children_.emplace_back(name); }
57 56
58 bool AddPrefixContext(const std::string& prefix, const std::string* context, 57 bool AddPrefixContext(const std::string& prefix, const std::string* context,
59 const std::string* schema) { 58 const std::string* type) {
60 if (std::find_if(prefixes_.begin(), prefixes_.end(), 59 if (std::find_if(prefixes_.begin(), prefixes_.end(),
61 [&prefix](const auto& t) { return t.name == prefix; }) != prefixes_.end()) { 60 [&prefix](const auto& t) { return t.name == prefix; }) != prefixes_.end()) {
62 return false; 61 return false;
63 } 62 }
64 63
65 prefixes_.emplace_back(prefix, context, schema); 64 prefixes_.emplace_back(prefix, context, type);
66 return true; 65 return true;
67 } 66 }
68 67
69 bool AddExactMatchContext(const std::string& exact_match, const std::string* context, 68 bool AddExactMatchContext(const std::string& exact_match, const std::string* context,
70 const std::string* schema) { 69 const std::string* type) {
71 if (std::find_if(exact_matches_.begin(), exact_matches_.end(), [&exact_match](const auto& t) { 70 if (std::find_if(exact_matches_.begin(), exact_matches_.end(), [&exact_match](const auto& t) {
72 return t.name == exact_match; 71 return t.name == exact_match;
73 }) != exact_matches_.end()) { 72 }) != exact_matches_.end()) {
74 return false; 73 return false;
75 } 74 }
76 75
77 exact_matches_.emplace_back(exact_match, context, schema); 76 exact_matches_.emplace_back(exact_match, context, type);
78 return true; 77 return true;
79 } 78 }
80 79
81 const std::string& name() const { return property_entry_.name; } 80 const std::string& name() const { return property_entry_.name; }
82 const std::string* context() const { return property_entry_.context; } 81 const std::string* context() const { return property_entry_.context; }
83 void set_context(const std::string* context) { property_entry_.context = context; } 82 void set_context(const std::string* context) { property_entry_.context = context; }
84 const std::string* schema() const { return property_entry_.schema; } 83 const std::string* type() const { return property_entry_.type; }
85 void set_schema(const std::string* schema) { property_entry_.schema = schema; } 84 void set_type(const std::string* type) { property_entry_.type = type; }
86 85
87 const PropertyEntryBuilder property_entry() const { return property_entry_; } 86 const PropertyEntryBuilder property_entry() const { return property_entry_; }
88 87
@@ -99,23 +98,23 @@ class TrieBuilderNode {
99 98
100class TrieBuilder { 99class TrieBuilder {
101 public: 100 public:
102 TrieBuilder(const std::string& default_context, const std::string& default_schema); 101 TrieBuilder(const std::string& default_context, const std::string& default_type);
103 bool AddToTrie(const std::string& name, const std::string& context, const std::string& schema, 102 bool AddToTrie(const std::string& name, const std::string& context, const std::string& type,
104 bool exact, std::string* error); 103 bool exact, std::string* error);
105 104
106 const TrieBuilderNode builder_root() const { return builder_root_; } 105 const TrieBuilderNode builder_root() const { return builder_root_; }
107 const std::set<std::string>& contexts() const { return contexts_; } 106 const std::set<std::string>& contexts() const { return contexts_; }
108 const std::set<std::string>& schemas() const { return schemas_; } 107 const std::set<std::string>& types() const { return types_; }
109 108
110 private: 109 private:
111 bool AddToTrie(const std::string& name, const std::string* context, const std::string* schema, 110 bool AddToTrie(const std::string& name, const std::string* context, const std::string* type,
112 bool exact, std::string* error); 111 bool exact, std::string* error);
113 const std::string* StringPointerFromContainer(const std::string& string, 112 const std::string* StringPointerFromContainer(const std::string& string,
114 std::set<std::string>* container); 113 std::set<std::string>* container);
115 114
116 TrieBuilderNode builder_root_; 115 TrieBuilderNode builder_root_;
117 std::set<std::string> contexts_; 116 std::set<std::string> contexts_;
118 std::set<std::string> schemas_; 117 std::set<std::string> types_;
119}; 118};
120 119
121} // namespace properties 120} // namespace properties
diff --git a/property_service/libpropertyinfoserializer/trie_builder_test.cpp b/property_service/libpropertyinfoserializer/trie_builder_test.cpp
index 2b948f3b0..50788108d 100644
--- a/property_service/libpropertyinfoserializer/trie_builder_test.cpp
+++ b/property_service/libpropertyinfoserializer/trie_builder_test.cpp
@@ -22,19 +22,19 @@ namespace android {
22namespace properties { 22namespace properties {
23 23
24TEST(propertyinfoserializer, BuildTrie_Simple) { 24TEST(propertyinfoserializer, BuildTrie_Simple) {
25 auto trie_builder = TrieBuilder("default", "default_schema"); 25 auto trie_builder = TrieBuilder("default", "default_type");
26 26
27 // Add test data to tree 27 // Add test data to tree
28 auto error = std::string(); 28 auto error = std::string();
29 EXPECT_TRUE(trie_builder.AddToTrie("test.", "1st", "1st_schema", false, &error)); 29 EXPECT_TRUE(trie_builder.AddToTrie("test.", "1st", "1st_type", false, &error));
30 EXPECT_TRUE(trie_builder.AddToTrie("test.test", "2nd", "2nd_schema", false, &error)); 30 EXPECT_TRUE(trie_builder.AddToTrie("test.test", "2nd", "2nd_type", false, &error));
31 EXPECT_TRUE(trie_builder.AddToTrie("test.test1", "3rd", "3rd_schema", true, &error)); 31 EXPECT_TRUE(trie_builder.AddToTrie("test.test1", "3rd", "3rd_type", true, &error));
32 EXPECT_TRUE(trie_builder.AddToTrie("test.test2", "3rd", "3rd_schema", true, &error)); 32 EXPECT_TRUE(trie_builder.AddToTrie("test.test2", "3rd", "3rd_type", true, &error));
33 EXPECT_TRUE(trie_builder.AddToTrie("test.test3", "3rd", "3rd_schema", true, &error)); 33 EXPECT_TRUE(trie_builder.AddToTrie("test.test3", "3rd", "3rd_type", true, &error));
34 EXPECT_TRUE(trie_builder.AddToTrie("this.is.a.long.string", "4th", "4th_schema", true, &error)); 34 EXPECT_TRUE(trie_builder.AddToTrie("this.is.a.long.string", "4th", "4th_type", true, &error));
35 35
36 ASSERT_EQ(5U, trie_builder.contexts().size()); 36 ASSERT_EQ(5U, trie_builder.contexts().size());
37 ASSERT_EQ(5U, trie_builder.schemas().size()); 37 ASSERT_EQ(5U, trie_builder.types().size());
38 38
39 auto& builder_root = trie_builder.builder_root(); 39 auto& builder_root = trie_builder.builder_root();
40 40
@@ -42,8 +42,8 @@ TEST(propertyinfoserializer, BuildTrie_Simple) {
42 EXPECT_EQ("root", builder_root.name()); 42 EXPECT_EQ("root", builder_root.name());
43 ASSERT_NE(nullptr, builder_root.context()); 43 ASSERT_NE(nullptr, builder_root.context());
44 EXPECT_EQ("default", *builder_root.context()); 44 EXPECT_EQ("default", *builder_root.context());
45 ASSERT_NE(nullptr, builder_root.schema()); 45 ASSERT_NE(nullptr, builder_root.type());
46 EXPECT_EQ("default_schema", *builder_root.schema()); 46 EXPECT_EQ("default_type", *builder_root.type());
47 47
48 EXPECT_EQ(0U, builder_root.prefixes().size()); 48 EXPECT_EQ(0U, builder_root.prefixes().size());
49 EXPECT_EQ(0U, builder_root.exact_matches().size()); 49 EXPECT_EQ(0U, builder_root.exact_matches().size());
@@ -55,8 +55,8 @@ TEST(propertyinfoserializer, BuildTrie_Simple) {
55 EXPECT_EQ("test", test_node->name()); 55 EXPECT_EQ("test", test_node->name());
56 ASSERT_NE(nullptr, test_node->context()); 56 ASSERT_NE(nullptr, test_node->context());
57 EXPECT_EQ("1st", *test_node->context()); 57 EXPECT_EQ("1st", *test_node->context());
58 ASSERT_NE(nullptr, test_node->schema()); 58 ASSERT_NE(nullptr, test_node->type());
59 EXPECT_EQ("1st_schema", *test_node->schema()); 59 EXPECT_EQ("1st_type", *test_node->type());
60 60
61 EXPECT_EQ(0U, test_node->children().size()); 61 EXPECT_EQ(0U, test_node->children().size());
62 EXPECT_EQ(1U, test_node->prefixes().size()); 62 EXPECT_EQ(1U, test_node->prefixes().size());
@@ -65,8 +65,8 @@ TEST(propertyinfoserializer, BuildTrie_Simple) {
65 EXPECT_EQ("test", property_entry.name); 65 EXPECT_EQ("test", property_entry.name);
66 ASSERT_NE(nullptr, property_entry.context); 66 ASSERT_NE(nullptr, property_entry.context);
67 EXPECT_EQ("2nd", *property_entry.context); 67 EXPECT_EQ("2nd", *property_entry.context);
68 ASSERT_NE(nullptr, property_entry.schema); 68 ASSERT_NE(nullptr, property_entry.type);
69 EXPECT_EQ("2nd_schema", *property_entry.schema); 69 EXPECT_EQ("2nd_type", *property_entry.type);
70 } 70 }
71 EXPECT_EQ(3U, test_node->exact_matches().size()); 71 EXPECT_EQ(3U, test_node->exact_matches().size());
72 EXPECT_EQ("test1", test_node->exact_matches()[0].name); 72 EXPECT_EQ("test1", test_node->exact_matches()[0].name);
@@ -80,18 +80,18 @@ TEST(propertyinfoserializer, BuildTrie_Simple) {
80 EXPECT_EQ("3rd", *test_node->exact_matches()[1].context); 80 EXPECT_EQ("3rd", *test_node->exact_matches()[1].context);
81 EXPECT_EQ("3rd", *test_node->exact_matches()[2].context); 81 EXPECT_EQ("3rd", *test_node->exact_matches()[2].context);
82 82
83 ASSERT_NE(nullptr, test_node->exact_matches()[0].schema); 83 ASSERT_NE(nullptr, test_node->exact_matches()[0].type);
84 ASSERT_NE(nullptr, test_node->exact_matches()[1].schema); 84 ASSERT_NE(nullptr, test_node->exact_matches()[1].type);
85 ASSERT_NE(nullptr, test_node->exact_matches()[2].schema); 85 ASSERT_NE(nullptr, test_node->exact_matches()[2].type);
86 EXPECT_EQ("3rd_schema", *test_node->exact_matches()[0].schema); 86 EXPECT_EQ("3rd_type", *test_node->exact_matches()[0].type);
87 EXPECT_EQ("3rd_schema", *test_node->exact_matches()[1].schema); 87 EXPECT_EQ("3rd_type", *test_node->exact_matches()[1].type);
88 EXPECT_EQ("3rd_schema", *test_node->exact_matches()[2].schema); 88 EXPECT_EQ("3rd_type", *test_node->exact_matches()[2].type);
89 89
90 // Check the long string node 90 // Check the long string node
91 auto expect_empty_one_child = [](auto* node) { 91 auto expect_empty_one_child = [](auto* node) {
92 ASSERT_NE(nullptr, node); 92 ASSERT_NE(nullptr, node);
93 EXPECT_EQ(nullptr, node->context()); 93 EXPECT_EQ(nullptr, node->context());
94 EXPECT_EQ(nullptr, node->schema()); 94 EXPECT_EQ(nullptr, node->type());
95 EXPECT_EQ(0U, node->prefixes().size()); 95 EXPECT_EQ(0U, node->prefixes().size());
96 EXPECT_EQ(0U, node->exact_matches().size()); 96 EXPECT_EQ(0U, node->exact_matches().size());
97 EXPECT_EQ(1U, node->children().size()); 97 EXPECT_EQ(1U, node->children().size());
@@ -120,8 +120,8 @@ TEST(propertyinfoserializer, BuildTrie_Simple) {
120 EXPECT_EQ("string", property_entry.name); 120 EXPECT_EQ("string", property_entry.name);
121 ASSERT_NE(nullptr, property_entry.context); 121 ASSERT_NE(nullptr, property_entry.context);
122 EXPECT_EQ("4th", *property_entry.context); 122 EXPECT_EQ("4th", *property_entry.context);
123 ASSERT_NE(nullptr, property_entry.schema); 123 ASSERT_NE(nullptr, property_entry.type);
124 EXPECT_EQ("4th_schema", *property_entry.schema); 124 EXPECT_EQ("4th_type", *property_entry.type);
125 } 125 }
126} 126}
127 127
diff --git a/property_service/libpropertyinfoserializer/trie_serializer.cpp b/property_service/libpropertyinfoserializer/trie_serializer.cpp
index 5326537f4..adeed1bf7 100644
--- a/property_service/libpropertyinfoserializer/trie_serializer.cpp
+++ b/property_service/libpropertyinfoserializer/trie_serializer.cpp
@@ -43,15 +43,15 @@ uint32_t TrieSerializer::WritePropertyEntry(const PropertyEntryBuilder& property
43 uint32_t context_index = property_entry.context != nullptr && !property_entry.context->empty() 43 uint32_t context_index = property_entry.context != nullptr && !property_entry.context->empty()
44 ? serialized_info()->FindContextIndex(property_entry.context->c_str()) 44 ? serialized_info()->FindContextIndex(property_entry.context->c_str())
45 : ~0u; 45 : ~0u;
46 uint32_t schema_index = property_entry.schema != nullptr && !property_entry.schema->empty() 46 uint32_t type_index = property_entry.type != nullptr && !property_entry.type->empty()
47 ? serialized_info()->FindSchemaIndex(property_entry.schema->c_str()) 47 ? serialized_info()->FindTypeIndex(property_entry.type->c_str())
48 : ~0u; 48 : ~0u;
49 uint32_t offset; 49 uint32_t offset;
50 auto serialized_property_entry = arena_->AllocateObject<PropertyEntry>(&offset); 50 auto serialized_property_entry = arena_->AllocateObject<PropertyEntry>(&offset);
51 serialized_property_entry->name_offset = arena_->AllocateAndWriteString(property_entry.name); 51 serialized_property_entry->name_offset = arena_->AllocateAndWriteString(property_entry.name);
52 serialized_property_entry->namelen = property_entry.name.size(); 52 serialized_property_entry->namelen = property_entry.name.size();
53 serialized_property_entry->context_index = context_index; 53 serialized_property_entry->context_index = context_index;
54 serialized_property_entry->schema_index = schema_index; 54 serialized_property_entry->type_index = type_index;
55 return offset; 55 return offset;
56} 56}
57 57
@@ -122,9 +122,9 @@ std::string TrieSerializer::SerializeTrie(const TrieBuilder& trie_builder) {
122 header->contexts_offset = arena_->size(); 122 header->contexts_offset = arena_->size();
123 SerializeStrings(trie_builder.contexts()); 123 SerializeStrings(trie_builder.contexts());
124 124
125 // Store where we're about to write the schemas. 125 // Store where we're about to write the types.
126 header->schemas_offset = arena_->size(); 126 header->types_offset = arena_->size();
127 SerializeStrings(trie_builder.schemas()); 127 SerializeStrings(trie_builder.types());
128 128
129 // We need to store size() up to this point now for Find*Offset() to work. 129 // We need to store size() up to this point now for Find*Offset() to work.
130 header->size = arena_->size(); 130 header->size = arena_->size();