欢迎使用优快云-markdown编辑器

!/bin/bash

MAX_TO_UNINSTALL=10;

function list_installed {
adb shell pm list packages | grep “$1” | sed s/package://g | tr -d ‘\r’
}

function count_installed {
echo $1 | wc -w
}

function uninstall {
PACKAGES=(listinstalled1)
INSTALLED=(echoPACKAGES | wc -w)

echo Found $INSTALLED matching apps:
list_installed $1 | sed "s/^/    /"

echo ""
if [ $INSTALLED -gt $MAX_TO_UNINSTALL ]; then
    echo "For security reasons cannot uninstall more than $MAX_TO_UNINSTALL apps"
    exit
elif [ $INSTALLED -eq 0 ]; then
    echo "Did not uninstall any apps"
    exit
fi

echo "Are you sure you want to uninstall these? (y/n)"
read ANSWER
echo ""
if [ "$ANSWER" = "y" ]; then
    echo $PACKAGES | xargs -n 1 adb uninstall
else
    echo "Did not uninstall anything"
fi

}

function check_devices {
CONNECTED=$(adb devices | wc -l)

if [ $CONNECTED -le 2 ]; then
    echo "No devices connected"
    echo "Did not uninstall any apps"
    exit
elif [ $CONNECTED -gt 3 ]; then
    echo "Too many devices connected ($(($CONNECTED-2)))"
    echo "Did not uninstall any apps"
    exit
fi

}

function check_input {
if [ -z “$1” ]; then
echo “You need to specify a package to uninstall”
exit
fi
}

echo “”
check_input 1checkdevicesuninstall1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值