Android/adb

ADB stands for Article description::Android Debug Bridge, and it is a part of the Android Software Development Kit (SDK). It can be installed with.

Install Android SDK Platform-Tools
Android SDK Platform-Tools is a component for the Android SDK. It includes tools that interface with the Android platform, primarily.

USB Communication
Enable the USB Debugging option on the Android device under Settings > Developer options.

For Android 4.2 and later, Developer options is hidden by default; use the following stepsː


 * 1) On the device, go to Settings > About.
 * 2) Tap the Build number seven times to make Settings > Developer options available enable.
 * 3) Go back to system settings and scroll down to bottom > Developer Options.
 * 4) Now hit Enable USB-Debugging.

Each user that wants to use ADB needs to be in the plugdev group. If you see an error message that says you're not in the plugdev group, add yourself to it using the following command:

Pair with a device for secure TCP/IP communication
Since Android 11 it is possible to connect to Wifi-debugging by pairing the device over wifi (access point)

On the android device, open Developer options, and enable Wireless debugging , then click the Pair device with pairing code , it will show the connecting information and pairing code on your android device and you will now be able to pair your device. (select pairing by code since qr-code is for android-studio and qemu emulator by default but there are third-party programs for this via the terminal such as "npm-wifi" but it is not default)

Port of adb server
Default port: 5037

Listen on given socket
Default: tcp:localhost:5037

Kill ADB daemon
Sometimes it may be necessary to kill adb if the device is not showing up connect. This can occur when adb is running before connecting the device. In this case kill and restart the adb server:

FastbootD mode
FastbootD is a new mode Android devices could boot to by using ADB Command, via Fastboot Command, and from the Stock Recovery as well for devices using A/B partitions for flashing. The easiest way to keep track of the difference between bootloader/fastboot and fastbootd is to first reboot to the bootloader via adb and then we gonna use fastboot command instead of adb command to fastbootd mode.

When device has rebooted and you got into bootloader mode now use fastboot to reboot to fastboot instead of adb command

Copy all files from device folder
Notice the trailing slash after the directory name:

Exampleː Print IMEI via a call service
Convert the output to a readable formatː

Print IMEI for slot 1 or 2
This works up to android 11

Imei 1:

Imei 2:

Print esim imei via uiautomator
The uiautomatorviewer tool provides a convenient visual interface to inspect the layout hierarchy and view the properties of UI components that are visible on the foreground of the device. This information lets you create more fine-grained tests using UI Automator. For example, you can create a UI selector that matches a specific visible property.

To launch IMEI (same result if you type in caller app: *#06#) we gonna dump screens output to /tmp/read_screen.txt via uiautomator and parse esim IMEI from our esim.

Set wallpaper
When an image is open in the photo gallery, set the image as wallpaper for all screens with below

Uninstall a package
Exampleː

Tip: Uninstalling several packages at once can be achieved by a loop:

Make a Demo Call
Establishes a fake Bluetooth connection to Dialer and must be called first to enable access to all call-related commands.

ADB Dumpsys
A tool that runs on Android devices and provides information about system services. To get a diagnostic output for all system services for the connected device, simply run. However, this outputs far more information than typically needed. For more manageable output, specify the service to examine by including it in the command.

List dumpsys options
Above command works on recent android versions, for older versions use

HTC backup
With a non rooted device, the only things you can backup locally is what the couple device/android will let you do. That is pretty much the same files you can copy with the already mentioned software. With the Android 4.x devices, a nice solution to make such a partial backup is the so-called "adb backup".

where:


 * -f : the path of the *.ab file that will be saved on your computer. This file is a compressed file that contains an archive of the data/apks from your device.
 * -apk|-noapk : indicates if the *.apk files should be backed up (default is -noapk)
 * -shared|-noshared: enable/disable backup of the device's shared storage / SD card contents (default is -noshared)
 * -all : indicates that you want the entire system backed up. you can use the packages filter to just backup specific packages, or use -all for a full system backup.
 * -system|-nosystem: indicates if all the system applications and data are included when backing up. (default is -system)
 * : this is where you can list specific packages to backup. Use these if you want to back up only specific applications. If using -all, you do not need to specify packages.

To backup the phone into

will start the daemon and show you the devices on the USB.

will backup every thing the device will let you to backup.

will restore the backup into the device.

To stop the daemon:

Fastboot
Fastboot is a communication protocol used primarily with Android devices. It is implemented in a command-line interface tool of the same name and as a mode of the bootloader of Android devices. It is included with the Android SDK package used primarily to modify the flash filesystem via a USB connection from a host computer. It requires that the device be started in Fastboot mode. If the mode is enabled, it will accept a specific set of commands sent to it via USB using a command line. Fastboot allows to boot from a custom recovery image. Fastboot does not require USB debugging to be enabled on the device. Not all Android devices have fastboot enabled.

Android device manufacturers are allowed to choose if they want to implement fastboot or some other protocol.

Booting into fastboot
You can flash a device when it's in the fastboot bootloader mode.

To enter fastboot mode when a device is undergoing a cold boot proccess by press 'vol down' + 'power button' in 7000ms, this applies to all android devices regardless model to restart device in any state, for enter fastboot mode keep holding the combination after device is restarted from the key combo and release the keys when device has entering download mode

Unlock bootloader
You can flash a custom system only if the bootloader allows it. Note, though, that the bootloader is locked by default. You can unlock the bootloader, but doing so deletes user data for privacy reasons. After unlocking, all data on the device is erased, that is, both private app data and shared data accessible over USB (including photos and movies). Before attempting to unlock the bootloader, back up any important files on the device.

Unlock bootloader only once, and you can re-lock it anytime.

Unlocking recent devices
All Nexus and Pixel devices released since 2014 (starting with Nexus 6 and Nexus 9) have factory-reset protection and require a multistep process to unlock the bootloader.

Enable OEM unlocking on the device
In Settings, tap About phone, then tap Build number seven times.

When you see the message You are now a developer!, tap the back button. In Settings, tap System, then tap Developer options and enable OEM unlocking and USB debugging. (If OEM unlocking is disabled, connect to the internet so the device can check in at least once. If it remains disabled, your device might be SIM locked by your carrier and the bootloader can't be unlocked.) Reboot into the bootloader and use fastboot to unlock it.

FastbootD mode
FastbootD is a new mode Android devices could boot to by using ADB Command, via Fastboot Command, and from the Stock Recovery as well for devices using A/B partitions for flashing. The easiest way to keep track of the difference between bootloader/fastboot and fastbootd is to first reboot to the bootloader via adb and then we gonna use fastboot command instead of adb command to fastbootd mode.

When device has rebooted and you got into bootloader mode now use fastboot to reboot to fastboot instead of adb command