From b94cc72729b7ae7e2e8b1542237dd881d960d02d Mon Sep 17 00:00:00 2001 From: Alexandre Jacinto Date: Thu, 24 Oct 2024 17:08:13 +0100 Subject: [PATCH] feat(camera): only request permission to save to the gallery for Android <= 9 (#2222) --- .../com/capacitorjs/plugins/camera/CameraPlugin.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/camera/android/src/main/java/com/capacitorjs/plugins/camera/CameraPlugin.java b/camera/android/src/main/java/com/capacitorjs/plugins/camera/CameraPlugin.java index 2dce20da1..d2a52ac46 100644 --- a/camera/android/src/main/java/com/capacitorjs/plugins/camera/CameraPlugin.java +++ b/camera/android/src/main/java/com/capacitorjs/plugins/camera/CameraPlugin.java @@ -204,6 +204,17 @@ private boolean checkCameraPermissions(PluginCall call) { boolean hasGalleryPerms = getPermissionState(SAVE_GALLERY) == PermissionState.GRANTED; // If we want to save to the gallery, we need two permissions + // actually we only need permissions to save to gallery for Android <= 9 (API 28) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + // we might still need to request permission for the camera + if (!hasCameraPerms) { + requestPermissionForAlias(CAMERA, call, "cameraPermissionsCallback"); + return false; + } + return true; + } + + // we need to request permissions to save to gallery for Android <= 9 if (settings.isSaveToGallery() && !(hasCameraPerms && hasGalleryPerms) && isFirstRequest) { isFirstRequest = false; String[] aliases;