Remote Android Application Shell with Hecl

Posted by David N. Welton Wed, 06 Feb 2008 22:41:00 GMT

The latest component of Android Hecl that I have been working on is a simple shell server that lets you interact with Hecl remotely, in order to be able to telnet in, run commands and see what they do. In order to give it a whirl, fetch Hecl from svn:

svn co http://hecl.svn.sourceforge.net/svnroot/hecl/trunk/hecl hecl

Then install the Hecl.apk:

adb install android/bin/Hecl.apk

Select the Hecl Server demo, at the bottom of the list:

Hecl Server

You also need to make sure that port forwarding is set up:

adb forward tcp:7405 tcp:7405

At this point, you can telnet to port 7405 on localhost, and run Hecl commands:

> puts hi
hi
> androidlog "hello world"

> java android.os.SystemProperties sysprops
sysprops
> java android.telephony.TelephonyProperties telprops
telprops
>     set number [sysprops get [telprops -field PROPERTY_LINE1_NUMBER]]
15555218135

Since this simple server runs in its own thread/interpreter, you can't control the GUI from it. To do that, there is a 'maineval' function that sends code back to the main interpreter:

> maineval {set layout [linearlayout -new [activity]}
1
>  maineval {set layout  [linearlayout -new [activity]]}
1
> maineval {$layout setorientation VERTICAL}
1
> maineval {set layoutparams [linearlayoutparams -new {FILL_PARENT WRAP_CONTENT}]}
1
> maineval {$layout addview [textview -new [activity] -text "Hi!" -layoutparams $layoutparams]}
1
> maineval {[activity] setcontentview $layout}
1

Gets us this very, very simple screen:

Hecl Hi

Hecl's Java reflection support is still fairly alphaish, but you can use it to query classes about their methods and constructors, and call them most of the time; errors should be sent to me or the mailing list.

I found this little server particularly useful when fiddling around with some of the undocumented android classes, as a way to experiment in a running system.

Tags ,  | 1 comment | no trackbacks

Comments

  1. kriss said about 12 hours later:

    Hi David

    Wow, that looks nice - I'll definitely try it out. - Can you do the same thing in Symbian already?

    Greetings from Berlin

Trackbacks

Use the following link to trackback from your own site:
http://journal.dedasys.com/articles/trackback/1847

Comments are disabled