Repository navigation
Expand file tree
/
Copy pathmise.toml
More file actions
193 lines (170 loc) · 7.75 KB
/
Copy pathmise.toml
File metadata and controls
193 lines (170 loc) · 7.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# EVSwipe development environment — aligned with EVTasker / EVProfile.
#
# mise install installs the JDK
# mise run test JVM unit tests
# mise tasks list everything
#
# Why pin the JDK: AGP 8.6 requires Java 17. The machine default (JDK 26) fails the build
# with an unhelpful class-version error.
[tools]
java = "17"
[env]
ANDROID_HOME = "{{env.HOME}}/Android/Sdk"
ANDROID_SDK_ROOT = "{{env.HOME}}/Android/Sdk"
_.path = [
"{{env.HOME}}/Android/Sdk/platform-tools",
"{{env.HOME}}/Android/Sdk/cmdline-tools/latest/bin",
]
# ── Emulator ─────────────────────────────────────────────────────────────────────
# The vehicle runs AAOS 9 (API 28), but Google publishes no Automotive image below
# API 33. Two profiles, each faithful on one axis:
# emulator-car API 33 Automotive — the automotive system UI (wrong OS version).
# emulator-screen API 28, the MG4 panel geometry, but a plain phone/tablet system UI.
# For this app the screen profile is the one that matters: the swipe strips live on the
# bottom edge, so their position depends entirely on the real panel geometry.
#
# One AVD pair per repo, like evtasker-* and evabrp-*, so a reshaped AVD here never
# surprises a sibling project. To exercise the default swipe target, install EVLauncher
# Launcher onto this AVD too (its `mise run run`, with EMU_SCREEN_AVD pointed here).
#
# Geometry: project compatibility target of 1920x1080 @ 160dpi. The README
# quotes 1920×720 — that is the usable app area left under the system UI, not the panel.
# To model the usable area instead, set EMU_HEIGHT=720 and re-run emulator-setup.
EMU_CAR_AVD = "evswipe-car"
EMU_CAR_IMAGE = "system-images;android-33;android-automotive;x86_64"
EMU_SCREEN_AVD = "evswipe-screen"
EMU_SCREEN_IMAGE = "system-images;android-28;google_apis;x86_64"
EMU_WIDTH = "1920"
EMU_HEIGHT = "1080"
EMU_DENSITY = "160"
# -Dorg.gradle.java.home: without it Gradle reuses a daemon started by the VS Code Java
# extension, whose JRE has no jlink — the build then fails on JdkImageTransform, unrelated
# to the code.
[tasks.build]
description = "Build the stable debug APK"
run = './gradlew -Dorg.gradle.java.home=$JAVA_HOME assembleStableDebug'
[tasks.build-unstable]
description = "Build the unstable debug APK (OTA enabled)"
run = './gradlew -Dorg.gradle.java.home=$JAVA_HOME assembleUnstableDebug'
[tasks.test]
description = "JVM unit tests, both channels"
run = './gradlew -Dorg.gradle.java.home=$JAVA_HOME testStableDebugUnitTest testUnstableDebugUnitTest'
[tasks.lint]
description = "Android lint, stable channel"
run = './gradlew -Dorg.gradle.java.home=$JAVA_HOME lintStableDebug lintUnstableDebug'
[tasks.permissions]
description = "Permission-drift gate (same check the CI runs)"
run = 'bash .github/security/check-permissions.sh'
[tasks.check]
description = "What the CI runs: permission gate + unit tests + lint"
depends = ["permissions", "test", "lint"]
[tasks.release]
description = "Stable release APK (needs the platform keystore)"
run = './gradlew -Dorg.gradle.java.home=$JAVA_HOME assembleStableRelease'
[tasks.clean]
run = './gradlew -Dorg.gradle.java.home=$JAVA_HOME clean'
[tasks.emulator-setup]
description = "Install the emulator + system images and create both AVDs"
run = '''
set -e
SDK="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
AVDM="$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager"
if [ ! -e /dev/kvm ]; then
echo "ERROR: /dev/kvm missing — no hardware acceleration, the emulator is unusable." >&2
echo "Under WSL2: enable nested virtualisation on the Windows side." >&2
exit 1
fi
if ! id -nG | tr ' ' '\n' | grep -qx kvm; then
echo "WARNING: user not in the kvm group. Fix with:" >&2
echo " sudo usermod -aG kvm $USER # then log out and back in" >&2
fi
yes | "$SDK" --sdk_root="$ANDROID_HOME" --licenses > /dev/null
"$SDK" --sdk_root="$ANDROID_HOME" "emulator" "platform-tools" "$EMU_CAR_IMAGE" "$EMU_SCREEN_IMAGE"
create_avd() {
name="$1"; image="$2"; device="$3"
if "$AVDM" list avd 2>/dev/null | grep -q "Name: $name"; then
echo "AVD $name already present"
else
echo no | "$AVDM" create avd -n "$name" -k "$image" -d "$device" --force
fi
cfg="$HOME/.android/avd/$name.avd/config.ini"
# MG4 panel geometry. Without this the AVD keeps the generic profile's density and the
# bottom swipe strips do not sit where the driver's thumb reaches.
sed -i '/^hw.lcd/d;/^disk.dataPartition.size/d' "$cfg"
{
echo "hw.lcd.width=$EMU_WIDTH"
echo "hw.lcd.height=$EMU_HEIGHT"
echo "hw.lcd.density=$EMU_DENSITY"
echo "disk.dataPartition.size=4G"
} >> "$cfg"
echo "AVD $name configured at ${EMU_WIDTH}x${EMU_HEIGHT} @ ${EMU_DENSITY}dpi"
}
create_avd "$EMU_CAR_AVD" "$EMU_CAR_IMAGE" "automotive_1024p_landscape"
create_avd "$EMU_SCREEN_AVD" "$EMU_SCREEN_IMAGE" "pixel_c"
'''
# swiftshader_indirect, not "host": WSL2 exposes no real GPU (Mesa llvmpipe only), and
# -gpu host makes the emulator die on startup with "Your GPU cannot be used for hardware
# rendering" before any window ever appears. Software rendering is slower but actually boots.
[tasks.emulator-car]
description = "Start the Automotive emulator (API 33 — automotive system UI)"
run = '''
set -e
"$ANDROID_HOME/emulator/emulator" -avd "$EMU_CAR_AVD" \
-gpu swiftshader_indirect -no-snapshot-save -no-boot-anim &
"$ANDROID_HOME/platform-tools/adb" wait-for-device
echo "Car emulator ready."
'''
[tasks.emulator-screen]
description = "Start the MG4 screen emulator (API 28, MG4 geometry — no car services)"
run = '''
set -e
"$ANDROID_HOME/emulator/emulator" -avd "$EMU_SCREEN_AVD" \
-gpu swiftshader_indirect -no-snapshot-save -no-boot-anim &
"$ANDROID_HOME/platform-tools/adb" wait-for-device
echo "Screen emulator ready."
'''
[tasks.emulator-stop]
description = "Stop the running emulator"
run = '"$ANDROID_HOME/platform-tools/adb" emu kill || true'
[tasks.run]
description = "Build, install, grant and start the APK on the emulator or the vehicle"
depends = ["build"]
run = '''
set -e
ADB="$ANDROID_HOME/platform-tools/adb"
if [ -z "$($ADB devices | sed '1d' | grep -w device || true)" ]; then
echo "No device. Run 'mise run emulator-screen' (or emulator-car), or plug in the vehicle." >&2
exit 1
fi
APK=$(ls -t app/build/outputs/apk/stable/debug/*.apk | head -1)
echo "Installing $APK"
$ADB install -r -g "$APK"
mise run grant-permissions
$ADB shell am start -n "com.evsuite.swipe/.PermissionActivity"
echo "Started."
'''
# The two permissions this app is built around are both "special" — neither is granted by
# `adb install -g`, and without them the app shows its permission gate and does nothing.
# Granting them from the shell is a development shortcut for a throwaway emulator; on a
# real head unit the user grants both through the system screens, deliberately.
[tasks.grant-permissions]
description = "Grant overlay + accessibility to this app on the connected device (dev only)"
run = '''
set -e
ADB="$ANDROID_HOME/platform-tools/adb"
PKG="com.evsuite.swipe"
SVC="$PKG/$PKG.AccService"
# SYSTEM_ALERT_WINDOW is an appop, not a runtime permission.
$ADB shell appops set "$PKG" SYSTEM_ALERT_WINDOW allow
echo "Overlay granted."
# Accessibility is a secure setting holding a ':'-separated list of enabled services.
# Append rather than overwrite: clobbering it would disable any other enabled service.
current=$($ADB shell settings get secure enabled_accessibility_services | tr -d '\r')
case "$current" in
*"$SVC"*) echo "Accessibility service already enabled." ;;
null|"") $ADB shell settings put secure enabled_accessibility_services "$SVC" ;;
*) $ADB shell settings put secure enabled_accessibility_services "$current:$SVC" ;;
esac
$ADB shell settings put secure accessibility_enabled 1
echo "Accessibility service enabled."
'''