安卓自动化的一些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}")
相关推荐
w***74405 分钟前
SQL Server 数据库迁移到 MySQL 的完整指南
android·数据库·mysql
摘星编程2 小时前
openGauss 快速上手:CentOS 环境下单机部署完整指南
linux·运维·centos
大喵桑丶7 小时前
中间件快速部署(Nginx,Keepalived)
运维·nginx·中间件
hanyi_qwe8 小时前
文本三剑客--awk
linux·运维·服务器
Caven778 小时前
【Linux 技巧】如何在登录时自动激活 Conda Base 环境
linux·运维·conda
zgyhc20508 小时前
【Android Audio】dumpsys media.metrics分析
android
nono牛9 小时前
Android Binder 详解与实践指南
android·binder
小镇学者9 小时前
【PHP】PHP WebShell(网页木马)分析
android·开发语言·php
凌寒119 小时前
Linux(Debian)安装、卸载 MySQL
linux·运维·mysql·debian
云飞云共享云桌面9 小时前
如何降低非标自动化工厂的研发软件采购成本
运维·服务器·网络·数据库·性能优化·自动化