From 9762569832c1112a62777b937961aea3bf01b424 Mon Sep 17 00:00:00 2001 From: lxh2875931338 Date: Fri, 23 Oct 2026 21:09:40 +0800 Subject: [PATCH] =?UTF-8?q?chore(tools):=20device-check=20=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=20Flyme=20=E8=A7=A3=E5=86=BB=EF=BC=8C=E9=87=8D?= =?UTF-8?q?=E8=AF=95=E6=97=B6=E5=BB=B6=E9=95=BF=E7=AD=89=E5=BE=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/device-check.ps1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/device-check.ps1 b/tools/device-check.ps1 index 93fd13d..ce5ef73 100644 --- a/tools/device-check.ps1 +++ b/tools/device-check.ps1 @@ -79,19 +79,21 @@ $creates = 0 # Flyme 有时不会立刻杀掉带前台服务的进程,导致抓不到启动日志:确认进程消失 + 最多重试两次 for ($attempt = 1; $attempt -le 2; $attempt++) { & adb -s $DeviceId shell am force-stop $pkg | Out-Null - $deadline = (Get-Date).AddSeconds(6) + $deadline = (Get-Date).AddSeconds(10) while ((& adb -s $DeviceId shell pidof $pkg) -and (Get-Date) -lt $deadline) { Start-Sleep -Milliseconds 300 } + # 进程还在说明被系统冻结/保活,直接等到超时也无意义,先给它一点时间解冻 + Start-Sleep -Seconds 1 & adb -s $DeviceId logcat -c - # 用 MAIN/LAUNCHER 意图启动:applicationId 带 .dev 后缀时, - # "am start -n $pkg/.MainActivity" 会把 .MainActivity 拼到 .dev 上,导致找不到类。 # 解析真正的启动组件再启动:applicationId 带 .dev 后缀时, # "$pkg/.MainActivity" 会把 .MainActivity 拼到 .dev 上导致找不到类; # 而 "am start -p $pkg" 在部分 ROM 上又解析不到,所以直接问 PackageManager。 $component = (& adb -s $DeviceId shell cmd package resolve-activity --brief $pkg 2>&1 | Select-Object -Last 1).Trim() & adb -s $DeviceId shell am start -W -n $component 2>&1 | Out-Null - Start-Sleep -Seconds $WaitSeconds + # 第一次按参数等待;第二次重试时多等一会儿(Flyme 解冻可能很慢) + $waitThisTime = if ($attempt -eq 1) { $WaitSeconds } else { [Math]::Max($WaitSeconds, 20) } + Start-Sleep -Seconds $waitThisTime & adb -s $DeviceId logcat -d -v time > $logPath # 注意:PS 5.1 的 > 重定向写出的是 UTF-16LE(带 BOM),读取时不要强制 utf8 $log = Get-Content $logPath