Skip to content

Commit 948f65b

Browse files
committed
feat: add debug auto-start mode for CI testing
- Auto-select Ubuntu on launch in debug builds - Auto-submit default credentials (user/password/password) - Auto-select SSH service type - Auto-accept large downloads without wifi check - Simplified test.yml: no UI automation needed, just launch and monitor - Added pm clear for fresh start, periodic UI/logcat dumps at 30s/90s/210s/390s
1 parent 2d03fe2 commit 948f65b

2 files changed

Lines changed: 90 additions & 66 deletions

File tree

.github/workflows/test.yml

Lines changed: 56 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -91,80 +91,66 @@ jobs:
9191
adb shell pm grant com.scisammy.ubuntuandroid android.permission.READ_EXTERNAL_STORAGE || true
9292
adb shell pm grant com.scisammy.ubuntuandroid android.permission.WRITE_EXTERNAL_STORAGE || true
9393
94+
echo "=== Clearing app data for fresh start ==="
95+
adb shell pm clear com.scisammy.ubuntuandroid || true
96+
sleep 2
97+
98+
echo "=== Granting permissions again after clear ==="
99+
adb shell pm grant com.scisammy.ubuntuandroid android.permission.READ_EXTERNAL_STORAGE || true
100+
adb shell pm grant com.scisammy.ubuntuandroid android.permission.WRITE_EXTERNAL_STORAGE || true
101+
94102
echo "=== Clearing logcat ==="
95103
adb logcat -c || true
96104
97-
echo "=== Launching app ==="
105+
echo "=== Launching app (debug auto-start will select Ubuntu) ==="
98106
adb shell am start -W -n com.scisammy.ubuntuandroid/tech.ula.MainActivity || true
99-
sleep 10
100-
101-
echo "=== UI after launch ==="
102-
adb shell uiautomator dump /sdcard/ui1.xml || true
103-
adb pull /sdcard/ui1.xml /tmp/ui1.xml || true
104-
105-
echo "=== Dismiss error dialog ==="
106-
adb shell input tap 278 143 || true
107-
sleep 3
108-
109-
echo "=== Tap Ubuntu ==="
110-
adb shell input tap 540 496 || true
111-
sleep 5
112-
113-
echo "=== UI after Ubuntu tap ==="
114-
adb shell uiautomator dump /sdcard/ui2.xml || true
115-
adb pull /sdcard/ui2.xml /tmp/ui2.xml || true
116-
117-
echo "=== Enter credentials ==="
118-
adb shell input tap 540 909 || true
119-
sleep 1
120-
adb shell input text "user" || true
121-
adb shell input keyevent 61 || true
122-
sleep 0.5
123-
adb shell input text "password" || true
124-
adb shell input keyevent 61 || true
125-
sleep 0.5
126-
adb shell input text "password" || true
127-
sleep 1
128-
adb shell input tap 854 1113 || true
129-
sleep 5
130-
131-
echo "=== UI after credentials ==="
132-
adb shell uiautomator dump /sdcard/ui3.xml || true
133-
adb pull /sdcard/ui3.xml /tmp/ui3.xml || true
134-
135-
echo "=== Select SSH ==="
136-
adb shell uiautomator dump /sdcard/ui3b.xml || true
137-
adb pull /sdcard/ui3b.xml /tmp/ui3b.xml || true
138-
sleep 2
139107
140-
echo "=== UI after SSH ==="
141-
adb shell uiautomator dump /sdcard/ui4.xml || true
142-
adb pull /sdcard/ui4.xml /tmp/ui4.xml || true
143-
144-
echo "=== Waiting for download ==="
145-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_1.xml && adb pull /sdcard/ui_check_1.xml /tmp/ui_check_1.xml || true
146-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_2.xml && adb pull /sdcard/ui_check_2.xml /tmp/ui_check_2.xml || true
147-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_3.xml && adb pull /sdcard/ui_check_3.xml /tmp/ui_check_3.xml || true
148-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_4.xml && adb pull /sdcard/ui_check_4.xml /tmp/ui_check_4.xml || true
149-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_5.xml && adb pull /sdcard/ui_check_5.xml /tmp/ui_check_5.xml || true
150-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_6.xml && adb pull /sdcard/ui_check_6.xml /tmp/ui_check_6.xml || true
151-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_7.xml && adb pull /sdcard/ui_check_7.xml /tmp/ui_check_7.xml || true
152-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_8.xml && adb pull /sdcard/ui_check_8.xml /tmp/ui_check_8.xml || true
153-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_9.xml && adb pull /sdcard/ui_check_9.xml /tmp/ui_check_9.xml || true
154-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_10.xml && adb pull /sdcard/ui_check_10.xml /tmp/ui_check_10.xml || true
155-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_11.xml && adb pull /sdcard/ui_check_11.xml /tmp/ui_check_11.xml || true
156-
sleep 15 && adb shell uiautomator dump /sdcard/ui_check_12.xml && adb pull /sdcard/ui_check_12.xml /tmp/ui_check_12.xml || true
157-
158-
echo "=== Final UI ==="
159-
adb shell uiautomator dump /sdcard/ui_final.xml || true
160-
adb pull /sdcard/ui_final.xml /tmp/ui_final.xml || true
161-
162-
echo "=== Logcat ula ==="
163-
adb logcat -d | grep -i -E "tech.ula|ServerService|LocalServer|MissingExec|FailedExec|startSSH|execInProot|proot|busybox|setupLinks|UlaApp|FATAL|AndroidRuntime" > /tmp/logcat_filtered.txt || true
108+
echo "=== Waiting 30s for app init and auto-start ==="
109+
sleep 30
110+
111+
echo "=== UI dump after 30s ==="
112+
adb shell uiautomator dump /sdcard/ui_30s.xml || true
113+
adb pull /sdcard/ui_30s.xml /tmp/ui_30s.xml || true
114+
115+
echo "=== Logcat after 30s ==="
116+
adb logcat -d > /tmp/logcat_30s.txt || true
117+
118+
echo "=== Waiting 60s more (download/setup progress) ==="
119+
sleep 60
120+
121+
echo "=== UI dump after 90s ==="
122+
adb shell uiautomator dump /sdcard/ui_90s.xml || true
123+
adb pull /sdcard/ui_90s.xml /tmp/ui_90s.xml || true
124+
125+
echo "=== Logcat after 90s ==="
126+
adb logcat -d > /tmp/logcat_90s.txt || true
127+
128+
echo "=== Waiting 120s more ==="
129+
sleep 120
130+
131+
echo "=== UI dump after 210s ==="
132+
adb shell uiautomator dump /sdcard/ui_210s.xml || true
133+
adb pull /sdcard/ui_210s.xml /tmp/ui_210s.xml || true
134+
135+
echo "=== Logcat after 210s ==="
136+
adb logcat -d > /tmp/logcat_210s.txt || true
137+
138+
echo "=== Waiting 180s more (long wait for extraction/server start) ==="
139+
sleep 180
140+
141+
echo "=== UI dump after 390s ==="
142+
adb shell uiautomator dump /sdcard/ui_390s.xml || true
143+
adb pull /sdcard/ui_390s.xml /tmp/ui_390s.xml || true
164144
165145
echo "=== Processes ==="
166146
adb shell ps -A > /tmp/ps_output.txt || true
167147
148+
echo "=== Logcat ula filtered ==="
149+
adb logcat -d | grep -i -E "tech.ula|ServerService|LocalServer|MissingExec|FailedExec|startSSH|execInProot|proot|busybox|setupLinks|UlaApp|FATAL|AndroidRuntime|DEBUG" > /tmp/logcat_filtered.txt || true
150+
151+
echo "=== Full logcat ==="
152+
adb logcat -d > /tmp/logcat_full.txt || true
153+
168154
echo "=== Screenshot ==="
169155
adb shell screencap -p /sdcard/screen.png || true
170156
adb pull /sdcard/screen.png /tmp/screen.png || true
@@ -177,8 +163,12 @@ jobs:
177163
with:
178164
name: test-results
179165
path: |
180-
/tmp/ui*.xml
166+
/tmp/ui_*.xml
181167
/tmp/screen.png
182168
/tmp/logcat_filtered.txt
169+
/tmp/logcat_full.txt
170+
/tmp/logcat_30s.txt
171+
/tmp/logcat_90s.txt
172+
/tmp/logcat_210s.txt
183173
/tmp/ps_output.txt
184174
if-no-files-found: ignore

app/src/main/java/tech/ula/MainActivity.kt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import androidx.navigation.Navigation
3131
import androidx.navigation.findNavController
3232
import androidx.navigation.ui.NavigationUI
3333
import androidx.navigation.ui.NavigationUI.setupWithNavController
34+
import com.scisammy.ubuntuandroid.BuildConfig
3435
import com.google.gson.Gson
3536
import kotlinx.android.synthetic.main.activity_main.* // ktlint-disable no-wildcard-imports
3637
import kotlinx.coroutines.CoroutineScope
@@ -245,6 +246,20 @@ class MainActivity : AppCompatActivity(), SessionListFragment.SessionSelection,
245246
autoStarted = true
246247
appHasBeenSelected(autoApp, true)
247248
}
249+
250+
if (BuildConfig.DEBUG && !autoStarted) {
251+
val ubuntuApp = App(
252+
name = "ubuntu",
253+
category = "distribution",
254+
filesystemRequired = "ubuntu",
255+
supportsCli = true,
256+
supportsGui = true,
257+
isPaidApp = false,
258+
version = 1
259+
)
260+
autoStarted = true
261+
appHasBeenSelected(ubuntuApp, true)
262+
}
248263
}
249264

250265
override fun onStart() {
@@ -423,6 +438,25 @@ class MainActivity : AppCompatActivity(), SessionListFragment.SessionSelection,
423438
}
424439

425440
private fun handleUserInputState(state: UserInputRequiredState) {
441+
if (BuildConfig.DEBUG) {
442+
return when (state) {
443+
is LowStorageAcknowledgementRequired -> {
444+
viewModel.lowAvailableStorageAcknowledged()
445+
}
446+
is FilesystemCredentialsRequired -> {
447+
viewModel.submitFilesystemCredentials("user", "password", "password")
448+
}
449+
is AppServiceTypePreferenceRequired -> {
450+
viewModel.submitAppServiceType(ServiceType.Ssh)
451+
}
452+
is LargeDownloadRequired -> {
453+
viewModel.startAssetDownloads(state.downloadRequirements)
454+
}
455+
is ActiveSessionsMustBeDeactivated -> {
456+
displayGenericErrorDialog(R.string.general_error_title, R.string.deactivate_sessions)
457+
}
458+
}
459+
}
426460
return when (state) {
427461
is LowStorageAcknowledgementRequired -> {
428462
displayLowStorageDialog()

0 commit comments

Comments
 (0)