Ubuntu 14.04

# lsusb
...

Bus 001 Device 023: ID 2b0e:1844

Manufacturer ID

Model ID

From http://87.88.254.143/linux/74-ubuntu/328-ubuntu-trusty-android-adb-fastboot-qtadb

Ubuntu 14.04 - Install Android Tools (ADB, Fastboot, ... & QtADB)

dropcap-ubuntu-android

If you own an Android Smartphone, you will need sooner or later to use some specific Android tools like ADB or fastboot.

If you need these tools, two options are available under Ubuntu : either to install the whole Android SDK or to install some specific packages that bring only these tools.

Another very insteresting tool is QtADB. Based on ADB protocol, it allows under a graphical interface to have a complete access to your Android device filesystem, to manage your installed applications, to get some system informations, ...

As most of Android smartphone or tablet users are not needing the whole Android SDK, this article explains the simple steps needed to install Android specific tools like ADB, fastboot or QtADB on a Ubuntu computer.

It has been tested under Ubuntu Trusty 14.04 LTS and it has been used to flash and root a Google Nexus 7 under Lollipop and to root a OnePlus One running CM11s.

1. Setup ADB Udev Rule

Before accessing your android device in ADB mode, you need to :

  • set the device to use USB Debug
  • declare a corresponding Udev rule on your Ubuntu box

After setting the device in USB Debug mode and connecting it to a USB port, throw the command :

Terminal
# lsusb
...
Bus 002 Device 059: ID 18d1:4e42 Google Inc.

This is the result for a Google Nexus 7 connected in MTP mode with USB Debug on. It gives  :

  • the Manufacturer ID
  • the Model ID.

To be on the safe side, we will declare some generic rules for main Android phones manufacturers.

These rules will be declared /etc/udev/rules.d/51-android.rules.

/etc/udev/rules.d/51-android.rules
# udev rule to detect android devices
# These rules refer to http://developer.android.com/tools/device.html

# Acer
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666", GROUP="plugdev"
# Archos
SUBSYSTEM=="usb", ATTR{idVendor}=="0e79", MODE="0666", GROUP="plugdev"
# Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666", GROUP="plugdev"
# Azpen Onda
SUBSYSTEM=="usb", ATTR{idVendor}=="1f3a", MODE="0666", GROUP="plugdev"
# BQ
SUBSYSTEM=="usb", ATTR{idVendor}=="2a47", MODE="0666", GROUP="plugdev"
# Dell
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666", GROUP="plugdev"
# Fairphone
SUBSYSTEM=="usb", ATTR{idVendor}=="2ae5", MODE="0666", GROUP="plugdev"
# Foxconn
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666", GROUP="plugdev"
# Fujitsu Toshiba 
SUBSYSTEM=="usb", ATTR{idVendor}=="04c5", MODE="0666", GROUP="plugdev"
# Garmin-Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="091e", MODE="0666", GROUP="plugdev"
# Google
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
# Haier
SUBSYSTEM=="usb", ATTR{idVendor}=="201e", MODE="0666", GROUP="plugdev"
# Hisense
SUBSYSTEM=="usb", ATTR{idVendor}=="109b", MODE="0666", GROUP="plugdev"
# HTC, Wiko
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
# Huawei
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", GROUP="plugdev"
# Intel
SUBSYSTEM=="usb", ATTR{idVendor}=="8087", MODE="0666", GROUP="plugdev"
# K-Touch
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666", GROUP="plugdev"
# KT Tech
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666", GROUP="plugdev"
# Kyocera
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666", GROUP="plugdev"
# Lab126
SUBSYSTEM=="usb", ATTR{idVendor}=="1949", MODE="0666", GROUP="plugdev"
# Lenovo
SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", MODE="0666", GROUP="plugdev"
# LG
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"
# Meizu
SUBSYSTEM=="usb", ATTR{idVendor}=="2a45", MODE="0666", GROUP="plugdev"
# Micromax
SUBSYSTEM=="usb", ATTR{idVendor}=="1ebf", MODE="0666", GROUP="plugdev"
# Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev"
# MTK
SUBSYSTEM=="usb", ATTR{idVendor}=="0e8d", MODE="0666", GROUP="plugdev"
# NEC
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666", GROUP="plugdev"
# Nook
SUBSYSTEM=="usb", ATTR{idVendor}=="2080", MODE="0666", GROUP="plugdev"
# Nvidia
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666", GROUP="plugdev"
# OnePlus Two (unknown vendor's name)
SUBSYSTEM=="usb", ATTR{idVendor}=="2a70", MODE="0666", GROUP="plugdev"
# Oppo
SUBSYSTEM=="usb", ATTR{idVendor}=="22d9", MODE="0666", GROUP="plugdev"
# OTGV
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666", GROUP="plugdev"
# Pantech
SUBSYSTEM=="usb", ATTR{idVendor}=="10a9", MODE="0666", GROUP="plugdev"
# Pegatron
SUBSYSTEM=="usb", ATTR{idVendor}=="1d4d", MODE="0666", GROUP="plugdev"
# Philips
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", MODE="0666", GROUP="plugdev"
# PMC-Sierra
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666", GROUP="plugdev"
# Qualcomm
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", GROUP="plugdev"
# Rockcwell Electronics
SUBSYSTEM=="usb", ATTR{idVendor}=="2207", MODE="0666", GROUP="plugdev"
# SK Telesys
SUBSYSTEM=="usb", ATTR{idVendor}=="1f53", MODE="0666", GROUP="plugdev"
# Samsung
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="plugdev"
# Sharp
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666", GROUP="plugdev"
# Sony
SUBSYSTEM=="usb", ATTR{idVendor}=="054c", MODE="0666", GROUP="plugdev"
# Sony Ericsson
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666", GROUP="plugdev"
# Spreadtrum
SUBSYSTEM=="usb", ATTR{idVendor}=="1782", MODE="0666", GROUP="plugdev"
# T & A Mobile Phones
SUBSYSTEM=="usb", ATTR{idVendor}=="1bbb", MODE="0666", GROUP="plugdev"
# Teleepoch
SUBSYSTEM=="usb", ATTR{idVendor}=="2340", MODE="0666", GROUP="plugdev"
# Texas Instruments UsbBoot
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", MODE="0666", GROUP="plugdev"
# Toshiba
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666", GROUP="plugdev"
# Wearners
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", GROUP="plugdev"
# Wileyfox
SUBSYSTEM=="usb", ATTR{idVendor}=="2970", MODE="0666", GROUP="plugdev"
# XiaoMi
SUBSYSTEM=="usb", ATTR{idVendor}=="2717", MODE="0666", GROUP="plugdev"
# YU
SUBSYSTEM=="usb", ATTR{idVendor}=="1ebf", MODE="0666", GROUP="plugdev"
# Zebra
SUBSYSTEM=="usb", ATTR{idVendor}=="05e0", MODE="0666", GROUP="plugdev"
# ZTE
SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0666", GROUP="plugdev"
# ZUK
SUBSYSTEM=="usb", ATTR{idVendor}=="2b4c", MODE="0666", GROUP="plugdev"
Terminal
# sudo wget -O /etc/udev/rules.d/51-android.rules https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/51-android.rules
# sudo chmod a+r /etc/udev/rules.d/51-android.rules

We can now restart udev for the new rules to become operationnal.

Terminal
# sudo service udev restart

2. Install Android tools

If you don't plan to do some development on your android device, you don't need to install the complete SDK.

Two android-tools packages are now available for Ubuntu. They provide a minimal set of tools like adb and fastboot.

These tools are exactly what you need to root your phone, to flash a ROM, to sideload an application, ...

As these packages are now in Ubuntu official repositories, is has become very easy to install these packages :

Terminal
# sudo apt-get install android-tools-adb android-tools-fastboot

3. Update to ADB 1.0.32

Since Android Lollipop 5.0, ADB 1.0.32 is needed to sideload your device.

As Ubuntu repository has still not been updated at the time of this article,  we need to update ADB with latest version found in Googlehttps://skia.googlesource.com/skia/ archives.

This can be done easily with these commands :

Terminal
# adb version
Android Debug Bridge version 1.0.31
# wget -O - https://skia.googlesource.com/skia/+archive/cd048d18e0b81338c1a04b9749a00444597df394/platform_tools/android/bin/linux.tar.gz | tar -zxvf - adb
# sudo mv adb /usr/bin/adb
# sudo chmod +x /usr/bin/adb
# adb version
Android Debug Bridge version 1.0.32

You now have latest ADB version which will allow you to handle your Lollipop devices.

4. Allow ADB trusted connexion

Starting from Android 4.2.2 onward, a new security feature has been introduced within ADB : You must confirm on your device that it is being attached to a trusted computer before any dialog can take place.

If you've not authorized the connexion, you'll get an unauthorized message :

Terminal
# adb devices
List of devices attached
015d2d426d640c1a      unauthorized

When you will plug your Android device for the first time, it will display a message asking you to allow connexion to your computer as a trusted computer.

You need to validate the message and to select the permanent checkbox.

Terminal
# adb devices
List of devices attached
015d2d426d640c1a      device

Your Android device is now fully accessible thru ADB.

5. If your device is not detected ...

If everything is ready

  • ADB installed on the computer
  • ADB enabled in the developper mode menu of your device

and your device is not detected by your computer, you may be facing the USB3 bug.

On modern computer, most of the USB ports are USB3 and there is an incompatibility between some Android devices and USB3 ports. 

This problem must be software related, as one of my phone is not recognized thru adb but is fully recognized thru fastboot on the same USB port !

The easiest way to solve it is damn simple : just connect a cheap, self-powered USB hub between your computer and your Android device. 

6. Install QtADB

android-qtadb

QtADB is a powerful graphical Android device manager based on ADB protocol.

QtADB will allow you to :

  • have a complete access to your Android device filesystem
  • manage your installed applications
  • get some device informations (battery level, memory usage, ...)
  • take some device display screenshot

6.1. Prerequisite on Phone or Tablet Side

To be able to fully use QtADB with your phone or tablet, the device needs to :

  • be rooted
  • have busybox installed (without busybox installed, half of QtADB functionalities won't work)

If your phone is running CyanogenMod, you should also allow root access for ADB.

This is done thru Settings / Superuser / Settings

android-qtadb-cm-adb-root

You can test your phone configuration with the following command from your computer :

Terminal
# adb shell busybox ls -l -a
drwxr-xr-x   16 root     root             0 Mar 30 14:27 .
drwxr-xr-x   16 root     root             0 Mar 30 14:27 ..
drwxr-xr-x    3 root     root             0 Mar 30 14:27 acct
drwxrwxrwt    2 root     root            40 Mar 30 14:27 app-cache
drwxrwx--x    1 system   cache         4096 Mar 31 14:08 cache
...

6.2. Installation

QtADB requires :

  • a working ADB installation (done previously)
  • Qt libs version 4.7

First step is to install the dependencies. You can then download executable from the site download section and install it.

Select the download package according to your distribution (32bits i386 or 64bits Amd64).

Terminal
# sudo apt-get install libqtgui4 libqt4-network libqt4-declarative libqt4-opengl
# wget http://bernaerts.dyndns.org/download/ubuntu/adb/QtADB_0.8.1_linux64.tar.gz
# tar -xvf QtADB*.tar.gz
# sudo mv ./QtADB*/QtADB /usr/local/sbin/qtadb
# sudo chmod +x /usr/local/sbin/qtadb
# rm -R QtADB*

QtADB is now installed on your computer.

6.3. Get Rid of the Startup Crash Bug

Version 0.8+ of QtADB is subject to a very nasty bug.

When you launch it, some internet update verification process makes it crash. 

Terminal
 # qtadb
Segmentation fault (core dumped)

As this update verification is set by default, we need to disable it.

This is done easily by creating the default QtADB.conf configuration file that disables the CheckForUpdateOnStart key :

Terminal
# mkdir $HOME/.config/Bracia
# wget $HOME/.config/Bracia/QtADB.conf https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/QtADB.conf
~/.config/Bracia/QtADB.conf
[General]
sdkPath=/usr/bin/
checkForUpdatesOnStart=false

QtADB should now stop to crash at startup.

6.4. Create Application Launcher

Last step is to declare the application to be used by your desktop launcher..

This is done by downloading an application icon and by creating a qtadb.desktop file :

Terminal
# sudo wget -O /usr/share/icons/qtadb.png http://bernaerts.dyndns.org/download/ubuntu/adb/qtadb.png
# sudo wget -O /usr/share/applications/qtadb.desktop https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/qtadb.desktop
/usr/share/applications/qtadb.desktop
[Desktop Entry]
Encoding=UTF-8
Name=QtADB
Exec=qtadb
Icon=qtadb
Type=Application
Categories=Utility;

You can now launch QtADB and your Android phone filesystem should now fully accessible.

For example, your can take full screenshot of your phone display in one click.

ubuntu-qtadb-oneplus-screenshot

 Be careful, you have the full powers !

Model ID

原文地址:https://www.cnblogs.com/lake-of-embedded-system/p/5629029.html