adb用最高權限殺程序
adb shell "su -c "kill 16276""
擷取手機目錄檔案
adb shell ls mnt/shell/emulated/0/
檢視程序
adb -s NX510J shell ps |find "com.kugou"
#ls //清單顯示目前檔案夾内容
#rm -r xxx //删除名字為xxx的檔案夾及其裡面的所有檔案
#rm xxx //删除檔案xxx
#rmdir xxx //删除xxx的檔案夾
#mkdir -p xxx //遞歸建立xxx的檔案夾
#cp [選項] [來源檔案] [目的檔案],-d 複制一個快捷方式/-r 複制一個目錄/-i 對一個存在的檔案,詢問是否覆寫
#mv [選項] [來源檔案] [目标檔案],-u 目标檔案存在時才會生效,如果源檔案比目标檔案新才會移動/-i 對一個存在的檔案,詢問是否覆寫;
複制檔案:
複制一個檔案或目錄到裝置:
adb push <source> <destination></destination></source>
如:adb push update.zip /sdcard/
從裝置上複制一個檔案或目錄:
adb pull <source> <destination></destination></source>
如:adb pull /sdcard/update.zip.
def IsContainFile(self,strtmp):
"""判斷手機路徑下是否存在檔案
@param strtmp: 檢視檔案是否存在手機,多個檔案用';'。預設路徑:mnt/shell/emulated/0/
"""
strlog = ""
strfile = strtmp.split(';')
logcmd = "adb shell ls mnt/shell/emulated/0/"
Popen = subprocess.Popen(logcmd, stdout=subprocess.PIPE, shell=True)
sleep(1) //等待subprocess執行
while True:
next_line = Popen.stdout.readline()
if next_line == '' and Popen.poll() != None:
break
strlog = strlog + next_line
for file in strfile:
if strlog.find(file) >= 0:
pass
else:
return False
return True
def GetProcess(strpro="com.kugou"):
"""擷取程序ID
@param strpro: 程序的名字
"""
logcmd = "adb shell ps |find " + '"' +strpro +'"'
proid = []
strtmp = []
Popen = subprocess.Popen(logcmd, stdout=subprocess.PIPE, shell=True)
while True:
next_line = Popen.stdout.readline()
if next_line == '' and Popen.poll() != None:
break
strtmp = next_line.split(' ');
proid.append(strtmp[3])
if len(proid)>0:
return proid
else:
return False
def killProcess(strpro):
"""擷取程序ID
@param strpro: 程序的PID,數組
"""
for strtmp in strpro:
subprocess.call('adb shell "su -c "kill %s""' %strtmp)