Skip to content

Runtime Error Occurs When Revoking Camera Permission During Image Cropping #627

@Jaypatelbond

Description

@Jaypatelbond

Description

Issue Overview:

Upon initiating image cropping in the Android application using the provided library, a runtime error is encountered. The error is specifically identified as a java.lang.SecurityException: Permission Denial, arising when the camera permission is revoked during the process. This error disrupts the flow of the application and negatively impacts user experience.

Error Details:

The error message is as follows:

Fatal Exception: java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.sec.android.app.camera/.Camera clip={text/uri-list hasLabel(0) {U(content)}} (has extras) } from ProcessRecord{3b739d2 31998:com.test.app/u0a418} (pid=31998, uid=10418) with revoked permission android.permission.CAMERA

Steps to Reproduce:

  1. Grant camera permission to the application.
  2. Initiate image cropping using the library's provided method (cropImage.launch(options { setGuidelines(Guidelines.ON) })).
  3. While the camera intent is open, revoke the camera permission.
  4. Proceed with capturing the image and then navigate back to the application.

Expected Behavior:

After revoking the camera permission during the image cropping process, the application should handle the permission change gracefully, either by prompting the user to grant permission again or by appropriately handling the lack of permission without causing a runtime error.

Proposed Solution:

Implement a permission check within the library's codebase, specifically during the image cropping process. This check should ensure that the necessary permissions are still granted before proceeding with any camera-related operations. Additionally, consider implementing error handling mechanisms to gracefully handle scenarios where permissions are revoked during critical operations.

Additional Information:

  • Device/OS: Android
  • Library in Use: [4.5.0]
  • Android SDK Version: [Android 14]

cropImage.launch(
options {
setGuidelines(Guidelines.ON)
}
)

This is the working recording when permission is given and not revoked during the cropping.
https://github.com/CanHub/Android-Image-Cropper/assets/29830677/54fc4643-59c5-411c-9903-ef3c1af9edef

This is the crash recording when encountered. Multiple people also raised this issue.
https://github.com/CanHub/Android-Image-Cropper/assets/29830677/b3168db1-cd11-4217-b8e8-81ecf89b7e4c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions