adb命令的练习
#!/usr/bin/env python
# encoding: utf-8
import os
import re
nameplt=re.compile("package: name='(.*?)' versionCode")
activityplt=re.compile("launchable activity name='(.*?)'label=")
adbshell="adb shell"#启用shell命令可以直接操作Android系统
adbstr="adb push D:/1.txt /mnt/txt/1.txt"#把电脑的文件推送到安卓
adbpng1="adb pull /sdcard/screencap.png d://"
adbpng2="adb pull /sdcard/screencap.png d://1.png"
adb_use_screencap="adb shell /system/bin/screencap -p /sdcard/667.png" #截取安卓的屏幕
adbpng3="adb pull /sdcard/667.png d://3.png" #把安卓的截图导入到电脑
get_app_info="adb shell pm list packages"#获取模拟器所有包名
change_disk=r"D:\Program Files\Nox\bin"
os.chdir(change_disk)
get_com_info=r"aapt dump badging D:\douyin.apk > douyin.txt"#获取抖音app的com信息
os.system(get_com_info)
with open("douyin.txt","r",encoding="utf-8") as fs:
donyin=fs.read()
donyin_package_name=nameplt.findall(donyin)[0]
douyin_activity_name=activityplt.findall(donyin)[0]
print("抖音activity",douyin_activity_name)
print("抖音的包名",donyin_package_name)
##os.system(adb_use_screencap)
# #print(os.system(adbpng3))
start_app=f"adb shell am start -n {donyin_package_name}/{douyin_activity_name}"
print("启动抖音")
os.system(start_app)
#2、如何把模拟器里面的文件或文件夹传到电脑上?
#print(os.system("adb pull /sdcard/screencap.png d:\\1.png"))
Unable to chmod sdcard: Read-only file system
cmd执行
adb shell
重挂载文件系统
mount -o remount rw /
再次执行
chmod 777 sdcard