-
-
Notifications
You must be signed in to change notification settings - Fork 305
Description
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:
- Grant camera permission to the application.
- Initiate image cropping using the library's provided method (
cropImage.launch(options { setGuidelines(Guidelines.ON) })). - While the camera intent is open, revoke the camera permission.
- 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