Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Do no require write storage permission to downloading files on devices with Android 11 and above #9830

Closed
Amejia481 opened this issue Mar 4, 2021 · 15 comments
Labels
<download> Component: feature-download help wanted Extra attention is needed
Milestone

Comments

@Amejia481
Copy link
Contributor

Amejia481 commented Mar 4, 2021

In devices with Android 11 and above we are using the scoped storage api and we are only writing to the public download directory that doesn't require any additional permission. We could waive the permission requirements for these devices as it's not needed.

┆Issue is synchronized with this Jira Task

@Amejia481 Amejia481 added help wanted Extra attention is needed <download> Component: feature-download labels Mar 4, 2021
@czlucius
Copy link
Contributor

May I work on this issue?

@Amejia481
Copy link
Contributor Author

Please, do so :)
If you need any help just let me know.

Mostly we have to skip the checks for permissions when we are on Android 11 and above.

@czlucius
Copy link
Contributor

czlucius commented Jul 23, 2021

The write storage permission is completely not required(not used at all in the downloads component)? Are there other areas that use this write permission even in >= API 30? If not, I can add maxSdkVersion to the permission in the Android Manifest.

I have removed checks for the permission by editing permissions in AndroidDownloadManager, which the other classes all refer to to request for this permission.
screen-2021-07-23-15-42-59

@czlucius
Copy link
Contributor

image
What do I do for the PR checklist? How do I run the test/what tests do I need to create?

Thank you.

@czlucius
Copy link
Contributor

I have made a PR for this issue: #10686

@Amejia481
Copy link
Contributor Author

maxSdkVersion

I'll have to double check, but I think It won't be a problem as for now we are only writing to the public downloads directory, but maybe when we allow to change the download directory could cause issues mozilla-mobile/fenix#5764.

@Amejia481
Copy link
Contributor Author

What do I do for the PR checklist?

The checklist is just for reference of what all PRs should have, when you complete an you just have to check it.

How do I run the test/what tests do I need to create?

I would focus on creating tests for the module that you changed (feature-downloads), making sure we don't require the permission on devices with Android 11.

For running test for feature-downloads you can use:
./gradlew :feature-downloads:testDebug

You can find more information here. This documentation could help you to have a better idea of how to work with Android Components locally. On CI, they should run on every PR you can see each task on the "Checks" Tab on GitHub.

@czlucius
Copy link
Contributor

czlucius commented Jul 24, 2021

maxSdkVersion

I'll have to double check, but I think It won't be a problem as for now we are only writing to the public downloads directory, but maybe when we allow to change the download directory could cause issues mozilla-mobile/fenix#5764.

Ok.
But I think the permission is deprecated on newer Android versions (>=11) and no longer grants any permissions.
https://developer.android.com/about/versions/11/privacy/storage#permissions-target-11

If there is a need to choose the download directory, the Storage Access Framework needs to be used to pick the directory

@Amejia481
Copy link
Contributor Author

👍🏽

@czlucius
Copy link
Contributor

czlucius commented Jul 27, 2021

I keep on receiving this error while building:

Gradle sync failed: Unrecognized Android Studio (or Android Support plugin for IntelliJ IDEA) version '202.7660.26.42.7486908', please retry with version 2020.3.1 or newer.

Here's my Android Studio configuration:
Android Studio 4.2.2
Build #AI-202.7660.26.42.7486908, built on June 24, 2021
Runtime version: 11.0.8+0-b944-P17168821 amd64
VM: OpenJDK 64-Bit Server VM by N/A
Linux 5.4.0-77-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 8
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: QAPlug, com.intellij.marketplace, com.thoughtworks.gauge, org.jetbrains.kotlin, org.intellij.plugins.markdown
Current Desktop: LXQt

It seems that the version of my installation is equal to the unknown version, but somehow building seems to fail.

@hkaancaliskan
Copy link

@czlucius team is currently working on Jetpack Compose, maybe you should try with Android Studio canary version 🤷

@czlucius
Copy link
Contributor

Noted. Thanks.

@Amejia481
Copy link
Contributor Author

Sorry about that, as @hakkikaancaliskan mentioned we trying to integrate Jetpack Compose and it requires

  • Java 11 (when invoking Gradle on the command line)
  • Android Studio - Arctic Fox [RC 1](comes with Java 11 bundled)
  • Everything else should be downloaded by Gradle as needed

czlucius added a commit to czlucius/mozilla-android-components that referenced this issue Aug 8, 2021
@czlucius
Copy link
Contributor

czlucius commented Aug 8, 2021

Hi
I've added some tests to the PR, is there anything else I need to do?
Thanks.

@Amejia481
Copy link
Contributor Author

Thanks @czlucius, no the tests were the last requirements. I'll take a look :)

Amejia481 added a commit to czlucius/mozilla-android-components that referenced this issue Aug 9, 2021
…ownloading files on devices with Android 10 and above
Amejia481 pushed a commit to czlucius/mozilla-android-components that referenced this issue Aug 9, 2021
…ownloading files on devices with Android 10 and above
Amejia481 pushed a commit to czlucius/mozilla-android-components that referenced this issue Aug 12, 2021
…ownloading files on devices with Android 10 and above
Amejia481 pushed a commit to czlucius/mozilla-android-components that referenced this issue Aug 12, 2021
…ownloading files on devices with Android 10 and above
Amejia481 pushed a commit to czlucius/mozilla-android-components that referenced this issue Aug 12, 2021
…ownloading files on devices with Android 10 and above
@mergify mergify bot closed this as completed in 2639ed8 Aug 16, 2021
@Amejia481 Amejia481 added this to the 93.0.0 🧂 milestone Aug 16, 2021
grigoryk pushed a commit to gabrielluong/android-components that referenced this issue Sep 11, 2021
…ownloading files on devices with Android 10 and above
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
<download> Component: feature-download help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants