Month: August 2009

Always discoverable on Android

Posted by on August 25, 2009

Something that is starting to annoy me about some of the newer smart phone operating system (I am looking at you iPhoneOS and Android) is that when you tick the box to make your phone discoverable by Bluetooth, it does not stay discoverable. Other operating systems give you an option to switch between hidden, temporally visible or always visible.

After a bit of hacking around on the my phone (a HTC Dream), I have discovered a way to make the Bluetooth stay discoverable. These instructions require adb (the Android Developer Bridge), an a (slightly) nonstandard rom. The reasoning behind requiring the non-standard rom, is that chown under android does weird things.

Remember that this is done at your own risk.

adb remount
adb pull /system/etc/bluez/hcid.conf ./hcid.conf
sed -i'' -e 's/iscan disable/iscan enable/;s/pscan enable;/&\n\n\t\#Make the device stay discoverable for ever\n\tdiscovto 0;/' hcid.conf
adb push hcid.conf /system/etc/bluez/hcid.conf
adb shell chmod 440 /system/etc/bluez/hcid.conf
adb shell busybox chown 1002.1002 /system/etc/bluez/hcid.conf
adb remount
rm -f hcid.conf

HCID_CONFIG="$(adb shell ls /data/misc/hcid/*/config | sed -e 's/\r//g')"
adb pull "$HCID_CONFIG" hcid_config
sed -i'' -e 's/^discovto.*$/discovto 0/' hcid_config
adb push hcid_config "$HCID_CONFIG"
adb shell chmod 644 "$HCID_CONFIG"
adb shell busybox chown 1002.1002 "$HCID_CONFIG"
rm -f hcid_config

After all this is done… Don’t forget to power cycle the Bluetooth system (untick, then tick the box for Bluetooth).