安卓自动化的一些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}")
相关推荐
ai小陈4 小时前
GPU服务器租用存储验收:检查点写入与磁盘吞吐实战
运维·服务器·人工智能·ai·ssh·gpu算力
有毒的教程6 小时前
VMware仅主机模式:物理机 ↔ 虚拟机 文件共享
运维
山岚的运维笔记9 小时前
ComfyUI NVIDIA安装教程:官方便携版下载+run_nvidia_gpu.bat启动,8G显存Windows实操
运维·服务器·windows·笔记·prompt·aigc·comfyui
海宇大数据9 小时前
零信任架构实战:基于海宇活体识别V步骤1构建自动化远程公证会话初始化网关
运维·人工智能·架构·自动化
lisanmengmeng10 小时前
Nagios邮件报警的配置
linux·运维·服务器
Ruiery10 小时前
Linux 6.6内核 CPU 深度解析(六):cpufreq
linux·运维·服务器
天远数科10 小时前
零信任架构实战:基于天远全能消金报告构建自动化消费分期网关
运维·人工智能·架构·自动化
硅基手札11 小时前
【linux内核专栏 08】时间与定时器
linux·运维·服务器
想做小南娘,发现自己是女生喵11 小时前
Linux之Ubuntu入门篇知识总结
linux·运维·服务器
帷幕落秋12 小时前
Redis哨兵模式
运维·数据库