Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephendonner/fed138e0415058b11c2bca50231683ba to your computer and use it in GitHub Desktop.
Save stephendonner/fed138e0415058b11c2bca50231683ba to your computer and use it in GitHub Desktop.

adb and fastboot must know

Install android SDK (bottom of the page) or full android studio if you need to develop on android.

fastboot looks like adb but it is used when device is in bootloader (or fastboot).

Check connected devices

adb:

adb devices

fastboot

fastboot devices

Reboot

normal reboot

adb reboot
fastboot reboot

bootloader reboot

adb reboot bootloader
fastboot reboot bootloader

recovery reboot

adb reboot recovery

Unlock / erase / flash / sideload

unlock bootloader

fastboot oem unlock

WARING: If you if you unlock the bootloader it will behave like a factory reset. So backup all your data before!

lock bootloader

fastboot oem lock

WARNING: If you lock back the bootloader, next time you need to unlock data will still behave like a factory reset

unlock flashing

fastboot flashing unlock

INFO: Unlocks the device. Allows flashing any partition except bootloader-related partitions

lock flashing

fastboot flashing lock

sideload

Most of the time when flashing ROMS or MODS you will first download it into the device first then you will enter TWRP recovery for flashing it from there.

But in some rare weird cases you may have accidently erased system partition don't have access to sdcards or you forgot to download your image / zip.

adb sideload will help you then to flash from your TWRP recovery with ROM from your computer.

More complete explanation from TWRP website

  1. reboot in recovery:
adb reboot recovery
  1. in TWRP

go menus:

  • advanced
  • ADB sideload

Note : better check wipe caches before swiping from there

  1. from your computer terminal:

check your see your devices:

adb devices

sideload ( = push + flash):

adb sideload YOUR_ROM.zip

erase

fastboot erase xxx

Erase partition xxx. Partition could be:

  • boot,
  • cache,
  • recovery
  • system,
  • radio,
  • userdata,
  • bootloader

flash

fastboot flash xxx yyy

Flash partition xxx with new yyy.

For example:

  • flash bootloader with a new bootloaler image:
    fastboot flash bootloader new_bootloader.img
  • flash radio with a new radio image:
    fastboot flash radio new_radio.img

File explorer

Explore files (use linux commands)

adb shell

copy files from computer to device

adb push FILE /sdcard

Copy a file FILE to device's sdcard.

copy files from device to computer

adb pull FILE /some_computer_directory

Copy a file FILE to computer's directory

remount

adb remount

install apk

adb install file_name.apk 

Backup and Restore (NO ROOT NEEDED)

backup

When you launch a backup command a password for this backup will be asked.

backup all (simple)

adb backup -all

Note: backup backup.ab is placed inside platform-tools by default.

backup parametized (less simple but accurate)

adb backup -apk -shared -all -f computer_destination_directory\backup.ab

Parameters:

  • -apk OR _noapk:
    • include or not apk
  • -shared OR -noshared:
    • include or not files from sdcard
  • -all
    • Save system files and applications files (wihtout apk files)
  • -f computer_destination_directory\backup.ab
    • define a directory

restore

adb retore computer_source_directory\backup.ab

Bonus: check signature of a downloaded file

check MD5 (LineageOS for exmaple uses md5 signature):

$ md5 <FILE_NAME>

check GPG

Note: you need GnuPG

gpg --verify <FILE_NAME>.tar.gz.asc

check sha256

shasum -a 256 <FILE_NAME>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment