Karumi/Dexter

Duplicate Permission in report

Closed this issue ยท 5 comments

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

Thank you so

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!

PR sent with the fix!

It was merged, but when the fix will arrived ?

I just released Dexter 6.2.2