Commit 1c0f4179 authored by Bhushan Shah's avatar Bhushan Shah 📱

[batterymonitor] Fix brightness resetting to 1 on startup

Summary:
This was tricky bug to track down, needed to add debug statements in
literally every functions.

The flow of events is something like this, At startup:

- We don't have information about actual brightness for few seconds
- In this period, brightness slider have default value of 1
- This triggers the function which sets batterymonitor.screenBrightness
- onScreenBrightnessChanged gets called, which sets the actual
brightness
- onScreenBrightnessChanged have a guard for disableBrightnessUpdate but
since we have it marked as false initially, we proceed to set actual
brightness to 1
- However before we set value of brightness to 1, we do get actual
brightness back from dataengine, and our call overrides it to 1 later.
- On desktop we do get 2nd dataChanged event from somewhere, so
brightness is proper, but on mobile that is not case and results in
brightness staying at 1.

To fix this bug, we set disableBrightnessUpdate true at startup, and
when there is actual brightness change from powerdevil or
powermanagement engine, Logic.js takes care of enabling and disabling
brightness change.

(I quite like the boolean trap there in variable name :P .. will fix in
another change in master)

Test Plan:
Tested on desktop and mobile, verified that

- Brightness keys work
- Brightness slider works
- Scroll to change brightness works

Reviewers: #plasma, broulik

Reviewed By: #plasma, broulik

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D8462
parent 6ca914cd
......@@ -83,7 +83,7 @@ Item {
Plasmoid.toolTipSubText: powermanagementDisabled ? i18n("Power management is disabled") : ""
Plasmoid.icon: "battery"
property bool disableBrightnessUpdate: false
property bool disableBrightnessUpdate: true
property int screenBrightness
readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0
......
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