安卓自动化的一些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}")
相关推荐
雪可问春风20 小时前
docker环境部署
运维·docker·容器
lwx91485220 小时前
Linux-Shell算术运算
linux·运维·服务器
翻斗包菜20 小时前
PostgreSQL 日常维护完全指南:从基础操作到高级运维
运维·数据库·postgresql
somi720 小时前
ARM-驱动-02-Linux 内核开发环境搭建与编译
linux·运维·arm开发
BoomHe21 小时前
Android AOSP13 原生 Launcher3 壁纸获取方式
android
海的透彻21 小时前
nginx启动进程对文件的权限掌控
运维·chrome·nginx
路溪非溪21 小时前
Linux驱动开发中的常用接口总结(一)
linux·运维·驱动开发
Digitally21 小时前
如何将联系人从 Android 转移到 Android
android
航Hang*1 天前
第3章:Linux系统安全管理——第2节:部署代理服务
linux·运维·服务器·开发语言·笔记·系统安全
北方的流星1 天前
华三网络设备的路由重定向配置
运维·网络·华三