Android: any-screen capture without ROOT and constant USB connection - android

I'm trying to make an app that takes a video capture of the screen by taking individual snapshots. I've been looking into taking the snapshot without root, and seems that most solutions use ddmlib and require the device to be constantly connected via USB.
The only solution that doesn't require root and a constant usb connection is the android screenshot library. However, from the forum comments as well as my experience with the demo app, this library doesn't work very reliably/consistently.
Is there any other solution?
Note: I've also looked at the Noroot Screenshotit app (https://play.google.com/store/apps/details?id=com.edwardkim.android.screenshotitfullnoroot&hl=en), and seem like they have a similar approach to the android screenshot library, but have no idea how they make it more reliable. If anyone has an idea, that would be helpful as well.
Thanks
Edit: We've already got the USB-connected implementation, but we want to be able to do it on the device alone, without needing any connection to another PC.

As of Android 5.0+, you can use the new functionality in the SDK called media projections to do screen capture without root privileges or a USB connection. There is sample code by Google available here.

Related

How to perform mobile app packet analysis?

I've written a an app and I'm having issues finding a solution to tcpdump data from the Android device running said app.
Android:
The only solution I've found is to root your phone (https://code.tutsplus.com/tutorials/analyzing-android-network-traffic--mobile-10663). Although this is not always possible. There needs to be a way to perform analysis via adb or Android Studio. Unfortunately I have not found a way to do that.
Additionally I've tried PCAPdroid which is an app. This does not seem to be giving me all of the packets I expect to see.
iOS:
Apple provides a feasible solution to create a virtual interface with a connected device where you can then tcpdump all traffic leaving said device.
https://developer.apple.com/documentation/network/recording_a_packet_trace?language=objc

Android as an UVC Camera

I'm stuck at home with a rather bad webcam. I was considering upgrading, but then it struck me: phones these days have really good cameras embedded in them. So why not use it as a webcam?
However, as I was researching this further I was really disappointed with the available apps for this. As far as I was able to find, we have Android apps that work roughly as follows:
Present phone camera as a network attached camera. Then you can use local software to use that feed as a webcam. See e.g., IP Webcam. This may be sufficient, but it's a complicated setup, and network latency makes this far from ideal.
The Android app sends the camera feed to an custom host application that in turn creates a virtual web camera. See e.g., DroidCam. This mostly solves the latency problem, but it is still rather complicated, and requiring us to install a specific third party application is troublesome in regard to user privacy. Especially since the applications are closed source.
So, I took the engineering approach and tried to see if it was even possible to improve the situation. As far as I was able to find, Android supports being used as a custom USB accessory. And looking over the USB video class documentation, it strikes me that it should be possible to create an Android app that presents the phone as a generic UVC webcam, such that we do not have to resort to tricks such as the ones above.
Ideally, I would have liked Android to add another USB device option ("Use USB connection as webcam") in addition to debug mode, file-transfer, etc. This seems quite unlikely to happen in the short term however.
So, my question is this: Does an application that does the above already exist? My searching thus far haven't yielded any results, but I might be missing something as googling for this turned out a bit harder than I expected.
Alternatively, am I wrong in my assumption above, such that there is some fundamental issue why an Android application cannot be made to work in that way?
There does not seem to be any complete app yet as of 2020-10, but the parts are mostly there:
https://github.com/tejado/android-usb-gadget has code to switch the Android device into gadget mode (but no UVC yet)
https://git.ideasonboard.org/uvc-gadget.git feeds v4l2 into the uvc gadget output
Sources:
http://www.davidhunt.ie/raspberry-pi-zero-with-pi-camera-as-usb-webcam/
https://www.raspberrypi.org/forums/viewtopic.php?t=148361
https://www.reddit.com/r/androiddev/comments/iabc2o/can_i_use_my_android_as_wired_camera_ie_as_a/g1nrijl/
It appears Google has started to take notice on this issue and are currently working on a "DeviceAsWebcam" service, which is exactly the solution to this problem, as seen in the Android review below:
https://android-review.googlesource.com/c/platform/system/sepolicy/+/2410788
Naturally though, this is a Android 14 feature, so it will like take a while before this is usable on a lot of devices. Hopefully, someone is able to backport this feature to older versions of Android.
If android / the version of Android that comes on your target phone provides / permits use of the USB gadget driver, then libguvc,
https://developer.ridgerun.com/wiki/index.php?title=USB_Video_Class_Gadget_Library_-_libguvc
can be used to "make an application appear as a USB webcam".
Potentially relevant to get you started would be https://stackoverflow.com/search?q=Android+USB+gadget (other SO references to the use of the USB gadget driver on Android).

Is it possible to know whether an android phone has OTG support without rooting?

Is it possible to know whether an android phone has OTG support without rooting? If so how? I am asked to check some information before developing an app for android.
Yes, you can download a USB On-The-Go checking application from Google Play.
This one below for instance doesn't require root, although it does require that you follow the exact plugging and unplugging steps.
Before I give you the link thought, I must warn you that this app asks for way too many permissions and can display very intrusive ads that can draw themselves on top of other apps. If you install this, definitely uninstall it and get rid of it as soon as you're done with it.
Another thing you could do is just google for the exact model name. That kind of information is usually included in the specs, in the pdf specs, in wikipedia, or in some tear-down blog. If the specs won't even tell you the usb version number at the very least, then you'll know to keep on looking.

Is it possible to screen record on Google Glass without a Computer?

I want to video record the screen of an application I made on Google Glass.
I've seen this link here: http://googleglassfans.com/archives/3814/record-google-glass-screen-using-adb/
that uses the screenrecord function along with command prompt to get a video but I wanted to see if it was possible to do that without hooking it up to a computer. No audio is necessary just the video. I'm new to programming with google glass so I'm not sure if this is possible.
Any help as to whether it is and if so how to learn how to do this would be greatly appreciated!
Thanks!
Running screenrecord requires a connected computer that has the adb command available. It is not possible to run this particular command without a connected computer.
The rest of my answer is not specific but will hopefully be able to guide you in the right direction.
There are a lot of open source projects on GitHub or elsewhere catering to capturing screen activity on Android. You may want to look at using those. However, they may have permission requirements (in the Android manifest sense) that are not allowed on Google Glass (see here for allowed permissions). Because of this, this solution may require you to root your Glass device and thus void your warranty.
If you are fine with voiding your warranty, this is one option for you.

Analog video capture to Android phone

I am looking for a way of displaying an analog video stream on an android phone. On a pc/mac/etc you can achieve this using a cheap usb analog-digital converter such as a grabby: http://www.terratec.net/en/products/Grabby_82248.html, and then view on VLC, for example.
Would such a thing work (in theory) on android if the proper drivers were available? (ie. are there any hardware issues which make this impossible?)
Does anyone know if such a device with android drivers is available?
Ultimately I want to make an app which interfaces with the grabby (or similar device) and allows the user to view video on the android and capture and send short clips.
First of all the Android device needs to support USB Host. This limits your userbase significantly.
Then there is the problem with power. Some USB Host devices will be incompatible simply because an Android phone will not be able to push enough power through to port to get it running properly.
I'm not sure about the drivers, but I'm 99% sure it won't work "out of the box".
You should certainly take a look at THIS project. It is pretty similar to what you are trying to do. Maybe you should consider getting in touch with that person.
EDIT:
Based on what it took to get that DVB-T dongle running in the project i mentioned above the chances of creating an app that everyone will be able to simply download and use are EXTREMELY slim. Getting that dongle running required using a modified kernel and special scripts. Of course I could be wrong. You can continue the research yourself or wait for someone with more experience than me to reply.

Categories

Resources