Editing from a Linux PC the phone book (contacts list) in an Android phone
July 25, 2011 17 Comments
A mobile phone stores contacts in the phone itself and/or on the SIM. Over the years, the phone book on my SIM became cluttered with duplicate entries, inconsistently-named contacts, and so on. I decided recently to tidy up the phone book, and looked for a way to do it from Linux.
Now, the last time I tidied up my phone book was back in 2003 when my SIM was in a Sony Ericsson T68i. These days I’m using the same SIM in an Android smartphone: the HTC Desire. Back then I used a shareware application called Mobile Navigator on a laptop running Windows XP. So, naturally, I thought it would be possible to do something similar from a PC running Linux.
An indirect method of editing a phone book in an Android phone is recommended in many Web forums. The advice is to synchronise the phone’s phone book with GMail on your PC, edit the contacts in GMail on the PC and then the contacts will be updated in the phone when the phone next synchronises with GMail. That is all very well, but I don’t want to import my phone contacts into GMail and thus have them stored in ‘The Cloud’, plus I don’t see why I should be forced to do that just to make it easier for me to tidy a phone book in my phone. So I set about searching for an application to do the job.
My search turned up three applications that appeared to enable a user to edit the phone book (phone and SIM):
1. Gammu (CLI) and Wammu (GUI front-end), FOSS with versions for both Linux and Windows.
2. MOBILedit!, a closed-source commercial product for Windows.
3. MyPhoneExplorer (Version 1.8.1), closed-source ‘donationware’ for Windows, recommended in various forums and that has been used with WINE in Linux. Not only does MyPhoneExplorer allow you to edit the phone book, it also provides a host of other features such as: viewing the phone’s call logs, messages, hardware status, files and applications; sending messages via the PC; etc. It’s a nifty application.
Web browsing told me that Gammu/Wammu does not yet work with the HTC Desire (see the bug report Don’t get any connection to HTC Desire via bluetooth in Wammu/Gammu). This is a pity, as Wammu and Gammu look well-designed, and Wammu has a professional feel to it.
The price for MOBILedit! is not extortionate but I wanted to find a cost-free solution if possible, and, more importantly, I could find no evidence on the Web of MOBILedit! having been used with WINE in Linux to edit the phone books in the HTC Desire.
The MyPhoneExplorer forums include a thread on using it with WINE, so MyPhoneExplorer looked like my only option (although it is a pity it is not FOSS). I installed MyPhoneExplorer with its own WINEPREFIX but, despite following the instructions in the MyPhoneExplorer forums, I was unable to get MyPhoneExplorer to connect to the HTC Desire via a USB cable in Linux. This may be because, despite what I have read on the android developers Web site (see Using Hardware Devices and OEM USB Drivers), as is the case with Windows it is necessary in Linux to install ADB USB drivers (the ADB drivers can be installed in Linux by installing the Android SDK). However, I was able to connect MyPhoneExplorer to my HTC Desire via WiFi at home (but not in a hotel, as connection depends on the router and internal network IP address space), and via Bluetooth (anywhere).
How to install MyPhoneExplorer in WINE
1. Use the Android Market to install MyPhoneExplorer Client on the phone.
2. Surf over to the MyPhoneExplorer Home Page and download
3. Open a Konsole/Terminal window and perform all the following steps in the same window.
4. Install MyPhoneExplorer on your PC under WINE:
(Make sure you select the WINEPREFIX first when using winetricks)
5. Edit your Desktop Environment’s menu to use the following command for launching MyPhoneExplorer:
(Of course replace “fitzcarraldo” with your user name.)
How to connect via Bluetooth
1. Look up the phone’s Bluetooth MAC address in the phone itself, write it down and keep it to hand. (I use the MAC address
11:22:33:AA:BB:C1 in the examples below.)
2. Enable Blutooth on your PC and phone, make them both discoverable, and pair them.
3. Launch MyPhoneExplorer Client on the phone and wait a few seconds for it to load and run.
4. Now check which channel is used by MyPhoneExplorer Client (In the example below it is Channel 17):
5. Bind a virtual serial device to the phone (You can look up the phone’s Bluetooth MAC address in the phone itself to double check):
N.B. If you have been tinkering already with binding, and the virtual device
/dev/rfcomm1 is therefore already bound, you will get an error message saying “
Can't create device: Address already in use“. You can release the virtual device by using the command:
6. Create a symbolic link for the virtual serial link:
7. Launch MyPhoneExplorer (e.g. in KDE this would be: Kickoff > Applications > Wine> Programs > MyPhoneExplorer > MyPhoneExplorer), then press F2 (or select File > Settings).
8. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘SonyEricsson phone with modeminterface’. Tick ‘Stable connection (some features are deactivated)’.
9. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘Phone with Google Android-OS’.
10. Select ‘Connection’ in the left pane and then select ‘Connect via…’ to be ‘Bluetooth’ and enter “COM2” (upper case, and without the quotes) and click on ‘OK’.
11. Press F1 (or select File > Connect) and your PC should be able to connect to the phone and synchronise with your phone’s phone book (Extras > Start Multi-sync), thus enabling you to edit the contents and re-synchronise to update the phone book in the phone.
Script to make subsequent connections via Bluetooth easier
Note that the channel used by MyPhoneExplorer Client will change the next time you want to connect, so there is no point editing
/etc/bluetooth/rfcomm.conf (the Linux configuration file in which you would normally specify the channel). Therefore, to make life a little easier, I wrote a simple Bash script to automate as much as possible the process of reconnecting via Bluetooth in future. If you want to do the same, use your favourite text editor and save the following script with the file name
#!/bin/bash echo -n "Please switch on Bluetooth via System Tray icon, make Bluetooth discoverable then press ENTER: " read RESPONSE echo -n "Please enable Bluetooth on the phone, make it discoverable then press ENTER: " read RESPONSE export WINEPREFIX="/home/fitzcarraldo/.wine-myphoneexplorer" export WINEARCH="win32" echo "Checking current rfcomm status..." sudo rfcomm -a echo "Trying to release rfcomm1 in case it is in use (no message means rfcomm1 is released and is now OK to use," echo "and the message Cannot release device: No such device also means rfcomm1 is OK to use)..." sudo rfcomm release /dev/rfcomm1 echo -n "Now please launch MyPhoneExplorer Client on the phone, wait a few seconds then press ENTER: " read RESPONSE echo "Find channel of MyPhoneExplorer Client:" sudo sdptool browse echo -n "Enter the channel number: " read RESPONSE sudo rfcomm bind 1 11:22:33:AA:BB:C1 $RESPONSE echo "Checking current rfcomm status..." sudo rfcomm -a echo "If all is OK then please launch MyPhoneExplorer from Kickoff > Applications > Wine > Programs > MyPhoneExplorer" echo "and press F1 to connect to the phone."
(Of course replace “fitzcarraldo” with your user name, and replace “
11:22:33:AA:BB:C1” with the Bluetooth MAC address of your phone.)
Then make the script executable:
The next time you want to use MyPhoneExplorer, open a Konsole/Terminal, execute the script:
and follow the instructions it displays in the Konsole/Terminal window.
How to connect via WiFi
Connecting MyPhoneExplorer to the phone via WiFi is easier than via Bluetooth. Note that WiFi connection will not work with a public WiFi network, just a home WiFi network.
1. Enable WiFi on your PC and phone.
2. Launch MyPhoneExplorer Client on the phone and wait a few seconds for it to load and run.
3. Launch MyPhoneExplorer (e.g. in KDE this would be: Kickoff > Applications > Wine> Programs > MyPhoneExplorer > MyPhoneExplorer), then press F2 (or select File > Settings).
4. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘SonyEricsson phone with modeminterface’. Tick ‘Stable connection (some features are deactivated)’.
5. Select ‘Connection’ in the left pane and then select ‘Phone type’ to be ‘Phone with Google Android-OS’.
6. Select ‘Connection’ in the left pane and then select ‘Connect via…’ to be ‘WiFi’ and click on ‘OK’.
7. Press F1 (or select File > Connect) and your PC should be able to connect to the phone and synchronise with your phone’s phone book (Extras > Start Multi-sync), thus enabling you to edit the contents and re-synchronise to update the phone book in the phone.
The MyPhoneExplorer forums are oriented to Windows as it is a Windows application, but there is a thread for Linux users: HowTo: Use MyPhoneExplorer under GNU/Linux (English Version)
The thread for Windows users of MyPhoneExplorer may also be of some use: Howto and FAQ: Use Android Phones with MyPhoneExplorer
Limitations in WINE
The only limitation I have found using MyPhoneExplorer 1.8.1 in WINE is that it crashes if I try to cut and paste when editing a phone book entry. Additionally, some people have reported that the buttons on the button bar do not work when you are connected to the phone; they usually do work for me (apparently it depends on whether you have installed msxml3) but sometimes don’t. In any case, if they don’t then you can use the pull-down menus from the menu bar instead.
Other than that, MyPhoneExplorer works well in WINE and enables me to edit the phone book in my Android phone without involving Big Brother! It’s a nice application.
Firewall rules if using WiFi
If you’re using MyPhoneExplorer to connect with the phone via WiFi instead of Bluetooth, and your PC has a firewall enabled, according to a post on 7 June 2011 in the MyPhoneExplorer forums you have to configure the firewall with the following rules:
TCP port 80 (outgoing) – Check for update
TCP port 5210 (outgoing) – Communication with client
UDP port 5211 (outgoing) – Communication with client
UDP port 5212 (inbound) – Broadcast from the client
Below I list the rules I implemented in Uncomplicated Firewall:
Alternatively you could just disable the firewall on your PC while you’re using MyPhoneExplorer with your phone, which I do anyway when I’m at home as my home network is protected by the firewall in my router.
EDIT (October 25, 2012): Now there is another way of editing an Android phone’s contacts list from Linux: AirDroid. And you don’t need to mess around with WINE to use it. For details see my post AirDroid, a handy Android app for managing your phone from Linux.