Commit Graph

239 Commits (1c44dc2259f7111f8432fcf1ab8509c68f48d9a0)

Author SHA1 Message Date
Luís Ferreira 02a882a0a2 Use a more portable shebang for bash
This should increase the portability of bash scripts across various *nix
systems such as BSD-like distributions.

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

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
CapsLock cf7bf3148c Use "/usr/bin/env bash" for build-wrapper.sh
PR #426 <https://github.com/Genymobile/scrcpy/pull/426>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont ae758f99d6 Adapt call() on ContentProvider for Android 11
This commit in AOSP framework_base added a parameter "attributionTag" to
the call() method:
12ac3f406f%5E%21/#F17

As a consequence, the method did not exist, so scrcpy used the legacy
call() method (using the authority "unknown") as a fallback, which fails
for security reasons.

Fixes #1468 <https://github.com/Genymobile/scrcpy/issues/1468>
4 years ago
brunoais 0bf110dd5c Reset power mode only if screen is on
PR #1670 <https://github.com/Genymobile/scrcpy/pull/1670>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont 0c5e0a4f6d Make Device methods static when possible
The behavior of some methods do not depend on the user-provided options.
These methods can be static. This will allow to call them directly from
the cleanup process.
4 years ago
Romain Vimont d7779d08e8 Bump version to 1.16 4 years ago
Romain Vimont 95f1ea0d80 Fix clipboard paste condition
To avoid possible copy-paste loops between the computer and the device,
the device clipboard is not set if it already contains the expected
content.

But the condition was wrong: it was not set also if it was empty.

Refs 1223a72eb8
Fixes #1658 <https://github.com/Genymobile/scrcpy/issues/1658>
4 years ago
Romain Vimont 38940ffe89 Revert "Inject WAKEUP instead of POWER"
WAKEUP does not work on some devices.

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

This reverts commit 322f1512ea.
4 years ago
Romain Vimont 633a51e9c4 Bump version to 1.15.1 4 years ago
Romain Vimont edc4f7675f Bump version to 1.15 4 years ago
Romain Vimont da63e3774b Merge branch 'master' into dev 4 years ago
brunoais cf9d44979c Keep the screen off on powering on
PR #1577 <https://github.com/Genymobile/scrcpy/pull/1577>
Fixes #1573 <https://github.com/Genymobile/scrcpy/issues/1573>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont 1223a72eb8 Set device clipboard only if necessary
Do not explicitly set the clipboard text if it already contains the
expected content. This avoids possible copy-paste loops between the
computer and the device.
4 years ago
Romain Vimont eabaf6f7bd Simplify PASTE option for "set clipboard"
When the client requests to set the clipboard, it may request to press
the PASTE key in addition. To be a bit generic, it was stored as a flag
in ControlMessage.java.

But flags suggest that it represents a bitwise union. Use a simple
boolean instead.
4 years ago
Romain Vimont 322f1512ea Inject WAKEUP instead of POWER
To power the device on, inject KEYCODE_WAKEUP to avoid a possible
race condition (the device might become off between the test
isScreenOn() and the POWER keycode injection).
4 years ago
brunoais 30714aba34 Restore power mode to normal on cleanup
This avoids to let the device screen turned off (as enabled by Ctrl+o or
--turn-screen-off).

PR #1576 <https://github.com/Genymobile/scrcpy/pull/1576>
Fixes #1572 <https://github.com/Genymobile/scrcpy/issues/1572>
4 years ago
Romain Vimont a973757fd1 Warn on ignored touch event
In theory, this was expected to only happen when a touch event is sent
just before the device is rotated, but some devices do not respect the
encoding size, causing an unexpected mismatch.

Refs #1518 <https://github.com/Genymobile/scrcpy/issues/1518>
4 years ago
Romain Vimont 5fa46ad0c7 Fix constants name in comment 4 years ago
Romain Vimont 334964c380 Make setScreenPowerMode() method static
Its implementation does not use the instance at all.
4 years ago
Romain Vimont f7d4b6d0db Do not crash on missing clipboard manager
Some devices have no clipboard manager.

In that case, do not try to enable clipboard synchronization to avoid
a crash.

Fixes #1440 <https://github.com/Genymobile/scrcpy/issues/1440>
Fixes #1556 <https://github.com/Genymobile/scrcpy/issues/1556>
4 years ago
xeropresence 3c1ed5d86c Handle repeating keycodes
Initialize "repeat" count on key events.

PR #1519 <https://github.com/Genymobile/scrcpy/pull/1519>
Refs #1013 <https://github.com/Genymobile/scrcpy/pull/1013>

Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont 488d22d4e2 Increase clipboard size from 4k to 256k
Beyond 256k, SDL_GetClipboardText() returns an empty string on my
computer.

Fixes #1117 <https://github.com/Genymobile/scrcpy/issues/1117>
4 years ago
Romain Vimont 245999aec4 Serialize text size on 4 bytes
This will allow to send text having a size greater than 65535 bytes.
4 years ago
Romain Vimont a00a8763d6 Avoid additional copy on Java text parsing
Directly pass the buffer range to the String constructor.
4 years ago
Romain Vimont 8f314c74b0 Reorganize message size constants
Make the max clipboard text length depend on the max message size.
4 years ago
Louis Leseur 1b73eff3c9 Add missing file in build_without_gradle.sh
Fixes #1481 <https://github.com/Genymobile/scrcpy/issues/1481>
PR #1482 <https://github.com/Genymobile/scrcpy/pull/1482>

Signed-off-by: Louis Leseur <louis.leseur@gmail.com>
Signed-off-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont 44fa4a090e Bump version to 1.14 4 years ago
Romain Vimont 93a5c5149d Push clipboard text only if not null
In practice, it does not change anything (it just avoids a spurious
wake-up), but semantically, it makes no sense to call
pushClipboardText() with a null value.
4 years ago
Romain Vimont d499ee53c9 Initialize a default log level
Clean up has been broken by 3df63c579d.

The verbosity was correctly initialized for the Server process, but not
for the CleanUp process.

To avoid the problem, initialize a default log level.
4 years ago
Romain Vimont fc1dec0270 Paste on "set clipboard" if possible
Ctrl+Shift+v synchronizes the computer clipboard to the Android device
clipboard. This feature had been added to provide a way to copy UTF-8
text from the computer to the device.

To make such a paste more straightforward, if the device runs at least
Android 7, also send a PASTE keycode to paste immediately.

<https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_PASTE>

Fixes #786 <https://github.com/Genymobile/scrcpy/issues/786>
4 years ago
Romain Vimont 4bbabfb4ef Move injection methods to Device
Only the main injection method was exposed on Device, the convenience
methods were implemented in Controller.

For consistency, move them all to the Device class.
4 years ago
Romain Vimont ffc57512b3 Avoid clipboard synchronization loop
The Android device listens for clipboard changes to synchronize with the
computer clipboard.

However, if the change comes from scrcpy (for example via Ctrl+Shift+v),
do not notify the change.
4 years ago
Romain Vimont c7a33fac36 Log actions on the caller side
Some actions are exposed by the Device class, but logging success should
be done by the caller.
4 years ago
Romain Vimont 81573d81a0 Pass a Locale to toUpperCase()
Make lint happy.
4 years ago
Romain Vimont 5c2cf88a1d Rename THRESHOLD to threshold
Since the field is not final anymore, lint expects the name not to be
capitalized.
4 years ago
Romain Vimont 3df63c579d Configure server verbosity from the client
Send the requested log level from the client.

This paves the way to configure it via a command-line argument.
4 years ago
Tzah Mazuz 080a4ee365 Add --codec-options
Add a command-line parameter to pass custom options to the device
encoder (as a comma-separated list of "key[:type]=value").

The list of possible codec options is available in the Android
documentation:
<https://d.android.com/reference/android/media/MediaFormat>

PR #1325 <https://github.com/Genymobile/scrcpy/pull/1325>
Refs #1226 <https://github.com/Genymobile/scrcpy/pull/1226>

Co-authored-by: Romain Vimont <rom@rom1v.com>
4 years ago
Romain Vimont c7155a1954 Add unit test for big "set clipboard" event
Add a unit test to avoid regressions.

Refs #1425 <https://github.com/Genymobile/scrcpy/issues/1425>
4 years ago
Romain Vimont 517dbd9c85 Increase buffer size to fix "set clipboard" event
The buffer size must be greater than any event message.

Clipboard events may take up to 4096 bytes, so increase the buffer size.

Fixes #1425 <https://github.com/Genymobile/scrcpy/issues/1425>
4 years ago
Romain Vimont acc4ef31df Synchronize device clipboard to computer
Automatically synchronize the device clipboard to the computer any time
it changes.

This allows seamless copy-paste from Android to the computer.

Fixes #1056 <https://github.com/Genymobile/scrcpy/issues/1056#issuecomment-631363684>
PR #1423 <https://github.com/Genymobile/scrcpy/pull/1423>
4 years ago
Romain Vimont 73e722784d Remove useless exception declaration
The interface declares it can throw a RemoteException, but the
implementation never throws such exception.
4 years ago
Romain Vimont e1cd75792c Simplify rotation watcher call
Remove unnecessary private method (which was wrongly public).
4 years ago
Romain Vimont e2d5f0e7fc Send scroll events as a touchscreen
Scroll events were sent with a mouse input device. When scrolling on a
list, this could cause the whole list to be focused, and drawn with the
focus color as background.

Send scroll events with a touchscreen input device instead (like motion
events).

Fixes #1362 <https://github.com/Genymobile/scrcpy/issues/1362>
4 years ago
Romain Vimont 74ece9b45b Simplify ScreenEncoder more
Commit 927d655ff6 removed the
iFrameInternal field and constructor argument.

Also remove it from createFormat() arguments.
4 years ago
Romain Vimont c77024314d Add an option to keep the device awake
Add an option to prevent the device to sleep:

    scrcpy --stay-awake
    scrcpy -w

The initial state is restored on exit.

Fixes #631 <https://github.com/Genymobile/scrcpy/issues/631>
4 years ago
Romain Vimont 4668638ee1 Handle "show touches" on the device-side
Now that the server can access the Android settings and clean up
properly, handle the "show touches" option from the server.

The initial state is now correctly restored, even on device
disconnection.
4 years ago
Romain Vimont dbb0df607c Move constants to ServiceManager
PACKAGE_NAME and USER_ID could be use by several "managers", so move
them to the service manager.
4 years ago
Romain Vimont 2f74ec2518 Add a clean up process on the device
In order to clean up on close, use a separate process which is not
killed when the device is disconnected (even if the main process itself
is killed).
4 years ago
Romain Vimont 8c6799297b Implement access to settings without Context
Expose methods to access the Android settings using private APIs.

This allows to read and write settings values immediately without
starting a new process to call "settings".
4 years ago
Romain Vimont 62c0c1321f Apply workarounds only on error
To avoid NullPointerException on some devices, workarounds have been
implemented. But these workaround produce (harmless) internal errors
causing exceptions to be printed in the console.

To avoid this problem, apply the workarounds only if it fails without
them.

Fixes #994 <https://github.com/Genymobile/scrcpy/issues/994>
Refs #365 <https://github.com/Genymobile/scrcpy/issues/365>
Refs #940 <https://github.com/Genymobile/scrcpy/issues/940>
4 years ago