-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(android)!: support API 33+ permissions #262
Conversation
Replace READ_EXTERNAL_STORAGE permission with READ_MEDIA_AUDIO, READ_MEDIA_VIDEO and READ_MEDIA_IMAGES
Do not request new permissions on older SDKs as they do not support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codewise I think is okay. I haven't ran these changes.
I did find the changes hard to follow, we may want to refactor this at some point in the future for readability, but I don't consider this a blocker for a merge.
private static String[] storagePermissions; | ||
static { | ||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
storagePermissions = new String[]{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally thought this was a mistake, however reading through the PR I see the list is added onto on demand.
Not a merge blocker but perhaps add a comment to make this clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it dont seem to work i have added all changes but on android 13 it gives permission denied error
any update on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Anyone else getting Android manifest merger errors with this? Our app uses a bunch of different plugins and it looks like these two items are being placed in the manifest from other plugins...
...and these these items appear to be coming from this (cordova-plugin-media-capture)
It looked like I might be able to do something in my app's config.xml in order to replace them ( https://stackoverflow.com/questions/25981156/tools-replace-not-replacing-in-android-manifest ) but I wasn't fully understanding it / created more errors in Android studio. Apologies if I'm off base, I'm not blaming this change, this looks like the better way to specify it, just not sure if there's anything else that needs done? Or maybe it's something on my end and need to find out what other plugins might be adding this and get them upgraded as well? Sorry if this is off topic. EDIT/UPDATE: I had to fork this plugin locally and remove the |
About @PabbleDabble feedback, please review PR #211 again and merge it? to fix Issue #209. |
@PabbleDabble I also ran into this exact scenario. We include cordova-plugin-camera which requests WRITE_EXTERNAL_STORAGE permissions... without the maxSdkVersion qualifier. AndroidManifest.xml includes the following entries after plugin installs... cordova-plugin-camera
cordova-plugin-media-capture
The maxSdkVersion qualifier foils the manifest merge process and the build throws up an error...
From a pending PR, the temporary workaround is to manually remove the maxSdkVersion qualifier before the cordova build. See SO post I made before seeing this comment... |
Except from fixing the merge process, a proper solution may be to have this maxSdk attribute identically set on both sides? And so to have a PR for the camera plugin and to make it be released soon. |
@ath0mas Indeed, adding the maxSdk qualifier to the camera plugin entry would resolve the merge problem. However, is that the correct end result for READ/WRITE_EXTERNAL_STORAGE permission? I'm not an expert in the permissions minefield. Or, does API 33+ just safely ignore the permissions and the maxSdk qualifier is not required? I can temporarily script either solution before the build. |
In API 33 these two permissions are ineffective when required from the code, so plugins are moving to conditionally calling these and thus the use of maxSdkVersion is a follow-up for the Manifest part. Better to add it into all applicable plugins, and make the corresponding code changes, even if not having it at all would still work but be possibly reported as incorrect. |
I posted an answer on SO, but cross-posting here, I have a gist that will clean extra https://gist.github.com/breautek/bd157b8598f9a816f2ec0d45e3d932c8 A more detailed answer on that topic can be found at https://stackoverflow.com/a/77078295/4685664 |
* Replace READ_EXTERNAL_STORAGE permission with READ_MEDIA_AUDIO, READ_MEDIA_VIDEO and READ_MEDIA_IMAGES * Fix READ_MEDIA_* permission on older SDKs * Do not request new permissions on older SDKs as they do not support
* feat(android)!: support API 33+ permissions (apache#262) * Replace READ_EXTERNAL_STORAGE permission with READ_MEDIA_AUDIO, READ_MEDIA_VIDEO and READ_MEDIA_IMAGES * Fix READ_MEDIA_* permission on older SDKs * Do not request new permissions on older SDKs as they do not support * Bump version --------- Co-authored-by: ochakov <[email protected]>
Platforms affected
Android
Motivation and Context
Allow building applications using Android SDK 33, support for Android 13
Description
Remove deprecated READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions and replace with new READ_MEDIA_IMAGES, READ_MEDIA_VIDEO and READ_MEDIA_AUDIO
Testing
Capture video and audio
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)