安卓自动化的一些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}")
相关推荐
polaris06301 分钟前
学生成绩管理系统(MySQL)
android·数据库·mysql
ljh5746491194 分钟前
Linux find命令
linux·运维·chrome
东方不败之鸭梨的测试笔记8 分钟前
基于RF自动化重跑
运维·自动化
纪伊路上盛名在12 分钟前
Zerotier-Tailscale 自动化监控
linux·运维·自动化·内网穿透
__Yvan13 分钟前
Kotlin 的 ?.let{} ?: run{} 真的等价于 if-else 吗?
android·开发语言·前端·kotlin
无忧智库15 分钟前
大型能源集团的数字中枢:EA框架如何驱动ERP系统从“流程自动化”迈向“智能决策”(PPT)
运维·自动化·能源
培小新25 分钟前
五、Dokcer网络
linux·运维·docker·容器
tangweiguo0305198729 分钟前
Android WorkManager 完整实战教程(含完整文件)
android·kotlin
杭州杭州杭州1 小时前
Docker实验2----4
运维·docker·容器
loitawu1 小时前
Rockchip Android16 系统裁剪指南
android·android16·android裁剪·系统裁剪·rockchip app