Category Archives: Android Platform

This Category hold content about all platform specific development on the choosen hardware.

Creating a remote Scroll Wheel for your Linux Machine using Android, Bluetooth and uinput

Scrolling long documents can be tiring for your index finger on a mouse wheel or on a touch pad. What if you could use your phones touch screen to scroll a document on your computer? While maybe not the most ergonomically solution it may well be a good example of how to work with bluetooth, uinput and Android.

Setup
Android Phone ( >= 2.1)
Ubuntu Laptop with Bluetooth
Two great Tutorials:
Bluez: http://people.csail.mit.edu/albert/bluez-intro/x604.html
uinput: http://thiemonge.org/getting-started-with-uinput

Concept
The application consists of two parts:

  • A client side on the phone that serves as touch pad to scroll.
  • A server part on the computer that receives commands from the phone and emulates scroll movement for uinput.

The Client is a simple Android Activity spawning a Bluetooth Thread. Touch events then result in a Bluetooth packet that tell the server if the user moved up or down. The source code is very straight forward; only Thread synchronization is a bit tricky as well as the way how the application is stopped (locks etc.).

The Server application connects the world of Bluetooth (RFCOMM/SDP) with the uinput event input system. Basically the server registers an SDP entry and then listens on an RFCOMM channel for incoming connections. As soon as a connection is established a new input device is created and scroll events are sent. Note that you probably need to be root (or use sudo) on the Linux machine to feed uinput new events.

Instructions

  • Pair your Android phone with the Linux device
  • Start the server on your Linux device: $ sudo ./btserver (make sure BT is turned on, else there could be a segfault -> working on that)
  • Install and start the app on the phone. In the menus select your Linux device.

Building Dependencies
To build the dev-libbluetooth package was necessary on our Ubuntu machine.

The code is available under GPL. Have fun playing around with it :)
Note: It’s very straight forward to create a remote control for your Linux machine with the sources. Key presses can be emulated very easily with uinput.

Source Code
Android Sources
Android APK
Server code for Linux
Our App on the Android Market

Leave a comment if you like what we did or have some improvements :)

How to programmatically remove/hide the system bar in Honeycomb (requires root)

Without the system bar it is almost impossible to control your Honeycomb tablet. Since no hardware control buttons are enforced for the tablet the system bar is the only way to control your slate.

However, if your application incorporates a way of removing the bar and on leaving restarting the bar there is no reason why not to support such a feature.

The easy part: Restarting the bar

Restarting the bar is pretty simple, drop to a shell and start the service using the “am” command:
# am startservice -n com.android.systemui/.SystemUIService

The difficult part is to shut it permanently down. One way is to navigate to the application settings and shut it down with the “force close” button. However, attempting to kill the process with

# killall com.android.systemui

will remove the bar for a few seconds. Sadly, it will return eventually since in the applications manifest file the “persistent” parameter enforces the system to restart the service unless it is shut down properly by the “system” user itself.

The following magic line will shut down the bar permanently if executed as root:

# service call activity 79 s16 com.android.systemui

What it does is sending the Activitymanager a shutdown signal for the systemui service.
This method was tested on an Iconia A500 with Android 3.01; although it should work with other devices as well (since the source code that we use is common).

Putting it together

To remove the system bar from your application create and execute a process:

Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"});
proc.waitFor();

To restore the system bar use the following code snippet:

Process proc = Runtime.getRuntime().exec(new String[]{"am","startservice","-n","com.android.systemui/.SystemUIService"});
proc.waitFor();

OsciPrime an Open Source Android Oscilloscope

Today we are releasing our first draft of the new Android Oscilloscope called OsciPrime.
We added a bunch of new features such as:

  • Trigger Offset
  • Signal Offset
  • Cursors for measurement
  • Performance Improvements
  • Running on Beagleboard with Rowboat Gingerbread

The Application is going to run on your phone as well. Although at the moment it requires you be able to record mono at 44100 [Hz] to use Audio.
You might also have to adjust measurement units in the source code.

We packed also libusb if you want to deploy the app on the Beagleboard directly into the APK.

Enjoy :)

Download the Source Code

(hint: You can open the menu using the menu button in the application, press once more to close again)

Turn your Linux computer into a huge Android USB Accessory

Google is promoting it’s Arduino-Like hardware to test and prototype with USB accessories. Meanwhile you are either waiting for your USB-Host board or deciding if you even want to get one at all. At that point we would like to share a way of how to write your first “Hello World” application using your Linux Desktop/Laptop (we use Ubuntu …).

Your Desktop/Laptop probably has a USB host controller. This opens you all doors to write accessory applications using “libusb”. We have written some C code as a template that let’s you act as Accessory on Linux side.

simplectrl.c

You can use it for instance to benchmark the data throughput and do all other kinds of crazy stuff. (Did I just hear “use your Nexus S as RFID reader”?)

Java Code to follow …

update:

to compile on Ubuntu install the following packages:
apt-get source libusb
apt-get install libusb-dev
apt-get install libusb-1.0-0-dev

And compile using the line
gcc simplectrl.c -I/usr/include/ -o simplectrl -lusb-1.0 -I/usr/include/ -I/usr/include/libusb-1.0

update
The Java example can be found here.
Please note that the example is very rudimentary as well as threading just temporarily. During the next weeks we are going to require a better and more robust example which will be followed by some post with source code.

Android Oscilloscope on the Beagleboard xM using Rowboat

We are pleased to announce that we are sitting together once more to provide a more stable and brushed up version of the USB Android Oscilloscope under the name OsciPrime. We are focusing on UI improvements and enable the Application to run on mobile phones (maybe even on the Android Market).

We already have a BB xM running the latest rowboat gingerbread build and are already able to communicate over USB.

Hint to make Libusb Working:
In Gingerbread you will need to change ueventd.rc to adjust permissions for your application:
/dev/bus/usb/* 0660
to
/dev/bus/usb/* 0666

Sources will be online early next week.
Thanks for all your support over the past year :)

OsciPrime Running on the Beagleboard
Beagleboard xM running rowboat android gingerbread 2.3