New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Device:Android: call "_decideFrontlightState" to keep "is_fl_on" in sync #10731
Conversation
just to be on the same page, because of (#10725 (comment))
koreader/frontend/device/generic/powerd.lua Lines 103 to 105 in d350418
koreader/frontend/device/generic/powerd.lua Lines 125 to 132 in d350418
|
Ok, thanks for the lengthy explanation. Now makes sense to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first hunk makes sense (c.f., e.g., BasePowerD's init, or even simply setIntensity
), but I'd stash the second one away in the imp.
@@ -510,6 +511,7 @@ function Device:_showLightDialog() | |||
elseif action == C.ALIGHTS_DIALOG_CANCEL then | |||
logger.dbg("Dialog Cancel, brightness: " .. self.powerd.fl_intensity) | |||
self.powerd:setIntensityHW(self.powerd.fl_intensity) | |||
self.powerd:_decideFrontlightState() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would possibly move that one inside Android's setIntensityHW
implementation. (We do the same on a few other platforms, e.g., Kobo).
…HW" (#10737) re #10731 (comment) This PR changes so that androids implementation of `setIntensityHW` always calls `_decideFrontlightState`
re #10725
This PR is so that variable
is_fl_on
is also kept in-sync whenfl_intensity
is being set, this could maybe be de-duplicated by always calling it after the bothif
's.Why?
because thing that depend on
is_fl_on
do not work correctly after justfl_intensity
being set, likeBasePowerD:isFrontlightOn
(by extension alsoBasePowerD:isFrontlightOff
) and so in turn things likeBasePowerD:toggleFrontlight
call the wrong function.Example:
(assuming #10726 is merged, makes it easier to explain)
initial state:
fl_intensity: 50
is_fl_on: true
then you go to the lights dialog, change
brightness
to0
(fronlight being off) and then justfl_intensity
is set to0
, butis_fl_on
staystrue
- which is wrong, and so if you then do something like eventToggleFrontlight
it will go the path ofFrontlight Disabled
, even though the frontlight was already disabled@pazos i hope this examples makes it more clear what i meant with #10725 (comment), i have go the path of
or to use powerd:_decideFrontlightState()
to make it less forgettable in the future maybe refactor this with one of the other options listed in the mentioned comment (like adding a helper function for only internal state)
This change is