-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Bypassed Storage Permission Check for Shared Images #6543
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
base: main
Are you sure you want to change the base?
Bypassed Storage Permission Check for Shared Images #6543
Conversation
The share intent provides files via content uris with temporary read permissions, so we do not need to obtain storage permissions
WalkthroughThe upload activity's permission check flow is modified to bypass storage permission requirements for share intents. When Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UploadActivity
participant PermissionCheck
participant SharedItemHandler
User->>UploadActivity: Send/Share intent
UploadActivity->>PermissionCheck: checkStoragePermissions()
alt Share Intent Detected (NEW)
PermissionCheck->>SharedItemHandler: receiveSharedItems()
SharedItemHandler->>SharedItemHandler: Process via content URIs
Note over SharedItemHandler: No storage permissions requested
else Standard Intent (PREVIOUS)
PermissionCheck->>PermissionCheck: hasAllPermissions or hasPartialAccess?
PermissionCheck->>SharedItemHandler: receiveSharedItems()
end
SharedItemHandler->>User: Display selected items
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.kt (1)
317-325: Share intent permission bypass looks good; consider visibility state and refactoring.The approach is sound—share intents provide temporary read permissions via content URIs, so bypassing storage permission checks is correct and should fix issue #6437.
Minor considerations:
Top card visibility: In the permission-granted path (line 330),
cvContainerTopCard.visibilityis set toVISIBLEbefore callingreceiveSharedItems(). The new share-intent path skips this. If the default XML visibility is notVISIBLE, multi-file uploads might not display the top card correctly. Consider adding:binding.cvContainerTopCard.visibility = View.VISIBLEbefore calling
receiveSharedItems()at line 323.Code duplication: The intent action check at lines 322 duplicates the check at line 485 in
receiveSharedItems(). Consider extracting a helper:private fun isShareIntent() = intent.action in listOf(Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE)
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.
Works great! :) Just a minor suggestion - I'll merge once addressed.
…on-external-share' into 6437-bypass-check-storage-perms-on-external-share
|
✅ Generated APK variants! |
The share intent provides files via content uris with temporary read permissions, so we do not need to obtain storage permissions
Description (required)
Fixes #6437
What changes did you make and why?
Modified
UploadActivity.checkStoragePermissionsto bypass checking for storage permission when receiving images from a share intent (and thus requesting storage permissions) as the share intent provides files via content uris with temporary read permissions, so we do not need to obtain storage permissions.Tests performed (required)
Tested betaDebug on Medium Phone with API level 35.
Tested prodDebug on Medium Phone with API level 35.
Note: Please ensure that you have read CONTRIBUTING.md if this is your first pull request.
Summary by CodeRabbit
Release Notes