delete packages of domain by adb shell pm

后端 未结 3 1389
终归单人心
终归单人心 2021-01-06 13:32

There is a command to ease the pain of managing packages for Android phone,

adb shell pm uninstall org.kde.necessitas.example.one
adb shell pm uninstall org.         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-06 14:22

    If you're sat in a shell on the phone itself, you can do this (all on one line, if you want):

    for i in $(pm list packages com.your.domain ) ; do
        pm uninstall ${i#*:} ;
    done
    

    If you're on the host machine and you're using something Unixy - Linux, Mac, Cygwin - then something similar will work there too, but you need to shove 'adb shell' in:

    for i in $(adb shell pm list packages com.your.domain ) ; do
        adb uninstall ${i#*:} ;
    done
    

    Since you're talking about removing the packages from all connected phones, you need yet another loop:

    for d in $(adb devices | sed '/List/d; /\*/d; s/device$//') ; do
        for i in $(adb -s $d shell pm list packages com.your.domain ) ; do
            adb -s $d uninstall ${i#*:} ;
        done
    done
    

提交回复
热议问题