安卓自动化的一些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}")
相关推荐
做咩啊~几秒前
CentOS 7部署OpenLDAP+phpLDAPadmin实现统一认证
linux·运维·centos
^乘风破浪^6 分钟前
Centos升级openssh及openssl
linux·运维·centos
满天星83035777 分钟前
【Linux】【进程间通信】管道
linux·运维·服务器
linux修理工8 分钟前
CentOS Stream 9 软件仓库 清华源
linux·运维·centos
城东米粉儿8 分钟前
为ViewGroup 对象的布局更改添加动画效果 笔记
android
naodianbozzz9 分钟前
nginx的https的搭建
运维·nginx·https
liefyuan10 分钟前
【嵌入式Linux】添加sshd (顺便dropbear--scp命令)
linux·运维
松☆11 分钟前
OpenHarmony + Flutter 多语言与国际化(i18n)深度适配指南:一套代码支持中英俄等 10+ 语种
android·javascript·flutter
_李小白11 分钟前
【Android FrameWork】第十八天:Binder服务
android·microsoft·binder
Han.miracle14 分钟前
JavaEE--网络编程 传输层 (一) UDP TCP特点
运维·服务器·网络·java-ee·三次握手·四次挥手·超时重传