安卓自动化的一些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}")
相关推荐
mklpo1478 分钟前
为不支持sse4.2命令集的老旧设备制作Win11 26H2系统镜像,2026-10-11。
运维·windows·python
GoldenSpider.AI12 分钟前
用 AI 改流程之前先做「四桶」体检:9 次返工里 8 次靠规则就能消掉(附 Python 发布前校验器)
人工智能·python·自动化·ai智能体
代码方舟16 分钟前
零信任架构实战:基于天远贷前风险报告构建自动化消费信贷资质预审网关
人工智能·架构·自动化
Vex2une31 分钟前
PowerShell 发展史:从命令行外壳到跨平台自动化引擎
windows·自动化·azure·powershell·vs code·脚本语言·dsc
碧海银沙音频科技研究院32 分钟前
炬芯ATS308X的扩音器:麦克风到扬声器直通功能实现
java·linux·运维
吴声子夜歌1 小时前
Docker入门与实战——实战案例(编程开发)(一)
运维·docker·容器
空空dream1 小时前
04 | 用 Jenkins 打通 CI自动构建镜像并推送到本地 Harbor
运维·ci/cd·jenkins
海宇AI1 小时前
零信任架构实战:基于海宇运营商近3个月平均账单构建自动化免押租赁授信网关
运维·人工智能·架构·自动化
此生决int2 小时前
Linux系列(06)——进程概念(上)
linux·运维·服务器
海宇服务2 小时前
零信任架构实战:基于海宇股权穿透构建自动化招投标供应商关联排查网关
运维·人工智能·架构·自动化