There are a lot of "magic numbers" that we really don't want to extract
as a constant.
Until now, many @SuppressWarnings annotations were added, but it makes
no sense to check for magic number if we silent the warnings everywhere.
Centralize video size management in ScreenInfo.
This allows to always send the correct initial video size to the client
if the video orientation is locked.
Some workarounds are needed on some devices. But applying them may cause
exceptions on other devices, where they are not necessary anyway.
Do not report these errors in release builds.
Closes#994 <https://github.com/Genymobile/scrcpy/issues/994>
Internally, a failure to invoke a method via reflection was partially
managed using exceptions, partially using a null return value.
Handle all errors at the same place, by not catching
NoSuchMethodException too early.
When an ApplicationInfo is set (commit
90293240cc), some devices (Nvidia Shield
TV) attempt to access the Application object, causing a
NullPointerException.
As a workaround, initialize an Application object.
Fixes <https://github.com/Genymobile/scrcpy/issues/940>
Commit 3da95b52bd renamed
'scrcpy-server.jar' to 'scrcpy-server' to avoid issues on the client
side.
However, removing the extension may cause issues with app_process, so
restore the extension only on the device side.
Fixes <https://github.com/Genymobile/scrcpy/issues/944>
The KEY_FRAME_RATE parameter value is necessary for the configuration of
the encoder, but its actual value does not impact the frame rate (only
resources used by the encoder).
Therefore, it's an internal detail and should not be exposed by the
ScreenEncoder class.
Send client version as first parameter and check it at server start.
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
Some devices internally create a Handler when creating an input Surface,
causing an exception:
> Surface: java.lang.RuntimeException: Can't create handler inside
> thread that has not called Looper.prepare()
As a workaround, call Looper.prepareMainLooper() beforehand.
Fixes:
- <https://github.com/Genymobile/scrcpy/issues/240>
- <https://github.com/Genymobile/scrcpy/issues/921>
Signed-off-by: Romain Vimont <rom@rom1v.com>
Some devices do not have some methods that we invoke via reflection, or
their call do not return the expected value. In that case, do not crash
the whole controller.
Enable the attribute "console" of custom_target() introduced in meson
0.48. This allows to get a feedback of what gradle does (which can takes
a very long time).
This produces warnings because we declare to support meson >= 0.37, but
we don't want to stop supporting older versions for that. Older versions
just ignore the option:
> WARNING: Unknown keyword arguments in target scrcpy-server: console
Newer meson versions use it, but warn because we declare supporting
older versions:
> WARNING: Project targetting '>= 0.37' but tried to use feature
> introduced in '0.48.0': console arg in custom_target
Meson does not support conditional branches to suppress such warnings,
so just keep the warnings.
Add two shortcuts:
- Ctrl+o to turn the device screen off while mirroring
- Ctrl+Shift+o to turn it back on
On power on (either via the POWER key or BACK while screen is off), both
the device screen and the mirror are turned on.
<https://github.com/Genymobile/scrcpy/issues/175>
After the recent refactorings, a "control event" is not necessarily an
"event" (it may be a "command"). Similarly, the unique "device event"
used to send the device clipboard content is more a "reponse" to the
request from the client than an "event".
Rename both to "message", and rename the message types to better
describe their intent.
It was already possible to _paste_ (with Ctrl+v) the content of the
computer clipboard on the device. Technically, it injects a sequence of
events to generate the text.
Add a new feature (Ctrl+Shift+v) to copy to the device clipboard
instead, without injecting the content. Contrary to events injection,
this preserves the UTF-8 content exactly, so the text is not broken by
special characters.
<https://github.com/Genymobile/scrcpy/issues/413>
Parsing a String from a serialized control event, encoded as length (2
bytes) + data, will be necessary in several events.
Extract it to a separate method.
On Ctrl+C:
- the client sends a GET_CLIPBOARD command to the device;
- the device retrieve its current clipboard text and sends it in a
GET_CLIPBOARD device event;
- the client sets this text as the system clipboard text, so that it
can be pasted in another application.
Fixes <https://github.com/Genymobile/scrcpy/issues/145>
The socket used the device-to-computer direction to stream the video and
the computer-to-device direction to send control events.
Some features, like copy-paste from device to computer, require to send
non-video data from the device to the computer.
To make them possible, use two sockets:
- one for streaming the video from the device to the client;
- one for control/events in both directions.
Several commands were grouped under the same event type "command", with
a separate field to indicate the actual command.
Move these commands at the same level as other control events. It will
allow to implement commands with arguments.