-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Check Storage Permission Before Upload #15240
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
Conversation
38a609b
to
92df4ea
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Looks like full file access permission fixed the issue, please read the issue and comments. #15039 (comment) |
92df4ea
to
d446815
Compare
d83b4f9
to
b7be9b8
Compare
app/src/main/java/com/owncloud/android/operations/upload/UploadFileOperationExtensions.kt
Fixed
Show resolved
Hide resolved
b7be9b8
to
f0632aa
Compare
d5dcd8d
to
f79c579
Compare
/backport to stable-3.32 |
if (!localFile.canRead()) { | ||
Log_OC.e(TAG, "Upload cancelled for " + getStoragePath() + ": file is not readable or inaccessible."); | ||
UploadFileOperationExtensionsKt.showStoragePermissionNotification(this); | ||
missingPermissionThrown.set(true); |
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 is set for one operation, but what if we have multiple runs?
E.g. user uploads 5x, one after the other?
Then it is always being reset and the user will receive 5x the "error" message?
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.
It's using same notification id also I added check for active notification thus it will only display one notification.
Screen.Recording.2025-08-14.at.09.08.55.mov
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
Signed-off-by: alperozturk <alper_ozturk@proton.me>
… "missingPermissionThrown" in one thread may not yield the value of the most recent write from another thread Signed-off-by: alperozturk <alper_ozturk@proton.me>
f79c579
to
95375f8
Compare
Signed-off-by: alperozturk <alper_ozturk@proton.me>
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/15240.apk |
.addAction(appPermissionsAction) | ||
.setAutoCancel(true) | ||
|
||
notificationManager.notify(MISSING_FILE_PERMISSION_NOTIFICATION_ID, notificationBuilder.build()) |
Check failure
Code scanning / CodeQL
Use of implicit PendingIntents High
An implicit Intent is created
Copilot Autofix
AI 3 days ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
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.
https://github.com/nextcloud/android/security/code-scanning/246

Already immutable and has specific action.
private fun getActionPendingIntent(context: Context, actionType: UploadFileBroadcastReceiverActions): PendingIntent {
val intent = Intent(context, UploadFileBroadcastReceiver::class.java).apply {
action = "com.owncloud.android.ACTION_UPLOAD_FILE_PERMISSION"
putExtra(UploadFileBroadcastReceiver.ACTION_TYPE, actionType)
}
return PendingIntent.getBroadcast(
context,
actionType.ordinal,
intent,
PendingIntent.FLAG_IMMUTABLE
)
}
Issue
Previously granted
MANAGE_EXTERNAL_STORAGE
orOnly Media Access
permission can be revoked if the app hasn't been used for a few months (e.g. if user not opens the app just using the app for auto upload) or after a system upgrade.Some other OS implementations may handle this differently, so we need to cover this edge case as well.
Also, it seems that some users have experienced this issue before and resolved it by re-granting the permission.
#15218 (comment)
#15039 (comment)
Changes
Notes
PermissionUtil.requestExternalStoragePermission
cannot be used to display the same permission dialog that appears at the beginning of the application, as it depends onAppCompatActivity
. Therefore, we inform the user and provide them with the option to choose between the standard app permission or full file access.@ZetaTom
Additionally, instead of handling the error after a failed upload, we proactively check for the necessary permissions before initiating the upload. This approach prevents unnecessary calls and simplifies the logic flow.
All files access action
App permissions action
We cannot redirect to the directly to the storage permission page. There is no intent action for that.