码迷,mamicode.com
首页 > 其他好文 > 详细

欢迎使用CSDN-markdown编辑器

时间:2015-08-03 10:16:17      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:shell

!/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

版权声明:本文为博主原创文章,未经博主允许不得转载。

欢迎使用CSDN-markdown编辑器

标签:shell

原文地址:http://blog.csdn.net/kevin_1025745654/article/details/47251357

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!