<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>David's Computer Stuff Journal: Remote Android Application Shell with Hecl</title>
    <link>http://journal.dedasys.com/articles/2008/02/06/remote-android-application-shell-with-hecl</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Remote Android Application Shell with Hecl</title>
      <description>&lt;p&gt;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:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;svn co http://hecl.svn.sourceforge.net/svnroot/hecl/trunk/hecl hecl
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then install the Hecl.apk:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;adb install android/bin/Hecl.apk
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Select the Hecl Server demo, at the bottom of the list:&lt;/p&gt;

&lt;p&gt;&lt;img src="/files/heclserver.png" alt="Hecl Server"/&gt;&lt;/p&gt;

&lt;p&gt;You also need to make sure that port forwarding is set up:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;adb forward tcp:7405 tcp:7405
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;At this point, you can telnet to port 7405 on localhost, and run Hecl commands:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; puts hi
hi
&amp;gt; androidlog "hello world"

&amp;gt; java android.os.SystemProperties sysprops
sysprops
&amp;gt; java android.telephony.TelephonyProperties telprops
telprops
&amp;gt;     set number [sysprops get [telprops -field PROPERTY_LINE1_NUMBER]]
15555218135
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; maineval {set layout [linearlayout -new [activity]}
1
&amp;gt;  maineval {set layout  [linearlayout -new [activity]]}
1
&amp;gt; maineval {$layout setorientation VERTICAL}
1
&amp;gt; maineval {set layoutparams [linearlayoutparams -new {FILL_PARENT WRAP_CONTENT}]}
1
&amp;gt; maineval {$layout addview [textview -new [activity] -text "Hi!" -layoutparams $layoutparams]}
1
&amp;gt; maineval {[activity] setcontentview $layout}
1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Gets us this very, very simple screen:&lt;/p&gt;

&lt;p&gt;&lt;img src="/files/heclhi.png" alt="Hecl Hi"/&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;</description>
      <pubDate>Wed, 06 Feb 2008 14:41:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:0706da47-523c-4b1e-927b-19e7847571ef</guid>
      <author>David N. Welton</author>
      <link>http://journal.dedasys.com/articles/2008/02/06/remote-android-application-shell-with-hecl</link>
      <category>hecl</category>
      <category>android</category>
      <enclosure type="image/png" url="http://journal.dedasys.com/files/heclhi1.png" length="4506"/>
      <trackback:ping>http://journal.dedasys.com/articles/trackback/1847</trackback:ping>
    </item>
    <item>
      <title>"Remote Android Application Shell with Hecl" by kriss</title>
      <description>&lt;p&gt;Hi David&lt;/p&gt;

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

&lt;p&gt;Greetings from Berlin&lt;/p&gt;</description>
      <pubDate>Thu, 07 Feb 2008 02:25:52 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:31450e6c-54e6-411b-b2ec-cd5c67ad3b61</guid>
      <link>http://journal.dedasys.com/articles/2008/02/06/remote-android-application-shell-with-hecl#comment-1138</link>
    </item>
  </channel>
</rss>
