安卓自动化的一些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}")
相关推荐
私人珍藏库6 小时前
【Android】Soul v5.86.0 内置模块版
android·app·工具·软件·多功能
EMTime6 小时前
Docker运行OpenWRT
运维·docker·容器
千里马学框架6 小时前
aosp新增窗口层级 Type 完整实现方案(有源码)-wms需求和面试题
android·智能手机·架构·wms·aaos·车机
lolo大魔王7 小时前
Linux 文件系统超全面详解(原理、结构、挂载、分区、inode、日志、管理命令)
linux·运维·服务器
zyl837219 小时前
Docker 使用手册
运维·docker·容器
古月方枘Fry9 小时前
MGRE实验
运维·服务器
stolentime10 小时前
FreeDomain 本地开发环境快速搭建指南
运维·服务器·网络
bush411 小时前
嵌入式linux学习记录四
linux·运维·学习
峥嵘life12 小时前
Android 蓝牙设备连接广播详解-2026
android·python·学习
lihao lihao12 小时前
软硬链接
linux·运维·服务器