Shell access via ADB#

Podeu posar el vostre dispositiu UBports en mode desenvoluament i accedir una consola Bash des del vostre ordinador. Això és útil per depuracions o per a un ús més avançat de la consola.

Instal·lació de l’ADB#

En primer lloc, us caldrà instal·lar l’ADB al vostre ordinador.

A l’Ubuntu:

sudo apt install android-tools-adb

Al Fedora:

sudo dnf install android-tools

And on macOS with Homebrew:

brew install android-platform-tools

For Windows, grab the command-line tools only package from developer.android.com.

Habiliteu el mode de desenvolupador#

A continuació, haureu d’activar el mode de desenvolupador.

  1. Poseu el vostre dispositiu en mode de desenvolupador (Configuració del sistema - Quant a - Mode de desenvolupador - marqueu la casella per activar-lo)

  2. Reinicieu el vostre dispositiu

  3. Plug the device into a computer with ADB installed

  4. Obriu una terminal i executeu adb devices.

Nota

Quan hagueu acabat d’usar la consola, és una bona idea desactivar un altre cop el mode de desenvolupament.

If there’s a device in the list here (The command doesn’t print «List of devices attached» and a blank line), you are able to use ADB. If not, continue to the next section.

Authorize access to the device#

When using adb for the first time on a computer, the following dialog will appear when you unlock the screen.

../../_images/adb_authorization_prompt.png

This ensures that ADB commands will not work on a new computer unless user unlock the phone and acknowledge the dialog. Selecting «Allow» will make the ADB commands work for this session, and will also remember this computer so that it won’t prompt you again in the future.

Nota

If you’re bringing up a port and you require ADB access before the UI is available, you can disable this protection by editing /etc/default/adbd and change ADBD_SECURE=1 to ADBD_SECURE=0.

Frequently used ADB commands#

ADB shell commands:

adb shell — Gives you access to the Linux command-line shell on your device.
adb shell [command] — Runs the specified shell command on your device.

Additional Adb commands:

adb push [source] [destination] — Pushes a file from your computer to your device.
adb pull [destination] [source] — Pulls a file from your device to your computer.

For more ADB commands, refer to the official documentation.

Addició d’identificadors de maquinari#

L’ADB no sempre sap a quins dispositius del vostre ordinador els hauria o no els hauria de parlar. Podeu afegir manualment els dispositiu amb els quals no sap com parlar.

Simplement executeu l’ordre per al vostre dispositiu seleccionat si hi és a sota. A continuació, executeu adb kill-server seguit de l’ordre que intentàveu executar inicialment.

Fairphone 2:

printf "0x2ae5 \n" >> ~/.android/adb_usb.ini

OnePlus One:

printf "0x9d17 \n" >> ~/.android/adb_usb.ini