开发我流程里我们无法直接调试手机时,需要根据日志分析一些崩溃或者异常问题。以下为脚本示例,仅供参考。
注意:需要提前配置好adb的环境变量
@echo off
set ver_str=3.13
echo =====================GetLog version %ver_str% ================================
adb start-server
adb devices|findstr /e device
if %errorlevel% EQU 0 (
echo ####find devices ................ [device] .........................
goto START
)
adb devices|findstr /e recovery
if %errorlevel% EQU 0 (
echo ####find devices ................ [recovery] .........................
goto START
)
echo !!!!!!!!!!!!!!!!!Can't find device!!!!!!!!!!!!!!!!!!!
goto END
:START
echo ####
:: echo Current: %time% 即 %time:~0,2%点%time:~3,2%分%time:~6,2%秒%time:~9,2%厘秒@
echo ####Current: %date% %time%
set date_time="%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%"
for /f "delims=" %%a in ('adb shell getprop ro.product.model') do set model=%%a
for /f "delims=" %%b in ('adb shell getprop ro.serialno') do set serialno=%%b
set Folder="%model%_BSN_%serialno%_Logs_%ver_str%_%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%"
echo ####start to get log to (%CD%\%Folder%)...
mkdir %Folder%
::======================Android light log===================================
:: common logs from android
echo ####get dmesg to dmesg.txt ...
adb shell dmesg > %Folder%\dmesg.txt
echo ####get ps list to ps.txt ...
adb shell ps > %Folder%\ps.txt
echo ####get ps thread list to ps_t.txt ...
adb shell ps -t > %Folder%\ps_t.txt
echo ####get properties to prop.txt ...
adb shell getprop > %Folder%\prop.txt
adb pull /data/user_de/0/com.huawei.powergenie/ %Folder%/com.huawei.powergenie/
::adb pull /system/app/HwPowerGenieEngine3/ %Folder%/
adb pull /data/user_de/0/com.huawei.powergenie/ %Folder%/com.huawei.powergenie/
adb pull /data/user/0/com.huawei.powergenie/databases/secesleep/ %Folder%/secesleep/
adb shell dumpsys powergenius -a > %Folder%/svcpowergenius.txt
adb shell dumpsys power > %Folder%/svcpower.txt
adb shell dumpsys alarm > %Folder%/svcalarm.txt
adb shell dumpsys deviceidle > %Folder%/svcdeviceidle.txt
adb shell dumpsys batterystats > %Folder%/svcbatterystats.txt
adb shell dumpsys activity services > %Folder%/svcservices.txt
adb shell dumpsys activity recents > %Folder%/svcrecents.txt
adb shell dumpsys activity processes > %Folder%/svcprocesses.txt
:: ======================TERMINL LOG========================================
:: get huawei persist log
echo ####get android_logs to .\android_logs ...
adb pull /data/log/android_logs/ %Folder%/android_logs/
adb pull /data/log/sleeplog/ %Folder%/sleeplog/
adb pull /data/log/charge-log/ %Folder%/charge-log/
adb pull /data/log/tcpdump/ %Folder%/tcpdump/
adb pull /data/log/dubai/ %Folder%/dubai/
adb shell dumpsys DubaiService --dumpDb
adb pull /data/log/dubai/dump %Folder%/dubai-new/
adb pull /data/log/dropbox/ %Folder%/dropbox/
adb pull /data/log/sensorhub-log/ %Folder%/sensorhub-log/
adb pull data/log/hilogs %Folder%/hilogs/
adb pull data/tombstones %Folder%/tombstones/
::=======================common logs ========================================
echo ####get adb log to .\adb-log
adb pull /data/log/adb/ %Folder%/adb-log/
REM echo ####get radio logcat to logcat_ril.txt ...
REM adb shell logcat -v threadtime -d -t 1000 -b radio > %Folder%\logcat_ril.txt
REM echo ####get AT logcat to logcat_at.txt ...
REM adb shell logcat -v threadtime -d -t 1000 -b radio -s AT > %Folder%\logcat_at.txt
echo ===============get log end; please check folder=%Folder%=========================
:END
pause
@echo on
评论区