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}")