安卓自动化的一些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}")
相关推荐
Debug 熊猫1 小时前
Nginx代理快速入门(结合vue3简单项目讲解)
运维·nginx
Orange_sparkle1 小时前
Windows/Linux离线部署IndexTTS2
linux·运维·服务器
2501_915909061 小时前
深度解析 iOS 内存占用,构建多工具协同的内存诊断、监控与优化体系
android·ios·小程序·https·uni-app·iphone·webview
番茄灭世神1 小时前
升级新版arm-none-eabi-gcc的方法
linux·运维·arm开发
sang_xb1 小时前
深入解析 HashMap:从存储架构到性能优化
android·java·性能优化·架构
ylmzfun2 小时前
CI/CD技术全景解析:从理念到高效落地的自动化流水线
运维·ci/cd·自动化
安科瑞小许2 小时前
企业能源精细化管理的科学之路:从挑战到智能解决方案
物联网·自动化·能源·智慧能源
Aze..2 小时前
PVE安装 Ubuntu 服务器版
运维·服务器·数据库
zt1985q2 小时前
fnOS 飞牛云 NAS 本地部署开源 TTS 文本转语音工具 EasyVoice 并实现外部访问
运维·服务器·网络协议·开源
java_logo2 小时前
PGADMIN4 Docker 容器化部署指南
运维·数据库·docker·postgresql·容器·数据库系统