Skip to content
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

fix(android): hasWritePermission for SDK 33 #608

Merged
merged 7 commits into from
Oct 17, 2023

Conversation

erisu
Copy link
Member

@erisu erisu commented Oct 17, 2023

Platforms affected

android

Motivation and Context

rebase, fix, and simplify changes from #581

Closes #581

Description

This PR performed following changes against #581:

  • Rebased against current main branch
  • Reverted previous changes to getWritePermission but applied suggestion to simplify. the condition check and to add extra accidental calls, even though the method would never be called in that scenario.
  • Simplifed hasWritePermission logic
  • Added comment suggestion to hasWritePermission

Testing

build test

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@erisu erisu changed the title Eyalin fix android 13 has write permission fix(android): hasWritePermission for SDK 33 Oct 17, 2023
@erisu erisu merged commit c10942a into apache:master Oct 17, 2023
5 of 10 checks passed
@erisu erisu deleted the EYALIN-fix-android-13-hasWritePermission branch October 17, 2023 23:32
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
int requestCode = pendingRequests.createRequest(rawArgs, action, callbackContext);
PermissionHelper.requestPermission(this, requestCode, Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is happening here in the else case?
Mostly asking because getWritePermission is always called providing a callbackContext.
Are we sure it does not wait indefinitely?
Is doing nothing really fine, or should callbackContext be called in every case, to guarantee the execution flow continues?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I "found" my own answer:
in current code, in the case of Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU, getWritePermission is never called ...
So my question does not really mater, even if strictly speaking it is probably a problem for the execution flow, indefinitely waiting for the callbackContext.

Details:
getWritePermission calls are always preceded by a check for needPermission(nativeURL, WRITE), that will return false in this same given versions condition, because hasWritePermission was changed to always return true for it.
So, the if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { added in getWritePermission is mostly useless, and should whether be removed or be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants