Shell access via ADB#
Możesz postawić swoje urządzenie w trybie programisty i uzyskać dostęp do powłoki Bash na twoim komputerze. To jest przydatne podczas debuggowania i bardziej zaawansowanych zastosowań.
Instalacja ADB#
Pierwsze co musisz zrobić to zainstalować ADB na twoim komputerze.
Na Ubuntu:
sudo apt install android-tools-adb
Na Fedorze:
sudo dnf install android-tools
And on macOS with Homebrew:
brew install android-platform-tools
Dla Windowsa, pobierz konsolowe narzędzia z developer.android.com.
Włącz tryb programisty#
Następnie włącz Tryb Programisty.
Umieść swoje urządzenie w trybie programisty (Ustawienia - Informacje - Tryb programisty - kliknij przycisk, aby go włączyć)
Uruchom ponownie urządzenie
Plug the device into a computer with ADB installed
Otwórz terminal i wykonaj komende
adb devices
.
Informacja
Kiedy skończysz korzystać z powłoki dobrym pomysłem jest ponowne wyłączenie Trybu Programisty.
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.
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.
Dodatkowe komendy adb:
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.
Dodaj ID sprzętu#
ADB nie zawsze wie, z którymi urządzeniami powinno rozmawiać, z którymi nie. Możesz ręcznie dodać urządzenia, z którymi nie wie jak rozmawiać.
Wykonaj tą komende dla twojego urządzenia, jeśli wyświetla się poniżej. Potem wykonaj adb kill-server
, po czym komende, którą początkowo chciałeś wykonać.
Fairphone 2:
printf "0x2ae5 \n" >> ~/.android/adb_usb.ini
OnePlus One:
printf "0x9d17 \n" >> ~/.android/adb_usb.ini