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

[On-device adaptive brightness] Implement a controller and add to browser.

Bug: 881215
Change-Id: I504764bd39f586d07e67eef1443565d4235a6a2c
Reviewed-on: https://chromium-review.googlesource.com/c/1322256Reviewed-by: default avatarDan Erat <derat@chromium.org>
Commit-Queue: Jia Meng <jiameng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606770}
parent f038ea34
......@@ -1604,6 +1604,8 @@ source_set("chromeos") {
"power/auto_screen_brightness/brightness_monitor.h",
"power/auto_screen_brightness/brightness_monitor_impl.cc",
"power/auto_screen_brightness/brightness_monitor_impl.h",
"power/auto_screen_brightness/controller.cc",
"power/auto_screen_brightness/controller.h",
"power/auto_screen_brightness/fake_als_reader.cc",
"power/auto_screen_brightness/fake_als_reader.h",
"power/auto_screen_brightness/fake_brightness_monitor.cc",
......
......@@ -82,6 +82,7 @@
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/device_local_account.h"
#include "chrome/browser/chromeos/power/auto_screen_brightness/controller.h"
#include "chrome/browser/chromeos/power/freezer_cgroup_process_manager.h"
#include "chrome/browser/chromeos/power/idle_action_warning_observer.h"
#include "chrome/browser/chromeos/power/ml/adaptive_screen_brightness_manager.h"
......@@ -1021,6 +1022,9 @@ void ChromeBrowserMainPartsChromeos::PostBrowserStart() {
std::make_unique<power::ml::UserActivityController>();
}
auto_screen_brightness_controller_ =
std::make_unique<power::auto_screen_brightness::Controller>();
ChromeBrowserMainPartsLinux::PostBrowserStart();
}
......@@ -1081,6 +1085,7 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
user_activity_controller_.reset();
adaptive_screen_brightness_manager_.reset();
diagnosticsd_bridge_.reset();
auto_screen_brightness_controller_.reset();
// Detach D-Bus clients before DBusThreadManager is shut down.
idle_action_warning_observer_.reset();
......
......@@ -62,6 +62,10 @@ namespace ml {
class AdaptiveScreenBrightnessManager;
class UserActivityController;
} // namespace ml
namespace auto_screen_brightness {
class Controller;
} // namespace auto_screen_brightness
} // namespace power
// ChromeBrowserMainParts implementation for chromeos specific code.
......@@ -141,6 +145,8 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
adaptive_screen_brightness_manager_;
std::unique_ptr<power::ml::UserActivityController> user_activity_controller_;
std::unique_ptr<power::auto_screen_brightness::Controller>
auto_screen_brightness_controller_;
std::unique_ptr<DemoModeResourcesRemover> demo_mode_resources_remover_;
std::unique_ptr<crostini::CrosvmMetrics> crosvm_metrics_;
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/power/auto_screen_brightness/controller.h"
#include "base/task/post_task.h"
#include "base/time/default_tick_clock.h"
#include "chrome/browser/chromeos/power/auto_screen_brightness/adapter.h"
#include "chrome/browser/chromeos/power/auto_screen_brightness/als_reader_impl.h"
#include "chrome/browser/chromeos/power/auto_screen_brightness/brightness_monitor_impl.h"
#include "chrome/browser/chromeos/power/auto_screen_brightness/gaussian_trainer.h"
#include "chrome/browser/chromeos/power/auto_screen_brightness/modeller_impl.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chromeos/dbus/dbus_thread_manager.h"
namespace chromeos {
namespace power {
namespace auto_screen_brightness {
Controller::Controller() {
als_reader_ = std::make_unique<AlsReaderImpl>();
als_reader_->Init();
chromeos::PowerManagerClient* power_manager_client =
chromeos::DBusThreadManager::Get()->GetPowerManagerClient();
DCHECK(power_manager_client);
brightness_monitor_ =
std::make_unique<BrightnessMonitorImpl>(power_manager_client);
ui::UserActivityDetector* user_activity_detector =
ui::UserActivityDetector::Get();
DCHECK(user_activity_detector);
const Profile* const profile = ProfileManager::GetPrimaryUserProfile();
DCHECK(profile);
modeller_ = std::make_unique<ModellerImpl>(
profile, als_reader_.get(), brightness_monitor_.get(),
user_activity_detector, std::make_unique<GaussianTrainer>());
adapter_ = std::make_unique<Adapter>(profile, als_reader_.get(),
brightness_monitor_.get(),
modeller_.get(), power_manager_client);
}
Controller::~Controller() = default;
} // namespace auto_screen_brightness
} // namespace power
} // namespace chromeos
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_CONTROLLER_H_
#define CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_CONTROLLER_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h"
namespace chromeos {
namespace power {
namespace auto_screen_brightness {
class Adapter;
class AlsReaderImpl;
class BrightnessMonitorImpl;
class ModellerImpl;
// This controller class sets up and destroys all components needed for the auto
// screen brightness feature.
class Controller {
public:
Controller();
~Controller();
private:
std::unique_ptr<AlsReaderImpl> als_reader_;
std::unique_ptr<BrightnessMonitorImpl> brightness_monitor_;
std::unique_ptr<ModellerImpl> modeller_;
std::unique_ptr<Adapter> adapter_;
DISALLOW_COPY_AND_ASSIGN(Controller);
};
} // namespace auto_screen_brightness
} // namespace power
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_CONTROLLER_H_
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