"""Create the stand-in Android SDK used by the real-app scenario.
Usage: python3 create-sdk.py <sdk-directory>
Then set ANDROID_HOME to that directory and inherit ANDROID_HOME into scenarios:prove.
No device-hub or T3 responses are mocked.
"""
from pathlib import Path
import sys

sdk = Path(sys.argv[1])
commands = {
    'cmdline-tools/latest/bin/avdmanager': '''#!/bin/sh
echo 'line 173: test: : integer expression expected' >&2
echo 'Unable to locate a Java Runtime.' >&2
exit 1
''',
    'emulator/emulator': '#!/bin/sh\nexit 0\n',
    'platform-tools/adb': '''#!/bin/sh
case "$*" in
 'devices -l'|'devices') printf 'List of devices attached\\nR52T10ABCDE device usb:1-1 product:gts9wifixx model:SM_X710 device:gts9wifi transport_id:1\\n' ;;
 '-s R52T10ABCDE shell getprop') printf '[ro.product.manufacturer]: [samsung]\\n[ro.product.model]: [SM-X710]\\n[ro.build.version.release]: [15]\\n[ro.kernel.qemu]: [0]\\n' ;;
esac
exit 0
''',
}
for name, body in commands.items():
    command = sdk / name
    command.parent.mkdir(parents=True, exist_ok=True)
    command.write_text(body)
    command.chmod(0o755)
