diff --git a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/params/SystemDialogsSafetyParams.kt b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/params/SystemDialogsSafetyParams.kt index e04cc6ea7..6ba974678 100644 --- a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/params/SystemDialogsSafetyParams.kt +++ b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/params/SystemDialogsSafetyParams.kt @@ -1,9 +1,13 @@ package com.kaspersky.kaspresso.params data class SystemDialogsSafetyParams( - val shouldIgnoreKeyboard: Boolean + val shouldIgnoreKeyboard: Boolean, + val shouldIgnorePermissionDialogs: Boolean ) { companion object { - fun default() = SystemDialogsSafetyParams(shouldIgnoreKeyboard = false) + fun default() = SystemDialogsSafetyParams( + shouldIgnoreKeyboard = false, + shouldIgnorePermissionDialogs = false + ) } } diff --git a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt index 52cbdec5c..394bd3ed8 100644 --- a/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt +++ b/kaspresso/src/main/kotlin/com/kaspersky/kaspresso/systemsafety/SystemDialogSafetyProviderImpl.kt @@ -32,9 +32,9 @@ class SystemDialogSafetyProviderImpl( private val attemptsToSuppress: List<(UiDevice, AdbServer) -> Unit> = listOf( { _, adbServer -> - adbServer.performShell("input keyevent KEYCODE_BACK") - adbServer.performShell("input keyevent KEYCODE_ENTER") - adbServer.performShell("input keyevent KEYCODE_ENTER") + adbServer.performShell("input", listOf("keyevent", "KEYCODE_BACK")) + adbServer.performShell("input", listOf("keyevent", "KEYCODE_ENTER")) + adbServer.performShell("input", listOf("keyevent", "KEYCODE_ENTER")) }, { uiDevice, _ -> uiDevice.wait(Until.findObject(By.res("android:id/button1")), DEFAULT_TIMEOUT).click() }, { uiDevice, _ -> uiDevice.wait(Until.findObject(By.res("android:id/closeButton")), DEFAULT_TIMEOUT).click() }, @@ -111,7 +111,12 @@ class SystemDialogSafetyProviderImpl( */ private fun isAndroidSystemDetected(): Boolean { with(uiDevice) { - var isSystemDialogVisible = SystemDialogSafetyPattern.values().any { isVisible(By.pkg(it.pattern).clazz(FrameLayout::class.java)) } + var isSystemDialogVisible = if (systemDialogsSafetyParams.shouldIgnorePermissionDialogs) { + SystemDialogSafetyPattern.values().filter { it != SystemDialogSafetyPattern.PERMISSION_API30 && it != SystemDialogSafetyPattern.PERMISSION_API23 } + .any { isVisible(By.pkg(it.pattern).clazz(FrameLayout::class.java)) } + } else { + SystemDialogSafetyPattern.values().any { isVisible(By.pkg(it.pattern).clazz(FrameLayout::class.java)) } + } if (systemDialogsSafetyParams.shouldIgnoreKeyboard) { val isKeyboardVisible = isVisible(By.pkg(Pattern.compile("\\S*google.android.inputmethod\\S*")).clazz(FrameLayout::class.java))