安卓自动化的一些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}")
相关推荐
AIMath~8 分钟前
hermes agent安装在Linux centos中
linux·运维·服务器
cjp5608 分钟前
001.Web Api_服务器,新建api
运维·服务器
GesLuck22 分钟前
Node-RED企业微信发送—群文件
android·java·企业微信
AC赳赳老秦25 分钟前
用 OpenClaw 整理团队技术分享:自动提取 PPT 内容、生成文字稿、同步到知识库
开发语言·python·自动化·powerpoint·wpf·deepseek·openclaw
whatever who cares27 分钟前
android中fragment demo举例
android·java·开发语言
zhangphil29 分钟前
Android将ImageView显示的图原样取出转换为Bitmap,Kotlin
android·kotlin
plainGeekDev32 分钟前
CountDownTimer → Flow
android·java·kotlin
仙俊红43 分钟前
如何优化 MySQL 深分页 SQL
android·sql·mysql
弹简特1 小时前
【接口自动化】01-pytest详解、pytest执行逻辑、pytest参数、配置文件和pytest标记
自动化·pytest
卧室小白1 小时前
K8S-Pod基本配置
linux·运维·服务器