安卓自动化的一些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}")
相关推荐
一可米1 小时前
gitHub.com Actions自动化发布
运维·自动化·github
智塑未来1 小时前
证券公司智能运维平台哪个品牌做得好?擎创科技智能运维 2.0 适配券商全场景
运维·科技·区块链
酷可达拉斯2 小时前
自动化运维-ansible配置文件与主机清单
linux·运维·自动化·ansible
Lesile2 小时前
Android:Hilt框架入门 · 在ViewUI和ComposeUI下的应用
android·android jetpack
用户423816229073 小时前
Android 16 WebView 页面顶部挖孔/通知栏不能显示UI问题排查
android
来者皆善3 小时前
ZYNQ linux上使用 USB CDC ACM
linux·运维·服务器
4/5$全真龙门3 小时前
廉价易行的内网穿透
运维
weixin_727535623 小时前
Loop 已死,Graph 新生:AI 工作流的范式革命
android·人工智能·rxjava
缓慢更新4 小时前
企业档案管理系统迁移实录:从文件服务器到智能检索引擎
运维·服务器
小北的AI科技分享4 小时前
企业AI开发:从技术选型到落地的关键路径
运维·模型·评估