Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-116181

Android: QFile can't open file in directory which is chosen by QFileDialog::getExistingDirectory()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.2.10, 6.5.3, 6.6.0 Beta4, 6.7.0 FF
    • 6.5.2, 6.6.0 Beta2
    • QPA: Android
    • None
    • Host:Linux x86_64
      Target:Android arm64_v8a Pixel6 Android13
    • Android
    • 381612f79 (dev), 7acc0875d (6.5), 43148c8a5 (tqtc/lts-6.2), 5a171799c (6.6)
    • 2023wk34FOQtforAndroid

    Description

      Steps to reproduce:
      1. Build and deploy qtbase/examples/widgets/gestures/imagegestures .
      2. Launch imagegestures example with Qt creator.
      3. Open (Device)/DCIM/Camera(actually /storage/emulated/0/DCIM/Camera) folder in FileDialog.
      4. Tap "Use this folder"
      5. Tap "Allow" to "Allow imagegestures to access files in Camera?" dialog.
      6. App crashes and application output says like this.

      I QtCore  : Start
      I Qt      : qt started
      D CompatibilityChangeReporter: Compat change id reported: 210923482; UID 10348; state: DISABLED
      D CompatibilityChangeReporter: Compat change id reported: 37756858; UID 10348; state: ENABLED
      D CompatibilityChangeReporter: Compat change id reported: 237531167; UID 10348; state: DISABLED
      D libEGL  : loaded /vendor/lib64/egl/libGLES_mali.so
      D CompatibilityChangeReporter: Compat change id reported: 78294732; UID 10348; state: DISABLED
      W e.imagegestures: Attempt to remove non-JNI local reference, dumping thread
      E BufferQueueProducer: [SurfaceView[org.qtproject.example.imagegestures/org.qtproject.qt.android.bindings.QtActivity]#2(BLAST Consumer)2](id:6b7100000002,api:0,p:-1,c:27505) disconnect: not connected (req=2)
      W imagegestures: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/primary%3ADCIM%2FCamera%2F20200918_220836.jpg from pid=27505, uid=10348 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
      W imagegestures:     at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
      W imagegestures:     at android.os.Parcel.createException(Parcel.java:2995)
      W imagegestures:     at android.os.Parcel.readException(Parcel.java:2978)
      W imagegestures:     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
      W imagegestures:     at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:153)
      W imagegestures:     at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:780)
      W imagegestures:     at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2027)
      W imagegestures:     at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1842)
      W imagegestures:     at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:1
      W imagegestures: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/primary%3ADCIM%2FCamera%2F20200918_220836.jpg.bmp/document/primary%3ADCIM%2FCamera%2F20200918_220836.jpg.bmp from pid=27505, uid=10348 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
      W imagegestures:     at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
      W imagegestures:     at android.os.Parcel.createException(Parcel.java:2995)
      W imagegestures:     at android.os.Parcel.readException(Parcel.java:2978)
      W imagegestures:     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
      W imagegestures:     at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:153)
      W imagegestures:     at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:780)
      W imagegestures:     at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2027)
      W imagegestures:     at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1842)
      W imagegestures:     at android.co
      W imagegestures: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/primary%3ADCIM%2FCamera%2F20200918_220836.jpg.cur/document/primary%3ADCIM%2FCamera%2F20200918_220836.jpg.cur from pid=27505, uid=10348 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
      W imagegestures:     at android.os.Parcel.createExceptionOrNull(Parcel.java:3011)
      W imagegestures:     at android.os.Parcel.createException(Parcel.java:2995)
      W imagegestures:     at android.os.Parcel.readException(Parcel.java:2978)
      W imagegestures:     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
      W imagegestures:     at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:153)
      W imagegestures:     at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:780)
      W imagegestures:     at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2027)
      W imagegestures:     at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1842)
      W imagegestures:     at android.co
      W imagegestures: java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/primary%3ADCIM%2FCamera%2F20200918_220836.jpg.gif/document/primary%3ADCIM%2FCamera%2F20200918_220836.jpg.gif from pid=27505, uid=10348 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
          :
          :
      W qt.examples.imagegestures: : "content://com.android.externalstorage.documents/tree/primary%3ADCIM%2FCamera/20220326_202216.jpg" : can't load image
      
      "org.qtproject.example.imagegestures" died.
      

      Listing files in the directory seems to succeed but QFile cannot open individual file in the directory.

      NOTE:
      KDAB's example does similar thing and works fine.
      https://github.com/KDAB/android/tree/master/examples/shared_storage
      ContentResolver in this example calls Android API's "takePersistableUriPermission" for each file in the directory.
      But in Qt6.5 it is implemented in QAndroidPlatformFileDialogHelper::takePersistableUriPermission() and it is private method.
      So there is no way to take permission for each file without QFileDialog.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            assam Assam Boudjelthia
            eighttails Tadahito Yao
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes