ADB detailed explanation and fastboot take Xiaomi as an example


foreword

Some system apps can be disabled using ADB commands (without root).
Generally uninstall system software Take system update as an example, there are two ways:
1) Disable ADB tool uninstallation.
2) Obtain root privileges, flash modules to disable upgrades.
This article describes the first method. This method is more secure and reliable than rooting.
However, it also needs to be used with caution, and it cannot be deleted randomly to cause bricking.


1. What is ADB and fastboot?

The full name of ADB is Android Debug Bridge. The role of the debug bridge is the debugging interface. It is a client-server (Android) program. ADB is a tool of Android SDK, which directly operates and manages Android devices.

ADB connection physical method:
adb supports two ways to connect to the Android system, USB and network. Generally, the android device will be set to the USB method by default (directly plugging in the data cable). A service (adbd) is running at the bottom of the android system. Inside the mobile phone system, manage the adb command connection on the computer side. This service will monitor the USB connection or network according to the configuration of the mobile phone when it starts.

How to connect the mobile phone with ADB command The mobile
phone is connected to the computer via USB (install the driver first) or WiFi. The
mobile phone turns on the debugging mode: Options-click the version number 8 times until the developer mode prompt pops up-developer options-debug mode
task manager close the mobile assistant software , to avoid port conflicts

adb devices 则默认连接到手机,默认端口为5037(USB)
adb connect/disconnect 手机IP地址(WiFi)

Some commands and folder execution require ROOT permission.
The adb version must match the mobile phone system.

Two, ADB installation

1. ADB download

ADB download address 1: https://adbshell.com/downloads
ADB download address 2: https://developer.android.com/studio/releases/platform-tools.html
Go to https://adbshell.com/downloads and select ADB Download the Kit toolkit. After the download is complete and decompressed, you can get the following three core files:
ADB

2.ADB driver installation

Generally, the data cable is directly inserted and installed automatically.

3.ADB installation

Method 1:
My Computer-"Right-click Properties-"Advanced System Settings-"Environment Variable Path-"Add adb tool path.
Method 2:
Cut the three files into the following two directories
C:\Windows\System32
C:\Windows\SysWOW64
ADB

4. fastboot installation

Fastboot, means quick start. Fastboot is a firmware communication protocol for a computer to flash, erase/format, debug, and transmit various instructions to a mobile phone's firmware through a USB data cable. It is also a command-line tool in Google's Android SDK Platform Tools. The USB driver for the phone needs to be installed on the computer.

In Android phones, Fastboot is a lower-level flashing mode than recovery (commonly known as fast boot mode).
Compared with some system card brushes, wire brushes are more reliable and safe. Fastboot literally means quick start, and it can also be regarded as a flashing interface, but it is lower than recovery, and this bottom layer is closer to the hardware layer.

When the phone cannot enter recovery, it can also enter Fastboot to save. When you cannot enter Fastboot, there are also Qualcomm 9006/9008 ports, MTK ports, and QCN ports that can be saved. But when the computer can't even connect to these phone flashing ports, it's a brick.

Three, ADB use

Step
1) Mobile phone - "Enter developer options -" Turn on USB debugging
2) Connect the mobile phone data cable to the computer - "Computer cmd enters the small black box
3) Use the adb command, see Chapter 4 for details.
For example, check all the packages in the system
to uninstall the system
You can unplug the data cable after uninstalling the apps in

Four, ADB common commands

adb devices		//查看adb已连接的设备信息,出现序列号和device表示已正常连接设备
adb shell pm list packages		//查看所有已安装应用的包名
adb shell pm uninstall -k --user 0 包名		//卸载包名所对应的软件(卸载命令1)
adb uninstall 包名		//卸载包名所对应的软件(卸载命令2,与卸载命令1功能相同,2选1即可)

1. Check the adb version

C:\Users\30608>adb version
Android Debug Bridge version 1.0.29

There are also other effects, it should be that there is a problem with the installation path

E:\other>adb version
Android Debug Bridge version 1.0.41
Version 29.0.1-5644136
Installed as C:\Windows\system32\adb.exe

2. View all packages in the system

adb shell pm list packages
insert image description here

3. Uninstall the software corresponding to the specified package name

adb shell pm uninstall -k --user 0 package name

How to choose the corresponding software package
Method 1) View the uninstalled software package name on the mobile phone through third-party software (such as APK viewer, etc.), for example, the package name of the system update here is com.android.updater
Method 2) Open the system settings— —Application Management, select "Show System Services" in the upper right corner. Click the application below, and then click the ⓘ icon in the upper right corner to view the application package name.
Prompt Success means uninstallation is successful. Take uninstalling system updates as an example
insert image description here
More adb commands https://adbshell.com/

用来连接设备
adb connect ip地址
断开设备
adb disconnect ip地址
终止adb服务/启动adb服务
adb kill-server/start-server
启动service
adb shell am startservervice
启动activity
adb shell am start -n 包名/类名
列出所有的选项说明及子命令
adb help

重启到recovery和fastboot
adb reboot recovery
adb reboot fastboot

安装APK:adb install [-lrtsdg] <path_to_apk>
卸载应用:adb uninstall [-k] <packagename>

清除应用数据和缓存:adb shell pm clear <packagename>
强制停止应用:adb shell am force-stop <packagename>

测试  得到1个小时,设置次数可能在百万以上
adb shell monkey -p com.xyy.vwill -s 100 10000--momkey

monkey日志分析:日志: app的日志(adb logcat :crash anr error等日志) monkey执行日志(执行过程,正常结束,异常结束,执行了哪些事件,执行时长)
关闭WiFi
adb shell svc wifi disable
开启WiFi
adb shell svc wifi enable
ping网络动态
ping -c 1 -w 1 119.29.29.29/ping 119.29.29.29

连接设备,传输文件从设备传到电脑
adb pull 文件路径 D:/file/20220421.txt(存放的文件路径和文件名)
从电脑传到设备端
adb push C:/users/desktop/gc2093_default_JX8006.json  vendor/etc/camera/rkisp2/gc2093_YT-RV1109-2-V2_40IR-2MP-F20.json

当传输文件提示没有权限,需要获得权限 adb root   adb  remount
adb shell screencap -p /sdcard/screenshots/01.png/adb pull /sdcard/screenshots D:/file--adb命令截图
消除屏幕图案:adb shell rm /data/system/gesture.key
截图:adb shell screencap <文件保存路径>
adb shell screencap /sdcard/screen.png--手机截图保存到SD卡
录像:adb shell screenrecord <文件保存路径>
注:Ctrl + C停止屏幕录制,或者到三分钟停止,且没有声音

adb shell
su
wm density--查看设备密度
wm density 120--改密度

卸载应用程序
adb uninstall com.imstlife.anaerobic
安装(可以直接拖到文件到cmd里,cmd自动识别路径)
adb install anaerobic.apk
adb shell pm list packages -3--显示第三方应用包名

设备压力测试
adb shell
su
am start -n com.cghs.stresstest/.StressTestActivity

权限
adb shell
su
chmod -R 777 vendor

查询手机cpu和内存信息
adb shell cat /proc/cpuinfo
adb shell cat /proc/meminfo
adb shell ps
adb shell kill pid

连接并进入设备:adb shell
发送广播:adb shell am broadcast -a 广播action
文件传输(复制):
传到板子:adb push <本地路径> <板子路径>
从板子传回:adb pull <板子路径> <本地路径>
adb push C:\a.txt /sdcard/
adb pull /sdcard/a.txt C:\

关机:cmd:adb shell reboot -p  serial:reboot -p
重启并进入烧录模式:cmd:adb shell reboot efex   serial:reboot efex

消除密码:adb shell rm /data/system/password.key

串口电量:echo 1 > /sys/class/axppower/axpdebug
查询当前充电电流:cat /sys/class/power_supply/battery/current_now

滑动解锁:adb shell input swipe x1 y1 x2 y2
注:1为起始坐标,2为终点坐标

点击操作:adb shell input tap x y
注:x,y为要点击的坐标

禁止休眠:echo testlock > /sys/power/wake_lock
恢复可休眠:echo testlock > /sys/power/wake_unlock

切换HMDI输出模式:echo 720p50hz > /sys/class/disp/disp/attr/hdmi_test_mode

查看SD卡是否被识别(定位驱动):ls /dev/block
查看各分区容量:df

查询当前策略:cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

切换策略:echo fantasys > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

获取log:
adb shell logcat -v time >>c:\1.5rc2#55-bug-logcat.log
adb shell dmesg >> c:\1.2-#01--BUG描述-dmesg.log
adb shell mount >> c:\1.2-#46-mount.log
logcat-- 查看日志
    adb logcat -v time *:W |grep pid > /data/data/log.txt
    adb pull /data/data/log.txt d:/log/
    adb shell "logcat -v time *:W |grep pid " > d:/log/log.txt
    adb logcat -c

日志的指令
logcat -v time -n 10 -r 102400 -f /sdcard/logcat.txt(一直发送)
logcat -v time -n 10 -r 102400 -f /sdcard/logcat.txt &(发送一次)

Organize the applications that can be deleted (the test can be used normally after deletion)
com.miui.systemAdSolution (Xiaomi System AdSolution, must be deleted) com.miui.analytics (Xiaomi Advertising Analysis, must be deleted) com.xiaomi.gamecenter.sdk.service (Xiaomi Game Center Service) com.xiaomi.gamecenter (Xiaomi Game Center) com.sohu.inputmethod.sogou.xiaomi (Sogou Input Method) com.baidu.input_mi (Baidu Input Method Xiaomi Version) com.miui.player (Xiaomi Music) com.miui.video (Xiaomi Video) com.miui .notes (Xiaomi notes) com.miui.translation.youdao (Youdao translation) com.miui.translation.kingsoft (Kingsoft translation) com.android.email (mail) com.xiaomi.scanner (Xiaomi scan) com.miui. hybrid (mixer) com.miui.bugreport (bug feedback) com.milink.service (Milian service) com.android.browser (browser) com.miui.gallery (album) com.miui.yellowpage (yellow page) com .xiaomi.midrop (Xiaomi Express) com.miui.virtualsim (Xiaomi Virtualizer) com.xiaomi.payment (Xiaomi Pay) com.mipay.wallet (Xiaomi Wallet) com.android.soundrecorder (recorder) com.miui.screenrecorder (screen recording) com.android.wallpaper (wallpaper) com.miui.voiceassist (voice assistant) com.miui.fm (radio) com.miui.touchassistant (floating ball) com.android.cellbroadcastreceiver (Xiaomi Broadcasting) com.xiaomi.mitunes (Xiaomi Assistant) com.xiaomi.pass (Xiaomi card package) com.android.thememanager (personality theme management) com.android.wallpaper (live wallpaper) com.android.wallpaper.livepicker (Live wallpaper acquisition) com.miui.klo.bugreport (KLO bug feedback)
Domestic version of MIUI
com.miui.cloudservice (Xiaomi cloud service)
com.xiaomi.account (Xiaomi account)
com.android.updater (system update)
com.miui.cloudbackup (cloud backup)
com.xiaomi.market (application market)
com .xiaomi.finddevice (find phone)
com.lbe.security.miui (privilege management service)
com.miui.securitycenter (mobile housekeeper)
MIUI international version (European version miui.eu) application package name (European version can be deleted at will)
com .google.android.googlequicksearchbox (Google)
com.miui.miservice (service and feedback)
com.mi.health (health)
com.mi.globalbrowser (international browser)
com.miui.huanji (Xiaomi replacement)
com. miui.newmidrive (Xiaomi Cloud Disk)
com.miui.bugreport (User Feedback)
com.miui.personalassistant (Smart Assistant)
com.android.hotwordenrollment.xgoogle (Google Assistant 1)
com.android.hotwordenrollment.okgoogle (Google Assistant 2)
com.xiaomi.mirecycle (Xiaomi recycling)
com.miui.videoplayer (Xiaomi video international version)
com.google.android.projection.gearhead (Google Auto/Google car)
com.google.android.gms.location.history (Google geographic Location History)
com.google.ar.lens (Google Smart (Virtual) Camera)

Five, fastboot common commands

How to connect fastboot to the mobile phone
Turn off the mobile phone and enter the bootloader mode, connect to the computer with a USB data cable

列出与电脑连接的设备
fastboot devices
解锁
fastboot oem unlock 解锁码
上锁
fastboot oem lock
刷入boot分区
fastboot flash boot boot.img 
刷入system分区
fastboot flash system system.img
 刷入recovery分区
fastboot flash recovery recovery.img
刷入引导+恢复+系统镜像文件
fastboot flashall
重启设备
fastboot reboot
重启到BootLoader 
fastboot reboot-bootloader
擦除系统分区
fastboot erase system
获取手机信息
fastboot getvar all

Summarize

工具下载
https://download.csdn.net/download/CHengYuP/87700055
谨慎删除。
引用链接
1)https://blog.csdn.net/weixin_69681418/article/details/125995030
2)https://blog.csdn.net/hhx123456798/article/details/121483826
3)https://blog.csdn.net/m0_60352504/article/details/120087498?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-1-120087498-blog-121483826.235%5Ev29%5Epc_relevant_default_base3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-1-120087498-blog-121483826.235%5Ev29%5Epc_relevant_default_base3&utm_relevant_index=2

Guess you like

Origin blog.csdn.net/CHengYuP/article/details/130200079