Saturday, August 6, 2011

Android Screen Control Without Root

Reactions: 
The ability to control the screen of my Android phone has been a major pain since I moved from Windows Mobile to Android quite some time ago.

The only solutions required root permissions. However there are scenarios where that is not an option such as in a corporate environment / providing remote support for a device that is not your own.

Android 2.1 onwards ( as far as I know) supports a API called MonkeyRunner that is to be used for application testing. Using this along with java sources provided by "The Android Open Source Project" I have put together a small application that will capture the screen and allow passing of click and key press events to the device.

It is highly limited to the extent that it allows only for touch events and keystrokes. It currently does not support drag events and typing of special characters but something is better than nothing :)


Download the zip file from here

http://www.mediafire.com/file/a8870ynh151vm9d/ScreenControl.zip

In order to run the files, you need to ensure that the device is connected via USB cable only and debugging has been enabled on the device.

Once this is done, Fire up the screen.bat and it should load up the window. The screen.bat is a single line command calling java.exe along with all the required class and jar files required to make this work.

I have also included adb.exe which is required, you could replace with your own, however mine will probably be more stable.



Again, Consider this only if your device is not rooted. If you have rooted your device I would recommend you use the either of the following better softwares

Android Screencast
http://code.google.com/p/androidscreencast/

This works with the USB connection

Droid VNC Server by José Luis Pereira
http://www.onaips.com/wordpress/?page_id=60

This works with Wifi



I hope this has been helpful for some of you all. Am sure there are more brilliant people out there who can modify the sources to add drag functionality as well. Do let me know !

Cheers,
Vikram Sridharan.

13 comments:

  1. I would sure love this to work!!! Exactly what I am looking for. Downloaded zip, usb connected, and 'storage in use', ran screen.bat, but the command window pops up and hangs. Nothing else. In reading some of the files, it mentions not having any other USB devices connected? I ahve sevearl (keyboard, drives, etc) Do I need to disconnect them all?

    ReplyDelete
  2. Other USB devices can be connected, it should not be an issue. Just make sure storage is not in use and the USB Debugging is checked. This option is in Settings -> Applications -> Development.

    Hope you have java available on your computer.

    ReplyDelete
  3. This is great work! Will you be adding the drag events or provide some way to scroll using the UI? If that feature is added it could definitely be used to remotely support Android devices.

    ReplyDelete
  4. Looks like drag is supported by the Money API. Just need to map it to the UI. Creating scroll up/down right/left buttons on the UI may be a good way to implement it at first and then connect the event to what the user is doing with the mouse in a later release.

    Example of someone using Monkey for a drag event.
    http://stackoverflow.com/questions/4396059/how-to-simulate-android-touch-event

    ReplyDelete
  5. @Anonymous

    Thanks ! Drag is support by Monkryrunner, however my knowledge is programming is quite limited, am trying to get some help on this which is why the zip has all the sources. Am open to anyone to help on this. If I do manage, will definitely update the files here.

    ReplyDelete
  6. Well you have done well for someone with limited programming knowledge!

    I would help if I could. I'm a C++ and .Net guy so I would have to come up a learning curve with the tools and environment before I could even contribute.

    ReplyDelete
  7. Great job! I had the first post about it not working... I had java and the SDK, but was missing some python stuff on my computer. It is now up and running. This shows a lot of promise. My three comments: (1) it seems laggy, especially when typing. I don't mind the slow screen refresh, but typing is very stop and go. (2) when typing, the space bar takes you completely back to the home screen. I read that there are problem handling the space bar in a string, but that there are work arounds. (3) my droid is in a desktop dock on the computer, so it is in landscape format. The PC emulator shows it in landscape, but rotated to portrait, so everything is sideways. I suppose I could figure out how to have the droid stay in portrait when docked... but until the spacebar is fixed, its not gonna work for me. Wish I could help you with the coding on it!!! I'll stay tuned.

    ReplyDelete
  8. Any idea when you'll have an update that allows for scrolling and fixes the space bar issues? I can hardly wait!

    ReplyDelete
  9. Hi There,

    I am getting the following Exception. Need Help please.

    Exception in thread "main" java.lang.NoClassDefFoundError: com/android/monkeyrun
    ner/controller/MonkeyController
    Caused by: java.lang.ClassNotFoundException: com.android.monkeyrunner.controller
    .MonkeyController
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: com.android.monkeyrunner.controller.MonkeyControl
    ler. Program will exit.

    ReplyDelete
  10. Hi Vikram,
    I am having trouble "firing up Screen.bat"
    Double clicking opens up gedit.
    If I use my terminal I get the following output:
    john@john-775Dual-880Pro:~/ScreenControl/files$ Screen.bat
    Screen.bat: command not found
    john@john-775Dual-880Pro:~/ScreenControl/files$ cd Screen.bat
    bash: cd: Screen.bat: Not a directory
    john@john-775Dual-880Pro:~/ScreenControl/files$ ./Screen.bat
    bash: ./Screen.bat: Permission denied
    john@john-775Dual-880Pro:~/ScreenControl/files$ sudo ./Screen.bat
    [sudo] password for john:
    sudo: ./Screen.bat: command not found
    john@john-775Dual-880Pro:~/ScreenControl/files$
    What am I doing wrong?
    John

    ReplyDelete
  11. @john

    You are running the files in a linux / unix operating system. The program is meant for windows.

    However considering it is a java based, am sure it should be possible to run on a unix platform but unfortunately am not sure of the right syntax.

    ReplyDelete
  12. is there actual any way round the hanging after launching the screen.bat file?

    ReplyDelete
  13. It also hangs for me (Win7 Pro, HTC Desire S). Someone replied earlier about "...missing some python stuff on my computer.." - how do I find out what might be missing?

    ReplyDelete