1. 24 Aug, 2018 21 commits
    • spiiroin's avatar
      [usb_moded] Explicitly start/stop mtp daemon. Fixes JB#41748 · 041d46de
      spiiroin authored
      The mtp functionality is started roughly as follows:
      
      1. usb-moded completes whole gadget configuration, and then
      2. signals mtp mode activation on D-Bus
      3. msyncd sees the mode change and loads mtp plugin
      4. mtp plugin writes endpoint configuration, and then
      5. scans storage ares to enumerate files exposed via mtp, but
      6. does not really respond to ptp/mtp requests until storages are ready
      
      The problems are:
      
      While the above sequence has worked with with android usb, it does cause
      timing issues for usb enumeration and longer than expected response times
      from pc side mtp initiator point of view.
      
      Additionally when configfs is used, the gadget configuration can't even
      be completed before mtp daemon gets a chance to write configuration data
      to the control endpoint.
      
      To remedy the situation the following changes are made:
      
      1. buteo-mtp-qt5-sync-plugin package is removed from the system -> mtp
         functionality is no longer handled by msyncd process
      
      2. mtp daemon is made to enumerate storage content before writing config
         data to control endpoint -> when usb enumeration is possible, mtp
         daemon is already ready to handle commands from initiator
      
      3. usb-moded explicitly starts/stops mtp daemon when it is about to
         activate/deactivate mtp_mode -> usb stays configured in charging
         mode until it is ready to handle mtp
      
      This patch handles step (3). Step (2) is in buteo-mtp-qt5 >= 0.5.0,
      and (1) needs to be fixed in device specific package configuration.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      041d46de
    • spiiroin's avatar
      [android] Use wrapper function for all sysfs writes. JB#41748 · 7896a728
      spiiroin authored
      Writing empty string gets ignored. This causes problems for example
      when switching from mass-storage mode to charging only as the
      lua/file attribute does not get cleared.
      
      Use a wrapper function to append a linefeed to strings written to sysfs.
      This avoids zero length writes and makes behavior similar to how
      redirected echo from command line works.
      
      Also tweak unexpected-sysfs-content-change tracker so that it ignores
      changes in whitespace.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      7896a728
    • spiiroin's avatar
      [modesetting] Refactor mass-storage mode handling · e659901c
      spiiroin authored
      Code duplication and interleaving of kernel module vs android usb logic
      makes it difficult to add support for configfs based systems.
      
      Use helper functions for common tasks.
      
      Use explicit checks for what backend should be used.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      e659901c
    • spiiroin's avatar
      [dyn-config] Drop unused syfs_path and sysfs_reset_value attributes · 6848228a
      spiiroin authored
      All "normal" modes ignore syfs_path and sysfs_reset_value configuration
      values.
      
      Remove redundant lines from sample configuration files and adjust
      configuration file sanity checking rules.
      
      Also fix a GKeyFile leak on error path in dynconfig_read_mode_file().
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      6848228a
    • spiiroin's avatar
      [dyn-config] Align config parsing for readability · 9dd55147
      spiiroin authored
      Long member and key names, and interleaved debug logging makes the config
      parsing code difficult to read.
      
      Add whitespace to increase ease visual inspection. Move debug logging
      to occur after each configuration block has been parsed.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      9dd55147
    • spiiroin's avatar
      [modesetting] Fix memory leak in modesetting_report_mass_storage_blocker() · ec49a62b
      spiiroin authored
      Line buffer allocated/managed by getline() is not released.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      ec49a62b
    • spiiroin's avatar
      [usb_moded] Do not track pc / charger connect separately. JB#41748 · 8e469091
      spiiroin authored
      Handling "connected to pc" and "connected to charger" as separate boolean
      states just complicates things.
      
      Move cable_state_t enumeration values from udev module to usb_moded.h
      to make them generally available.
      
      Utilize cable_state_t also within usb_moded.c module.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      8e469091
    • spiiroin's avatar
      [usb_moded] Arrange a route for signaling mode switch failures. JB#41748 · 94978637
      spiiroin authored
      If gadget configuration / other mode selection related activites fail,
      usb-moded attempts to activate charging only configuration / does fallback
      to undefined mode. This situation is not propagated upwards and thus
      incorrect information is exposed over D-Bus.
      
      Add feedback function that lower level functionality can use to signal
      failures / successfully completed mode change, and delay broadcasting
      of D-Bus signals until completing the change.
      
      As the mode change actions can potentially block for extended periods of
      time and render usb-moded unresponsive, mark places where worker thread
      signaling could be utilized instead of function calls.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      94978637
    • spiiroin's avatar
      [trigger] Fix resource leaks · 4a8d5988
      spiiroin authored
      Looks like trigger_udev_sysname variable stays valid only because
      udev_device_new_from_syspath() return value is leaked in trigger_init().
      
      Take a copy of udev_device_get_sysname() return value instead on relying on
      borrowed string pointer staying valid.
      
      Remove all mid-function returns, release unneeded resources on success, and
      all acquired resources in case of failure.
      
      Having a boolean function return false on success / true on failure is
      a bit confusing, so rectify that while at it.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      4a8d5988
    • spiiroin's avatar
      [trigger] Use trigger_xxx prefix for variable naming · e67accc7
      spiiroin authored
      Static variables do not have unique names and are shadowed by
      function parameters even within this compilation module.
      
      Make the code easier to follow by using common prefix for
      module variables.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      e67accc7
    • spiiroin's avatar
      [usb_moded] Use common code for evaluating "can-export" state · 623c2ee1
      spiiroin authored
      When usb-moded is compiled with MEEGOLOCK feature enabled, only limited
      functionality is available while device is locked. However the scattered
      use of MEEGOLOCK compilation time conditionals makes the code
      unnecessarily difficult to read.
      
      Add a utility function to handle evaluation of the can-export state and
      remove the now unnecessary preprocessor conditionals.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      623c2ee1
    • spiiroin's avatar
      [usb_moded] Tweak mode selection dialog related D-Bus signaling · 046e1b71
      spiiroin authored
      The USB_CONNECTED_DIALOG_SHOW signal is sent just before the usb mode
      changes to MODE_ASK. Handling it as a part of activity on mode change
      instead of as precursor to mode change makes the logic more robust
      and a bit simpler.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      046e1b71
    • spiiroin's avatar
      [usb_moded] Move connect/disconnect signaling to udev · 39a3a90c
      spiiroin authored
      Cable connect/disconnect is detected at udev module - handling the
      related dbus signaling in the same place allows simplifying the usb
      mode related logic.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      39a3a90c
    • spiiroin's avatar
      [dyn-config] Drop unused softconnect keys · b1c56ebf
      spiiroin authored
      The "softconnect" attributes were used to configure android usb specific
      enable/disable sysfs controls. These attributes are no longer used, and
      at least in theory the same config files can be used for both android
      usb and configfs based systems.
      
      Remove unused attributes.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      b1c56ebf
    • spiiroin's avatar
      [usb_moded] Refactor entering/leaving usb mode. JB#41748 · 64350689
      spiiroin authored
      Split mode switching to three layers: Tracking cable connection state,
      choosing target mode, and performing required actions to activate
      the chosen mode.
      
      Try to minimize places where layer borders are crossed - which should
      work also as an enabler for moving blocking actions to separate thread
      later on.
      
      Arrange logic in such manner that usb gadget is always configured as
      being able to serve some function - fallback being the dummy mass_storage
      function used for charging.
      
      Deprecate command line options that serve no useful purpose after the
      changes.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      64350689
    • spiiroin's avatar
      [android] Normalize numerical id-values to lower case hex. JB#41748 · 18efbfcc
      spiiroin authored
      Configfs wants to have numbers in '0xbeef' form while android usb wants to
      have 'beef'. Normalizing the output to expected format allows either form
      to be used in usb-moded configuration files.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      18efbfcc
    • spiiroin's avatar
      [android] Refactor android usb handling module. JB#41748 · 4f9ffa6d
      spiiroin authored
      Make it logically match what is available in configfs module.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      4f9ffa6d
    • spiiroin's avatar
      [usb_moded] Drop --android-bootup-function option. JB#41748 · 4f53cf48
      spiiroin authored
      The target is to always have android usb enabled with valid function, so
      this workaround is not relevant anymore.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      4f53cf48
    • spiiroin's avatar
      [usb_moded] Normalize multiline comments · 7a386e38
      spiiroin authored
      Just to make it easier for editor to handle automatic indentation, make
      all C comment continuation lines start with whitespace followed by '*'.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      7a386e38
    • spiiroin's avatar
      [mtp-mode] Require buteo-mtp-qt5 · 154bc19c
      spiiroin authored
      The "buteo-mtp" package name is probably old qt4 package that does not
      exist anymore.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      154bc19c
    • spiiroin's avatar
      [usb_moded] Add configfs support. Fixes JB#42083 · 692c2cb3
      spiiroin authored
      Add custom Makefile for faster smoke-test rebuilds without spending time
      in configure, autotools, document generation and/or rolling rpm packages.
      
      Add multiple include protection to all header files.
      
      Move function prototypes away from header files that included in the
      development package.
      
      Mass rename functions to have a prefix giving context for the function.
      For the most part the prefix is derived from the name of the compilation
      module containing the function.
      
      Mass normalize indentation to four spaces in all source files.
      
      Augment author lists on each source file based on git committers.
      
      Remove "inline" attributes from not-really-inlineable functions.
      
      Remove .gitignore.
      
      Remove unused modules-android.c source file.
      
      Define _GNU_SOURCE for whole build rather than in individual files.
      
      Fix resource leaks here and there.
      
      Try to avoid hard-coding android usb paths.
      
      Add configfs backend for usb cadget configuration.
      
      Probe supported backends (configfs, android usb, or kmod) on usb-moded
      startup and make them mutually exclusive with each other.
      
      Allow configfs and android usb control structures some time to show up
      if usb-moded is started during device bootup.
      
      Refactor udev event listener to utilize a state machine. Simplifies
      book keeping and makes pc/charger detection heuristics easier to control.
      
      Refactor mode selection to utilize three interconnected mini state machines.
      Allows separating logically wanted mode from mode programmed to usb and
      mode exposed over D-Bus.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      692c2cb3
  2. 06 Jun, 2018 2 commits
  3. 05 Jun, 2018 3 commits
  4. 04 Apr, 2018 2 commits
  5. 29 Mar, 2018 3 commits
  6. 28 Mar, 2018 7 commits
  7. 14 Mar, 2018 2 commits