Skip to content

Commit

Permalink
Merge pull request #657 from KasperskyLab/ISSUE-656-Add-flag-to-turn-…
Browse files Browse the repository at this point in the history
…off-checking-permissioncontroller-dialogs

ISSUE-656: add flag to remove PermissionController
  • Loading branch information
CherchesovAzamat authored Nov 22, 2024
2 parents 7045390 + 9dc0052 commit 501d871
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() },
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 501d871

Please sign in to comment.