安卓自动化的一些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}")
相关推荐
笨鸟先飞,勤能补拙几秒前
Web 服务器与计算机网络全景原理
运维·服务器·前端·网络·人工智能·计算机网络·web安全
caimouse11 分钟前
ReactOS 图形系统分析(3):显示驱动 DDI framebuf.dll
linux·运维·网络
小孔龙11 分钟前
GraphicBuffer 跨进程共享
android
代码方舟12 分钟前
零信任架构实战:基于天远车辆vin码查车辆信息详版构建自动化汽车金融审批网关
人工智能·架构·自动化·汽车
qq_2676128923 分钟前
Gitee CodePecker行业场景化落地指南:金融、车联网与IoT双引擎选型与工程化路径
前端·gitee·自动化
跨境小彭24 分钟前
Temu运营优化方案:活动库存自动化管控,解决断流、超卖与权重下跌问题
大数据·运维·人工智能·自动化·跨境电商·temu·temu电商运营
AI多Agent协作实战派31 分钟前
AI多Agent协作系统实战(三十九):AI修对了Bug,却越了权——自动化团队的第一条铁律
人工智能·自动化·bug
漫谈数据智理32 分钟前
IDS-RAM 如何支撑数据空间走向可
大数据·运维·微服务
佳児素花痴╮33 分钟前
网络问题与基础理论
运维·服务器·网络
行业研究员38 分钟前
Android内置GPS与腾讯地图定位技术对比分析
android·android定位·腾讯地图定位