Skip to content

Commit

Permalink
Merge branch 'jb48562_initial_battery_level' into 'master'
Browse files Browse the repository at this point in the history
[batterynotifier] Use -1 for unknown battery level

See merge request mer-core/lipstick!134
  • Loading branch information
spiiroin committed Feb 4, 2020
2 parents b29b864 + ae4af33 commit b585668
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/notifications/batterynotifier.cpp
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (C) 2012-2019 Jolla Ltd.
** Copyright (c) 2019 Open Mobile Platform LLC.
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (c) 2012 - 2020 Jolla Ltd.
** Copyright (c) 2019 - 2020 Open Mobile Platform LLC.
**
** Contact: Robin Burchell <robin.burchell@jollamobile.com>
**
Expand Down Expand Up @@ -342,7 +342,8 @@ bool BatteryNotifier::evaluateNotificationLevel(BatteryNotifier::NotificationTyp
break;
case BatteryNotifier::NotificationNotEnoughPower:
/* Battery level has dropped since charger was connected. */
level = (state.m_batteryLevel < state.m_minimumBatteryLevel);
level = (state.m_batteryLevel >= 0
&& state.m_batteryLevel < state.m_minimumBatteryLevel);
break;
}
return level;
Expand Down Expand Up @@ -501,7 +502,8 @@ void BatteryNotifier::updateLowBatteryNotifier()
bool incall = m_currentState.m_callState != QMceCallState::None;
if (active || incall) {
/* Device is in "active use" */
if (m_currentState.m_batteryLevel <= m_lowBatteryRepeatLevel) {
if (m_currentState.m_batteryLevel >= 0
&& m_currentState.m_batteryLevel <= m_lowBatteryRepeatLevel) {
/* Significant battery level drop since the last warning
* -> repeat the warning immediately. */
m_lowBatteryRepeatActivity->run();
Expand Down
10 changes: 5 additions & 5 deletions src/notifications/batterynotifier.h
@@ -1,8 +1,8 @@
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (C) 2012-2019 Jolla Ltd.
** Copyright (c) 2019 Open Mobile Platform LLC.
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
** Copyright (c) 2012 - 2020 Jolla Ltd.
** Copyright (c) 2019 - 2020 Open Mobile Platform LLC.
**
** Contact: Robin Burchell <robin.burchell@jollamobile.com>
**
Expand Down Expand Up @@ -92,8 +92,8 @@ private slots:
QMceChargerType::Type m_chargerType = QMceChargerType::None;
bool m_chargerState = false;
QMceBatteryStatus::Status m_batteryStatus = QMceBatteryStatus::Ok;
int m_batteryLevel = 50;
int m_minimumBatteryLevel = 0;
int m_batteryLevel = -1;
int m_minimumBatteryLevel = -1;
bool m_powerSaveMode = false;
QMceDisplay::State m_displayState = QMceDisplay::DisplayOn;
bool m_tkLock = false;
Expand Down

0 comments on commit b585668

Please sign in to comment.