feat(rtos): 安装前补传PNG图标并等待成功回调
这个提交包含在:
1 父节点
c3649c626f
当前提交
17b51d98ae
18 个文件已更改
+579
-48
没有与搜索条件相匹配的文件
+20
-3
@@ -103,6 +103,19 @@ class Bridge:
|
||||
raise RuntimeError('Phone upload integrity mismatch')
|
||||
return name
|
||||
|
||||
def install(self, filename, icon=None, timeout=180):
|
||||
"""Phone validates the package and waits for PNG callback200 before sending PKG."""
|
||||
command = {'command': 'install'}
|
||||
image = Path(icon) if icon else Path(filename).parent / 'icon.png'
|
||||
if icon or image.is_file():
|
||||
if not image.is_file() or not 0 < image.stat().st_size <= 4 * 1024 * 1024:
|
||||
raise ValueError('Matching icon must be 1 byte to 4 MiB')
|
||||
if image.read_bytes()[:8] != b'\x89PNG\r\n\x1a\n':
|
||||
raise ValueError('Expected a real PNG icon, not renamed PGF data')
|
||||
command['iconFile'] = self.upload(image)
|
||||
command['file'] = self.upload(filename)
|
||||
return self.command(command, timeout)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
@@ -112,7 +125,7 @@ def main():
|
||||
parser.add_argument('--timeout', type=int, default=180)
|
||||
sub = parser.add_subparsers(dest='action', required=True)
|
||||
setup = sub.add_parser('setup', help='Install the debug APK and start the bridge')
|
||||
setup.add_argument('--apk', default=str(Path(__file__).parent / 'artifacts/RTOS-Phone-Bridge-0.2.0-debug.apk'))
|
||||
setup.add_argument('--apk', default=str(Path(__file__).parent / 'artifacts/RTOS-Phone-Bridge-0.3.0-debug.apk'))
|
||||
connect = sub.add_parser('connect')
|
||||
connect.add_argument('--app-id', default='test')
|
||||
connect.add_argument('--config', help='Local JSON with appId, license and optional service; keep credentials out of Git')
|
||||
@@ -126,6 +139,8 @@ def main():
|
||||
child.add_argument('file')
|
||||
if action == 'send-file':
|
||||
child.add_argument('--remote', required=True)
|
||||
else:
|
||||
child.add_argument('--icon', type=Path, help='Matching app PNG when the package contains a PGF icon; defaults to sibling icon.png')
|
||||
sub.add_parser('message').add_argument('message')
|
||||
logs = sub.add_parser('logs')
|
||||
logs.add_argument('enabled', choices=['on', 'off'])
|
||||
@@ -159,6 +174,8 @@ def main():
|
||||
if result.get('state') != 'success' or result.get('result', {}).get('connected') is not True:
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
return 2
|
||||
elif args.action == 'install':
|
||||
result = bridge.install(args.file, args.icon, args.timeout)
|
||||
elif args.action == 'events':
|
||||
cursor = args.after
|
||||
while True:
|
||||
@@ -172,9 +189,9 @@ def main():
|
||||
else:
|
||||
command = {'command': args.action}
|
||||
if args.action in ('check', 'launch'): command['package'] = args.package
|
||||
elif args.action in ('install', 'send-file'):
|
||||
elif args.action == 'send-file':
|
||||
command['file'] = bridge.upload(args.file)
|
||||
if args.action == 'send-file': command['remote'] = args.remote
|
||||
command['remote'] = args.remote
|
||||
elif args.action == 'message': command['message'] = args.message
|
||||
elif args.action == 'logs': command['enabled'] = args.enabled == 'on'
|
||||
elif args.action == 'rpc': command.update(method=args.method, params=args.params)
|
||||
|
||||
在新工单中引用
屏蔽一个用户