Loading tools/aconfig/aconfig_storage_file/protos/aconfig_storage_metadata.proto +2 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,8 @@ message storage_file_info { optional string flag_val = 5; optional string flag_info = 6; optional string local_overrides = 7; optional int64 timestamp = 8; optional string default_flag_val = 8; optional int64 timestamp = 9; } message storage_files { Loading tools/aconfig/aconfig_storage_read_api/include/aconfig_storage/aconfig_storage_read_api.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ enum FlagInfoBit { struct MappedStorageFile { void* file_ptr; size_t file_size; ~MappedStorageFile(); virtual ~MappedStorageFile(); }; /// Package read context query result Loading tools/aconfig/aconfig_storage_write_api/aconfig_storage_write_api.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -17,11 +17,6 @@ using namespace android::base; namespace aconfig_storage { /// destructor MutableMappedStorageFile::~MutableMappedStorageFile() { munmap(file_ptr, file_size); } /// Map a storage file Result<MutableMappedStorageFile*> map_mutable_storage_file(std::string const& file) { struct stat file_stat; Loading tools/aconfig/aconfig_storage_write_api/include/aconfig_storage/aconfig_storage_write_api.hpp +1 −5 Original line number Diff line number Diff line Loading @@ -11,11 +11,7 @@ using namespace android::base; namespace aconfig_storage { /// Mapped flag value file struct MutableMappedStorageFile{ void* file_ptr; size_t file_size; ~MutableMappedStorageFile(); }; struct MutableMappedStorageFile : MappedStorageFile {}; /// Map a storage file Result<MutableMappedStorageFile*> map_mutable_storage_file( Loading tools/aconfig/aconfig_storage_write_api/tests/storage_write_api_test.cpp +5 −17 Original line number Diff line number Diff line Loading @@ -80,13 +80,10 @@ TEST_F(AconfigStorageTest, test_boolean_flag_value_update) { ASSERT_TRUE(mapped_file_result.ok()); auto mapped_file = std::unique_ptr<api::MutableMappedStorageFile>(*mapped_file_result); auto ro_mapped_file = api::MappedStorageFile(); ro_mapped_file.file_ptr = mapped_file->file_ptr; ro_mapped_file.file_size = mapped_file->file_size; for (int offset = 0; offset < 8; ++offset) { auto update_result = api::set_boolean_flag_value(*mapped_file, offset, true); ASSERT_TRUE(update_result.ok()); auto value = api::get_boolean_flag_value(ro_mapped_file, offset); auto value = api::get_boolean_flag_value(*mapped_file, offset); ASSERT_TRUE(value.ok()); ASSERT_TRUE(*value); } Loading @@ -97,7 +94,6 @@ TEST_F(AconfigStorageTest, test_invalid_boolean_flag_value_update) { auto mapped_file_result = api::map_mutable_storage_file(flag_val); ASSERT_TRUE(mapped_file_result.ok()); auto mapped_file = std::unique_ptr<api::MutableMappedStorageFile>(*mapped_file_result); auto update_result = api::set_boolean_flag_value(*mapped_file, 8, true); ASSERT_FALSE(update_result.ok()); ASSERT_EQ(update_result.error().message(), Loading @@ -110,16 +106,12 @@ TEST_F(AconfigStorageTest, test_flag_has_server_override_update) { ASSERT_TRUE(mapped_file_result.ok()); auto mapped_file = std::unique_ptr<api::MutableMappedStorageFile>(*mapped_file_result); auto ro_mapped_file = api::MappedStorageFile(); ro_mapped_file.file_ptr = mapped_file->file_ptr; ro_mapped_file.file_size = mapped_file->file_size; for (int offset = 0; offset < 8; ++offset) { auto update_result = api::set_flag_has_server_override( *mapped_file, api::FlagValueType::Boolean, offset, true); ASSERT_TRUE(update_result.ok()) << update_result.error(); auto attribute = api::get_flag_attribute( ro_mapped_file, api::FlagValueType::Boolean, offset); *mapped_file, api::FlagValueType::Boolean, offset); ASSERT_TRUE(attribute.ok()); ASSERT_TRUE(*attribute & api::FlagInfoBit::HasServerOverride); Loading @@ -127,7 +119,7 @@ TEST_F(AconfigStorageTest, test_flag_has_server_override_update) { *mapped_file, api::FlagValueType::Boolean, offset, false); ASSERT_TRUE(update_result.ok()); attribute = api::get_flag_attribute( ro_mapped_file, api::FlagValueType::Boolean, offset); *mapped_file, api::FlagValueType::Boolean, offset); ASSERT_TRUE(attribute.ok()); ASSERT_FALSE(*attribute & api::FlagInfoBit::HasServerOverride); } Loading @@ -139,16 +131,12 @@ TEST_F(AconfigStorageTest, test_flag_has_local_override_update) { ASSERT_TRUE(mapped_file_result.ok()); auto mapped_file = std::unique_ptr<api::MutableMappedStorageFile>(*mapped_file_result); auto ro_mapped_file = api::MappedStorageFile(); ro_mapped_file.file_ptr = mapped_file->file_ptr; ro_mapped_file.file_size = mapped_file->file_size; for (int offset = 0; offset < 8; ++offset) { auto update_result = api::set_flag_has_local_override( *mapped_file, api::FlagValueType::Boolean, offset, true); ASSERT_TRUE(update_result.ok()); auto attribute = api::get_flag_attribute( ro_mapped_file, api::FlagValueType::Boolean, offset); *mapped_file, api::FlagValueType::Boolean, offset); ASSERT_TRUE(attribute.ok()); ASSERT_TRUE(*attribute & api::FlagInfoBit::HasLocalOverride); Loading @@ -156,7 +144,7 @@ TEST_F(AconfigStorageTest, test_flag_has_local_override_update) { *mapped_file, api::FlagValueType::Boolean, offset, false); ASSERT_TRUE(update_result.ok()); attribute = api::get_flag_attribute( ro_mapped_file, api::FlagValueType::Boolean, offset); *mapped_file, api::FlagValueType::Boolean, offset); ASSERT_TRUE(attribute.ok()); ASSERT_FALSE(*attribute & api::FlagInfoBit::HasLocalOverride); } Loading Loading
tools/aconfig/aconfig_storage_file/protos/aconfig_storage_metadata.proto +2 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,8 @@ message storage_file_info { optional string flag_val = 5; optional string flag_info = 6; optional string local_overrides = 7; optional int64 timestamp = 8; optional string default_flag_val = 8; optional int64 timestamp = 9; } message storage_files { Loading
tools/aconfig/aconfig_storage_read_api/include/aconfig_storage/aconfig_storage_read_api.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ enum FlagInfoBit { struct MappedStorageFile { void* file_ptr; size_t file_size; ~MappedStorageFile(); virtual ~MappedStorageFile(); }; /// Package read context query result Loading
tools/aconfig/aconfig_storage_write_api/aconfig_storage_write_api.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -17,11 +17,6 @@ using namespace android::base; namespace aconfig_storage { /// destructor MutableMappedStorageFile::~MutableMappedStorageFile() { munmap(file_ptr, file_size); } /// Map a storage file Result<MutableMappedStorageFile*> map_mutable_storage_file(std::string const& file) { struct stat file_stat; Loading
tools/aconfig/aconfig_storage_write_api/include/aconfig_storage/aconfig_storage_write_api.hpp +1 −5 Original line number Diff line number Diff line Loading @@ -11,11 +11,7 @@ using namespace android::base; namespace aconfig_storage { /// Mapped flag value file struct MutableMappedStorageFile{ void* file_ptr; size_t file_size; ~MutableMappedStorageFile(); }; struct MutableMappedStorageFile : MappedStorageFile {}; /// Map a storage file Result<MutableMappedStorageFile*> map_mutable_storage_file( Loading
tools/aconfig/aconfig_storage_write_api/tests/storage_write_api_test.cpp +5 −17 Original line number Diff line number Diff line Loading @@ -80,13 +80,10 @@ TEST_F(AconfigStorageTest, test_boolean_flag_value_update) { ASSERT_TRUE(mapped_file_result.ok()); auto mapped_file = std::unique_ptr<api::MutableMappedStorageFile>(*mapped_file_result); auto ro_mapped_file = api::MappedStorageFile(); ro_mapped_file.file_ptr = mapped_file->file_ptr; ro_mapped_file.file_size = mapped_file->file_size; for (int offset = 0; offset < 8; ++offset) { auto update_result = api::set_boolean_flag_value(*mapped_file, offset, true); ASSERT_TRUE(update_result.ok()); auto value = api::get_boolean_flag_value(ro_mapped_file, offset); auto value = api::get_boolean_flag_value(*mapped_file, offset); ASSERT_TRUE(value.ok()); ASSERT_TRUE(*value); } Loading @@ -97,7 +94,6 @@ TEST_F(AconfigStorageTest, test_invalid_boolean_flag_value_update) { auto mapped_file_result = api::map_mutable_storage_file(flag_val); ASSERT_TRUE(mapped_file_result.ok()); auto mapped_file = std::unique_ptr<api::MutableMappedStorageFile>(*mapped_file_result); auto update_result = api::set_boolean_flag_value(*mapped_file, 8, true); ASSERT_FALSE(update_result.ok()); ASSERT_EQ(update_result.error().message(), Loading @@ -110,16 +106,12 @@ TEST_F(AconfigStorageTest, test_flag_has_server_override_update) { ASSERT_TRUE(mapped_file_result.ok()); auto mapped_file = std::unique_ptr<api::MutableMappedStorageFile>(*mapped_file_result); auto ro_mapped_file = api::MappedStorageFile(); ro_mapped_file.file_ptr = mapped_file->file_ptr; ro_mapped_file.file_size = mapped_file->file_size; for (int offset = 0; offset < 8; ++offset) { auto update_result = api::set_flag_has_server_override( *mapped_file, api::FlagValueType::Boolean, offset, true); ASSERT_TRUE(update_result.ok()) << update_result.error(); auto attribute = api::get_flag_attribute( ro_mapped_file, api::FlagValueType::Boolean, offset); *mapped_file, api::FlagValueType::Boolean, offset); ASSERT_TRUE(attribute.ok()); ASSERT_TRUE(*attribute & api::FlagInfoBit::HasServerOverride); Loading @@ -127,7 +119,7 @@ TEST_F(AconfigStorageTest, test_flag_has_server_override_update) { *mapped_file, api::FlagValueType::Boolean, offset, false); ASSERT_TRUE(update_result.ok()); attribute = api::get_flag_attribute( ro_mapped_file, api::FlagValueType::Boolean, offset); *mapped_file, api::FlagValueType::Boolean, offset); ASSERT_TRUE(attribute.ok()); ASSERT_FALSE(*attribute & api::FlagInfoBit::HasServerOverride); } Loading @@ -139,16 +131,12 @@ TEST_F(AconfigStorageTest, test_flag_has_local_override_update) { ASSERT_TRUE(mapped_file_result.ok()); auto mapped_file = std::unique_ptr<api::MutableMappedStorageFile>(*mapped_file_result); auto ro_mapped_file = api::MappedStorageFile(); ro_mapped_file.file_ptr = mapped_file->file_ptr; ro_mapped_file.file_size = mapped_file->file_size; for (int offset = 0; offset < 8; ++offset) { auto update_result = api::set_flag_has_local_override( *mapped_file, api::FlagValueType::Boolean, offset, true); ASSERT_TRUE(update_result.ok()); auto attribute = api::get_flag_attribute( ro_mapped_file, api::FlagValueType::Boolean, offset); *mapped_file, api::FlagValueType::Boolean, offset); ASSERT_TRUE(attribute.ok()); ASSERT_TRUE(*attribute & api::FlagInfoBit::HasLocalOverride); Loading @@ -156,7 +144,7 @@ TEST_F(AconfigStorageTest, test_flag_has_local_override_update) { *mapped_file, api::FlagValueType::Boolean, offset, false); ASSERT_TRUE(update_result.ok()); attribute = api::get_flag_attribute( ro_mapped_file, api::FlagValueType::Boolean, offset); *mapped_file, api::FlagValueType::Boolean, offset); ASSERT_TRUE(attribute.ok()); ASSERT_FALSE(*attribute & api::FlagInfoBit::HasLocalOverride); } Loading