-3

I'm using Python to access Android phone via USB. Library I'm using is PyUSB. Is there any internal structure I can find that can lead me to access the screen buffer? Or is Python too high level that I need to switch to C/C++? If so, is there a way to access the screen buffer on the Android? Please provide a detailed instruction.

1 Answers1

-1

a VNC server accesses the frame buffer, in droidVNCserver that is open source this is done in native C ( JNI - Java Native Interface ) and i think it is only possible in low level C. the source code is in https://github.com/oNaiPs/droidVncServer/tree/master/ , see https://github.com/oNaiPs/droidVncServer/tree/master/jni/vnc and see https://github.com/oNaiPs/droidVncServer/tree/master/jni/vnc/screenMethods for the jni code

How Droid VNC works?

so with this you can access the frame buffer on the android device however then you have to grab the image over USB using python what is not trivial. you can i.e. mount the android as mass storage or PTP ( picture transfer protocol ) or MTP ( media transfer protocol ) device or use adb however this is not easy

if you want an easy solution install droidVNCserver on your android and write a python program using libraries like https://pypi.python.org/pypi/vncdotool to access it...

ralf htp
  • 9,149
  • 4
  • 22
  • 34
  • does Android need to run a background service? – WhoAmIWhereAmIWhatIAmDoing Mar 16 '18 at 20:04
  • was looking for a way that no background service is needed. If C is the only way, so be it. – WhoAmIWhereAmIWhatIAmDoing Mar 16 '18 at 20:05
  • and programming wise. How should i do it? That's more I concerned with – WhoAmIWhereAmIWhatIAmDoing Mar 16 '18 at 20:15
  • you have to run code on the android and so you either need an app or program or a ( background ) service that are registered by android os. the phone has its own processor and this processor is owned and protected by android operating system, so any manipulation on this processor like accessing the memory of the frame buffer is under the authority of android. maybe it is possible to circumvent the security of android and then read the frame buffer but this is equal to hacking the phone ( if it is possible anyway ... ) – ralf htp Mar 17 '18 at 09:27
  • there was this program called seven-square. didnt actually dig into the program, but it didnt require an app or service on the Android – WhoAmIWhereAmIWhatIAmDoing Mar 19 '18 at 01:45
  • seven-square uses adb. In the source code the file `adbfb.cpp` accesses the framebuffer via adb. adb runs a process or service however mutually so it runs a service you do not explicitly start ... – ralf htp Mar 19 '18 at 12:07