Merge "BENCHMARK_MAIN now requires a semicolon."
diff --git a/fs_mgr/Android.bp b/fs_mgr/Android.bp
index ed165ed..f23150d 100644
--- a/fs_mgr/Android.bp
+++ b/fs_mgr/Android.bp
@@ -25,6 +25,9 @@
"-Werror",
"-Wno-unused-variable",
],
+ cppflags: [
+ "-std=gnu++1z",
+ ],
}
cc_library_static {
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 2c18a6d..34afed1 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -23,6 +23,10 @@
#include <sys/mount.h>
#include <unistd.h>
+#include <algorithm>
+#include <utility>
+#include <vector>
+
#include <android-base/file.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
@@ -397,16 +401,17 @@
}
static std::string read_fstab_from_dt() {
- std::string fstab;
if (!is_dt_compatible() || !is_dt_fstab_compatible()) {
- return fstab;
+ return {};
}
std::string fstabdir_name = get_android_dt_dir() + "/fstab";
std::unique_ptr<DIR, int (*)(DIR*)> fstabdir(opendir(fstabdir_name.c_str()), closedir);
- if (!fstabdir) return fstab;
+ if (!fstabdir) return {};
dirent* dp;
+ // Each element in fstab_dt_entries is <mount point, the line format in fstab file>.
+ std::vector<std::pair<std::string, std::string>> fstab_dt_entries;
while ((dp = readdir(fstabdir.get())) != NULL) {
// skip over name, compatible and .
if (dp->d_type != DT_DIR || dp->d_name[0] == '.') continue;
@@ -427,41 +432,54 @@
file_name = android::base::StringPrintf("%s/%s/dev", fstabdir_name.c_str(), dp->d_name);
if (!read_dt_file(file_name, &value)) {
LERROR << "dt_fstab: Failed to find device for partition " << dp->d_name;
- fstab.clear();
- break;
+ return {};
}
fstab_entry.push_back(value);
- fstab_entry.push_back(android::base::StringPrintf("/%s", dp->d_name));
+
+ std::string mount_point;
+ file_name =
+ android::base::StringPrintf("%s/%s/mnt_point", fstabdir_name.c_str(), dp->d_name);
+ if (read_dt_file(file_name, &value)) {
+ LINFO << "dt_fstab: Using a specified mount point " << value << " for " << dp->d_name;
+ mount_point = value;
+ } else {
+ mount_point = android::base::StringPrintf("/%s", dp->d_name);
+ }
+ fstab_entry.push_back(mount_point);
file_name = android::base::StringPrintf("%s/%s/type", fstabdir_name.c_str(), dp->d_name);
if (!read_dt_file(file_name, &value)) {
LERROR << "dt_fstab: Failed to find type for partition " << dp->d_name;
- fstab.clear();
- break;
+ return {};
}
fstab_entry.push_back(value);
file_name = android::base::StringPrintf("%s/%s/mnt_flags", fstabdir_name.c_str(), dp->d_name);
if (!read_dt_file(file_name, &value)) {
LERROR << "dt_fstab: Failed to find type for partition " << dp->d_name;
- fstab.clear();
- break;
+ return {};
}
fstab_entry.push_back(value);
file_name = android::base::StringPrintf("%s/%s/fsmgr_flags", fstabdir_name.c_str(), dp->d_name);
if (!read_dt_file(file_name, &value)) {
LERROR << "dt_fstab: Failed to find type for partition " << dp->d_name;
- fstab.clear();
- break;
+ return {};
}
fstab_entry.push_back(value);
-
- fstab += android::base::Join(fstab_entry, " ");
- fstab += '\n';
+ // Adds a fstab_entry to fstab_dt_entries, to be sorted by mount_point later.
+ fstab_dt_entries.emplace_back(mount_point, android::base::Join(fstab_entry, " "));
}
- return fstab;
+ // Sort fstab_dt entries, to ensure /vendor is mounted before /vendor/abc is attempted.
+ std::sort(fstab_dt_entries.begin(), fstab_dt_entries.end(),
+ [](const auto& a, const auto& b) { return a.first < b.first; });
+
+ std::string fstab_result;
+ for (const auto& [_, dt_entry] : fstab_dt_entries) {
+ fstab_result += dt_entry + "\n";
+ }
+ return fstab_result;
}
bool is_dt_compatible() {
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 c2114cc..8c3507e 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
@@ -172,6 +172,9 @@
TrieNode root_node() const { return trie(header()->root_offset); }
private:
+ void CheckPrefixMatch(const char* remaining_name, const TrieNode& trie_node,
+ uint32_t* context_index, uint32_t* schema_index) const;
+
const PropertyInfoAreaHeader* header() const {
return reinterpret_cast<const PropertyInfoAreaHeader*>(data_base());
}
diff --git a/property_service/libpropertyinfoparser/property_info_parser.cpp b/property_service/libpropertyinfoparser/property_info_parser.cpp
index 84f8c29..89864dd 100644
--- a/property_service/libpropertyinfoparser/property_info_parser.cpp
+++ b/property_service/libpropertyinfoparser/property_info_parser.cpp
@@ -87,6 +87,21 @@
return true;
}
+void PropertyInfoArea::CheckPrefixMatch(const char* remaining_name, const TrieNode& trie_node,
+ uint32_t* context_index, uint32_t* schema_index) const {
+ const uint32_t remaining_name_size = strlen(remaining_name);
+ for (uint32_t i = 0; i < trie_node.num_prefixes(); ++i) {
+ auto prefix_len = trie_node.prefix(i)->namelen;
+ if (prefix_len > remaining_name_size) continue;
+
+ if (!strncmp(c_string(trie_node.prefix(i)->name_offset), remaining_name, prefix_len)) {
+ *context_index = trie_node.prefix(i)->context_index;
+ *schema_index = trie_node.prefix(i)->schema_index;
+ return;
+ }
+ }
+}
+
void PropertyInfoArea::GetPropertyInfoIndexes(const char* name, uint32_t* context_index,
uint32_t* schema_index) const {
uint32_t return_context_index = ~0u;
@@ -104,6 +119,10 @@
return_schema_index = trie_node.schema_index();
}
+ // Check prefixes at this node. This comes after the node check since these prefixes are by
+ // definition longer than the node itself.
+ CheckPrefixMatch(remaining_name, trie_node, &return_context_index, &return_schema_index);
+
if (sep == nullptr) {
break;
}
@@ -128,18 +147,8 @@
}
}
// Check prefix matches for prefixes not deliminated with '.'
- const uint32_t remaining_name_size = strlen(remaining_name);
- for (uint32_t i = 0; i < trie_node.num_prefixes(); ++i) {
- auto prefix_len = trie_node.prefix(i)->namelen;
- if (prefix_len > remaining_name_size) continue;
-
- if (!strncmp(c_string(trie_node.prefix(i)->name_offset), remaining_name, prefix_len)) {
- if (context_index != nullptr) *context_index = trie_node.prefix(i)->context_index;
- if (schema_index != nullptr) *schema_index = trie_node.prefix(i)->schema_index;
- return;
- }
- }
- // Return previously found '.' deliminated prefix match.
+ CheckPrefixMatch(remaining_name, trie_node, &return_context_index, &return_schema_index);
+ // Return previously found prefix match.
if (context_index != nullptr) *context_index = return_context_index;
if (schema_index != nullptr) *schema_index = return_schema_index;
return;
diff --git a/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp b/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp
index 5fa3463..b3fae26 100644
--- a/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp
+++ b/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp
@@ -763,5 +763,86 @@
}
}
+TEST(propertyinfoserializer, GetPropertyInfo_prefix_without_dot) {
+ auto property_info = std::vector<PropertyInfoEntry>{
+ {"persist.radio", "1st", "1st", false},
+ {"persist.radio.something.else.here", "2nd", "2nd", false},
+ };
+
+ auto serialized_trie = std::string();
+ auto build_trie_error = std::string();
+ ASSERT_TRUE(BuildTrie(property_info, "default", "default", &serialized_trie, &build_trie_error))
+ << build_trie_error;
+
+ auto property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_trie.data());
+
+ const char* context;
+ const char* schema;
+ property_info_area->GetPropertyInfo("persist.radio", &context, &schema);
+ EXPECT_STREQ("1st", context);
+ EXPECT_STREQ("1st", schema);
+ property_info_area->GetPropertyInfo("persist.radio.subproperty", &context, &schema);
+ EXPECT_STREQ("1st", context);
+ EXPECT_STREQ("1st", schema);
+ property_info_area->GetPropertyInfo("persist.radiowords", &context, &schema);
+ EXPECT_STREQ("1st", context);
+ EXPECT_STREQ("1st", schema);
+ property_info_area->GetPropertyInfo("persist.radio.long.long.long.sub.property", &context,
+ &schema);
+ EXPECT_STREQ("1st", context);
+ EXPECT_STREQ("1st", schema);
+ property_info_area->GetPropertyInfo("persist.radio.something.else.here", &context, &schema);
+ EXPECT_STREQ("2nd", context);
+ EXPECT_STREQ("2nd", schema);
+ property_info_area->GetPropertyInfo("persist.radio.something.else.here2", &context, &schema);
+ EXPECT_STREQ("2nd", context);
+ EXPECT_STREQ("2nd", schema);
+ property_info_area->GetPropertyInfo("persist.radio.something.else.here.after", &context, &schema);
+ EXPECT_STREQ("2nd", context);
+ EXPECT_STREQ("2nd", schema);
+ property_info_area->GetPropertyInfo("persist.radio.something.else.nothere", &context, &schema);
+ EXPECT_STREQ("1st", context);
+ EXPECT_STREQ("1st", schema);
+ property_info_area->GetPropertyInfo("persist.radio.something.else", &context, &schema);
+ EXPECT_STREQ("1st", context);
+ EXPECT_STREQ("1st", schema);
+}
+
+TEST(propertyinfoserializer, GetPropertyInfo_prefix_with_dot_vs_without) {
+ auto property_info = std::vector<PropertyInfoEntry>{
+ {"persist.", "1st", "1st", false},
+ {"persist.radio", "2nd", "2nd", false},
+ {"persist.radio.long.property.exact.match", "3rd", "3rd", true},
+ };
+
+ auto serialized_trie = std::string();
+ auto build_trie_error = std::string();
+ ASSERT_TRUE(BuildTrie(property_info, "default", "default", &serialized_trie, &build_trie_error))
+ << build_trie_error;
+
+ auto property_info_area = reinterpret_cast<const PropertyInfoArea*>(serialized_trie.data());
+
+ const char* context;
+ const char* schema;
+ property_info_area->GetPropertyInfo("persist.notradio", &context, &schema);
+ EXPECT_STREQ("1st", context);
+ EXPECT_STREQ("1st", schema);
+ property_info_area->GetPropertyInfo("persist.radio", &context, &schema);
+ EXPECT_STREQ("2nd", context);
+ EXPECT_STREQ("2nd", schema);
+ property_info_area->GetPropertyInfo("persist.radio.subproperty", &context, &schema);
+ EXPECT_STREQ("2nd", context);
+ EXPECT_STREQ("2nd", schema);
+ property_info_area->GetPropertyInfo("persist.radiowords", &context, &schema);
+ EXPECT_STREQ("2nd", context);
+ EXPECT_STREQ("2nd", schema);
+ property_info_area->GetPropertyInfo("persist.radio.long.property.prefix.match", &context, &schema);
+ EXPECT_STREQ("2nd", context);
+ EXPECT_STREQ("2nd", schema);
+ property_info_area->GetPropertyInfo("persist.radio.long.property.exact.match", &context, &schema);
+ EXPECT_STREQ("3rd", context);
+ EXPECT_STREQ("3rd", schema);
+}
+
} // namespace properties
} // namespace android
diff --git a/rootdir/etc/ld.config.txt b/rootdir/etc/ld.config.txt
index 3183b80..2cba1e3 100644
--- a/rootdir/etc/ld.config.txt
+++ b/rootdir/etc/ld.config.txt
@@ -76,7 +76,7 @@
namespace.sphal.link.default.shared_libs = libc.so:libm.so:libdl.so:libstdc++.so:liblog.so:libnativewindow.so:libEGL.so:libsync.so:libGLESv1_CM.so:libGLESv2.so:libvndksupport.so:libz.so
# WARNING: only VNDK-SP libs can be listed here. DO NOT EDIT this line.
-namespace.sphal.link.vndk.shared_libs = android.hardware.renderscript@1.0.so:android.hardware.graphics.allocator@2.0.so:android.hardware.graphics.mapper@2.0.so:android.hardware.graphics.common@1.0.so:android.hidl.memory@1.0.so:libhwbinder.so:libbase.so:libcutils.so:libhardware.so:libhidlbase.so:libhidlmemory.so:libhidltransport.so:libion.so:libutils.so:libc++.so
+namespace.sphal.link.vndk.shared_libs = android.hardware.renderscript@1.0.so:android.hardware.graphics.mapper@2.0.so:android.hardware.graphics.common@1.0.so:android.hidl.memory@1.0.so:libhwbinder.so:libbase.so:libcutils.so:libhardware.so:libhidlbase.so:libhidlmemory.so:libhidltransport.so:libion.so:libutils.so:libc++.so
# Renderscript gets separate namespace
namespace.sphal.link.rs.shared_libs = libRS_internal.so
@@ -99,7 +99,7 @@
namespace.rs.links = default,vndk
namespace.rs.link.default.shared_libs = libc.so:libm.so:libdl.so:libstdc++.so:liblog.so:libnativewindow.so:libEGL.so:libsync.so:libGLESv1_CM.so:libGLESv2.so:libmediandk.so:libvndksupport.so:libz.so:libft2.so
-namespace.rs.link.vndk.shared_libs = android.hardware.renderscript@1.0.so:android.hardware.graphics.allocator@2.0.so:android.hardware.graphics.mapper@2.0.so:android.hardware.graphics.common@1.0.so:android.hidl.memory@1.0.so:libhwbinder.so:libbase.so:libcutils.so:libhardware.so:libhidlbase.so:libhidlmemory.so:libhidltransport.so:libion.so:libutils.so:libc++.so
+namespace.rs.link.vndk.shared_libs = android.hardware.renderscript@1.0.so:android.hardware.graphics.mapper@2.0.so:android.hardware.graphics.common@1.0.so:android.hidl.memory@1.0.so:libhwbinder.so:libbase.so:libcutils.so:libhardware.so:libhidlbase.so:libhidlmemory.so:libhidltransport.so:libion.so:libutils.so:libc++.so
###############################################################################
# "vndk" namespace