What All’s Possible with the Android Dual-SIM Smartphone — MediaTek MT6516

Droid time...

A dual-SIM smartphone manufactured in China runs Android 2.2.1 Froyo. Geeks always find noteworthy products based on Linux!

Today, people are rarely surprised to see a dual-SIM phone. Phone manufacturers have been thinking about this feature for a long time — almost since the early 2000s. The pioneer was a Finnish company, Benefon, which came out with the Benefon Twin phone. The market didn’t take to it, since mobiles were comparatively rare back then. Also, subscriptions from multiple GSM providers were regarded as a luxury.

However, the start of the price wars brought on by the increase in the number of operators in a particular market, led to a situation where customers enjoyed tariff plans with low rates for calls made to subscribers of the same cellular operator. A “universal” service plan, with reasonable prices to all destinations, hadn’t even been introduced in mid-2005.

Naturally, people simultaneously using multiple GSM operators began to carry two or more cellphones. This consumer behaviour had its effect; Philips, LG and Samsung gradually began to market dual-SIM devices. These were ordinary phones, not smartphones, lacking any bells and whistles in terms of the OS and mobile content support (not even a fully functional W3C browser, but Opera Mini or even a simple WAP browser).

Soon, the Chinese market became the most interesting, in terms of the rapid saturation in mobile connections. Due to reasons like the low average national industry wages (high profits came only from exporting, and from the coastal areas of China), the demand was for low-cost phones.

Notably, most low-cost phones were from one company — MediaTek, head-quartered in Taiwan. MediaTek manufactures a GSM integrated solution — a System-on-Chip (SoC) that is the main component used by many phone manufacturers in China. This SoC includes Bluetooth, sometimes a Wi-Fi chipset, and almost always has support for several SIM cards (usually, two). CPU performance is not too great, so it runs a simple OS that’s designed by Mentor Graphics.

It’s hard to be specific about Chinese mobile operators and their 2G/3G data and voice tariff plans, but judging by the number of dual-SIM phones available in local stores, it seems that price wars are in full swing. In addition, Chinese factories can produce their own units in almost any quantity.

You may ask, “Where is that promised smartphone? And who manufactures it?” It turns out that it’s MediaTek that has won almost the entire mobile OEM market in China. After several profitable years, it wisely invested profits in R&D, and created a promising SoC named MT6516, with sufficient capability to run Windows Mobile 6.5 — and later, Google’s Android. And the zero license charges for Android raised the question, “Why use Windows Mobile with the MT6516?” So from 2009 onwards, all smartphones based on the MT6516 were only sold with Android!

Well, let’s now proceed from the lyrical side of the story to the hardware level, and see what this device’s capabilities are.

Android is the same as Linux… but slimmer

After a preliminary examination, the problem was how to get under the hood and get access to internal resources? The beautiful Android UI is cool, but the underlying characteristics of this smartphone are interesting, because only by knowing about them, can you estimate the programming resources available for your future application — how fast it will perform, how much RAM it can get, and so on.

Luckily, with Android-based devices, it’s easy to get a console shell (compared to the same procedure for, say, an iPhone). Just install the Android SDK on your PC, and use adb (the Android debugger) to connect to a shell with just an ordinary user’s privileges (which is better than no access at all). Get the SDK archive, unpack it, run the android application, and choose your Android release:

$ tar xjvf android-sdk_r11-linux_x86.tgz
$ cd android-sdk-linux_x86
$ ./tools/android

Of course, you need a JRE pre-installed on your PC, since almost all the SDK tools are written in Java.

After launching the android application, correctly set the proxy field in Settings, if you connect to the Internet via a proxy. Otherwise, leave it blank. Next, in the Available Packages tab, click the Refresh button. Select the same Android release used on your phone. In my case, I needed to check SDK Platform Android 2.2, API 8, revision 2, with Android SDK Tools, revision 11, as well as Android SDK Platform-tools, revision 4. After that, click Install Selected and wait while the Android SDK environment is prepared. You can now get access to the smartphone’s internals.

After connecting the phone with the USB cable, please also check that you are able to run the tools/ddms SDK application (Dalvik Debug Monitor System), and/or get a screenshot (Device –> Screen Capture). You may see errors like those listed below:

08:33:56 E/DDMS: insufficient permissions for device
com.android.ddmlib.AdbCommandRejectedException: insufficient permissions for device
at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.java:736)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:373)
at com.android.ddmlib.Device.executeShellCommand(Device.java:276)
at com.android.ddmuilib.SysinfoPanel.loadFromDevice(SysinfoPanel.java:159)
at com.android.ddmuilib.SysinfoPanel.deviceSelected(SysinfoPanel.java:126)
at com.android.ddmuilib.SelectionDependentPanel.deviceSelected(SelectionDependentPanel.java:52)
at com.android.ddms.UIThread.selectionChanged(UIThread.java:1684)
at com.android.ddmuilib.DevicePanel.notifyListeners(DevicePanel.java:752)
at com.android.ddmuilib.DevicePanel.notifyListeners(DevicePanel.java:740)
at com.android.ddmuilib.DevicePanel.access$1100(DevicePanel.java:56)
at com.android.ddmuilib.DevicePanel$1.widgetSelected(DevicePanel.java:357)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at com.android.ddms.UIThread.runUI(UIThread.java:492)
at com.android.ddms.Main.main(Main.java:103)

This means that the udev subsystem on your PC is mis-configured. To fix it, create a file /etc/udev/rules.d/53-android.rules with the following contents:

SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666",

Here, replace idVendor with the ID of your phone manufacturer, which can usually be found in the manufacturers list [link]. As the root, restart the udev subsystem with /etc/init.d/boot.udev, and then disconnect and replug the USB cord.

[1001646.344032] hub 2-0:1.0: unable to enumerate USB device on port 1
[1001647.084044] usb 2-1: new high speed USB device using ehci_hcd and address 13
[1001647.216857] usb 2-1: New USB device found, idVendor=0bb4, idProduct=0c03
[1001647.216861] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1001647.216864] usb 2-1: Product: MT65xx Android Phone
[1001647.216866] usb 2-1: Manufacturer: MediaTek
[1001647.216868] usb 2-1: SerialNumber: MT-S9NPaAMhQdBBD1gBEBDfAxvA
[1001647.217399] scsi36 : usb-storage 2-1:1.0
[1001648.235664] scsi 36:0:0:0: Direct-Access     MediaTek MT65xx MS        0100 PQ: 0 ANSI: 2
[1001648.235825] sd 36:0:0:0: Attached scsi generic sg2 type 0
[1001648.239143] sd 36:0:0:0: [sdb] 3964677 512-byte logical blocks: (2.02 GB/1.88 GiB)
[1001648.240137] sd 36:0:0:0: [sdb] Write Protect is off
[1001648.240140] sd 36:0:0:0: [sdb] Mode Sense: 03 00 00 00
[1001648.240143] sd 36:0:0:0: [sdb] Assuming drive cache: write through
[1001648.242886] sd 36:0:0:0: [sdb] Assuming drive cache: write through
[1001648.242893]  sdb:
[1001648.247761] sd 36:0:0:0: [sdb] Assuming drive cache: write through
[1001648.247764] sd 36:0:0:0: [sdb] Attached SCSI removable disk

Why exactly were these parameters used? Just because my smartphone has this manufacturer ID, although this is not a device from HTC at all!

$ lsusb | grep 0bb4
Bus 002 Device 015: ID 0bb4:0c03 High Tech Computer Corp.

ADB access

Run adb now, and enjoy your access to the Android prompt on the phone!

$ ./platform-tools/adb shell
$ cat /proc/cpuinfo
Processor       : ARM926EJ-S rev 5 (v5l)
BogoMIPS        : 207.66
Features        : swp half thumb fastmult edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant     : 0x0
CPU part        : 0x926
CPU revision    : 5
Hardware        : MT6516 E1K
Revision        : 659e8b01
Serial          : 0000000000000000

You can see that magical BogoMIPS number — frankly, I don’t know how well it reflects the actual frequency of the CPU, because MediaTek itself declares the CPU to be running at 416 MHz. Even with ordinary user rights, you can do many interesting things, such as scanning the Wi-Fi network:

$ iwlist wlan0 scan
wlan0     Scan completed :
Cell 01 - Address: 00:15:D1:4B:E6:F7
ESSID:"my_net"
Frequency:2.412 GHz (Channel 1)
Mode:Managed
Signal level=-65 dBm
Encryption key:off
Bit Rates:54 Mb/s
Extra:Rates (Mb/s): 1 2 5.5 11 6 9 12 18 24 36 48 54
Cell 02 - Address: F1:7D:68:48:C2:A0
ESSID:"dd-wrt"
Frequency:2.437 GHz (Channel 6)
Mode:Managed
Signal level=-68 dBm
Encryption key:off
Bit Rates:54 Mb/s
Extra:Rates (Mb/s): 1 2 5.5 11 6 9 12 18 24 36 48 54

You can find the IP address that DHCP assigned to the smartphone when it joined the wireless network with ifconfig wlan0, display the phone’s installed RAM with cat /proc/meminfo, or run mount to view mounted block devices, besides other commands you would expect. The basic Android system commands are located in /system/bin and /system/sbin. You can list them and see that /system/bin has almost the same commands as those in the /bin directory on a Linux desktop installation. However, there are several special features, like the service command, which lets you display the full list of services by running service list.

All Android OS parameters are available via the getprop command. For instance, a question that tortured me for months was exactly what type of touchscreen the device had — resistive or capacitive? The getprop output has [ro.kernel.touchpanel.type]:[capacitive], but I doubt it, because I can use my pencil on the virtual keyboard, and it works. This is impossible with a real capacitive screen. So, the question is still open :-)

Please don’t forget the dmesg command! After a reboot, you can see the initialisation of internal sensors and devices. For example, I could clearly see that the ROM is a NAND device: Manufacturer ID: 0x98, Chip ID: 0xbc (Toshiba NAND 512MiB 1,8 V 16Manufacturer ID: 0x98, Chip ID: 0xbc (Toshiba NAND 512MiB 1,8 V 16-bit) and also information on the GPS sensor:

GPS: mt3326_gps_power: Switching GPS device on
GPS: mt3326_gps_power: ignore power control: 1
GPS: mt3326_gps_probe: Registering chardev
GPS: mt3326_gps_probe: major: 229, minor: 0
GPS: mt3326_gps_probe: Done

SSH access over Wi-Fi

For quicker shell access (and easy file transfers using the sshfs facility), you can install an SSH daemon and connect via Wi-Fi. I installed QuickSSHD, which listens on port 2222. Once installed, run the ssh client on your PC and connect to the IP address determined earlier via adb, as follows:

ssh -C -p 2222 10.10.1.22
QuickSSHD for Android
Single-User mode (Any username works).
Root your device to allow users.
[email protected]'s password:
$

Rooting the device

Basically, most applications can be happily run with ordinary user rights, but the most interesting things are available only to the root. To gain root access, install the z4root and Superuser applications. The first app allows you to do temporary rooting, constant rooting, or to return from a rooted state to the original condition. The second app controls access to the root level, like the su command on a PC. It’s amazing how fast an Android phone can be rebooted by root :-)

With superuser privileges, you can do a lot of exciting things, including gain access to restricted parts of Android, format the SD card, change the IMEI, make a phone call via the service command, and much more. For example, to make a call from the first SIM card, run service call phone 2 s16 "MyNumber", where MyNumber is the number to be dialled. Root privileges are also required if you decide to assign an internal IP address when establishing a network connection via USB cable [link].

Building a simple console application

As you might know, the core of Android is Dalvik — a slightly modified JVM (Java Virtual Machine) intended to effectively run mobile-sphere applications. Dalvik does not align to Java SE nor Java ME class library profiles (for example, Java ME classes, AWT or Swing are not supported). Instead, it uses its own library, built on a subset of the Apache Harmony Java implementation.

Let’s now build a simple “Hello, World” console application for Android [link]. To compile the Java source on your PC, you should also have the JDK packages pre-installed. The elementary code is given below:

package org.apache;
public class HelloWorld {
    public static void main(String[] args) {
       System.out.println("Hello World!");
    }
}

Compile it, and package it into a jar archive, as follows:

$ javac -d . -g Helloworld.java
$ jar -cvf  Temp.jar *
added manifest
adding: classes.dex(in = 776) (out= 432)(deflated 44%)
adding: CmdLine.jar(in = 552) (out= 533)(deflated 3%)
adding: HelloWorld.java(in = 144) (out= 117)(deflated 18%)
adding: org/(in = 0) (out= 0)(stored 0%)
adding: org/apache/(in = 0) (out= 0)(stored 0%)
adding: org/apache/HelloWorld.class(in = 556) (out= 341)(deflated 38%)

Next, transform it into a modified archive that can be run by the Dalvik VM:

$ ./platform-tools/dx --dex --output=classes.dex Temp.jar
$ ./platform-tools/aapt add CmdLine.jar classes.dex
./platform-tools/aapt: /lib/libz.so.1: no version information available (required by ./platform-tools/aapt)
'classes.dex' as 'classes.dex'...

After this, transfer the final CmdLine.jar file to the smartphone. You can launch it as follows:

$ dalvikvm -cp CmdLine.jar  org.apache.HelloWorld
Hello World!

Ruby on Android

In addition to the usual Java applications, it’s also possible to run an Android port of Ruby. While for GUI programs you must spend more time installing additional libraries, for basic tasks, the core library is already there:

$ dalvikvm -classpath IRB-0.5.2-release.apk org.jruby.Main -e "puts 'Hello, this is Ruby!'"
warning: could not compile; pass -d or -J-Djruby.jit.logging.verbose=true for more details
Hello, this is Ruby!

Though execution time is a bit longer compared to Java, Ruby works here too. For a more sophisticated version of your application, it’s advisable to put it into a single file. But first, let’s make our Ruby experience a bit more pleasant:

$ cp  IRB-0.5.2-release.apk  ruboto.jar
$ dalvikvm -classpath  ruboto.jar org.jruby.Main -X-C -e "require 'java'; puts java.lang.System.get_property('java.vendor')"
The Android Project

Well, Ruby operations work well. Now let’s put our program into a separate file, named test.rb:

require 'java'
import java.lang.System

class Ruboto
def greet(who)
puts "Hello, #{who}!"
end
end

name = System.get_property('java.runtime.name')
Ruboto.new.greet(name)

As you can see, our Ruby script retrieves a Java environment property. Run it thus:

$ dalvikvm -classpath ruboto.jar org.jruby.Main -X-C test.rb
Hello, Android Runtime!

Getting Python installed

If you want Python-based applications too, you’ll have to transfer a Python installer onto the phone, and install the full Python environment from it. Transfer the installer via SSH (Wi-Fi or USB connection) or simply run an adb command like the following, on your PC:

$ ./platform-tools/adb install -s /home/anton/python_for_android_r1.apk
774 KB/s (31714 bytes in 0.039s)
pkg: /sdcard/tmp/python_for_android_r1.apk
Success

Now, go to the main screen and click the Python icon to launch it, in order to install all other modules. After a while, installation is complete, and you can run the interpreter. Please pay attention to where Python hides: /data/data/com.googlecode.pythonforandroid/files/python/. Thus, to run Python from the command line, use the following code:

$ /data/data/com.googlecode.pythonforandroid/files/python/bin/python
Could not find platform independent libraries
Consider setting $PYTHONHOME to
[:]
'import site' failed; use -v for traceback
Python 2.6.2 (r262:71600, Sep 19 2009, 11:03:28)
[GCC 4.2.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "Hello, World!"
Hello, World!

Again, it’s advisable to put your app into a single script file, as well as set up the necessary variable, namely $PYTHONHOME.

In addition to these languages, Google also offers Perl, Lua and even more. As you can see, Android is a fun thing — attach a big keyboard and screen, and you’ll get a developer’s machine for Android, under Android :)

Android smartphones are everywhere these days. You can find interesting models like the Acer beTouch E110, the LG Optimus GT540, or the Samsung Galaxy Next. The same companies offer dual-SIM models as well, like the LG GX500 and Samsung GT-B7722 Duos. However, neither of the two qualify as an Android-based device — and, to be honest, the prices for the dual-SIM models are almost twice those of a single-SIM unit! With this in mind, devices based on the MT6516 look very attractive, especially when you consider their price, quality and technical capabilities.

And then, don’t forget one aspect — this isn’t simply an open source Android platform, but a full-featured (well, almost full-featured) Linux computer. It can run Java applications, Ruby and Python (and other) scripts, or even ordinary binaries for the ARM processor. Isn’t it a good starting point for newbies, and even professionals, to start learning something new about Android, and Linux in general? All you need is a device, your skills and knowledge, and a will to program.

  • José Antonio Rocha

    With Ubuntu 12.04, the udev rule is:

    SUBSYSTEM==”usb”, ATTRS{idVendor}==”0bb4″, MODE=”0666″,

  • Decio

    Hi, I have a problem with a phone mini g21 mtk6573. It has invalid IMEI numbers. I’ve tried everything all around the internet to get root into this phone and change the IMEI numbers. z4root didn’t work for me, as well as SuperOneClick, or pushing the files directly through adb (it says invalid permition).
    Is there any other way I can get around all this and just correct the IMEI numebrs?

    Thanks. Oh, the original link for the phone is this one:
    http://www.ahappydeal.com/product-88756.html

    PS.: Oh, I found this thread because when you run the lsusb I get the same result as yours.
    “ID 0bb4:0c03 High Tech Computer Corp.”

    Best regards.

All published articles are released under Creative Commons Attribution-NonCommercial 3.0 Unported License, unless otherwise noted.
Open Source For You is powered by WordPress, which gladly sits on top of a CentOS-based LEMP stack.

Creative Commons License.