@@ -25,8 +25,7 @@ Write-Host "#####################################################"
2525$BuildDir = $ (GetNewProjectBuildPath)
2626$ApkFileName = " test.apk"
2727$ProcessName = " io.sentry.unity.integrationtest"
28- $TestActivityName = " $ProcessName /com.unity3d.player.UnityPlayerActivity"
29- $FallBackTestActivityName = " $ProcessName /com.unity3d.player.UnityPlayerGameActivity"
28+ $TestActivityName = $null # Detected after install via dumpsys
3029
3130$_ArtifactsPath = (Test-Path env:ARTIFACTS_PATH) ? $env: ARTIFACTS_PATH : (Join-Path $BuildDir " ../test-artifacts/" $ (Get-Date - Format " HHmmss" ))
3231
@@ -199,6 +198,15 @@ else
199198 return 1
200199}
201200
201+ # Detect the launcher activity from the installed package
202+ $dumpOutput = adb - s $device shell dumpsys package $ProcessName 2>&1 | Out-String
203+ if ($dumpOutput -match " com.unity3d.player.UnityPlayerGameActivity" ) {
204+ $TestActivityName = " $ProcessName /com.unity3d.player.UnityPlayerGameActivity"
205+ } else {
206+ $TestActivityName = " $ProcessName /com.unity3d.player.UnityPlayerActivity"
207+ }
208+ Write-Log " Detected activity: $TestActivityName "
209+
202210function ProcessNewLogs ([array ]$newLogs , [ref ]$lastLogCount , [array ]$logCache ) {
203211 if ($newLogs ) {
204212 $currentLogs = @ ($newLogs ) # Force array creation even for single line
@@ -227,21 +235,19 @@ function RunTest([string] $Name, [string] $SuccessString, [string] $FailureStrin
227235 adb - s $device shell am force- stop $ProcessName
228236 Start-Sleep - Milliseconds 500
229237
230- $activityName = $TestActivityName
231-
232238 Write-Log " Setting configuration"
233239
234240 # Mark the full-screen notification as acknowledged
235241 adb - s $device shell " settings put secure immersive_mode_confirmations confirmed"
236242 adb - s $device shell " input keyevent KEYCODE_HOME"
237243
238- Write-Log " Starting app '$activityName '"
244+ Write-Log " Starting app '$TestActivityName '"
239245
240246 # Start the adb command as a background job so we can wait for it to finish with a timeout
241247 $job = Start-Job - ScriptBlock {
242248 param ($device , $activityName , $Name )
243249 & adb - s $device shell am start - n $activityName - e test $Name - W 2>&1
244- } - ArgumentList $device , $activityName , $Name
250+ } - ArgumentList $device , $TestActivityName , $Name
245251
246252 # Wait for the job to complete or to timeout
247253 $completed = Wait-Job $job - Timeout 60
@@ -252,27 +258,9 @@ function RunTest([string] $Name, [string] $SuccessString, [string] $FailureStrin
252258 return $false
253259 }
254260
255- $output = Receive-Job $job
261+ Receive-Job $job | Out-Null
256262 Remove-Job $job
257263
258- Write-Log " Checking if activity started"
259-
260- # Check if the activity failed to start
261- if ($output -match " Error type 3" -or $output -match " Activity class \{$activityName \} does not exist." )
262- {
263- $activityName = $FallBackTestActivityName
264- Write-Log " Trying fallback activity $activityName "
265-
266- $output = & adb - s $device shell am start - n $activityName - e test $Name - W 2>&1
267-
268- # Check if the fallback activity failed to start
269- if ($output -match " Error type 3" -or $output -match " Activity class \{$activityName \} does not exist." )
270- {
271- Write-Log " Activity does not exist"
272- return $false
273- }
274- }
275-
276264 Write-Log " Activity started successfully"
277265
278266 $appPID = PidOf $device $ProcessName
0 commit comments