Skip to content
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

Read/write settings via command on Android >= 12 #2802

Merged
merged 7 commits into from
Nov 18, 2021
Merged

Read/write settings via command on Android >= 12 #2802

merged 7 commits into from
Nov 18, 2021

Commits on Nov 18, 2021

  1. Wrap settings management into a Settings class

    Until now, the code that needed to read/write the Android settings had
    to explicitly open and close a ContentProvider.
    
    Wrap these details into a Settings class.
    
    This paves the way to provide an alternative implementation of settings
    read/write for Android >= 12.
    
    PR #2802 <#2802>
    rom1v committed Nov 18, 2021
    Configuration menu
    Copy the full SHA
    6717043 View commit details
    Browse the repository at this point in the history
  2. Report settings errors via Exceptions

    Settings read/write errors were silently ignored. Report them via a
    SettingsException so that the caller can handle them.
    
    This allows to log a proper error message, and will also allow to
    fallback to a different settings method in case of failure.
    
    PR #2802 <#2802>
    rom1v committed Nov 18, 2021
    Configuration menu
    Copy the full SHA
    94feae7 View commit details
    Browse the repository at this point in the history
  3. Add throwable parameter to Log.w()

    When an exception occurs, we might want to log a warning instead of an
    error.
    
    PR #2802 <#2802>
    rom1v committed Nov 18, 2021
    Configuration menu
    Copy the full SHA
    48b572c View commit details
    Browse the repository at this point in the history
  4. Read/write settings via command on Android >= 12

    Before Android 8, executing the "settings" command from a shell was
    very slow (~1 second), because it spawned a new app_process to execute
    Java code. Therefore, to access settings without performance issues,
    scrcpy used private APIs to read from and write to settings.
    
    However, since Android 12, this is not possible anymore, due to
    permissions changes.
    
    To make it work again, execute the "settings" command on Android 12 (or
    on previous version if the other method failed). This method is faster
    than before Android 8 (~100ms).
    
    Fixes #2671 <#2671>
    Fixes #2788 <#2788>
    PR #2802 <#2802>
    rom1v committed Nov 18, 2021
    Configuration menu
    Copy the full SHA
    cc0902b View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    411bb0d View commit details
    Browse the repository at this point in the history
  6. Do not quit on cleanup configuration failure

    Cleanup is used for some options like --show-touches to restore the
    state on exit.
    
    If the configuration fails, do not crash the whole process. Just log an
    error.
    
    PR #2802 <#2802>
    rom1v committed Nov 18, 2021
    Configuration menu
    Copy the full SHA
    c29a0bf View commit details
    Browse the repository at this point in the history
  7. Configure init and cleanup asynchronously

    Accessing the settings (like --show-touches) on start should not delay
    screen mirroring.
    
    PR #2802 <#2802>
    rom1v committed Nov 18, 2021
    Configuration menu
    Copy the full SHA
    ee93d2a View commit details
    Browse the repository at this point in the history