Skip to content

Android - Camera permissions #462

@hrodrick

Description

@hrodrick

Hi! The library is awesome. However, I found out that the app crashes when trying to open the camera on android devices.

Error:

java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 xflg=0x4 cmp=com.android.camera2/com.android.camera.CaptureActivity clip={text/uri-list hasLabel(0) {U(content)}} (has extras) } from ProcessRecord{9c55489 12282:org.anawimstudios.amoble/u0a218} (pid=12282, uid=10218) with revoked permission android.permission.CAMERA
                                                                                                    	at android.os.Parcel.createExceptionOrNull(Parcel.java:3340)
                                                                                                    	at android.os.Parcel.createException(Parcel.java:3324)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:3307)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:3249)
                                                                                                    	at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:2178)
                                                                                                    	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1995)
                                                                                                    	at android.app.Activity.startActivityForResult(Activity.java:5997)
                                                                                                    	at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.kt:694)
                                                                                                    	at androidx.core.app.ActivityCompat.startActivityForResult(ActivityCompat.java:243)
                                                                                                    	at androidx.activity.ComponentActivity$activityResultRegistry$1.onLaunch(ComponentActivity.kt:224)
                                                                                                    	at androidx.activity.result.ActivityResultRegistry$register$3.launch(ActivityResultRegistry.kt:191)
                                                                                                    	at androidx.activity.result.ActivityResultLauncher.launch(ActivityResultLauncher.kt:40)
                                                                                                    	at io.github.vinceglb.filekit.dialogs.FileKit_androidKt$openCameraPicker$2.invokeSuspend(FileKit.android.kt:123)
                                                                                                    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
                                                                                                    	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
                                                                                                    	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:124)
                                                                                                    	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
                                                                                                    	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
                                                                                                    	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.ui.platform.MotionDurationScaleImpl@bad045e, androidx.compose.runtime.BroadcastFrameClock@eb3b03f, StandaloneCoroutine{Cancelling}@1ef6d0c, AndroidUiDispatcher@9734655]
                                                                                                    Caused by: android.os.RemoteException: Remote stack trace:
                                                                                                    	at com.android.server.wm.ActivityTaskSupervisor.checkStartAnyActivityPermission(ActivityTaskSupervisor.java:1211)
                                                                                                    	at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:1231)
                                                                                                    	at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:870)
                                                                                                    	at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1315)
                                                                                                    	at com.android.server.wm.ActivityTaskManagerService.startActivityAsUser(ActivityTaskManagerService.java:1259)

Basically I see that the system doesn't request runtime camera permissions when trying to open the camera, causing a crash. It would be a very nice to have addition to the library so we don't have to look at other 3rd party libraries in order to implement the feature.

Note 1 : It may also happen on iOS but I didn't tested it yet.
Note 2 : Camera permissions are not exactly "revoked" as the error mentions but rather on an "Ask every time" state, which is a common use case.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions