安卓自动化的一些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}")
相关推荐
AOwhisky4 分钟前
Linux防火墙管理指南
linux·运维·服务器
白玉瑕16 分钟前
服务器存储基础
运维·服务器
蚊子码农36 分钟前
算法题解记录-208实现Trie前缀树
运维·服务器·算法
RisunJan1 小时前
Linux命令-iptables(配置防火墙规则的核心工具)
linux·运维·服务器
川石课堂软件测试1 小时前
Android和iOS APP平台测试的区别
android·数据库·ios·oracle·单元测试·测试用例·cocoa
UpYoung!1 小时前
【Windows 文件系统管理工具】实用工具之XYplorer 完全指南:专业级文件系统管理的终极解决方案
运维·运维开发·实用工具·文件系统管理·办公学习·xyplorer·windows文件管理工具
叁金Coder1 小时前
【CentOS-Stream-9 配置网卡信息】
linux·运维·centos
石像鬼₧魂石1 小时前
139/445 端口(Samba 服务)渗透测试全流程总结与复习
运维·安全·ssh
赵一舟1 小时前
linux下的磁盘清理
linux·运维·服务器
花卷HJ1 小时前
Android 通用 BaseDialog 实现:支持 ViewBinding + 全屏布局 + 加载弹窗
android