欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

获取某个app的userid的方法

程序员文章站 2024-03-20 17:49:40
...

1、通过adb shell ps|grep package获取进程pid,执行adb shell cat /proc/<pid>/status获取Uid=10099

State:  S (sleeping)
Tgid:   11861
Pid:    11861
PPid:   544
TracerPid:      0
Uid:    10099   10099   10099   10099
Gid:    10099   10099   10099   10099
Ngid:   0
FDSize: 128
Groups: 3003 9997 50099
VmPeak:  2167612 kB
VmSize:  2122792 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:    154452 kB
VmRSS:    149980 kB
VmData:   213440 kB
VmStk:      8196 kB
VmExe:        16 kB
VmLib:    137876 kB
VmPTE:      1032 kB
VmSwap:        0 kB

2、通过执行adb shell cat /data/system/packages.xml(package.list)获取uid=10099

        <item name="com.miui.userguide.permission.MIPUSH_RECEIVE" package="com.miui.userguide" protection="2" />
    <package name="com.miui.userguide" codePath="/system/app/Userguide" nativeLibraryPath="/system/app/Userguide/lib" publicFlags="944291397" privateFlags="0" pkgFlagsEx="0" ft="1671b848950" it="166a7009830" ut="1671b848950" version="10010203" userId="10099" cpuAbiDerived="true" installer="com.xiaomi.market">
            <item name="com.miui.userguide.permission.MIPUSH_RECEIVE" granted="true" flags="0" />

转载于:https://www.jianshu.com/p/16f84983c90b