Skip to content

Commit 36ea4f4

Browse files
committed
优化判断设备是否支持 logcat --uid 命令的代码逻辑
1 parent 247e193 commit 36ea4f4

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

shell/device-tools/DisplayLogcat.sh

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@ cd "${originalDirPath}" || exit 1
1515
unset scriptDirPath
1616
unset originalDirPath
1717

18-
isSupportLogcatUidFilter() {
19-
local deviceId=$1
20-
local outputPrint
21-
outputPrint=$(adb -s "${deviceId}" logcat --help 2>&1)
22-
if echo "${outputPrint}" | grep -q -- "--uid"; then
23-
return 0
24-
else
25-
return 1
26-
fi
27-
}
28-
2918
waitUserInputParameter() {
3019
echo "请输入查看 Logcat 的应用包名(留空则查看所有应用的日志):"
3120
while true; do
@@ -66,7 +55,7 @@ displayLogcatSingleDevice() {
6655
return 1
6756
fi
6857

69-
if isSupportLogcatUidFilter "${deviceId}"; then
58+
if (( androidVersionCode >= 31 )); then
7059
echo "📝 设备支持 uid 过滤,使用原生过滤的方式(UID: ${uid}"
7160
adb -s "${deviceId}" logcat --uid "${uid}" < /dev/null
7261
else

0 commit comments

Comments
 (0)