Skip to content

Commit bd35462

Browse files
committed
修复获取应用 uid 失败的问题
1 parent b0768c1 commit bd35462

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

shell/device-tools/DisplayLogcat.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ displayLogcatSingleDevice() {
4646
if [[ -z ${packageName} ]]; then
4747
adb -s "${deviceId}" logcat < /dev/null
4848
else
49-
uid=$(adb -s "${deviceId}" shell am getuid -n "${packageName}" 2>/dev/null | cut -d: -f2 | xargs)
49+
local uid
50+
if (( $(getAndroidVersionCodeByAdb "${deviceId}") >= 26 )); then
51+
uid=$(adb -s "${deviceId}" shell pm list packages -U < /dev/null 2>/dev/null | grep "${packageName}" | awk -F 'uid:' '{print $2}')
52+
fi
53+
5054
if [[ -z "${uid}" || ! "${uid}" =~ ^[0-9]+$ ]]; then
5155
uid=$(adb -s "${deviceId}" shell dumpsys package "${packageName}" < /dev/null 2>/dev/null | awk -F'=' '/userId/{print $2; exit}' | awk '{print $1}' | tr -d '\r')
5256
fi

0 commit comments

Comments
 (0)