Karumi / Dexter

Android library that simplifies the process of requesting permissions at runtime.
http://karumi.com
Apache License 2.0
5.23k stars 671 forks source link

Duplicate Permission in report #270

Closed aiKrice closed 3 years ago

aiKrice commented 3 years ago

I have this code:

class PermissionsRepositoryImpl(
    private val permissionManager: DexterBuilder.Permission
) : PermissionsRepository {

    override fun isPhotoAccessPermissionEnabled(): Single<DomainMultiplePermissions> {
        return Single.create { single ->
            permissionManager
                .withPermissions(Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE)
                .withListener(object: MultiplePermissionsListener {
                    override fun onPermissionsChecked(report: MultiplePermissionsReport?) {
                        when (report) {
                            null -> single.onError(DomainPermissionReportException(
                                DomainPermissionReportException.Error.REPORT_ERROR,
                                "Permission report is null"))
                            else -> single.onSuccess(report.toDomain())
                        }
                    }

                    override fun onPermissionRationaleShouldBeShown(permissions: List<PermissionRequest?>?, token: PermissionToken?) {
                        token?.continuePermissionRequest()
                    }
                })
                .check()
        }
    }
}

Expected behaviour

The report should include just 2 grantedPermissions if i accept both.

Actual behaviour

The report includes 3 grantedPermissions if i accept both.

Steps to reproduce

I Call this code from a button from UI. I accept first the READ_EXTERNAL_STORAGE permission and refuse once the CAMERA permission. Then i re-tap the button to retrigger isPhotoAccessPermissionEnabled(). Only the popup for CAMERA is displayling but in the onPermissionsChecked callback, report.grantedPermissionResponse array size = 3 and READ_EXTERNAL_STORAGE appears twice.

Version of the library

Last version

traviszim commented 3 years ago

Thank you so

pedrovgs commented 3 years ago

You are absolutely right. I've just reproduced your error and there is one permission duplicated. I have no idea where it comes from. I'm going to take a look. Thanks for reporting!

pedrovgs commented 3 years ago

PR sent with the fix!

aiKrice commented 3 years ago

It was merged, but when the fix will arrived ?

pedrovgs commented 3 years ago

I just released Dexter 6.2.2