• Toni Barzic's avatar
    Introduce BacklightsForcedOffSetter · 9d0c82f4
    Toni Barzic authored
    Extracts code that deals with calling powerd SetBacklightsForcedOff
    method from PowerButtonDisplayController to a separate class that can
    handle multiple concurrent requests to set backlights off (by keeping
    track of the active set backlights forced off requests).
    
    While currently only PowerButtonDisplayController uses
    SetBackligthsForcedOff, it's planned to add similar ability to lock
    screen note launching code in a follow-up (the idea is to force
    backlights off if the lock screen app is launched while the display is
    turned off, until the app launch is done).
    Goal of BacklightsForcedOffSetter is to prevent these two classes from
    conflicting with each other - it will ensure backlights are forced off
    as long as at least one backlights forced off request is active.
    
    Backlights can be forced off using
    BacklightsForcedOffSetter::ForceBacklightsOff, which returns
    ScopedBacklightsForcedOff unique ptr - to stop backlights forced off
    request, callers should just reset the returned unique ptr.
    
    BUG=767711
    TEST=Press power button, verify display is turned off. Press power
         button again - display is turned on.
    
    Change-Id: Ie47f546edb51659bb82ba4618b069569a2d188c6
    Reviewed-on: https://chromium-review.googlesource.com/758963
    Commit-Queue: Toni Barzic <tbarzic@chromium.org>
    Reviewed-by: default avatarDan Erat <derat@chromium.org>
    Reviewed-by: default avatarQiang(Joe) Xu <warx@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#521923}
    9d0c82f4
BUILD.gn 73 KB