Commit 01d76bd1 authored by Olivier Robin's avatar Olivier Robin Committed by Commit Bot

Implement PowerMonitorDeviceSource::IsOnBatteryPowerImpl on iOS

The NOTIMPLEMENTED is reached at startup.
Implement the method.

Bug: 852369
Change-Id: I843f7cd7e168a0b4317e030e3f48349ef3cd025c
Reviewed-on: https://chromium-review.googlesource.com/1098965Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567588}
parent 60d31377
...@@ -9,8 +9,17 @@ ...@@ -9,8 +9,17 @@
namespace base { namespace base {
bool PowerMonitorDeviceSource::IsOnBatteryPowerImpl() { bool PowerMonitorDeviceSource::IsOnBatteryPowerImpl() {
NOTIMPLEMENTED(); #if TARGET_IPHONE_SIMULATOR
return false; return false;
#else
UIDevice* currentDevice = [UIDevice currentDevice];
BOOL isCurrentAppMonitoringBattery = currentDevice.isBatteryMonitoringEnabled;
[UIDevice currentDevice].batteryMonitoringEnabled = YES;
UIDeviceBatteryState batteryState = [UIDevice currentDevice].batteryState;
currentDevice.batteryMonitoringEnabled = isCurrentAppMonitoringBattery;
DCHECK(batteryState != UIDeviceBatteryStateUnknown);
return batteryState == UIDeviceBatteryStateUnplugged;
#endif
} }
void PowerMonitorDeviceSource::PlatformInit() { void PowerMonitorDeviceSource::PlatformInit() {
......
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