安卓自动化的一些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}")
相关推荐
好好学习天天向上~~7 分钟前
6_Linux学习总结_自动化构建
linux·学习·自动化
doupoa16 分钟前
内存指针是什么?为什么指针还要有偏移量?
android·c++
wangjialelele1 小时前
Linux下的IO操作以及ext系列文件系统
linux·运维·服务器·c语言·c++·个人开发
非凡ghost1 小时前
PowerDirector安卓版(威力导演安卓版)
android·windows·学习·软件需求
HypoxiaDream1 小时前
LINUX-Ext系列⽂件系统
linux·运维·服务器
小毛驴8501 小时前
Linux curl 命令用法
linux·运维·chrome
李斯啦果2 小时前
【Linux】Linux目录配置
linux·运维·服务器
AI+程序员在路上2 小时前
linux下线程中pthread_detach与pthread_join区别
linux·运维·服务器
独行soc2 小时前
2026年渗透测试面试题总结-19(题目+回答)
android·网络·安全·web安全·渗透测试·安全狮
logocode_li2 小时前
说透 Linux Shell:命令与语法的底层执行逻辑
linux·运维·ssh