Commit abe1d406 authored by Jia's avatar Jia Committed by Commit Bot

[On-device adaptive brightness] Fixes a bug that does not set metrics reporter...

[On-device adaptive brightness] Fixes a bug that does not set metrics reporter when model is disabled

Bug: 881215
Change-Id: Icb120b47a37c078b3b98dd947369f4240da81d68
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626059
Commit-Queue: Jia Meng <jiameng@chromium.org>
Reviewed-by: default avatarMichael Martis <martis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662525}
parent 348d7397
......@@ -237,11 +237,11 @@ void Adapter::OnModelInitialized(const Model& model) {
}
void Adapter::OnModelConfigLoaded(base::Optional<ModelConfig> model_config) {
DCHECK(!model_config_exists_.has_value());
DCHECK(!enabled_by_model_configs_.has_value());
model_config_exists_ = model_config.has_value();
enabled_by_model_configs_ = model_config.has_value();
if (model_config_exists_.value()) {
if (enabled_by_model_configs_.value()) {
InitParams(model_config.value());
}
......@@ -337,7 +337,7 @@ Adapter::Adapter(Profile* profile,
void Adapter::InitParams(const ModelConfig& model_config) {
if (!base::FeatureList::IsEnabled(features::kAutoScreenBrightness)) {
adapter_status_ = Status::kDisabled;
enabled_by_model_configs_ = false;
return;
}
......@@ -357,7 +357,7 @@ void Adapter::InitParams(const ModelConfig& model_config) {
const int model_curve = base::GetFieldTrialParamByFeatureAsInt(
features::kAutoScreenBrightness, "model_curve", 2);
if (model_curve < 0 || model_curve > 2) {
adapter_status_ = Status::kDisabled;
enabled_by_model_configs_ = false;
LogParameterError(ParameterError::kAdapterError);
return;
}
......@@ -376,6 +376,7 @@ void Adapter::InitParams(const ModelConfig& model_config) {
features::kAutoScreenBrightness, "user_adjustment_effect",
static_cast<int>(params_.user_adjustment_effect));
if (user_adjustment_effect_as_int < 0 || user_adjustment_effect_as_int > 2) {
enabled_by_model_configs_ = false;
LogParameterError(ParameterError::kAdapterError);
return;
}
......@@ -428,10 +429,10 @@ void Adapter::UpdateStatus() {
return;
}
if (!model_config_exists_.has_value())
if (!enabled_by_model_configs_.has_value())
return;
if (!model_config_exists_.value()) {
if (!enabled_by_model_configs_.value()) {
adapter_status_ = Status::kDisabled;
SetMetricsReporterDeviceClass();
return;
......
......@@ -324,15 +324,18 @@ class Adapter : public AlsReader::Observer,
base::Optional<bool> brightness_monitor_success_;
// |model_config_exists_| will remain nullopt until |OnModelConfigLoaded| is
// called. Its value will then be set to true if the input model config exists
// (not nullopt), else its value will be false.
base::Optional<bool> model_config_exists_;
// |enabled_by_model_configs_| will remain nullopt until |OnModelConfigLoaded|
// is called. Its value will then be set to true if the input model config
// exists (not nullopt), and if |InitParams| properly sets params and checks
// the model is enabled.
base::Optional<bool> enabled_by_model_configs_;
bool model_initialized_ = false;
base::Optional<bool> power_manager_service_available_;
// |adapter_status_| should only be set to |kDisabled| or |kSuccess| by
// |UpdateStatus|.
Status adapter_status_ = Status::kInitializing;
// This is set to true whenever a user makes a manual adjustment, and if
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment