adaptive_charging_controller.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_SYSTEM_POWER_ADAPTIVE_CHARGING_CONTROLLER_H_
  5. #define ASH_SYSTEM_POWER_ADAPTIVE_CHARGING_CONTROLLER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/system/power/adaptive_charging_notification_controller.h"
  8. #include "ash/system/power/adaptive_charging_nudge_controller.h"
  9. #include "base/scoped_observation.h"
  10. #include "chromeos/dbus/power/power_manager_client.h"
  11. #include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
  12. namespace ash {
  13. // The controller responsible for the adaptive charging toast and notifications,
  14. // and communication with the power daemon.
  15. //
  16. // Is currently a stub. TODO(b:216035280): add in real logic.
  17. class ASH_EXPORT AdaptiveChargingController
  18. : public chromeos::PowerManagerClient::Observer {
  19. public:
  20. AdaptiveChargingController();
  21. AdaptiveChargingController(const AdaptiveChargingController&) = delete;
  22. AdaptiveChargingController& operator=(const AdaptiveChargingController&) =
  23. delete;
  24. ~AdaptiveChargingController() override;
  25. // Returns whether AdaptiveCharging is supported by hardware. This value is
  26. // set 1 second after PowerManager DBus initialized.
  27. bool IsAdaptiveChargingSupported();
  28. // Whether the power daemon is currently suspending charging.
  29. bool is_adaptive_delaying_charge() { return is_adaptive_delaying_charge_; }
  30. private:
  31. // chromeos::PowerManagerClient::Observer:
  32. void PowerChanged(const power_manager::PowerSupplyProperties& proto) override;
  33. bool is_adaptive_delaying_charge_ = false;
  34. bool is_on_charger_ = false;
  35. base::ScopedObservation<chromeos::PowerManagerClient,
  36. chromeos::PowerManagerClient::Observer>
  37. power_manager_observation_{this};
  38. const std::unique_ptr<AdaptiveChargingNudgeController> nudge_controller_;
  39. const std::unique_ptr<AdaptiveChargingNotificationController>
  40. notification_controller_;
  41. };
  42. } // namespace ash
  43. #endif // ASH_SYSTEM_POWER_ADAPTIVE_CHARGING_CONTROLLER_H_