scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Support Kitkat

Open consp1racy opened this issue 3 years ago • 6 comments

This is another attempt at suporting API 19. We're developing for a market that's often stuck 10 years ago and seeing this work felt amazing. Maybe label it as experimental.

What this consists of:

  • Rebase the original api19 branch on top of master.
  • Polyfill android.system.Os.write(FileDescriptor, ByteBuffer).
  • Backport MediaCodec.getOutputBuffer API.
  • Set ANDROID_HOME=/data/local/tmp for server.

What doesn't work:

  • Emulators. See https://issuetracker.google.com/issues/36982354
  • ~Philips 10BDL3051T (no root). See https://github.com/Genymobile/scrcpy/issues/98#issuecomment-379046536~

What definitely works:

  • HTC Desire 601(rooted)
  • Philips 10BDL3051 (no root) with the ANDROID_DATA hack

The performance isn't amazing but it works.

htc desire 601

philips 10bdl3051t

consp1racy avatar Jun 20 '22 08:06 consp1racy

I've made it so the AndroidX annotation-1.3.0.jar lives as a copy inside the repo. It's a compile-only dependency both in server/build.gradle and server/build_without_gradle.sh. That way it contributes to developer experience in Android Studio, it contributes to lint, but has no effect on the produced artifact. The annotations and their calls are not present scrcpy-server binary.

The same thing now applies to the libcore.io package. This package is part of the framework and only needs to be presetn at compile time. The binary doesn't contain any of these classes.

~The same approach should be done in the future with the system AIDL interfaces (e.g. IRotationWatcher.aidl or IClipboard) these are part of the framework and shouldn't be part of the binary.~ This only applies to gradle build.

android.system package remains shadowed for now. ~Tried doing it better but it bloated the binary.~

Removed unnecessary logic from MediaCodecCompat.

Extracted MediaCodecListCompat from ScreenEncoder to keep it clean.

consp1racy avatar Jun 25 '22 14:06 consp1racy

  • We no longer shadow android.system package. Instead there's new androidx.system package.
  • OsCompat.write(FileDescriptor, ByteBuffer) now advances buffer position on all platforms. This was fixed in Lollopop MR1. This is no longer part of IO.writeFully.
  • OsCompat.write automatically retries on EINTR.
  • As a side-effect, we can now use lambdas.

This wraps up API 19 support. I think devices without an encoder, like the watch, should be handled separately, by querying PackageManager features or listing media codecs and failing with better error message.

consp1racy avatar Jun 27 '22 02:06 consp1racy

  • Make the /data/local/tmp/dalvik-cache directory ourselves.

consp1racy avatar Jun 27 '22 15:06 consp1racy

Why the video socket is using file descriptors, not standard Java streams? Is file descriptor faster than stream or something?

yume-chan avatar Feb 03 '23 18:02 yume-chan

Why the video socket is using file descriptors, not standard Java streams? Is file descriptor faster than stream or something?

https://github.com/Genymobile/scrcpy/commit/66def38b734829170654647086bd76f99efdec70

consp1racy avatar Feb 03 '23 20:02 consp1racy

I really need it. How can I download it?

hebing0305 avatar Apr 07 '24 01:04 hebing0305