# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import subprocess def create_banner_html(lang="en"): html_template = """

ARTEMIS

Autonomous Real-time Testing, Exploration & Mobile Interaction System
__TAGLINE__
__PROMPT_LABEL__
__PROMPT_STATUS__
> __PROMPT_TEXT__
__CONSOLE_TITLE__
__CONSOLE_BADGE__
✓ __STEP_1__
✓ __STEP_2__
__STEP_3_TITLE__ __STEP_3_TIME__
__STEP_3_DESC__
__METRIC_1_LABEL__ 4.2%
__METRIC_2_LABEL__ __METRIC_2_VAL__
__METRIC_3_LABEL__ 48kHz / A2DP
○ __STEP_4__
__SCREEN_TITLE__ __DEVICE_TAG__
🎵
Coldplay - Yellow __ITEM_SUB__
__ITEM_PRICE__
__SEC_TEXT__ 🎧 Pixel Buds Pro (A2DP)
__GROUNDING_TAG__
__MOCK_BTN__
""" if lang == "cn": replacements = { "__TAGLINE__": "用 Artemis 测试任意安卓手机", "__PROMPT_LABEL__": "目标 / 提示词", "__PROMPT_STATUS__": "设备实机运行中", "__PROMPT_TEXT__": "连接蓝牙耳机播放歌曲,并持续采集 CPU 性能指标", "__CONSOLE_TITLE__": "宿主智能体控制台", "__CONSOLE_BADGE__": "实时监控中", "__STEP_1__": "1. 自动连接蓝牙耳机", "__STEP_2__": "2. 打开播放器并播放歌曲", "__STEP_3_TITLE__": "▶ 3. 持续采集 CPU 性能指标", "__STEP_3_TIME__": "运行中", "__STEP_3_DESC__": "ADB 轮询 top -n 1 (进程 ID: 14208)", "__METRIC_1_LABEL__": "目标应用 CPU", "__METRIC_2_LABEL__": "蓝牙音频状态", "__METRIC_2_VAL__": "● 已连接", "__METRIC_3_LABEL__": "音频采样率", "__STEP_4__": "4. 断言验证 CPU < 5.0% 阈值", "__SCREEN_TITLE__": "正在播放", "__DEVICE_TAG__": "● PIXEL 实机", "__ITEM_SUB__": "输出设备: Pixel Buds Pro", "__ITEM_PRICE__": "播放中 ▶", "__SEC_TEXT__": "当前音频输出设备", "__GROUNDING_TAG__": "🎯 AI 视觉锚定 (0.99)", "__MOCK_BTN__": "媒体输出控制器", } else: replacements = { "__TAGLINE__": "Test Any Android Phone with Autonomous Assistant Platform", "__PROMPT_LABEL__": "Goal / Prompt", "__PROMPT_STATUS__": "RUNNING ON DEVICE", "__PROMPT_TEXT__": "Connect to Bluetooth earbuds, play a song, and capture CPU usage metrics", "__CONSOLE_TITLE__": "Host Agent Console", "__CONSOLE_BADGE__": "MONITORING", "__STEP_1__": "1. Connect to Bluetooth earbuds", "__STEP_2__": "2. Launch music player & play song", "__STEP_3_TITLE__": "▶ 3. Capture CPU usage metrics", "__STEP_3_TIME__": "Active", "__STEP_3_DESC__": "ADB polling top -n 1 (pid: 14208)", "__METRIC_1_LABEL__": "Target App CPU", "__METRIC_2_LABEL__": "Bluetooth Audio", "__METRIC_2_VAL__": "● Connected", "__METRIC_3_LABEL__": "Sample Rate", "__STEP_4__": "4. Assert CPU < 5.0% threshold", "__SCREEN_TITLE__": "Now Playing", "__DEVICE_TAG__": "● PIXEL LAB", "__ITEM_SUB__": "Output: Pixel Buds Pro", "__ITEM_PRICE__": "Playing ▶", "__SEC_TEXT__": "Active Audio Output Device", "__GROUNDING_TAG__": "🎯 GROUNDED (0.99)", "__MOCK_BTN__": "Media Output Controls", } for key, val in replacements.items(): html_template = html_template.replace(key, val) return html_template def render_image(html_str, output_path): temp_html = f"/tmp/banner_{os.path.basename(output_path)}.html" with open(temp_html, "w", encoding="utf-8") as f: f.write(html_str) cmd = [ "google-chrome", "--headless=new", "--disable-gpu", "--virtual-time-budget=2000", "--window-size=1280,480", "--device-scale-factor=2", "--hide-scrollbars", f"--screenshot={output_path}", f"file://{temp_html}", ] res = subprocess.run(cmd, capture_output=True, text=True) if os.path.exists(output_path): print(f"Rendered {output_path} ({os.path.getsize(output_path)} bytes)") else: print(f"Error rendering {output_path}: {res.stderr}") from pathlib import Path assets_dir = Path(__file__).resolve().parent os.makedirs(assets_dir, exist_ok=True) # Generate English main banner and en banner en_html = create_banner_html(lang="en") render_image(en_html, str(assets_dir / "artemis-banner.png")) render_image(en_html, str(assets_dir / "artemis-banner-en.png")) # Generate Chinese banner cn_html = create_banner_html(lang="cn") render_image(cn_html, str(assets_dir / "artemis-banner-cn.png"))