zoontek / react-native-permissions

An unified permissions API for React Native on iOS, Android and Windows.
MIT License
4.11k stars 837 forks source link

Getting unavailable photoLibrary on select Xiaomi devices #908

Open christian-hess-94 opened 1 week ago

christian-hess-94 commented 1 week ago

Before submitting a new issue

Bug summary

We have a QA person that does manual testing of our app. He uses, on android, a Xiaomi phone (specs below). For some reason when we request PERMISSIONS.ANDROID.READ_MEDIA_IMAGES he gets the native popup and is able to give permissions. However it's returned as unavailable after allowing access. We use this to render a button so the users can upload photos directly from their photo reel. Testing other xiaomi devices and even Samsung and motorola device, this issue does not present itself. It only happens on this specific Xiaomi device our QA is using.

Phone Specs image

Library version

5.1.0

Environment info

System:
  OS: Windows 11 10.0.22631
  CPU: "(16) x64 AMD Ryzen 7 3800X 8-Core Processor             "
  Memory: 19.32 GB / 31.93 GB
Binaries:
  Node:
    version: 18.20.4
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.1
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 10.7.0
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-241.18034.62.2411.12169540
  Visual Studio: Not Found
Languages:
  Java:
    version: 17.0.12
    path: C:\Program Files\Microsoft\jdk-17.0.12.7-hotspot\bin\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.5
    wanted: 0.74.5
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

info React Native v0.76.2 is now available (your project is running on v0.74.5).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.76.2
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.74.5
info For more info, check out "https://reactnative.dev/docs/upgrading?os=windows".

Steps to reproduce

  1. Install the permissions package (5.1.0)
  2. Create a button that request PERMISSIONS.ANDROID.READ_MEDIA_IMAGES permission
  3. Give the permission once prompted
  4. Use check() to retrieve the permission status
  5. Install the phone on a Xiaomi Redmi Note 9 Pro

Reproducible sample code

//This is the code we execute to request the library and camera permissions

const camera = await request(PERMISSIONS.ANDROID.CAMERA);
      const photoLibrary = await request(PERMISSIONS.ANDROID.READ_MEDIA_IMAGES);

      const cameraGranted = camera === 'granted';
      const photoLibraryGranted = photoLibrary === 'granted';
      const photoLibraryUnavailable = photoLibrary === 'unavailable';
      const allPermissionsGiven = cameraGranted && photoLibraryGranted;
      response = {
        cameraGranted,
        photoLibraryGranted,
        photoLibraryUnavailable,
        allPermissionsGiven,
        camera,
        photoLibrary,
      };
      console.log('[Android]Camera permission status: ', response);
return response
haiderTkxel commented 2 days ago

Any solution of above issue?

zoontek commented 2 days ago

@christian-hess-94 @haiderTkxel I cannot reproduce with a Pixel or other Android 14 devices, so I guess this is a MIUI issue. I will try something, but I'm blind as I cannot test it, so there will be a beta and you will have to confirm before shipping.

zoontek commented 8 hours ago

@christian-hess-94 @haiderTkxel Not sure if it helps with the issue (I cannot test with MIUI), but could you try with 5.2.1?

christian-hess-94 commented 7 hours ago

we could try that here, yes @zoontek

christian-hess-94 commented 7 hours ago

@zoontek we have deployed a version of our app internally with version 5.2.1 so our QA person can test.

I tried on iOS and Android (other devices, Samsung etc) and it all works fine. We'll need to wait for the QA's feedback. I'll post whatever happens tomorrow at most