[batterymonitor] Fix brightness resetting to 1 on startup
ClosedPublic

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

Details

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

Diff Detail

Repository
R120 Plasma Workspace
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bshah created this revision.Oct 25 2017, 5:39 AM
Restricted Application added a project: Plasma. · View Herald TranscriptOct 25 2017, 5:39 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik accepted this revision.Oct 25 2017, 7:47 AM
This revision is now accepted and ready to land.Oct 25 2017, 7:47 AM
This revision was automatically updated to reflect the committed changes.