安卓自动化的一些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}")
相关推荐
Ruiery5 小时前
Linux 6.6内核 CPU 深度解析(七):调度器启动 — 从单核到多核,调度器分阶段点亮
linux·运维·服务器
50万马克的面包5 小时前
CSDN-栈队列数组-知识点整理
linux·运维·服务器
MicrosoftCloud6 小时前
用户权限 04|/etc/sudoers 安全配置:从最小授权到「别把 ALL 随便给人」
运维·安全·ubuntu·sudo·sudoers
꯭自꯭闭꯭7 小时前
达梦事物特性及MVCC
linux·运维·数据库
亚川楼宇自控系统数据中心厂家8 小时前
实验室智能化管理系统|人环物智一体化管控平台
运维
zmsup9 小时前
Agent 上下文调优:结合 OpsArk 运维智能体,设计模型每一步真正需要的信息
运维·agent·上下文压缩·运维智能体·上下文调优
吴声子夜歌12 小时前
Nginx应用与运维——Nginx负载均衡应用实战(二)
运维·nginx·负载均衡
lisanmengmeng12 小时前
NRPE 添加命令(一)
linux·运维·服务器
pt104312 小时前
CML网络仿真入门-2:使用CML模拟网络实验环境
运维·网络协议
五彩小白13 小时前
自回归和上下文
android