Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions.Button new option to permission_deny_and_dont_ask_again_button #690

Open
ZadorozhnyiSemen opened this issue Dec 20, 2024 · 0 comments · May be fixed by #691
Open

Permissions.Button new option to permission_deny_and_dont_ask_again_button #690

ZadorozhnyiSemen opened this issue Dec 20, 2024 · 0 comments · May be fixed by #691
Labels
enhancement New feature or request

Comments

@ZadorozhnyiSemen
Copy link

Is your feature request related to a problem? Please describe.
On a newer version of Android first clickOn(Permissions.Button.DENY) works, but consequent automated permission deny will fail because under the hood deny button changes resource from permission_deny_button to permission_deny_and_dont_ask_again_button

Describe the solution you'd like
New enum value for "deny_and_dont_ask" button

enum class Button {
    ...
    DENY,
    DENY_AND_DONT_ASK,
}

Describe alternatives you've considered
As a workaround you can use UiDevice and find UiObject manually

fun Device.denyForeverViaDialog() {
    wait(
        timeoutMs = DIALOG_TIMEOUT_MS
    ) {
        val uiObjectButton = getDenyForeverPermissionButtonAsUiObject(this.uiDevice)
        if (uiObjectButton != null && uiObjectButton.exists()) {
            uiObjectButton.click()
        }
    }
}

private fun getDenyForeverPermissionButtonAsUiObject(uiDevice: UiDevice): UiObject? {
    return try {
        val btnSelector = UiSelector()
            .clickable(true)
            .checkable(false)
            .resourceId("com.android.permissioncontroller:id/permission_deny_and_dont_ask_again_button")
        uiDevice.findObject(btnSelector)
    } catch (e: UiObjectNotFoundException) {
        null
    } catch (e: Throwable) {
        throw e
    }
}
@ZadorozhnyiSemen ZadorozhnyiSemen added the enhancement New feature or request label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant