Skip to content

Conversation

@felipheallef
Copy link

@felipheallef felipheallef commented Jul 12, 2022

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Feature: Added support for the new Android 13 granular media permissions: READ_MEDIA_IMAGES, READ_MEDIA_VIDEO and READ_MEDIA_AUDIO.

⤵️ What is the current behavior?

Apps should ask for READ_EXTERNAL_STORAGE to read data from the external storage.

🆕 What is the new behavior (if this is a feature change)?

Apps targeting Android 13 must request one or more new permissions instead of the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions.

If the user previously granted your app the READ_EXTERNAL_STORAGE permission, the system automatically grants each of the new permissions to the app.

💥 Does this PR introduce a breaking change?

No, everything should work as expected.

🐛 Recommendations for testing

Run the example project at permission_handler/example using an emulator or physical device running Android 13.

📝 Links to relevant issues/docs

🤔 Checklist before submitting

  • I made sure all projects build.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I followed the style guide lines (code style guide).
  • I updated the relevant documentation.
  • I rebased onto current master.

@TatsuUkraine
Copy link

any timeline when these changes might be released?

@eherbut
Copy link

eherbut commented Aug 22, 2022

Android 13 started to rollout, we still have no ability to use these READ_MEDIA_IMAGES, READ_MEDIA_VIDEO and READ_MEDIA_AUDIO
Who can answer when this change will be released?

@armandojimenez
Copy link

Any plans to release this? Android 13 is already out

@felipheallef
Copy link
Author

This PR needs to be approved and merged by a maintainer in order to be released, so I don't have any idea when these changes will be released.

@MilosKarakas
Copy link
Contributor

Until this get merged you can use compileSdk 32 and targetSdk 32 and it will work just fine. I hope this gets merged soon so we could use API 33, but it is what it is for now.

@alexmercerind
Copy link

Hi!
Does this work on Android 12 or lower?
Do I need to separately handle permission to request full media (all photos, videos & audio) separately inside code?

Thanks.

@MilosKarakas
Copy link
Contributor

Android 13 introduces the granular permissions. Android 12 and lower does not have that and everything should work the same as is used to.

@armandojimenez
Copy link

Android 13 introduces the granular permissions. Android 12 and lower does not have that and everything should work the same as is used to.

Yes, but now do we have to check if Android < 12 keep asking for storage permission and if Android > 12 ask for media or pictures permissions? Or just ask for a granular one on Android 13 and it should fallback to storage permission if it's a lower android version?

@alexmercerind
Copy link

@armandojimenez

I tried using only READ_MEDIA_AUDIO (i.e. only audio, video or images) on Android 12, it turns out it does nothing.

I see this on my terminal (using Permission.storage.audio):

no permissions found in manifest for: []32

I still needed to use existing Permission.storage.request on Android 12.
Likely READ_MEDIA_XYZ is only Android 13 specific. Maybe querying Android version is only option & using Permission.storage & Permission.audio based on that. package:device_info_plus or MethodChannel impl. within project can be used for this purpose I guess.


  • I did upgrade my targetSdkVersion & compileSdkVersion to 33.
  • Added READ_MEDIA_AUDIO to my AndroidManifest.xml.

Android is not my field expertise, deprecated methods everywhere after every release. More & more permissions with each SDK.

Still, It would've been cooler if Android engineers could handle it automatically. i.e. showing full-media access dialog on Android 12 or lower.

@armandojimenez
Copy link

Anyone knows how can I use this branch in my app?

@armandojimenez
Copy link

@armandojimenez

I tried using only READ_MEDIA_AUDIO (i.e. only audio, video or images) on Android 12, it turns out it does nothing.

I see this on my terminal (using Permission.storage.audio):

no permissions found in manifest for: []32

I still needed to use existing Permission.storage.request on Android 12. Likely READ_MEDIA_XYZ is only Android 13 specific. Maybe querying Android version is only option & using Permission.storage & Permission.audio based on that. package:device_info_plus or MethodChannel impl. within project can be used for this purpose I guess.

  • I did upgrade my targetSdkVersion & compileSdkVersion to 33.
  • Added READ_MEDIA_AUDIO to my AndroidManifest.xml.

Android is not my field expertise, deprecated methods everywhere after every release. More & more permissions with each SDK.

Still, It would've been cooler if Android engineers could handle it automatically. i.e. showing full-media access dialog on Android 12 or lower.

This is what I will test now. I created a method channel that returns me the SDK Int, and will add new logic only if Android > 12

@armandojimenez
Copy link

Tried like this:

permission_handler: 
    git:
      url: https://github.com/felipheallef/flutter-permission-handler
      path: permission_handler 

But I am getting this error with pub get:

Because every version of permission_handler from git depends on permission_handler_platform_interface ^3.8.0 which doesn't match any versions, permission_handler from git is forbidden.
So, because believe depends on permission_handler from git, version solving failed.
pub get failed (1; So, because believe depends on permission_handler from git, version solving failed.)

@felipheallef
Copy link
Author

Hi! Does this work on Android 12 or lower? Do I need to separately handle permission to request full media (all photos, videos & audio) separately inside code?

Thanks.

Yes, it does work on Android < 13 but you still need to set targetSdkVersion 33. Also I'd recommend you to use device_info_plus to check if Android SDK version is 33 or higher and then ask this permissions.

@felipheallef
Copy link
Author

Tried like this:

permission_handler: 
    git:
      url: https://github.com/felipheallef/flutter-permission-handler
      path: permission_handler 

But I am getting this error with pub get:

Because every version of permission_handler from git depends on permission_handler_platform_interface ^3.8.0 which doesn't match any versions, permission_handler from git is forbidden.
So, because believe depends on permission_handler from git, version solving failed.
pub get failed (1; So, because believe depends on permission_handler from git, version solving failed.)

@armandojimenez this happens because I have increased the version number for the packages in this PR. But I can publish these changes into a new package on pub.dev if you want to use these features.

@armandojimenez
Copy link

Tried like this:

permission_handler: 
    git:
      url: https://github.com/felipheallef/flutter-permission-handler
      path: permission_handler 

But I am getting this error with pub get:

Because every version of permission_handler from git depends on permission_handler_platform_interface ^3.8.0 which doesn't match any versions, permission_handler from git is forbidden.
So, because believe depends on permission_handler from git, version solving failed.
pub get failed (1; So, because believe depends on permission_handler from git, version solving failed.)

@armandojimenez this happens because I have increased the version number for the packages in this PR. But I can publish these changes into a new package on pub.dev if you want to use these features.

Please do! I had to fork your branch, then edit the interface package version number to 3.7.0 so it does not throw errors, and then I had to do overrides like this:

dependency_overrides:
  permission_handler_android: 
    git:
      url: https://github.com/armandojimenez/flutter-permission-handler
      path: permission_handler_android  

  permission_handler_platform_interface: 
    git:
      url: https://github.com/armandojimenez/flutter-permission-handler
      path: permission_handler_platform_interface

I just tested this and everything is working! But I had to create a method channel that returns the SDK int and do a condition to ask for Permission.photo when > Android12, and Permission.storage when < Android12. It would be good if the logic in the package verified the SDK version, and fallback to Permission.storage, so we don't need to handle that logic on the dart side

@jack24254029
Copy link

jack24254029 commented Sep 20, 2022

All checks have failed.
You should be improve these problems.

@armandojimenez
Copy link

With this pull I was able to release my app with SDK 33. Since this was closed, any plans to implement this permissions?

@Zazo032
Copy link

Zazo032 commented Oct 3, 2022

@felipheallef why was this closed?

@MatthewPatience
Copy link

@Zazo032 @armandojimenez It appears because PR #934 supersedes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants