<table><tr><td style="">bshah created this revision.<br />bshah added reviewers: Plasma, broulik.<br />Restricted Application added a project: Plasma.<br />Restricted Application added a subscriber: plasma-devel.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D8462" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>This was tricky bug to track down, needed to add debug statements in<br />
literally every functions.</p>

<p>The flow of events is something like this, At startup:</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">We don't have information about actual brightness for few seconds</li>
<li class="remarkup-list-item">In this period, brightness slider have default value of 1</li>
<li class="remarkup-list-item">This triggers the function which sets batterymonitor.screenBrightness</li>
<li class="remarkup-list-item">onScreenBrightnessChanged gets called, which sets the actual</li>
</ul>

<p>brightness</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">onScreenBrightnessChanged have a guard for disableBrightnessUpdate but</li>
</ul>

<p>since we have it marked as false initially, we proceed to set actual<br />
brightness to 1</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">However before we set value of brightness to 1, we do get actual</li>
</ul>

<p>brightness back from dataengine, and our call overrides it to 1 later.</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">On desktop we do get 2nd dataChanged event from somewhere, so</li>
</ul>

<p>brightness is proper, but on mobile that is not case and results in<br />
brightness staying at 1.</p>

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

<p>(I quite like the boolean trap there in variable name :P .. will fix in<br />
another change in master)</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>Tested on desktop and mobile, verified that</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">Brightness keys work</li>
<li class="remarkup-list-item">Brightness slider works</li>
<li class="remarkup-list-item">Scroll to change brightness works</li>
</ul></div></div><br /><div><strong>REPOSITORY</strong><div><div>R120 Plasma Workspace</div></div></div><br /><div><strong>BRANCH</strong><div><div>fix-brightness-reset</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D8462" rel="noreferrer">https://phabricator.kde.org/D8462</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>applets/batterymonitor/package/contents/ui/batterymonitor.qml</div></div></div><br /><div><strong>To: </strong>bshah, Plasma, broulik<br /><strong>Cc: </strong>plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart<br /></div>