• Simo Piiroinen's avatar
    [usb_moded] Implement and use common mode selection logic. Fixes JB#53122 · 3f3d04ff
    Simo Piiroinen authored
    When device is booted up with cable connected and device lock code is
    not used, usb-mode is left at fallback_charging. This happens because
    usb-mode is re-evaluated on device unlock event, which does not occur
    when device lock is not used. Due to duplication of mode selection
    logic in various notification handlers, similar hard to find corner
    cases are likely to occur also when order of events is not as
    Collect all mode selection logic into a single function and refactor
    control flow so that all triggers that might require a mode change are
    directed there.
    Additional changes to existing logic:
    - All mode changes are blocked until usb-moded enters mainloop
    - When shutdown is initiated, dynamic mode changes are blocked
    - Dynamic modes are canceled when user change is started, and
    - Re-evaluated / activated after user change is finished
    - Exception: already active rescue mode persists over user changes
    Reduce the amount of conditional MEEGOLOCK code by adding abstract
    helper functions in usb_moded.c and using those instead of functions
    that might not be available based on configuration options.
    Clean up unnecessary header file includes resulting from these and
    earlier changes.
    Signed-off-by: default avatarSimo Piiroinen <simo.piiroinen@jolla.com>