Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2019-01-21 13:14:08 +0300
committermpimenov <mpimenov@users.noreply.github.com>2019-01-22 15:01:32 +0300
commitd5eb25cfb0f7eb8392ee01cd40f97ef505b6ea08 (patch)
treea6a6a7604130b4d8a7f7602d513726733a50d5fa /platform
parent8b0122aeeedfc90ac04c44d8f69a1cdbf23d99c6 (diff)
[power manager] battery level tracking
Diffstat (limited to 'platform')
-rw-r--r--platform/platform.hpp1
-rw-r--r--platform/platform_ios.mm13
-rw-r--r--platform/platform_linux.cpp5
-rw-r--r--platform/platform_mac.mm6
4 files changed, 25 insertions, 0 deletions
diff --git a/platform/platform.hpp b/platform/platform.hpp
index 5e727e1dbb..9d92513670 100644
--- a/platform/platform.hpp
+++ b/platform/platform.hpp
@@ -291,6 +291,7 @@ public:
static bool IsConnected() { return ConnectionStatus() != EConnectionType::CONNECTION_NONE; }
static ChargingStatus GetChargingStatus();
+ static uint8_t GetBatteryLevel();
void SetupMeasurementSystem() const;
diff --git a/platform/platform_ios.mm b/platform/platform_ios.mm
index c4383dfa96..cd8c068800 100644
--- a/platform/platform_ios.mm
+++ b/platform/platform_ios.mm
@@ -225,6 +225,19 @@ Platform::ChargingStatus Platform::GetChargingStatus()
}
}
+uint8_t Platform::GetBatteryLevel()
+{
+ auto const level = UIDevice.currentDevice.batteryLevel;
+ if (level == -1.0)
+ return 100;
+
+ auto const result = static_cast<uint8_t>(level * 100);
+
+ CHECK_LESS_OR_EQUAL(result, 100, ());
+
+ return result;
+}
+
void Platform::SetupMeasurementSystem() const
{
auto units = measurement_utils::Units::Metric;
diff --git a/platform/platform_linux.cpp b/platform/platform_linux.cpp
index c86e81fc55..0f014e0a9d 100644
--- a/platform/platform_linux.cpp
+++ b/platform/platform_linux.cpp
@@ -260,6 +260,11 @@ Platform::ChargingStatus Platform::GetChargingStatus()
return Platform::ChargingStatus::Plugged;
}
+uint8_t Platform::GetBatteryLevel()
+{
+ return 100;
+}
+
void Platform::SetGuiThread(unique_ptr<base::TaskLoop> guiThread)
{
m_guiThread = move(guiThread);
diff --git a/platform/platform_mac.mm b/platform/platform_mac.mm
index 2da6bfc6b5..63f1ff6957 100644
--- a/platform/platform_mac.mm
+++ b/platform/platform_mac.mm
@@ -168,11 +168,17 @@ Platform::EConnectionType Platform::ConnectionStatus()
return EConnectionType::CONNECTION_WIFI;
}
+// static
Platform::ChargingStatus Platform::GetChargingStatus()
{
return Platform::ChargingStatus::Plugged;
}
+uint8_t Platform::GetBatteryLevel()
+{
+ return 100;
+}
+
void Platform::SetGuiThread(unique_ptr<base::TaskLoop> guiThread)
{
m_guiThread = move(guiThread);