From fa5b0cd9e7bb3e1d472dc7da2f2d73b6112ddddf Mon Sep 17 00:00:00 2001 From: Matti Viljanen Date: Fri, 12 Jun 2020 14:32:25 +0300 Subject: [PATCH] Warn if restoring charger status fails at exit --- service/src/battery.cpp | 8 +++++--- service/src/battery.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/service/src/battery.cpp b/service/src/battery.cpp index 7f28eb7..70de4b2 100644 --- a/service/src/battery.cpp +++ b/service/src/battery.cpp @@ -218,7 +218,9 @@ void Battery::shutdown() { notifyTimer->stop(); qDebug() << "Notification stopped"; } - setChargingEnabled(true); - chargingEnabledFile->setPermissions(originalPerms); - qDebug() << "Charger control file permissions restored."; + if(!setChargingEnabled(true)) { + qWarning() << "ERROR! Could not restore charger status! Your device" << endl + << "may not start until reboot! If that doesn't help," << endl + << "uninstall Battery Buddy and reboot your device."; + } } diff --git a/service/src/battery.h b/service/src/battery.h index 702c247..240a82e 100644 --- a/service/src/battery.h +++ b/service/src/battery.h @@ -46,7 +46,7 @@ public: QString getState(); bool getChargingEnabled(); - void setChargingEnabled(bool); + bool setChargingEnabled(bool); public slots: void updateData();