Sunday, September 13, 2009

Android Bluetooth Introduction

Check out this SlideShare Presentation :)

Tuesday, September 8, 2009

Android ROM images from community

When I got the Android Dev phone, I download the official Android images from HTC site. Sometimes I build some packages myself, then upload them to ADP. Yesterday, I started to try Android images from community. I am so surprised that I can see so many different and versatile images. Their images are even based on the newest Android code. jserv gave me a link that someone is using my work "android obex" in their Android images about two weeks ago, but I didn't figure it out. I was trying to find out how HTC HERO users can get root access and how I can flash Android images from community. I tried to flash about 5 different images and played all day long. Too interesting to quit...:D

Here is a very detailed table chart and it shows kinds of Android images. I can pick one based on its status, like kernel version, WiFi or BT status, what input method, or application status....etc.

The first image I tried is from CyanogenMod. I downloaded this image file and push it to /sdcard in ADP. We can enter into 'Recovery' mode to update this image.

I also found there is 'cyanogen-updater' application in Android Market. I can install it in ADP and then I can update with their newest image version. It can download ROM image and update it in Recovery mode automatically. After rebooting it, I found it has bluez utils and my obex stuff inside. It means users needn't download hidd, hcitool, or those binary files, and they needn't build those stuff themselves either. I think that is better for normal and common users. Some of my friends, they don't even know what Android phone is, but they know how to use Facebook, how to use Internet. If they buy an Android phone someday, they can use this application to flash image without pain or tears. How cool it is!

Furthermore, I found Chinese Input mothod in another Android image. It's my first time to try this HTC Chinese input method. I used handwriting method to write words and it's pretty good to use. It can recognize all my writings. I thought I would need a cell phone with qwerty keyboard, but now I think that I can use touch input as well. XD

Sunday, September 6, 2009

Android emulator + external GSM modem

Recently, I am working on this issue 'Use GTA02 GSM Passthrough mode as external Android GSM modem' and the goal is to use Beagle board as a platform. Since we are still using cupcake in beagle board, I choose to use Android emulator with latest donut in the beginning. When we have donut image in beagle board, i will switch it on that time.

In Android emulator, it would use a qemud socket as GSM modem and it can simulate GSM network. Like camp to GSM base station (Android 3G :P), receive incoming call, dial out a phone call, has a simulated SIM Card, send SMS messages....etc. In my previous article about tracing RIL, I tried to run two emulators and made a phone call to each other. It's pretty fun, coz it can simulate real GSM network.

But it's still a fake one, not real GSM network, it doesn't camp to the nearby network like your mobile does. Therefore..... I changed few lines and made Android emulator to run an external GSM modem. Here is my experiment!

rild: allow it to use other GSM device in qemu

diff --git a/rild/rild.c b/rild/rild.c
index 14a6ea9..bd91314 100644
--- a/rild/rild.c
+++ b/rild/rild.c
@@ -161,7 +161,7 @@ int main(int argc, char **argv)

- if (strstr(buffer, "android.qemud=") != NULL)
+ if (strstr(buffer, "android.qemud=") == NULL)
/* the qemud daemon is launched after rild, so
* give it some time to create its GSM socket

Modify rild lib argument and change device name

diff --git a/target/board/generic/system.prop b/target/board/generic/system.prop
index f2424c9..1b84596 100644
--- a/target/board/generic/system.prop
+++ b/target/board/generic/system.prop
@@ -3,4 +3,4 @@

-rild.libargs=-d /dev/ttyS0
+rild.libargs=-d /dev/ttyS2

GTA02 NEO phone

erin@daydreamer:~$ sudo ifconfig usb0
erin@daydreamer:~$ ssh root@
root@om-gta02:~# echo 1 > /sys/devices/platform/neo1973-pm-gsm.0/power_on
root@om-gta02:~# echo ate1 | ./tickminicom
root@om-gta02:~# nc -l -p 4270 < /dev/ttySAC0 > /dev/ttySAC0 &

PS. tickminicom is here

Running pty in host machine

# ./pty 4270

PS.1 where is pty? how do I know it? it's from Thomas! I was co-working with him about gsmd and dialer UI in 2007.

Running emulator with serial port option

erin@daydreamer:~/android/mydroid_emu/out$ ./host/linux-x86/bin/emulator -system ./target/product/generic/system.img -sysdir ./target/product/generic/system -data ./target/product/generic/userdata.img -kernel ../prebuilt/android-arm/kernel/kernel-qemu -ramdisk ./target/product/generic/ramdisk.img -qemu -serial /dev/pts/2

Cannot receive any incoming call
I was stuck on this case and it would send hangup command to any incoming calls without any notification UI. I found this issue is a known one and we can set 'Settings.Secure.DEVICE_PROVISIONED' to 1. Then no problem now.

What it can do now?
* Camp to GSM network
* Dial out a phone call
* Receive an incoming call
* Send SMS
* Receive SMS

Wednesday, September 2, 2009

Connect Bluetooth Keyboard in Android Dev Phone

I have an Apple Wireless Keyboard and how do I connect it with G1 or any Android phones? I am using Android Dev Phone for my example, so I already have its root permission. If you are using other Android phone, not ADP, you have to get root permission first!! BTW, my working machine is Ubuntu 9.04!

Download related bluetooth utilities here or build it yourself!

$ wget
$ wget
$ wget

Change mount and folder permission in Android Dev Phone

$ su
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
# chmod 777 /system/xbin

Upload related bluetooth utilities to Android Dev phone

$ adb push hidd /system/xbin
$ adb push hcitool /system/xbin
$ adb push hciconfig /system/xbin

Turn Bluetooth ON from Setting UI and click 'Scan for devices'

Press 'Apple Wireless Keyboard' and it would appear Pair request

Type '0000' or '1111' as pin code and it would appear 'Paired but not connected'

Let's type some bluez utilities commands to make it work!

# hciconfig
hci0: Type: UART
BD Address: 00:22:A5:B8:AD:65 ACL MTU: 1021:4 SCO MTU: 180:4
RX bytes:8672 acl:98 sco:0 events:285 errors:0
TX bytes:3336 acl:102 sco:0 commands:89 errors:0

# hcitool dev
hci0 00:22:A5:B8:AD:65

# hcitool scan
Scanning ...
00:1D:4F:A7:9A:49 Apple Wireless Keyboard
00:22:43:C6:5B:B9 daydreamer-0
00:18:C5:42:18:78 Erin-Nokia N73

# hidd --connect 00:1D:4F:A7:9A:49

# hcitool con
< ACL 00:1D:4F:A7:9A:49 handle 1 state 1 lm MASTER

DONE! I can connect to Bluetooth Keyboard in Android. It's more convenient when I type email, message, or chat with friends now!