安卓自动化的一些API

python 复制代码
def run_adb_command():
    pass

创建指定大小的文件

python 复制代码
def create_random_file(file_path: str, file_size: int = 1024):
        # 1M = 1024 * 1024
        if file_path.endswith("/"):
            raise Exception(f"请输入正确的文件路径:{file_path}")
        file_name = file_path.rsplit("/", 1)[1]
        cmd = "dd if=/dev/zero of={} bs={} count=1".format(file_path, file_size)
        result = run_adb_command(func=cmd)
        if file_name in run_adb_command(func=f"ls {file_path}"):
            return True
        raise Exception(f"创建文件失败: {result}")

查看安卓系统时间

python 复制代码
def get_android_time(format: str = "+%Y%m%d%H%M%S"):
        """
            format:
                "+%Y%m%d%H%M%S": 20240612042045
                "+%F": 2024-06-12
                "+%R": 04:20
                "+%s": 1718241156
        """
        return run_adb_command(func=f"date {format}")
相关推荐
好的佩奇20 分钟前
蓝牙之 GATT 数据操作
android·flutter·蓝牙
workflower1 小时前
如何培养FDE-3
前端·网络·安全·机器人·自动化
志栋智能1 小时前
超自动化安全的报告自动生成与分发
运维·安全·自动化
三少爷的鞋1 小时前
Android 面试系列之-lifecycleScope 和 CoroutineScope(Dispatchers.Main)
android
海宇服务3 小时前
零信任架构实战:基于海宇企业司法涉诉构建自动化分包商准入合规审查网关
数据库·人工智能·架构·自动化
Mars-xq3 小时前
Android studio下载很慢download fail
android·ide·android studio
开开心心就好3 小时前
定时结束进程的小工具,到点还能关机
linux·运维·服务器·智能手机·pdf·电脑·word
风翼靓崽3 小时前
ansible
linux·运维·ansible
2501_915909064 小时前
iOS 上架 App Store 后推送收不到,APNs 证书和生产沙盒环境排查
android·小程序·https·uni-app·iphone·webview
吃不胖爹4 小时前
安卓原生开发的app如何打包成应用
android