Files
StarPilot/openpilot/starpilot/companion/android/tests/test_android_manifest.py
T
Danny f63e715d2d Android: Add the StarPilot companion and signed release workflow
Connect over LAN or Bluetooth with network discovery, build-matched Galaxy
pages, phone GPS and a background uplink. Guide pairing with readiness retries,
cancellable progress and bond cleanup. Include app updates, regression tests,
the current APK, and a workflow to test, build and sign releases.
2026-10-22 15:37:20 -07:00

29 lines
1.4 KiB
Python

from pathlib import Path
import xml.etree.ElementTree as ET
ANDROID = "{http://schemas.android.com/apk/res/android}"
MANIFEST = Path(__file__).parents[1] / "app/src/main/AndroidManifest.xml"
def test_main_activity_handles_rotation_without_recreating_bluetooth_session():
root = ET.parse(MANIFEST).getroot()
activity = next(node for node in root.iter("activity") if node.get(ANDROID + "name") == ".MainActivity")
changes = set(activity.get(ANDROID + "configChanges", "").split("|"))
assert {"orientation", "screenSize", "screenLayout", "smallestScreenSize"} <= changes
def test_in_app_updater_has_scoped_install_permission_and_receiver():
root = ET.parse(MANIFEST).getroot()
permissions = {node.get(ANDROID + "name") for node in root.findall("uses-permission")}
assert "android.permission.REQUEST_INSTALL_PACKAGES" in permissions
receiver = next(node for node in root.iter("receiver") if node.get(ANDROID + "name") == ".AppInstallReceiver")
assert receiver.get(ANDROID + "exported") == "false"
def test_update_completion_survives_replacement_without_exporting_receiver():
root = ET.parse(MANIFEST).getroot()
receiver = next(node for node in root.iter("receiver") if node.get(ANDROID + "name") == ".AppUpdateCompletion")
assert receiver.get(ANDROID + "exported") == "false"
assert {node.get(ANDROID + "name") for node in receiver.iter("action")} == {"android.intent.action.MY_PACKAGE_REPLACED"}