安卓自动化的一些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}")
相关推荐
studyForMokey1 小时前
【Android面试】Activity生命周期专题
android·面试·职场和发展
3DVisionary1 小时前
突破3C质检产能瓶颈:XTOM蓝光扫描仪配合自动化转台实现精密件批量检测
运维·人工智能·自动化·xtom扫描仪·自动化检测·消费电子质检·良率控制
chehaoman2 小时前
MySQL的索引
android·数据库·mysql
Luke Ewin2 小时前
Linux中部署Qwen3.5大模型
linux·运维·服务器·ai·llm·qwen3.5
xin_yao_xin2 小时前
Windows 下 Docker Desktop 安装教程及常用命令(2026 最新)
运维·docker·容器
春日见2 小时前
云服务器开发与SSH
运维·服务器·人工智能·windows·git·自动驾驶·ssh
还是做不到嘛\.2 小时前
DVWA靶场-Brute Force
运维·服务器·数据库·学习
克莱因3583 小时前
linux主机名与Hosts映射 (顺带个DNS简介
linux·运维·服务器