Index: components/arc/power/arc_power_bridge.cc |
diff --git a/components/arc/power/arc_power_bridge.cc b/components/arc/power/arc_power_bridge.cc |
index a9a47f52230fa89212c416b9dfca5a0d4cbbd55d..7e461a38cc574421d74e794c26af5715ff1ba96d 100644 |
--- a/components/arc/power/arc_power_bridge.cc |
+++ b/components/arc/power/arc_power_bridge.cc |
@@ -74,6 +74,16 @@ void ArcPowerBridge::OnPowerStateChanged( |
power_instance->SetInteractive(enabled); |
} |
+void ArcPowerBridge::NotifyBrightnessChange(double percent) { |
+ mojom::PowerInstance* power_instance = ARC_GET_INSTANCE_FOR_METHOD( |
+ arc_bridge_service()->power(), UpdateBrightness); |
+ if (!power_instance) |
+ return; |
+ |
+ int brightness = round(percent * 2.55); |
Muyuan
2017/04/05 18:41:10
Document why multiply this by 2.55
yueli
2017/04/05 19:59:47
Done.
|
+ power_instance->UpdateBrightness(brightness); |
+} |
+ |
void ArcPowerBridge::OnAcquireDisplayWakeLock(mojom::DisplayWakeLockType type) { |
if (!chromeos::PowerPolicyController::IsInitialized()) { |
LOG(WARNING) << "PowerPolicyController is not available"; |
@@ -126,6 +136,28 @@ void ArcPowerBridge::IsDisplayOn(const IsDisplayOnCallback& callback) { |
ash::Shell::GetInstance()->display_configurator()->IsDisplayOn()); |
} |
+void ArcPowerBridge::SetBrightness(int32_t brightness) { |
+ if (!chromeos::DBusThreadManager::IsInitialized()) { |
+ LOG(WARNING) << "DBusThreadManager is not available"; |
+ return; |
+ } |
+ chromeos::DBusThreadManager::Get() |
+ ->GetPowerManagerClient() |
+ ->SetScreenBrightnessPercent(brightness / 2.55, true); |
+ return; |
+} |
+ |
+void ArcPowerBridge::SyncBrightness() { |
+ if (!chromeos::DBusThreadManager::IsInitialized()) { |
+ LOG(WARNING) << "DBusThreadManager is not available"; |
+ return; |
+ } |
+ chromeos::DBusThreadManager::Get() |
+ ->GetPowerManagerClient() |
+ ->SyncScreenBrightness(); |
+ return; |
+} |
+ |
void ArcPowerBridge::ReleaseAllDisplayWakeLocks() { |
if (!chromeos::PowerPolicyController::IsInitialized()) { |
LOG(WARNING) << "PowerPolicyController is not available"; |