ADB and Fastboot

Aus Volla Wiki

This guide is intended for all users who are aware of the risks associated with modifying developer options and have familiarized themselves with the capabilities of ADB. Volla disclaims any liability in case of data loss or device complications.

Using this tutorial is at your own risk and is expressly not recommended for users without experience.

ADB - Android Debug Bridge

Basics of ADB Commands

ADB commands are entered via a terminal (Windows: Command Prompt/PowerShell, macOS/Linux: Terminal). The general syntax is:

adb [option] [command] [parameter]

  • You must ensure that ADB is installed on your computer (either via the Android SDK or as a Minimal ADB Tool).
  • The device must be connected with USB debugging or wireless debugging enabled (see).

Common ADB Commands with Explanation

1. Connection and Status Commands

adb devices

Description: Lists all connected devices.
Example: adb devices → Output: "1234567890abcdef device" (device connected) or "192.168.1.100:5555 device" (wireless).
Tip: If "unauthorized" appears, check the debugging prompt on the device.

adb connect <IP>:<Port>

Description: Connects to a device via Wi-Fi.
Example: adb connect 192.168.1.100:5555

adb disconnect <IP>:<Port>

Description: Disconnects a wireless connection.
Example: adb disconnect 192.168.1.100:5555

adb pair <IP>:<Port>

Description: Pairs a device with a pairing code (for wireless debugging).
Example: adb pair 192.168.1.100:37000 → Enter the code (e.g., "123456").

2. Shell Access

adb shell

Description: Opens an interactive shell on the device to execute Linux commands.
Example: adb shell → Then, e.g., ls (shows commands like dir on Windows).

adb shell <command>

Description: Executes a single command without keeping the shell open.
Example: adb shell pm list packages → Lists all installed apps (package names).

3. App Management

adb install <path-to-APK>

Description: Installs an APK file on the device.
Example: adb install C:\Apps\myapp.apk
Option: -r overwrites an existing app (e.g., adb install -r myapp.apk).

adb uninstall <package-name>

Description: Uninstalls an app (requires package name).
Example: adb uninstall com.example.app
Option: -k keeps data/cache (e.g., adb uninstall -k com.example.app).

adb shell pm disable-user <package-name>

Description: Disables an app without uninstalling (e.g., bloatware).
Example: adb shell pm disable-user com.samsung.bloat

adb shell pm enable <package-name>

Description: Re-enables a disabled app.
Example: adb shell pm enable com.samsung.bloat

4. File Transfer

adb push <local-path> <device-path>

Description: Copies a file from the computer to the device.
Example: adb push C:\Files\test.txt /sdcard/
Tip: The target directory must exist and be accessible.

adb pull <device-path> <local-path>

Description: Copies a file from the device to the computer.
Example: adb pull /sdcard/test.txt C:\Files\

5. Device Information and Debugging

adb logcat

Description: Displays real-time device logs (useful for developers).
Example: adb logcat → Press Ctrl+C to exit.
Option: adb logcat | grep "Error" filters by specific terms.

adb shell dumpsys

Description: Provides detailed system information.
Example: adb shell dumpsys battery → Shows battery status.

adb shell getprop

Description: Lists device properties (e.g., Android version).
Example: adb shell getprop ro.build.version.release → Shows, e.g., "14".

6. Device Control

adb reboot

Description: Restarts the device.
Example: adb reboot
Options: adb reboot recovery (to Recovery mode) or adb reboot bootloader (to Fastboot).

adb shell input tap <x> <y>

Description: Simulates a tap on the screen (coordinates in pixels).
Example: adb shell input tap 500 1000 → Taps at X=500, Y=1000.

adb shell input text <text>

Description: Inputs text.
Example: adb shell input text "Hello" → Types "Hello".

7. Network and Screenshots

adb shell screencap <path>

Description: Takes a screenshot on the device.
Example: adb shell screencap /sdcard/screenshot.png → Then download with adb pull.

adb shell screenrecord <path>

Description: Records a screen video (max. 3 minutes).
Example: adb shell screenrecord /sdcard/video.mp4 → Ctrl+C to stop.

adb shell ifconfig

Description: Shows network details (e.g., IP address).
Example: adb shell ifconfig wlan0

Advanced ADB Commands

adb shell pm grant <package-name> <permission>

Description: Grants a specific permission to an app.
Example: adb shell pm grant com.example.app android.permission.WRITE_SECURE_SETTINGS

adb shell wm size <width>x<height>

Description: Changes screen resolution (for testing).
Example: adb shell wm size 720x1280
Reset: adb shell wm size reset

adb shell am start -n <package-name>/<activity>

Description: Starts an app or activity directly.
Example: adb shell am start -n com.android.settings/.Settings

adb backup -apk -shared -all -f <file>

Description: Creates a device backup.
Example: adb backup -apk -shared -all -f backup.ab

Practical Examples

  • Remove bloatware without root:
    • Find package name: adb shell pm list packages | grep "package-name"
    • Disable: adb shell pm disable-user com.<package-name-output>
  • Automated screenshot:
    • adb shell screencap /sdcard/screenshot.png && adb pull /sdcard/screenshot.png C:\Screenshots\
  • Install app without store:
    • adb install C:\Downloads\app.apk

Tips and Tricks

  • Multiple devices: If multiple devices are connected, add -s <serial-number>, e.g., adb -s 1234567890abcdef shell.
  • Combine commands: Use && for multiple actions, e.g., adb shell screencap /sdcard/test.png && adb pull /sdcard/test.png.
  • Aliases: Create shortcuts in your terminal (e.g., alias screenshot='adb shell screencap...').

Limitations

  • Without root access, many system areas are restricted (e.g., /system).

Fastboot

is another powerful tool in the Android ecosystem, often used in combination with ADB but operating at a lower level. It is particularly useful for bootloader operations, flashing firmware, and device modifications.

What is Fastboot?

Fastboot is a protocol and command-line tool that allows direct interaction with an Android device's bootloader. The bootloader is the software loaded when the device starts, before the operating system (Android) boots. With Fastboot, you can flash system partitions, unlock the bootloader, or reset devices—tasks not possible with ADB.

  • Difference from ADB: ADB operates within the running Android system, while Fastboot is active in bootloader mode.
  • Prerequisite: Fastboot must be installed on your computer (via Android SDK or Minimal ADB and Fastboot).

Prerequisites for Fastboot

  • Fastboot drivers: Ensure Fastboot drivers are installed on your PC (on Windows, often part of Google USB Drivers).
  • USB cable: Fastboot works only via USB connection (no wireless mode).
  • Bootloader mode: The device must be started in Fastboot mode (also called "bootloader mode").
    • Input: Power off the device, hold a key combination (e.g., Power + Volume Down), and connect it to the PC via USB.
    • Alternatively via ADB: adb reboot bootloader
  • Unlocked bootloader (optional): Many commands require an unlocked bootloader (see below).

Common Fastboot Commands

1. Connection and Status Commands

fastboot devices

Description: Lists all devices in Fastboot mode.
Example: fastboot devices → Output: "1234567890 fastboot"
Tip: If nothing appears, check the USB connection or drivers.

fastboot getvar <variable>

Description: Displays device information (e.g., bootloader status).
Example: fastboot getvar unlocked → Output: "yes" (unlocked) or "no" (locked).

2. Bootloader Operations

fastboot oem unlock

Description: Unlocks the bootloader (Warning: Erases all data!).
Example: fastboot oem unlock
Note: Not available on all devices; some (e.g., Xiaomi) require an unlock code from the manufacturer.
Alternative: fastboot flashing unlock (newer devices).

fastboot oem lock

Description: Relocks the bootloader.
Example: fastboot oem lock
Note: Often resets the device.

fastboot flashing lock

Description: Alternative for locking (newer Android versions).
Example: fastboot flashing lock

3. Flashing Partitions

fastboot flash <partition> <file>

Description: Writes an image file to a specific partition (e.g., Boot, Recovery, System).
Example: fastboot flash recovery recovery.img → Flashes a custom recovery like TWRP.
Common partitions:
  • boot: Kernel and RAM disk.
  • recovery: Recovery mode.
  • system: Android operating system.
  • vbmeta: Verification data (for Android Verified Boot).

fastboot flashall

Description: Flashes all partitions from a factory image (e.g., boot.img, system.img).
Example: fastboot flashall (files must be in the same directory).

fastboot erase <partition>

Description: Erases a partition.
Example: fastboot erase userdata → Deletes all user data.

4. Device Control

fastboot reboot

Description: Restarts the device into the normal system.
Example: fastboot reboot

fastboot reboot recovery

Description: Boots into the recovery menu.
Example: fastboot reboot recovery

fastboot reboot bootloader

Description: Restarts into Fastboot mode.
Example: fastboot reboot bootloader

fastboot boot <file>

Description: Boots an image (e.g., Recovery) without flashing—ideal for testing.
Example: fastboot boot recovery.img

5. Advanced Commands

fastboot update <ZIP-file>

Description: Installs an update from a ZIP file (e.g., OTA update).
Example: fastboot update update.zip

fastboot oem device-info

Description: Displays device information (e.g., bootloader status).
Example: fastboot oem device-info

fastboot set_active <slot>

Description: Switches between A/B partitions (on devices with seamless updates).
Example: fastboot set_active a or fastboot set_active b

Practical Examples

  • Unlock bootloader:
    • adb reboot bootloader
    • fastboot flashing unlock
    • Confirm on the device → Data is erased, bootloader is unlocked.
  • Install TWRP Recovery (if available):
    • adb reboot bootloader
    • fastboot flash recovery twrp-<version>.img
    • fastboot reboot recovery → Boots into TWRP.
  • Restore factory image:
    • Extract the factory image
    • adb reboot bootloader
    • fastboot flashall → Flashes Boot, System, Recovery, etc.
  • Temporarily test a recovery:
    • fastboot boot twrp-<version>.img → Boots TWRP without installation.

Important Notes

  • Data loss: Commands like oem unlock or erase delete all data. Create a backup beforehand!
  • Warranty: Unlocking the bootloader may void the warranty.
  • Brick risk: Incorrect flashing (e.g., incompatible image) can render the device unusable (soft-brick).

Troubleshooting

  • "Fastboot not found": Check if Fastboot is installed (fastboot --version).
  • Device not recognized: Try a different USB cable/port or update drivers.
  • "Waiting for device": Ensure the device is in Fastboot mode (fastboot devices).

This guide is intended for all users who are aware of the risks associated with modifying developer options and have familiarized themselves with the capabilities of ADB. Volla disclaims any liability in case of data loss or device complications.

Using this tutorial is at your own risk and is expressly not recommended for users without experience.