bat脚本启动mtklog、抓取log文件

本文介绍如何创建一个Windows批处理脚本,通过ADB命令自动启动MTK设备的log,包括设置用户版本日志、检查并启用、以及抓取并保存各种log文件。涉及变量赋值、条件判断和adb命令的整合,便于非专业用户操作。
摘要由CSDN通过智能技术生成
问题描述

有时候我们需要让厂商或者客户提供log文件,需要很多adb指令,不太方便客户使用。
整理成一个脚本文件方便客户查看log抓取是否ok。

1、启动user版本mtk log脚本

Windows下面新建文件,然后修改文件名和后缀,例如 enable_log.bat
ps:对bat和adb的合作方式还不是很熟,纠结了很久

主要卡在:
1、adb获取系统属性后赋值给变量,暂时用的for复制一个变量,感觉有点重
2、if语句 空格要注意 否则提示语法错误
3、goto语句
其它都是常规的adb命令
如果有更好的写法请留言告诉我,脚本我还不熟,请多指教~!

adb.exe  wait-for-device
adb.exe  kill-server
adb.exe  wait-for-device
adb.exe  root
adb.exe  wait-for-device
adb.exe devices
adb.exe wait-for-device

echo enable mtk log
adb.exe shell am broadcast -a com.debug.loggerui.ADB_CMD -e cmd_name start --ei cmd_target -1 -n com.debug.loggerui/.framework.LogReceiver

:checkEnable
@echo off
for /f %%a in ('adb shell getprop vendor.MB.running') do (
  set name=%%a
)
echo %name%

ping -n 2 127.0.0.1 >nul

if %name%==0 (
    goto checkEnable
) else (
    goto Enable
)
:Enable
echo enable successed

pause
2、抓取log

同事提供的脚本、有很多东西,先这样用吧

adb.exe  wait-for-device
adb.exe  kill-server
adb.exe  wait-for-device
adb.exe  root
adb.exe  wait-for-device

mkdir   .\all_log
::mkdir .\all_log\persist
mkdir   .\all_log\data
mkdir   .\all_log\data\vendor
mkdir   .\all_log\Screenshots

mkdir   .\all_log\persist_rfs_msm_mpss
mkdir   .\all_log\data\vendor\data_tombstones
::mkdir ./all_log/data_ss-ram-dumps
::mkdir ./all_log/data_dontpanic
::mkdir ./all_log/data_local_tmp

adb.exe wait-for-device
adb.exe devices
adb.exe wait-for-device
::adb shell vendor/bin/lc_nvram_prinfo read 0 31 
adb.exe shell screencap -p /data/screencap.png
adb.exe pull data/screencap.png   ./all_log/Screenshots
adb.exe pull sdcard/Pictures/Screenshots    ./all_log/Screenshots

adb.exe pull /data/app_dump                                ./all_log/data/
adb.exe pull /data/anr                                     ./all_log/anr/
adb.exe pull /data/local/tmp                               ./all_log/data/
adb.exe pull /data/vendor/aee_exp/      ./all_log/crash_dump/
adb.exe pull /data/aee_exp/       ./all_log/aee_exp/
::adb pull  /sys/fs/pstore/console-ramoops-0             ./all_log/data/vendor/ 
::adb pull /data/vendor/etc/motorola/12m/cqatest_cfg     ./all_log/data/
adb.exe pull /data/vendor/aplogd/                          ./all_log/aplogd/
::adb pull /data/vendor/bt-ram-dumps/                    ./all_log/data/vendor/
adb.exe pull /data/vendor/diag_mdlog                       ./all_log/data/vendor/
adb.exe pull /data/vendor/dontpanic                        ./all_log/data/vendor/
adb.exe pull /data/vendor/power_supply_logger              ./all_log/power_supply_logger/
::adb pull /sdcard/Android/data/com.motorola.motocit/files ./all_log/FOD_CSV
adb.exe pull /data/vendor/ramdump                          ./all_log/data/vendor/
adb.exe pull /data/vendor/ss-ram-dumps/                    ./all_log/data/vendor/
adb.exe pull /data/vendor/ssrdump/                         ./all_log/data/vendor/
adb.exe pull /data/tombstones/                             ./all_log/tombstones/
adb.exe pull /data/misc/radio                              ./all_log/qxdm/
::adb pull /firmware/image/qdsp6m.qdb                    ./all_log/diaglogs/qdsp6m.qdb
::adb pull sys/fs/pstore/console-ramoops-0               ./all_log/data/
::adb pull /vendor/bin/hw/                               ./all_log/hw
::adb pull /data/vendor/wifi/wlan_logs               ./all_log/wlan
::adb pull data/misc/bluetooth/logs                   ./all_log/Bluetooth
adb.exe pull /sdcard/runintest2/                    ./all_log/runintest2/
::adb pull /sdcard/alt_autocycle                  ./all_log/alt_autocycle
::adb pull /sdcard/PASS                                 ./all_log/pass/
::adb pull /data/misc/logd                            ./all_log/logd/
adb.exe pull /data/debuglogger/mobilelog/                       ./all_log/debuglogger
adb.exe pull /storage/emulated/0/debuglogger/   ./all_log/debuglogger

adb.exe pull data/debuglogger/connsyslog/             ./all_log/connsyslog/

::adb pull sdcard/DEPTH_1600x1200.NV21          ./all_log/depth/
::adb pull sdcard/DEPTH_V_1600x1200.NV21      ./all_log/depth/
::adb pull sdcard/MAIN_4640x3472.NV21         ./all_log/depth/
::adb pull sdcard/MAIN_V_4640x3472.NV21     ./all_log/depth/
::adb pull sdcard/WIDE_3264x2448.NV21          ./all_log/depth/
::adb pull sdcard/WIDE_V_3264x2448.NV21       ./all_log/depth/
::adb pull sdcard/cal12.bin                                 ./all_log/depth/
::adb pull /mnt/vendor/persist/camera/dualcal   ./all_log/depth/

::adb pull /mnt/vendor/persist/rfs/msm/mpss/             ./all_log/persist_rfs_msm_mpss
adb.exe shell dumpsys audio               >     ./all_log/audio.txt
adb.exe shell dumpsys media.audio_flinger >     ./all_log/flinger.txt
adb.exe shell dumpsys media.audio_policy  >     ./all_log/policy.txt
adb.exe shell cat /sys/storage/vendor     >     ./all_log/emmcVendor.txt
adb.exe shell getprop                     >     ./all_log/sysprop.txt
adb.exe shell dumpsys sensorservice       >     ./all_log/sensorservice.txt
adb.exe shell pm list packages-f          >     ./all_log/packages.txt


::adb bugreport                         >     ./all_log/bugreport.txt
::adb logcat -b all                    >     ./all_log/log.txt

::adb shell "cat /d/6a00000.dwc3/events > /data/usbcontroller_events.txt"
::adb shell "cat /d/6a00000.dwc3/int_events > /data/usb_int_events.txt"
::adb shell "cat /d/6a00000.dwc3/regdump > /data/usb_regdump.txt"
::adb pull /data/usbcontroller_events.txt .\all_log
::adb pull /data/usb_int_events.txt .\all_log
::adb pull /data/usb_regdump.txt .\all_log
adb shell screencap -p /sdcard/screen.png
::adb pull /sdcard/screen.png .\all_log
::adb shell rm /sdcard/screen.png
::adb shell "bugreport > /sdcard/bugreport.log"
::adb pull /sdcard/bugreport.log .\all_log
::adb shell tcmd_send 00970000
adb.exe bugreport >  .\all_log\bugreport.txt

adb.exe pull /mnt/sdcard/Pictures/Screenshots ./all_log/Screenshots
::adb pull /mnt/sdcard/.csv      ./all_log/touch log

for /F "skip=1 tokens=1,2 delims=:" %%a IN (./all_log/sysprop.txt)  do @if [ro.serialno]==%%a set TrackId=%%b 
for /F "skip=1 tokens=1,2 delims=:" %%a IN (./all_log/sysprop.txt)  do @if [ro.build.description]==%%a set SoftwareVersion=%%b 

@echo %SoftwareVersion%

::for /F "tokens=3,4 delims= " %%a IN ("%SoftwareVersion%")  do set SoftwareVersion=%%a %%b
::@echo %SoftwareVersion%



::@echo %TrackId%
::@echo %SoftwareVersion%

set "TrackId=%TrackId:[=%"
set "TrackId=%TrackId:]=%"
set "TrackId=%TrackId: =%"
::@echo %TrackId%

::set "SoftwareVersion=%SoftwareVersion:~32,11%"
::set "SoftwareVersion=%SoftwareVersion: =%"
::@echo %SoftwareVersion%

:: rule
:: %[cmd]:start, str-num%

::set yyyy=%date:~0,4%
set mm=%date:~5,2%
set dd=%date:~8,2%
set H = %time:~0,2%
set M = %time:~3,5%
set S = %time:~6,2%

set file_name=%mm%-%dd%_%H%%M%%S%_%TrackID%_all_log

echo "sw version" > ./all_log/"%SoftwareVersion%.txt"

::adb reboot bootloader

::fastboot devices

::fastboot oem partition dump logfs  >./all_log/

RENAME all_log %file_name%

pause

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值