[batterymonitor] Fix brightness resetting to 1 on startup

Authored by bshah on Oct 25 2017, 5:21 AM.

Description

[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

Details

Committed
bshahOct 25 2017, 7:47 AM
Reviewer
Plasma
Differential Revision
D8462: [batterymonitor] Fix brightness resetting to 1 on startup
Parents
R120:6ca914cdf0a3: Merge branch 'Plasma/5.11'
Branches
Unknown
Tags
Unknown