Skip to content

Different exit codes for failure to connect and disconnect - #3085

Closed
madduck wants to merge 1 commit into
Genymobile:masterfrom
madduck:exit-codes
Closed

madduck wants to merge 1 commit into
Genymobile:masterfrom
madduck:exit-codes

Conversation

@madduck

@madduck madduck commented Mar 5, 2022

Copy link
Copy Markdown
Contributor

Modify the return logic such that exit code 1 is used when the initial
connection fails, but if a session is established, and then the device
disconnects, exit code 2 is emitted.

Closes: Github:#3083
Signed-off-by: martin f. krafft madduck@madduck.net

Modify the return logic such that exit code 1 is used when the initial
connection fails, but if a session is established, and then the device
disconnects, exit code 2 is emitted.

Closes: Github:Genymobile#3083
Signed-off-by: martin f. krafft <madduck@madduck.net>
rom1v added a commit that referenced this pull request Mar 6, 2022
We must distinguish 3 cases for await_for_server():
 - an error occurred
 - no error occurred, the device is connected
 - no error occurred, the device is not connected (user requested to
   quit)

For this purpose, use an additional output parameter to indicate if the
device is connected (only set when no error occurs).

Refs #3085 <#3085>
rom1v pushed a commit that referenced this pull request Mar 6, 2022
Modify the return logic such that exit code 1 is used when the initial
connection fails, but if a session is established, and then the device
disconnects, exit code 2 is emitted.

Fixes #3083 <#3083>
PR #3085 <#3085>
Signed-off-by: martin f. krafft <madduck@madduck.net>
Signed-off-by: Romain Vimont <rom@rom1v.com>
@rom1v

rom1v commented Mar 6, 2022

Copy link
Copy Markdown
Collaborator

Hi,

Thank you for your PR.

I added a preliminary commit to report the 3 possible states in await_for_server() (this simplifies the implementation of this feature): 1f4c801

Then I made minor changes to your commit:

  • use a dedicated enum scrcpy_exit_code (to avoid exposing SDL constants resulting of implementation details)
  • (nitpick) EXIT CODES → EXIT STATUS in manpage (for consistency with other manpages)

The resulting branch is here: exit_code

Please review/test :)

@madduck

madduck commented Mar 8, 2022

Copy link
Copy Markdown
Contributor Author

@rom1v I've been running scrcpy from your exit-code branch, and it works just fine. Thank you!

@madduck

madduck commented Mar 8, 2022

Copy link
Copy Markdown
Contributor Author

Do you need me to migrate your branch over to this PR or should we just close this and make a new one on the basis of your branch?

rom1v added a commit that referenced this pull request Mar 10, 2022
@rom1v

rom1v commented Mar 10, 2022

Copy link
Copy Markdown
Collaborator

Merged into dev.

I also added a commit to document the exit statis in scrcpy --help: b1dbc30

Exit status:

      0  Normal program termination
      1  Start failure
      2  Device disconnected while running

@rom1v rom1v closed this Mar 10, 2022
rom1v added a commit that referenced this pull request Jun 18, 2023
Audio did not work on Honor devices.

Two workarounds are necessary:
 - a system context must be set as a base context of FakeContext (so
   that a PackageManager is available),
 - the same workaround as for Meizu phones must also be applied (so that
   ActivityThread.currentApplication() return a valid instance).

These workarounds must not be applied for all devices, they cause other
issues.

Fixes #4015 <#4015>
Refs #3085 <#3805>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
rom1v added a commit that referenced this pull request Jun 19, 2023
Audio did not work on Honor devices.

To make it work, a system context must be set as a base context of
FakeContext (so that a PackageManager is available), and a current
ActivityThread must be initialized.

These workarounds must not be applied for all devices, because they
might cause other issues.

Fixes #4015 <#4015>
Refs #3085 <#3805>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
rom1v added a commit that referenced this pull request Jun 19, 2023
Audio did not work on Honor devices.

To make it work, a system context must be set as a base context of
FakeContext (so that a PackageManager is available), and a current
ActivityThread must be initialized.

These workarounds must not be applied for all devices, because they
might cause other issues.

Fixes #4015 <#4015>
Refs #3085 <#3805>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
rom1v added a commit that referenced this pull request Jun 19, 2023
Audio did not work on Honor devices.

To make it work, a system context must be set as a base context of
FakeContext (so that a PackageManager is available), and a current
Application must be initialized.

These workarounds must not be applied for all devices, because they
might cause other issues.

Fixes #4015 <#4015>
Refs #3085 <#3805>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
rom1v added a commit that referenced this pull request Jun 19, 2023
Audio did not work on Honor devices.

To make it work, a system context must be set as a base context of
FakeContext (so that a PackageManager is available), and a current
Application must be initialized.

These workarounds must not be applied for all devices, because they
might cause other issues.

Fixes #4015 <#4015>
Refs #3085 <#3805>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
rom1v added a commit that referenced this pull request Jun 19, 2023
Audio did not work on Honor devices.

To make it work, a system context must be set as a base context of
FakeContext (so that a PackageManager is available), and a current
Application and ActivityThread must be set.

These workarounds must not be applied for all devices, because they
might cause other issues.

Fixes #4015 <#4015>
Refs #3085 <#3805>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
Linux4 pushed a commit to Linux4/scrcpy that referenced this pull request Sep 5, 2025
scrcpy v1.24

Changes since v1.23:
 - Adapt input injection for Android 13 (Genymobile#3186, Genymobile#3190)
 - Add --no-power-on (Genymobile#3148, Genymobile#3210)
 - Read $ANDROID_SERIAL if no selector is specified (Genymobile#3111, Genymobile#3113)
 - Consider emulators as TCP/IP devices (-e) (Genymobile#3137)
 - Apply requested window size in OTG mode (Genymobile#3099, Genymobile#3219)
 - Add specific exit code for device disconnection (Genymobile#3083, Genymobile#3085)
 - Enable libusb support for Windows 32-bit releases (Genymobile#3204, Genymobile#3206)
 - Upgrade libusb to 1.0.26 in Windows releases (Genymobile#3206)
 - Upgrade platform-tools to 33.0.1 (adb) in Windows releases (Genymobile#3206)
 - Upgrade SDL to 2.0.22 in Windows releases
 - Upgrade FFmpeg to 5.0.1 in Windows 64-bit releases
 - Improve some error messages
 - Various technical fixes
lingyicute pushed a commit to lingyicute/scrcpy that referenced this pull request Nov 19, 2026
Audio did not work on Honor devices.

To make it work, a system context must be set as a base context of
FakeContext (so that a PackageManager is available), and a current
ActivityThread must be initialized.

These workarounds must not be applied for all devices, because they
might cause other issues.

Fixes Genymobile#4015 <Genymobile#4015>
Refs Genymobile#3085 <Genymobile#3805>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
lingyicute pushed a commit to lingyicute/scrcpy that referenced this pull request Nov 19, 2026
Audio did not work on Honor devices.

To make it work, a system context must be set as a base context of
FakeContext (so that a PackageManager is available), and a current
Application must be initialized.

These workarounds must not be applied for all devices, because they
might cause other issues.

Fixes Genymobile#4015 <Genymobile#4015>
Refs Genymobile#3085 <Genymobile#3805>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
lingyicute pushed a commit to lingyicute/scrcpy that referenced this pull request Nov 19, 2026
Audio did not work on Honor devices.

To make it work, a system context must be set as a base context of
FakeContext (so that a PackageManager is available), and a current
ActivityThread must be initialized.

These workarounds must not be applied for all devices, because they
might cause other issues.

Fixes Genymobile#4015 <Genymobile#4015>
Refs Genymobile#3085 <Genymobile#3805>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
lingyicute pushed a commit to lingyicute/scrcpy that referenced this pull request Nov 19, 2026
Audio did not work on Honor devices.

To make it work, a system context must be set as a base context of
FakeContext (so that a PackageManager is available), and a current
Application must be initialized.

These workarounds must not be applied for all devices, because they
might cause other issues.

Fixes Genymobile#4015 <Genymobile#4015>
Refs Genymobile#3085 <Genymobile#3805>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
lingyicute pushed a commit to lingyicute/scrcpy that referenced this pull request Nov 19, 2026
Audio did not work on Honor devices.

Two workarounds are necessary:
 - a system context must be set as a base context of FakeContext (so
   that a PackageManager is available),
 - the same workaround as for Meizu phones must also be applied (so that
   ActivityThread.currentApplication() return a valid instance).

These workarounds must not be applied for all devices, they cause other
issues.

Fixes Genymobile#4015 <Genymobile#4015>
Refs Genymobile#3085 <Genymobile#3805>

Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants