安卓自动化的一些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}")
相关推荐
保持低旋律节奏2 分钟前
linux——make/Makefile自动化工程构建
linux·运维·自动化
周杰伦_Jay13 分钟前
【Linux Shell】命令完全指南
linux·运维·服务器
乾元13 分钟前
SDN 与 AI 协同:控制面策略自动化与策略一致性校验
运维·网络·人工智能·网络协议·华为·系统架构·ansible
sky北城19 分钟前
Linux的回收站机制实现方式总结
linux·运维·服务器
水滴与鱼1 小时前
DOCKER制作ROS运行的镜像文件
运维·docker·容器
董三毛1 小时前
Kotlin Coroutine 底层实现原理
android
L108701 小时前
AutoJsPro GoogleMaterial3 M3组件使用示例
android
实心儿儿2 小时前
Linux —— 基础开发工具4
linux·运维·服务器
一尘之中2 小时前
Linux命令行查看磁盘大小完全指南
linux·运维·ai写作
马儿能够一直跑2 小时前
同一个环境中安装两个不同版本esp-idf的python冲突解决方案
linux·运维·服务器