Merge "aconfig: update cpp_codegen to just read from new storage" into main am: 5b6b40e037
am: 390991bd61
Original change: https://android-review.googlesource.com/c/platform/build/+/3266995 Change-Id: Ie99ad0d876a2fe823952ab7df17a2c1f8292ec40 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include "aconfig_storage/aconfig_storage_read_api.hpp"
|
||||
#include <android/log.h>
|
||||
#define LOG_TAG "aconfig_cpp_codegen"
|
||||
#define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
|
||||
#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
|
||||
{{ -endif }}
|
||||
{{ endif }}
|
||||
|
||||
@@ -76,13 +76,14 @@ namespace {cpp_namespace} \{
|
||||
: boolean_start_index_()
|
||||
{{ -endif }}
|
||||
, flag_value_file_(nullptr)
|
||||
, read_from_new_storage_(false)
|
||||
, use_new_storage_value(false) \{
|
||||
, read_from_new_storage_(false) \{
|
||||
|
||||
struct stat buffer;
|
||||
if (stat("/metadata/aconfig_test_missions/mission_1", &buffer) == 0) \{
|
||||
if (stat("/metadata/aconfig/boot/enable_only_new_storage", &buffer) == 0) \{
|
||||
read_from_new_storage_ = true;
|
||||
} else \{
|
||||
}
|
||||
|
||||
if (!read_from_new_storage_) \{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,15 +91,13 @@ namespace {cpp_namespace} \{
|
||||
"{container}",
|
||||
aconfig_storage::StorageFileType::package_map);
|
||||
if (!package_map_file.ok()) \{
|
||||
ALOGI("error: failed to get package map file: %s", package_map_file.error().c_str());
|
||||
return;
|
||||
ALOGE("error: failed to get package map file: %s", package_map_file.error().c_str());
|
||||
}
|
||||
|
||||
auto context = aconfig_storage::get_package_read_context(
|
||||
**package_map_file, "{package}");
|
||||
if (!context.ok()) \{
|
||||
ALOGI("error: failed to get package read context: %s", context.error().c_str());
|
||||
return;
|
||||
ALOGE("error: failed to get package read context: %s", context.error().c_str());
|
||||
}
|
||||
|
||||
// cache package boolean flag start index
|
||||
@@ -111,18 +110,13 @@ namespace {cpp_namespace} \{
|
||||
"{container}",
|
||||
aconfig_storage::StorageFileType::flag_val);
|
||||
if (!flag_value_file.ok()) \{
|
||||
ALOGI("error: failed to get flag value file: %s", flag_value_file.error().c_str());
|
||||
return;
|
||||
ALOGE("error: failed to get flag value file: %s", flag_value_file.error().c_str());
|
||||
}
|
||||
|
||||
// cache flag value file
|
||||
flag_value_file_ = std::unique_ptr<aconfig_storage::MappedStorageFile>(
|
||||
*flag_value_file);
|
||||
|
||||
use_new_storage_value = server_configurable_flags::GetServerConfigurableFlag(
|
||||
"aconfig_flags.core_experiments_team_internal",
|
||||
"com.android.providers.settings.use_new_storage_value",
|
||||
"false") == "true";
|
||||
}
|
||||
{{ -endif }}
|
||||
{{ -endif }}
|
||||
@@ -131,44 +125,30 @@ namespace {cpp_namespace} \{
|
||||
virtual bool {item.flag_name}() override \{
|
||||
{{ -if item.readwrite }}
|
||||
if (cache_[{item.readwrite_idx}] == -1) \{
|
||||
{{ if allow_instrumentation- }}
|
||||
if (read_from_new_storage_) \{
|
||||
auto value = aconfig_storage::get_boolean_flag_value(
|
||||
*flag_value_file_,
|
||||
boolean_start_index_ + {item.flag_offset});
|
||||
|
||||
if (!value.ok()) \{
|
||||
ALOGE("error: failed to read flag value: %s", value.error().c_str());
|
||||
}
|
||||
|
||||
cache_[{item.readwrite_idx}] = *value;
|
||||
} else \{
|
||||
cache_[{item.readwrite_idx}] = server_configurable_flags::GetServerConfigurableFlag(
|
||||
"aconfig_flags.{item.device_config_namespace}",
|
||||
"{item.device_config_flag}",
|
||||
"{item.default_value}") == "true";
|
||||
}
|
||||
{{ -else- }}
|
||||
cache_[{item.readwrite_idx}] = server_configurable_flags::GetServerConfigurableFlag(
|
||||
"aconfig_flags.{item.device_config_namespace}",
|
||||
"{item.device_config_flag}",
|
||||
"{item.default_value}") == "true";
|
||||
}
|
||||
|
||||
|
||||
{{ if allow_instrumentation- }}
|
||||
if (read_from_new_storage_) \{
|
||||
if (!flag_value_file_) \{
|
||||
ALOGI("error: failed to get flag {item.flag_name}: flag value file is null");
|
||||
return cache_[{item.readwrite_idx}];
|
||||
}
|
||||
|
||||
auto value = aconfig_storage::get_boolean_flag_value(
|
||||
*flag_value_file_,
|
||||
boolean_start_index_ + {item.flag_offset});
|
||||
|
||||
if (!value.ok()) \{
|
||||
ALOGI("error: failed to read flag value: %s", value.error().c_str());
|
||||
return cache_[{item.readwrite_idx}];
|
||||
}
|
||||
|
||||
bool expected_value = cache_[{item.readwrite_idx}];
|
||||
if (*value != expected_value) \{
|
||||
ALOGI("error: {item.flag_name} value mismatch, new storage value is %s, old storage value is %s",
|
||||
*value ? "true" : "false", expected_value ? "true" : "false");
|
||||
}
|
||||
|
||||
if (use_new_storage_value) \{
|
||||
return *value;
|
||||
} else \{
|
||||
return expected_value;
|
||||
}
|
||||
}
|
||||
{{ -endif }}
|
||||
|
||||
|
||||
}
|
||||
return cache_[{item.readwrite_idx}];
|
||||
{{ -else }}
|
||||
{{ -if item.is_fixed_read_only }}
|
||||
@@ -189,7 +169,6 @@ namespace {cpp_namespace} \{
|
||||
std::unique_ptr<aconfig_storage::MappedStorageFile> flag_value_file_;
|
||||
|
||||
bool read_from_new_storage_;
|
||||
bool use_new_storage_value;
|
||||
{{ -endif }}
|
||||
{{ -endif }}
|
||||
|
||||
|
Reference in New Issue
Block a user