Android Tablet and ADB on Linux Mint/MATE

locked-computer-cartoonADB is the tool used to connect to your Android Linux tablet from your Linux PC. This post concerns how to get ADB working so you can change the system files inside your Android tablet, such as the boot animation and sound, and gives an example script.

ADB can be downloaded from Android Studio at http://developer.android.com/sdk/index.html as part of the complete development set or as just the SDK alone. To install the Android Studio, follow the instructions at http://developer.android.com/sdk/installing/index.html?pkg=studio. To install the SDK follow the instructions at http://developer.android.com/sdk/installing/index.html?pkg=tools (download the .zip archive and unpack it somewhere, remembering where you put it so you can go there later to use it from the command line). The Android Studio requires Sun Java version at least 6, preferably 7. I have bad memories of installing that before, so I opted for just the SDK alone.

Getting Connected – ADB must see your tablet before it can talk to your tablet

Login as root and run lsusb. Output will be something like

# lsusb
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 003: ID 06a3:8020 Saitek PLC Eclipse Keyboard
Bus 006 Device 002: ID 0e1a:0004 Unisys 
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 003: ID 045e:00f5 Microsoft Corp. LifeCam VX-3000
Bus 005 Device 002: ID 046d:c05a Logitech, Inc. M90/M100 Optical Mouse
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 015: ID 0bda:0151 Realtek Semiconductor Corp. Mass Storage Device (Multicard Reader)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 045e:0040 Microsoft Corp. Wheel Mouse Optical
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 058f:9254 Alcor Micro Corp. Hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Connect your Android Tablet device to the usb and observe what new line appears. That is your necessary data. In my case, using an AllWinner (China) device, I see:

# lsusb
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 008: ID 1f3a:1002  
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 003: ID 06a3:8020 Saitek PLC Eclipse Keyboard
Bus 006 Device 002: ID 0e1a:0004 Unisys 
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 003: ID 045e:00f5 Microsoft Corp. LifeCam VX-3000
Bus 005 Device 002: ID 046d:c05a Logitech, Inc. M90/M100 Optical Mouse
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 015: ID 0bda:0151 Realtek Semiconductor Corp. Mass Storage Device (Multicard Reader)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 045e:0040 Microsoft Corp. Wheel Mouse Optical
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 058f:9254 Alcor Micro Corp. Hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Notice the second line is new, and it contains all the info that we need to designate the device in /etc/udev/rules.d/51-android.rules. I have also heard it is necessary to do the same thing with/lib/udev/rules.d/11-android.rules so anyone can use ADB. This line (above) reads “Bus 002 Device 008: ID 1f3a:1002” and the part of interest to us is the “1f3a:1002”: “1f3a” is the Vendor ID for AllWinner Corp in China, and “1002” is the Product ID of the tablet.

If it does not yet exist, create /etc/udev/rules.d/51-android.rules. Edit it and add a line such as

#AllWinner
SUBSYSTEM=="usb", ATTR{idVendor}=="1f3a", ATTR{idProduct}=="1002", MODE="0666", GROUP="plugdev" OWNER="jdnash"

Use the actual numbers from your system: the numbers from my system are not necessairly the same as for yours. Common manufacturer IDs can be found at http://developer.android.com/tools/device.html#VendorIds.

Change to your ~.android folder and edit adb_usb.ini. If it does not yet exist create it. Add the vendor ID to this file on a line by itself using hex format, as this:

0x1f3a

Kill and restart the ADB server, then check for your devices again:

$ adb kill-server
$ adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
$ adb devices
List of devices attached 
034c1b27467500000000	device

I found some good info concerning the need for adb_usb.ini  at http://community.linuxmint.com/tutorial/view/888 and http://askubuntu.com/questions/213874/how-to-configure-adb-access-for-android-devices (near the bottom of the comments on both).

Command and Control of your tablet

Now that you are connected you can issue commands change the content of your tablet. Of course since you are now inside your tablet you can also mess things up, so no liability is accepted here. You are on your own at your own risk!

The commands I use most are shel, push, and pull. If you are familear with Linux you’ll have no problem guessing what commands work with adb. Or get a list with adb –help.

Shell executes your command inside the device at its command line; push and pull push files into or pull files out of the device from/to your PC. I change some system files, such as the boot animation.

adb shell mount -o rw,remount /system
adb shell ls

Gives me output:

$ adb shell ls
acct
bootloader
cache
charger
cloudsota
config
d
data
databk
default.prop
dev
etc
file_contexts
fstab.sun8i
init
init.environ.rc
init.rc
init.recovery.sun8i.rc
init.sun8i.rc
init.sun8i.usb.rc
init.trace.rc
init.usb.rc
initlogo.rle
mnt
nand.ko
proc
property_contexts
res
root
sbin
sdcard
seapp_contexts
sepolicy
storage
sys
system
ueventd.rc
ueventd.sun8i.rc
vendor

$ adb shell ls system/media
audio
boot.wav
bootanimation.zip
bootlogo.bmp
initlogo.bmp

Boot Animations

I found some pretty cool boot animations. To learn more about how to change your boot animation you can do a search on YouTube.com “how to change your boot animation on android” to see many related videos. The files of interest are usually in /system/media but sometimes are elsewhere. For example:

$ adb shell mv system/media/bootanimation.zip system/media/bootanimation.zip.bak

$ adb shell ls system/media
audio
boot.wav
bootanimation.zip.bak
bootlogo.bmp
initlogo.bmp

$ adb push bootanimation-zap.zip /system/media/bootanimation.zip
3658 KB/s (6194621 bytes in 1.653s)

$ adb shell ls system/media
audio
boot.wav
bootanimation.zip
bootanimation.zip.bak
bootlogo.bmp
initlogo.bmp

$ 

Because my public charity buys tablets as part of training seniors in using new technology, then allows those interested to buy the tablet they used in class, I want to be sure each tablet works. I downloaded a bunch of boot animations, which as just .jpg files numbered 1, 2, 3, … and zipped together into a file named “bootanimation.zip”, into a folder “new_media” in my sdk/platform-tools folder, from which folder I run adb.

To test and brand each tablet I made a small script:

adb shell mount -o rw,remount /system
adb shell mv /system/media/bootlogo.bmp /system/media/bootlogo.bmp.bak
adb push bootlogo.bmp /system/media
adb shell mv /system/media/initlogo.bmp /system/media/initlogo.bmp.bak
adb push initlogo.bmp /system/media
adb shell mv /system/media/bootanimation.zip /system/media/bootanimation.zip.bak
adb push bootanimation-zap.zip /system/media/bootanimation.zip
adb shell reboot

Hope this helps!
–kubuai

Comments are closed