Skip to content

Commit 3a51578

Browse files
Bypassed Storage Permission Check for Shared Images (#6543)
* Bypassed Storage Perms Check for External Share The share intent provides files via content uris with temporary read permissions, so we do not need to obtain storage permissions * Removed Unnecessary Local Variable * Moved Bypass to the Start of checkStoragePermissions() * Removed Duplicate Check in receiveSharedItems --------- Co-authored-by: Ritika Pahwa <83745993+RitikaPahwa4444@users.noreply.github.com>
1 parent 14ecbe9 commit 3a51578

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,20 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
311311
}
312312

313313
private fun checkStoragePermissions() {
314+
// The share intent provides files via content uris with temporary read permissions,
315+
// so we do not need to obtain storage permissions
316+
val action = intent.action
317+
if (Intent.ACTION_SEND == action || Intent.ACTION_SEND_MULTIPLE == action) {
318+
// Get the external items first
319+
receiveExternalSharedItems()
320+
receiveSharedItems()
321+
return
322+
}
323+
314324
// Check if all required permissions are granted
315325
val hasAllPermissions = hasPermission(this, PERMISSIONS_STORAGE)
316326
val hasPartialAccess = hasPartialAccess(this)
327+
317328
if (hasAllPermissions || hasPartialAccess) {
318329
// All required permissions are granted, so enable UI elements and perform actions
319330
receiveSharedItems()
@@ -472,9 +483,7 @@ class UploadActivity : BaseActivity(), UploadContract.View, UploadBaseFragment.C
472483
private fun receiveSharedItems() {
473484
val intent = intent
474485
val action = intent.action
475-
if (Intent.ACTION_SEND == action || Intent.ACTION_SEND_MULTIPLE == action) {
476-
receiveExternalSharedItems()
477-
} else if (ContributionController.ACTION_INTERNAL_UPLOADS == action) {
486+
if (ContributionController.ACTION_INTERNAL_UPLOADS == action) {
478487
receiveInternalSharedItems()
479488
}
480489

0 commit comments

Comments
 (0)