Tasks not cleaned up after `ActivityScenario.launch`

Abierto
#2,152 6 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
28/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
android, kotlin

Línea de trabajo

Comienza con las llamadas a ActivityScenario.launch y scenario.close mostradas en el issue, después reproduce el problema en Android 13 e inspecciona la salida de adb shell dumpsys activity recents indicada. Compara las tareas de MainActivity y InstrumentationActivityInvoker$EmptyActivity para determinar si ambas deberían eliminarse cuando se cierra el escenario; se considera completado cuando se haya explicado el comportamiento o se haya corregido y verificado la limpieza.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description

I am trying for the first time to use ActivityScenario.launch in instrumented tests for a physical device. No matter what I do, I cannot get the tasks to be cleaned up.

Steps to Reproduce
  1. Using Samsung Galaxy. Close all apps first.
  2. Use code below

main

class MainActivity : ComponentActivity()

test

class LaunchAndroidInstrumentedTests {
    @Test
    fun activityStarts() {
        val scenario = ActivityScenario.launch(MainActivity::class.java)
        scenario.close()
    }
}
Expected Results

When the test is done, there are no running apps.

Actual Results

When the test is done, my phone shows 2 running apps.

If I run adb shell dumpsys activity recents, I see this at the bottom of the output

Visible recent tasks (most recent first):
  * RecentTaskInfo #0:
    id=5745 userId=0 hasTask=false lastActiveTime=3723437970
    baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=matt.launch.test/androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity }
    realActivity={matt.launch.test/androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity}
    isExcluded=false activityType=standard windowingMode=fullscreen supportsSplitScreenMultiWindow=true supportsMultiWindow=true
    taskDescription { colorBackground=#ff303030 colorPrimary=#ff212121 iconRes=/0 iconBitmap=false resizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION minWidth=-1 minHeight=-1 colorBackgroundFloating=#ff424242 }
    lastSnapshotData { taskSize=Point(1080, 2316) contentInsets=Rect(0, 67 - 0, 126) bufferSize=Point(1080, 2316) }
  * RecentTaskInfo #1:
    id=5744 userId=0 hasTask=false lastActiveTime=3723437784
    baseIntent=Intent { flg=0x10008000 cmp=matt.launch/.MainActivity }
    realActivity={matt.launch/matt.launch.MainActivity}
    isExcluded=false activityType=standard windowingMode=fullscreen supportsSplitScreenMultiWindow=true supportsMultiWindow=true
    taskDescription { colorBackground=#fff0f0f3 colorPrimary=#ff191c1e iconRes=/0 iconBitmap=false resizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION minWidth=-1 minHeight=-1 colorBackgroundFloating=#fff0f0f3 }
    lastSnapshotData { taskSize=Point(1080, 2316) contentInsets=Rect(0, 67 - 0, 126) bufferSize=Point(1080, 2316) }

To summarize, the EmptyActivity and MainActivity were not properly cleaned up. On my phone, they actually show as two different apps in the recent app list. Both are blank white screens, but one of them says "matt.launch.MainActivity". The other one has no text.

AndroidX Test and Android OS Versions

androidx.test: 1.5.0
android OS: 13

Link to a public git repo demonstrating the problem:

I did not make one because I am hoping there is a quick solution or that it will be easy to reproduce with the code I copied and pasted above. If there is not quick solution and it is not simple to reproduce, I will be happy to make a repo. Please just let me know.

Lenguaje dominante
Java
Estrellas
1.2k
Forks
342
Merge medio
1 d 14 h
PR fusionados (30 d)
5

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de android/android-test

Todos los issues de android/android-test

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.