Shell access via ADB#

Puoi impostare il tuo dispositivo UBports in modalità sviluppatore e dal tuo PC accedere alla console. Questo è comodo per il debugging o per utilizzi avanzati della console stessa.

Installare ADB#

Per prima cosa avrai bisogno di installare ADB sul tuo computer.

Su Ubuntu:

sudo apt install android-tools-adb

Su Fedora:

sudo dnf install android-tools

And on macOS with Homebrew:

brew install android-platform-tools

Per Windows, procurati il pacchetto strumenti a sola riga di comando da developer.android.com.

Abilita la modalità sviluppatore#

Poi, dovrai attivare la Modalità Sviluppatore.

  1. Imposta il tuo dispositivo in modalità sviluppatore (Impostazioni - Informazioni - Modalità Sviluppatore - seleziona la casella per attivarla)

  2. Riavvia il tuo dispositivo

  3. Plug the device into a computer with ADB installed

  4. Apri il terminale ed esegui adb devices.

Nota

Al termine dell’utlizzo della shell, è consigliato disabilitare la Modalità Sviluppatore.

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.

Comandi Adb addizionali:

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.

Aggiungere gli identificativi (IDs) hardware#

ADB non sempre sa con quali dispositivi collegati al tuo computer può o non può comunicare. Puoi aggiungere manualmente i dispositivi con cui possa comunicare.

Esegui semplicemente il comando per il tuo dispositivo selezionato, se mostrato qui sotto. Quindi, esegui adb kill-server seguito dal comando che inizialmente stavi cercando di eseguire.

Fairphone 2:

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

OnePlus One:

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