feat(设备端): 素材页轮询当前账号 + 切号/读名后广播下发
- 新增 GET /api/device/agent/account(adb dumpsys account,1.5s 缓存) - push_account_name() 广播给设备端 AccountReceiver,不抢焦点 - switch_account 切号成功 / read_account_name 读名成功后自动推送 - probe_one_dumpsys 支持 timeout(HTTP 轮询用 5s) - 测试与 DEVICE_AGENT/API 文档同步
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""`dumpsys account` 解析用例(纯字符串,不连设备、不连库)。"""
|
||||
import base64
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
@@ -8,6 +9,7 @@ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='repla
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
||||
os.chdir(sys.path[0])
|
||||
|
||||
from core import account_probe as ap # noqa: E402
|
||||
from core.account_probe import parse_dumpsys_account # noqa: E402
|
||||
|
||||
fails = []
|
||||
@@ -42,6 +44,24 @@ r = parse_dumpsys_account("Accounts: 1\n Account {name=abc, type=com.xiaomi}")
|
||||
check('name 为空', r['name'], '')
|
||||
check('masked=False', r['masked'], False)
|
||||
|
||||
print('=== 3. push_account_name 走广播(假 adb,不连设备)===')
|
||||
_calls = []
|
||||
_orig_adb = ap.adb_helper._adb
|
||||
ap.adb_helper._adb = lambda *a, **kw: (
|
||||
_calls.append(a), "Broadcast completed: result=0"
|
||||
)[1]
|
||||
try:
|
||||
ok, msg = ap.push_account_name("A:5555", "锋哥苏***实录")
|
||||
finally:
|
||||
ap.adb_helper._adb = _orig_adb
|
||||
check('返回 ok', ok, True)
|
||||
check('消息', msg, '已下发 锋哥苏***实录')
|
||||
check('显式广播组件', _calls[0][5:7],
|
||||
("-n", "com.example.deviceagent/.AccountReceiver"))
|
||||
check('使用 name_b64', _calls[0][10], "name_b64")
|
||||
check('base64 是标准编码', base64.b64decode(_calls[0][11]).decode("utf-8"),
|
||||
"锋哥苏***实录")
|
||||
|
||||
print()
|
||||
if fails:
|
||||
print('❌ 失败 %d 项:%s' % (len(fails), ' / '.join(fails)))
|
||||
|
||||
@@ -25,6 +25,9 @@ from core import video_plan as vp # noqa: E40
|
||||
from tasks.generic import task as gt # noqa: E402
|
||||
from tasks.generic import publish_flow as flow # noqa: E402
|
||||
|
||||
# 假设备用例:读名/切号后不要尝试 adb 广播(不连真机)
|
||||
gt.GenericStepsWorker.account_push_enabled = False
|
||||
|
||||
fails = []
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ os.chdir(_ROOT)
|
||||
|
||||
from tasks.generic import task as gt # noqa: E402
|
||||
|
||||
# 假设备用例:切号成功后不要尝试 adb 广播(不连真机)
|
||||
gt.GenericStepsWorker.account_push_enabled = False
|
||||
|
||||
fails = []
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user