-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Do not ask for storage permissions when it's a fresh installation #4297
Conversation
4289b3a
to
fc3b134
Compare
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.
Would be great to get some testing. Maybe just a small test for areStoragePermissionsGranted
that verifies that true
is always returned if scoped storage is enabled?
I like what you've done with PermissionUtils
. I'm wondering whether it's also a good opportunity to rename it to maybe PermissionsRequester
or PermissionsProvider
?
I thought the same at the end of my day yesterday. I'll try to add something valuable. |
fc3b134
to
cfa08fe
Compare
I like what you've done with PermissionUtils. I'm wondering whether it's also a good opportunity to rename it to maybe PermissionsRequester or PermissionsProvider? It's ready, I added some tests and implemented code refactoring. |
collect_app/src/test/java/org/odk/collect/android/permissions/PermissionsProviderTest.java
Outdated
Show resolved
Hide resolved
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.
Looks good other than the main test... 🙃 Feel free to mark as needs testing
once that's fixed and conflicts are resolved.
f702b0b
to
ecbf1d5
Compare
public static String getFileExtensionFromUri(Uri fileUri) { | ||
String mimeType = getContentResolver().getType(fileUri); | ||
|
||
String extension = fileUri.getScheme() != null && fileUri.getScheme().equals(ContentResolver.SCHEME_CONTENT) |
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.
Wouldn't we always be dealing with content URIs here? In what cases would we have file URIs?
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.
Or was that the selfie video case again?
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.
This was the fix added for a crash some time ago f98b98d so I wanted to keep it just in case seeing how other cases might be tricky.
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.
Got it. Would be great to follow up with #2834 because this method has gone through lots of big changes during this PR that probably would have been avoided with tests.
714a264
to
d23c73d
Compare
@lognaturel Generally I think it's ready for testing unless you see something important. |
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.
This has turned into an adventure! Good to see so much code going away.
Lots of little things to check around the media selection questions like are temporary files cleaned up and all the cases around MIME types and file extensions I listed earlier.
I added some improvements to handle |
Nice. But does this mean that recording video with that default app would never work? I wonder if this is going to be a broader issue -- are media apps for older OS versions not going to work because they expect the blanket read permissions to be given? |
I tested emulators with apis 22-30 and noticed that problem on api 23 and 25. In those cases recording is not possible with default camera apps. Granting storage permission fixes the issue but I thought it was a bug in those camera apps. In the doc where recording videos is described https://developer.android.com/training/camera/videobasics there is nothing about storage permission and we use exactly that way. Apparently they love to confuse people. I also read https://developer.android.com/training/data-storage/shared/media and https://developer.android.com/training/data-storage/shared/documents-files and my understanding is that we shouldn't need that permissions. |
a580e74
to
67b416c
Compare
67b416c
to
bb23041
Compare
Tested with success Verified on Android 7.0, 8.1, 10.0 Verified cases:
|
Verified also on Androids 5.1, 7.1 and 9.0. @getodk-bot unlabel "needs testing" |
Regarding that problems with permissions: If it's not our fault bug external apps that do not grant uri permission we may need to consider adding something like: 17431bb |
Closes #4288
What has been done to verify that this works as intended?
I tested the behavior.
Why is this the best possible solution? Were any other approaches considered?
I decided to call
requestStoragePermissions()
like before but add one trick which is here:https://github.com/getodk/collect/pull/4297/files#diff-fe2bc5034d6dfe946ff681f198d0552c83038caed992865f5e7ce030447a276bR98
Another option would be to check if we need storage permission before calling
requestStoragePermissions()
but that would require adding more if/else statements and the code would be more cluttered.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Fresh installs should not ask for storage permission that's the only change. In order to confirm that everything works fine it would be good to go through some functionalities where normally we would be asked for permissions.
Do we need any specific form for testing your changes? If so, please attach one.
No.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew checkAll
and confirmed all checks still pass OR confirm CircleCI build passes and run./gradlew connectedDebugAndroidTest
locally.