This is an example of one of those applications that work so well, consists of simple parts, and leverages these simple tools very cleverly.
It's a solution that I think 'why didn't I write this?'
Very awesome work rom1v, and very much appreciate you explaining your usage of adb screenfetch and how you are able to arbitrarily run java code from /tmp. This opened up an entire new world for me.
This seems pretty neat. What is the purpose of such an app though? Is it intended for use by Android developers? I don't see what I'd use it for but I'm interested in how people use the app.
It has been devoloped for a specific use case (it is included in a B2B application where the user may need to display and control devices connected on USB).
But you might use it for other reasons, like typing text messages from your computer, or showing your device in a conference (e.g. to demo an app).
Demoing an app on Android has been a pain, so far. Vysor was the easiest solution but comes with ads if you don't buy the license. This seemingly being an ad-free alternative makes it very interesting to me and my team.
Only thing is I tried to compile the code base on a Macbook Pro and it took maybe 10+ minutes on my only attempt. I had to cancel it b/c my laptop was going into "jet" mode w/ the noise levels during a conference call. I'm going to try and compile it again and see how long it really takes for me.
I can see android users using it in place of an emulator. From what I've heard (I'm not an Android dev) the emulators are generally pretty slow and using a device is way faster.
This would let you control it right from your computer, instead of having to actually tap on your phone, which can be tedious, especially when typing.
While the modern Android emulator is nowdays actually faster than devices, testing on the actual hardware is still important due to device-specific issues.
And having such tool makes this way easier since you don't have to constantly reach for a phone and be wrapped in cables :)
I'm getting just old enough that my near vision is starting to fail. It'd be nice to be able to use my mouse and a computer screen, with a slightly enlarged Android display, to control games and such on my phone.
And since it apparently handles keyboard support, typing on the phone would be a lot easier, too.
If it could control the phone through the network allowing to simulate swiping with the mouse it would be even more useful. As an example, I'm allergic to Whatsapp but am forced to keep it in (on a tablet which stays at home 24/7, data plan only SIM) because of a handful of friends who refuse to use more advanced IM software, so when I'm away they cannot contact me. The WA web app is a joke and forces one to keep the phone/tablet at hand anyway, so although I don't miss Whatsapp at all, being able to tunnel the access to it could be useful sometimes.
This opens up the possibility of making something akin to niffy [1], which offers a sane/easy way to automate UI testing. Unfortunately, in the case of Android apps you wouldn't have css selectors to simplify simulation of clicks on specific elements.
I'm an Android dev currently working on a team using NativeScript. My coworkers' latops have only 4GB RAM and they are unable to use an AVD for development. From now we are going to use scrpy :)
Very clever, and nice writeup! A few years ago I wrote a bunch of bash scripts to control my phone over adb (found it useful to script certain things and write messages etc. Before things like WhatsApp had a Web client). This has taken that concept to its most elegant formulation! Well done.
Looks great. It certainly has become much easier to build such apps on modern Android :)
For something a bit more old school, I’d like to insert a shameless plug here that we open sourced something similar several years ago. It’s focused on the enterprise side, so setting it up is unfortunately quite a bit more involved. Screen rendering is obviously far less advanced as well, though still decent enough. It’s compatible with (almost) all Android versions since 2.3 which has its own fun challenges!
AFAIK, till now the only alternative for the features mentioned in OP was Vysor by clockworkmod which is a monthly paid app. I had to subscribe it for occasional demos, I'll be happy if Scrcpy fills in the role.
Its kind of the same thing, Vysor has ads in it though and isn't open source. So this seems like an improvement in general as it doesn't have ads and its open sourced.
The solution would be to change the direction of the connection, and use "adb forward", but then scrcpy would try to connect before the server is started, so it would need to retry until connected (and the error would not be noticed on connect, but on first read, due to the tunnel).
It's a solution that I think 'why didn't I write this?'
Very awesome work rom1v, and very much appreciate you explaining your usage of adb screenfetch and how you are able to arbitrarily run java code from /tmp. This opened up an entire new world for me.