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.

Enable USB debugging
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.

Tips: You might also want to enable the Stay awake option, to prevent Device from sleeping while plugged into the USB port.

Enable Wireless debugging
Since Android 11 it is possible to connect to Wifi-debugging by pairing the device over wifi

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)

Set TCP port
To use adb over a WiFi connection instead of using the cable, type the below command with the USB plugged in first timeː

Print IP address
To get the IP of the connected Android device (cabled connection):

Connect over IP/TCP
Once the IP address is known, use it to connect to the device:

Now control the device as usual via.

Detect devices
If the device is listed then connect to the android devices shell (the first time an authorized request on the device must be accepted when typing adb shell):

To run adb without root privileges then the unprivileged user account must be added to the plugdev group:

Multiple devices
When multiple devices are connected to the PC then the  option will be needed to specify which device. If the device has not been specified, an error message message similar to the following will appearː

error: more than one device/emulator

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:

System reboot
The device can be rebooted from adb:

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

Push all files in a folder
Files from the directory will be transferred into storage/on/device. Notice the trailing slash on the directory name is specifiied in the command:

Pull all files in a 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.

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 options
If above command does not work then useː

Print current application in use via dumpsys
This is a good command to figure out how to start the application via am:

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: