安卓自动化的一些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}")
相关推荐
shih9454 小时前
16G 内存不够用之后,我把旧安卓手机接进了 k3s 集群
android·k3s
阿杰m5 小时前
Android源码第三十章:Android Automotive、TV 与桌面模式
android
fengkai45459 小时前
Python运维
运维·python·监控·psutil·ipy
无足鸟ICT12 小时前
【RHCA+】_proc_pid_task_
linux·运维·服务器
AAwangzong13 小时前
从RPA到APA:企业级智能体如何复用自动化资产?
人工智能·经验分享·自动化·rpa
意念回复14 小时前
Transformer 系列(五):从 Block 到模型——三大架构、因果掩码与自回归生成
android·回归·transformer
weixin_4046793114 小时前
cc 在 linux 安装
linux·运维·服务器
云上工程笔记15 小时前
大模型平台私有化部署怎么选?2026年合规要求、运维难度与架构成本评测
运维·架构
松仔log16 小时前
Kotlin中级——KMP
android·开发语言·kotlin
GY-9316 小时前
【Android】SQL数据库
android