Saturday, October 11, 2014

Wear Shell - Exploring Android Wear

Having a LG G Watch for a while I thought that it would be interesting to run code directly on the watch without having to create an APK. Sometimes I just wanted to run some code snippets on the watch and view the result instantly.
Creating a complete project, compiling and deploying the APK on the Wear device is quite time consuming and somewhat annoying.

I tried to write an app to execute BeanShell code directly on the Wear device. This is all experimental and the possibilities are quite limited compared to an regular app, but for an execution of some code snippets that seemed to be a good idea.

The result is Wear Shell, an app that consists of a mobile and a Wear part. The mobile part moves the code for execution to the smart watch, collects the result and passes it to the calling application.

So I hope owners of an Android Wear smart watch have fun with the app and find it as interesting as I did to explore things from the perspective of a watch.

WearShell App


Web Interface

To make tests easier, the app contains a small (PAW based) web server with a web interface. Inside this interface you can type the code inside a text area, press the Execute button and wait for the result to be displayed.

Web Interface with Wear System Information


The web interface also contains a page containing code snippets for you to try out. These snippets include code for database, Bluetooth and system info access and should provide a good starting point for further explorations.

Developers

Developers have the possibility to use the functionality of the app within their own applications by using a Result Intent.

Action: de.fun2code.android.wear.shell.EXEC
Request String Extra: bsh
Response String Extra: result

Just pass the BeanShell code to execute to the bsh parameter and read the result from the resulting Intent.

Links 

Download: WearShell APK
Discussion: XDA Developers

8 comments:

  1. Cool project, do you have source code available on github, or somewhere else?

    ReplyDelete
  2. Do you need any device rooted? huawei watch + samsung s4
    It doesn't install the watch component. I tried separately WearShell_0.6.0 and WearShell_0.6.0_wear - one uninstall the other one.

    ReplyDelete
    Replies
    1. Root is not needed. Did you try to install and WearShell_0.6.0_wear dircetly on the watch? You can also post your question here: http://goo.gl/pCTTt5

      Delete
  3. I'm not very used to execute applications from adb console, but is it possible to launch a Beanshell from an ADB console in the mobile device in a way like this?

    am start -a de.fun2code.android.wear.shell.EXEC --es "key" "bsh: command(param)"

    Hope you can help me, I just wanted to collect the result of the stt Beanshell in Tasker and I can't figure out how to assign the stt result to a Tasker variable from the intent menu, so I thought making a script would be a better idea.

    I executed succesfully Beanshells like tts, vibrate, etc... but I find useful to use the voice recognition in a watch and having a response right to Tasker app.

    Hope you can help me.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Finally I discovered by myself:

    am broadcast -a de.fun2code.android.wear.shell.EXEC --es bsh "stt(\"Say something\")"


    I also found how to use tts.bsh in other languages:

    tts("Dime algo bonito",new Locale("es", "ES"))​
    tts("Dime algo bonito",Locale.getDefault())​

    By the way I have modified stt to copy the text back to the phone. I will publish it on XDA because here I can't post mediafire links.

    I would like how to:

    - add a Tasker variable
    - load it with the recognised text

    from a bean shell to avoid using files.

    Keep doing this good work, hope we can make new things soon.

    Thank you!

    ReplyDelete
  6. This is highly informatics, crisp and clear. I think that everything has been described in systematic manner so that reader could get maximum information and learn many things.
    Android Wear

    ReplyDelete

Note: Only a member of this blog may post a comment.