安卓自动化的一些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}")
相关推荐
2401_8322981014 分钟前
云服务器:边缘计算时代的“智能节点”
运维·服务器·边缘计算
Coder_Boy_26 分钟前
基于SpringAI的智能运维平台(AI驱动)
大数据·运维·人工智能
lifewange1 小时前
linux管理服务的命令有哪些
linux·运维·服务器
圆号本昊1 小时前
Flutter Android Live2D 2026 实战:模型加载 + 集成渲染 + 显示全流程 + 10 个核心坑( OpenGL )
android·flutter·live2d
麒qiqi2 小时前
进程间通信(IPC):管道通信全解析
linux·运维·服务器
冬奇Lab2 小时前
ANR实战分析:一次audioserver死锁引发的系统级故障排查
android·性能优化·debug
冬奇Lab2 小时前
Android车机卡顿案例剖析:从Binder耗尽到单例缺失的深度排查
android·性能优化·debug
无奈笑天下3 小时前
银河麒麟V10虚拟机安装vmtools报错:/bin/bash解释器错误, 权限不够
linux·运维·服务器·开发语言·经验分享·bash
ZHANG13HAO3 小时前
调用脚本实现 App 自动升级(无需无感、允许进程中断)
android