#!/usr/bin/env python3 """ Android 2.3 (API 10) and Tablet Layout Verification Script. 1. Boots Android 2.3.7 emulator, captures non-black screenshots of SlopRoot and SuManager. 2. Boots Tablet emulator (Nexus 7, 800x1280), verifies dual-pane tablet layouts for SlopRoot and SuManager. 3. Shuts down all emulators cleanly. """ import os import sys import time import shutil import subprocess from PIL import Image BASE_DIR = "/mnt/16aebe95-f920-450d-b96c-c06bb50ba672/sloproot" ARTIFACT_DIR = "/home/koutsie/.gemini/antigravity-cli/brain/a27700c5-eca4-4bd4-8f04-fddd76c9f8a6" DOCS_SCREENSHOTS = os.path.join(BASE_DIR, "docs/screenshots") os.makedirs(DOCS_SCREENSHOTS, exist_ok=True) ANDROID_HOME = os.path.join(BASE_DIR, "android-sdk") ANDROID_AVD_HOME = os.path.join(BASE_DIR, "avd") env = os.environ.copy() env["ANDROID_HOME"] = ANDROID_HOME env["ANDROID_AVD_HOME"] = ANDROID_AVD_HOME env["PATH"] = f"{ANDROID_HOME}/emulator:{ANDROID_HOME}/platform-tools:{env['PATH']}" PORT = "5554" DEVICE = f"emulator-{PORT}" def adb_cmd(*args): return subprocess.run(["adb", "-s", DEVICE] + list(args), env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) def take_screenshot(filename, description, min_colors=50): out_path = os.path.join(DOCS_SCREENSHOTS, filename) print(f"Capturing: {description} -> {filename}...") time.sleep(2) res = subprocess.run(["python3", os.path.join(BASE_DIR, "tests/adb_screenshot.py"), out_path, DEVICE], env=env) if res.returncode != 0 or not os.path.exists(out_path): raise RuntimeError(f"Screenshot failed for {filename}") with Image.open(out_path) as im: colors = im.getcolors(maxcolors=100000) num_colors = len(colors) if colors else 100000 print(f" Verified {filename}: size={im.size}, colors={num_colors}") if num_colors < min_colors: raise ValueError(f"Screenshot {filename} has insufficient colors: {num_colors} < {min_colors}") artifact_path = os.path.join(ARTIFACT_DIR, filename) shutil.copyfile(out_path, artifact_path) print(f" Saved to artifact directory: {artifact_path}") return out_path def test_android23(): print("\n==========================================") print("Testing Android 2.3.7 (API 10) Screenshots") print("==========================================") subprocess.run(["adb", "emu", "kill"], env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) time.sleep(2) proc = subprocess.Popen( ["emulator", "-avd", "test_api10_x86", "-port", PORT, "-no-window", "-no-audio", "-no-boot-anim"], env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL ) try: adb_cmd("wait-for-device") for i in range(60): res = adb_cmd("shell", "getprop", "sys.boot_completed") if res.stdout.strip() == "1": print(f"Android 2.3.7 booted in {i}s") break time.sleep(1) # Unlock screen: double menu press for Gingerbread keyguard adb_cmd("shell", "input", "keyevent", "82") time.sleep(1) adb_cmd("shell", "input", "keyevent", "82") time.sleep(2) # Install latest APKs adb_cmd("install", "-r", os.path.join(BASE_DIR, "sumanager/build/sumanager.apk")) adb_cmd("install", "-r", os.path.join(BASE_DIR, "app/build/sloproot.apk")) # Launch SlopRoot on Android 2.3 adb_cmd("shell", "am", "start", "-n", "org.sloproot/.MainActivity") time.sleep(3) take_screenshot("20_android23_sloproot_main.png", "SlopRoot on Android 2.3.7 (Gingerbread)") # Launch SuManager on Android 2.3 adb_cmd("shell", "am", "start", "-n", "org.sloproot.sumanager/.MainActivity") time.sleep(3) take_screenshot("21_android23_sumanager_main.png", "SuManager on Android 2.3.7 (Gingerbread)") print("PASS: Android 2.3.7 screenshots verified successfully!") finally: adb_cmd("emu", "kill") try: proc.terminate() proc.wait(timeout=5) except Exception: proc.kill() time.sleep(2) def test_tablet(): print("\n==========================================") print("Testing Tablet Layout on Nexus 7 (800x1280)") print("==========================================") subprocess.run(["adb", "emu", "kill"], env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) time.sleep(2) proc = subprocess.Popen( ["emulator", "-avd", "test_tablet_api19", "-port", PORT, "-no-window", "-no-audio", "-no-boot-anim", "-gpu", "swiftshader_indirect"], env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL ) try: adb_cmd("wait-for-device") for i in range(60): res = adb_cmd("shell", "getprop", "sys.boot_completed") if res.stdout.strip() == "1": print(f"Tablet booted in {i}s") break time.sleep(1) # Unlock screen adb_cmd("shell", "sqlite3", "/data/data/com.android.providers.settings/databases/settings.db", 'INSERT OR REPLACE INTO secure (name, value) VALUES ("lockscreen.disabled", "1");') adb_cmd("shell", "svc", "power", "stayon", "true") adb_cmd("shell", "input", "keyevent", "82") adb_cmd("shell", "input", "keyevent", "3") time.sleep(2) # Install latest APKs adb_cmd("install", "-r", os.path.join(BASE_DIR, "sumanager/build/sumanager.apk")) adb_cmd("install", "-r", os.path.join(BASE_DIR, "app/build/sloproot.apk")) # 1. SlopRoot Tablet Dual-Pane Main Screen adb_cmd("shell", "am", "start", "-n", "org.sloproot/.MainActivity") time.sleep(3) take_screenshot("22_tablet_sloproot_dual_pane.png", "SlopRoot on Tablet (dual-pane layout: controls + console)") # 2. SlopRoot Check Root on Tablet (Tap Check root: x=80, y=240 in left pane) adb_cmd("shell", "input", "tap", "80", "240") time.sleep(3) take_screenshot("23_tablet_sloproot_check_root.png", "SlopRoot on Tablet after Check root execution") # 3. SlopRoot Root Terminal on Tablet adb_cmd("shell", "input", "tap", "80", "290") time.sleep(3) take_screenshot("24_tablet_sloproot_terminal.png", "SlopRoot interactive root terminal on Tablet") # Back adb_cmd("shell", "input", "keyevent", "4") time.sleep(1) # 4. SuManager Tablet Dual-Pane Main Screen (Apps tab) adb_cmd("shell", "am", "start", "-n", "org.sloproot.sumanager/.MainActivity") time.sleep(3) take_screenshot("25_tablet_sumanager_dual_pane.png", "SuManager on Tablet (dual-pane: controls + policy list)") # 5. SuManager Logs Tab on Tablet (Tap Logs: x=400, y=100) adb_cmd("shell", "input", "tap", "400", "100") time.sleep(2) take_screenshot("26_tablet_sumanager_logs.png", "SuManager Logs tab on Tablet") # 6. SuManager Settings Tab on Tablet (Tap Settings: x=650, y=100) adb_cmd("shell", "input", "tap", "650", "100") time.sleep(2) take_screenshot("27_tablet_sumanager_settings.png", "SuManager Settings tab on Tablet") print("PASS: Tablet dual-pane layout screenshots verified successfully!") finally: adb_cmd("emu", "kill") try: proc.terminate() proc.wait(timeout=5) except Exception: proc.kill() time.sleep(2) def main(): test_android23() test_tablet() print("\n========================================================") print("ALL ANDROID 2.3 AND TABLET SCREENSHOTS VERIFIED PASS!") print("========================================================") if __name__ == "__main__": main()