Skip to content

Permissions.Button new option to permission_deny_and_dont_ask_again_button #690

@ZadorozhnyiSemen

Description

@ZadorozhnyiSemen

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
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions