Commit Graph

180 Commits (9e78b765da01843b4986f93179b0c92701269062)

Author SHA1 Message Date
Romain Vimont bea1c11f8e Do not log success on failure
If calling the private API does not work, an exception is printed. In
that case, do not log that the action succeeded.
4 years ago
e_vigurskiy 4150eedcdf Add display id parameter
Add --display command line parameter to specify a display id.

PR #1238 <https://github.com/Genymobile/scrcpy/pull/1238>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont 5031b2c8ff Remove MagicNumber checkstyle
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.
4 years ago
Romain Vimont 4adf5fde6d Log device details on server start 4 years ago
Romain Vimont 3504c0016b Add tests for control message length
This will avoid regressions for #1245.

<https://github.com/Genymobile/scrcpy/issues/1245>
4 years ago
Romain Vimont 89d1602185 Fix expected message length for touch events
The expected length for a touch event control message was incorrect. As
a consequence, a BufferUnderflowException could occur.

Fixes #1245 <https://github.com/Genymobile/scrcpy/issues/1245>
4 years ago
Romain Vimont 566ba766af Remove unused constant
It has not been removed when mouse and touch events have been merged.
4 years ago
Tzah Mazuz a0af402d96 Fix the printed versions (were opposite)
PR #1224 <https://github.com/Genymobile/scrcpy/pull/1224>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont ae2d094362 Handle locked video orientation from ScreenInfo
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.
4 years ago
Romain Vimont c5f5d1e456 Rename "rotation" to "device rotation"
This paves the way to reduce confusion in ScreenInfo when it will handle
locked video orientation.
4 years ago
Romain Vimont 63286424bb Compute all screen info from ScreenInfo
Screen information was partially initialized from Device. Move this
initialization to ScreenInfo.
4 years ago
Romain Vimont da18c9cdab Remove useles import 4 years ago
George Stamoulis 1982bc439b Add option to lock video orientation
PR #1151 <https://github.com/Genymobile/scrcpy/pull/1151>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont ef56cc6ff7 Retrieve screen info once
The method getScreenInfo() is synchronized, and the result may change
between calls.

Call it once and store the result in a local variable.
4 years ago
Romain Vimont 96bd2c974d Do not report workarounds errors
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>
4 years ago
Romain Vimont 83d48267a7 Accept --max-fps before Android 10
KEY_MAX_FPS_TO_ENCODER existed privately before Android 10:
<https://github.com/Genymobile/scrcpy/issues/488#issuecomment-567321437>
5 years ago
Romain Vimont 4687a0ebac Bump version to 1.12.1 5 years ago
Romain Vimont a0f8e7fd9f Bump version to 1.12 5 years ago
Romain Vimont e0b117de13 Fix checkstyle warning 5 years ago
Romain Vimont eb0f339271 Add shortcut to rotate screen
On Ctrl+r, disable auto-rotation (if enabled), set the screen rotation
and re-enable auto-rotation (if it was enabled).

Closes #11 <https://github.com/Genymobile/scrcpy/issues/11>
5 years ago
Romain Vimont bdd05b4a16 Refactor wrappers for Android SDK classes
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.
5 years ago
Romain Vimont 525d6d4a75 Try new methods before legacy ones
Use the legacy methods when the new ones do not exist.
5 years ago
Romain Vimont 8a694a9785 Suggest workaround for error 0xfffffc0e
When the hardware encoder is not able to encode at the given definition,
it fails with an error 0xfffffc0e.

It is documented in the FAQ:
<https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#i-get-an-error-could-not-open-video-stream>

But it is better to directly suggest the workaround in the console.
5 years ago
Romain Vimont 26529d377f Use virtual device id to avoid NPE
Inject mouse events using id -1 (virtual device) instead of 0 which
does not exist (and causes the InputDevice to be null).

Fixes <https://github.com/Genymobile/scrcpy/issues/962>
5 years ago
Romain Vimont 6abb8fd0cd Reformat Java code
Reformated by Android studio to match the 150 characters column defined
in checkstyle.
5 years ago
Romain Vimont 2b845680b0 Initialize Application object to avoid NPE
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>
5 years ago
Romain Vimont ebdc2ee8b5 Rename variable for consistency
Use suffix "Field" for fields variables.
5 years ago
Romain Vimont 83ace84280 Restore the .jar extension on the device side
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>
5 years ago
yangfl 7d7f3daff2 Fix aidl option in build_without_gradle.sh
Debian's aidl complains about the missing path for -o option.

Signed-off-by: Romain Vimont <rom@rom1v.com>
5 years ago
Romain Vimont 2aa65015bc Bump version to 1.11 5 years ago
act262 90293240cc Fix meizu 16th NPE
Fill AppInfo to avoid NullPointerException on some devices.

Fixes <https://github.com/Genymobile/scrcpy/issues/365>

Signed-off-by: Romain Vimont <rom@rom1v.com>
5 years ago
Romain Vimont 213c468c20 Move workarounds to a separate class
Extract workarounds (currently only one) to a separate class to avoid
polluting the main code.
5 years ago
Romain Vimont 601b0fecdd Extract DEBUG flag in build_without_gradle.sh 5 years ago
Romain Vimont 7fd800d583 Generate VERSION_NAME in build_without_gradle.sh
Since commit b963a3b9d5, the server uses
BuildConfig.VERSION_NAME.

Generate this field manually for building without gradle.
5 years ago
Romain Vimont 1d97d7213d Add option --max-fps
Add an option to limit the capture frame rate. It only works for devices
with Android >= 10.

Fixes <https://github.com/Genymobile/scrcpy/issues/488>
5 years ago
Romain Vimont fb976816f9 Do not expose frame rate in ScreenEncoder
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.
5 years ago
Yu-Chen Lin b963a3b9d5 Check client and server mismatch
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>
5 years ago
olbb e282100d0b Call Looper.prepareMainLooper() to avoid exception
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>
5 years ago
Romain Vimont 3da95b52bd Rename scrcpy-server.jar to scrcpy-server
The server name ending with .jar has several drawbacks:
 - meson requires the jar executable to attempt to modify it:
     <https://github.com/Genymobile/scrcpy/issues/404#issuecomment-456065923>
     <https://github.com/mesonbuild/meson/issues/4844>
 - meson warns during "ninja install"
     <https://github.com/Genymobile/scrcpy/issues/458>
 - some users try to execute it on the computer as a java executable

Removing the extension solves all these problems.
5 years ago
Romain Vimont c72f677435 Merge branch 'master' into dev 5 years ago
Romain Vimont d841718956 Add a script to build the server without gradle
Gradle versions may sometimes cause problems. This script offers an
alternative.
5 years ago
Romain Vimont f9938dbf88 Inject button state for touch/mouse events
The buttons state was forwarded, but ignored by the server.
5 years ago
Romain Vimont c33a147fd0 Fix "turn screen off" on Android Q
Call getInternalDisplayToken(), which retrieve the id of the first
physical display (which is not necessarily 0 anymore).

Fixes <https://github.com/Genymobile/scrcpy/issues/835>
5 years ago
Romain Vimont 8b33c6c108 Adapt copy-paste methods for Android 10
The methods getPrimaryClip() and setPrimaryClip() expect an additional
parameter since Android 10.

Fixes <https://github.com/Genymobile/scrcpy/issues/796>.
5 years ago
Romain Vimont 5b7a0cd8e9 Extract String literal to static constant 5 years ago
Romain Vimont bab9361948 Do not crash on control error
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.
5 years ago
Romain Vimont 6220456def Merge mouse and touch events
Both are handled the very same way on the device.
5 years ago
Romain Vimont 7e1d52c119 Rename "touch pointer" to "pointer"
There are only touch pointers now, mouse pointers have been removed.
5 years ago
Romain Vimont 280d5b718c Use common pointers for mouse and touch
The mouse is a pointer like any other.
5 years ago
Romain Vimont f765aae352 Inject touch events on the server
On receiving an "inject touch" control message, update the local
pointers state and inject touches.
5 years ago