安卓自动化的一些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}")
相关推荐
Goldbioinformatics18 小时前
Windows版Claude Cowork启动Linux问题
linux·运维·windows
念恒1230618 小时前
Ext系列文件系统(下)
linux·运维·服务器
俩个逗号。。19 小时前
Gradle 踩过的坑
android
布吉岛的石头19 小时前
Docker Compose编排实战:多容器应用从开发到生产
运维·docker·容器
身如柳絮随风扬19 小时前
Nginx 完全指南:核心用途、配置文件详解与动态配置实践
运维·nginx
2601_9561394220 小时前
广州VI设计公司哪家强
linux·运维·服务器·python
@encryption20 小时前
RHCE --- 第三节
运维
Vinton_Liu20 小时前
NAT 类型详解:四种 NAT 的数据流与原理解析
运维·服务器
一个处女座的程序猿O(∩_∩)O20 小时前
如何保持nginx配置与前端打包dist的路径保持一致、解决页面刷新白屏以及页面跳转问题
运维·前端·nginx