Skip to content

fix: import PermissionsAndroid and fix broken permission check in Utils.ts#2107

Open
anushkasrvstv wants to merge 4 commits into
SB2318:mainfrom
anushkasrvstv:fix/permissions-android-import-utils
Open

fix: import PermissionsAndroid and fix broken permission check in Utils.ts#2107
anushkasrvstv wants to merge 4 commits into
SB2318:mainfrom
anushkasrvstv:fix/permissions-android-import-utils

Conversation

@anushkasrvstv

Copy link
Copy Markdown
Contributor

Pull Request

Description

Fixes three bugs in frontend/src/helper/Utils.ts around Android permission
handling:

  1. Missing importPermissionsAndroid was used but never imported
    from react-native, causing a ReferenceError and crash on Android.
  2. No-op permission requestrequestMultiple([]) was called with an
    empty array, so it requested zero permissions even after the import fix.
    Now requests WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE for
    Android versions below API 33.
  3. Incorrect return type — the function ended with a bare return;,
    resolving to undefined instead of a boolean. Callers using
    if (await checkPermission())-style logic were getting undefined
    rather than a real pass/fail result. Now returns true only when both
    permissions are granted.

Closes #2099

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

…ls.ts

- Add missing PermissionsAndroid import from react-native
- Fix requestMultiple([]) no-op by passing WRITE_EXTERNAL_STORAGE and
  READ_EXTERNAL_STORAGE for Android < 33
- Return a proper boolean (true only when both permissions granted)
  instead of an implicit undefined

Closes SB2318#2099
@github-actions

Copy link
Copy Markdown
Contributor

Thank you @, for creating the PR and contributing to our UltimateHealth project 💗.
Our team will review the PR and will reach out to you soon! 😇
Make sure that you have marked all the tasks that you are done with ✅.
Thank you for your patience! 😀

@github-actions

Copy link
Copy Markdown
Contributor

Automated Review Feedback

Provide actionable comments grouped by severity:

Suggestions

Consider adding automated tests (e.g., integration or E2E tests) to verify the correct behavior of permission requests on Android. While PermissionsAndroid interactions can be challenging to unit test, ensuring this critical functionality works as expected across different Android versions would improve long-term stability.

Maintainer Note:

Once the initial automated feedback has been addressed, maintainer @SB2318 will review the pull request for final evaluation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞[Bug]: PermissionsAndroid used without import in Utils.ts — crashes on Android

1 participant