Skip to content
  • Bhushan Shah's avatar
    [batterymonitor] Fix brightness resetting to 1 on startup · 1c0f4179
    Bhushan Shah authored
    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
    1c0f4179