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

QFile Permission Denial: reading com.android.externalstorage.ExternalStorageProvider

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.15.0 Beta1
    • 5.13.0 Beta2
    • Core: I/O
    • None
    • Android
    • dcb38e4bc74337d0d670bc30b8193cbd73f11599 (qt/qtbase/5.15)

    Description

      When I try to open a file under Android 9.0 my app crashes.

      I use the QML FileDialog to get the URI. It seems that the URI has to following format

      content://com.android.externalstorage.documents/documents/primary:<myFile>

      QFile code 

      QFile myFile("content://com.android.externalstorage.documents/documents/primary:<myFile>");
      myFile.open(QIODevice::ReadOnly)

      When I pass this URI to QFile the app crashes with the error

      JNI DETECTED ERROR IN APPLICATION: JNI GetStaticMethodID called with pending exception java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri :xxxxx

      Inside the AndroidManifest.xml the READ_EXTERNAL_STORAGE is added 

      <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

      Stack trace

      F io.welle.welle: java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: JNI GetStaticMethodID called with pending exception java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri :xxxxx from pid=10879, uid=10072 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
      F io.welle.welle: java_vm_ext.cc:542] at java.lang.Exception android.os.Parcel.createException(int, java.lang.String) (Parcel.java:1950)
      F io.welle.welle: java_vm_ext.cc:542] at void android.os.Parcel.readException(int, java.lang.String) (Parcel.java:1918)
      F io.welle.welle: java_vm_ext.cc:542] at void android.database.DatabaseUtils.readExceptionFromParcel(android.os.Parcel, java.lang.String, int) (DatabaseUtils.java:183)
      F io.welle.welle: java_vm_ext.cc:542] at void android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(android.os.Parcel) (DatabaseUtils.java:146)
      F io.welle.welle: java_vm_ext.cc:542] at android.content.res.AssetFileDescriptor android.content.ContentProviderProxy.openTypedAssetFile(java.lang.String, android.net.Uri, java.lang.String, android.os.Bundle, android.os.ICancellationSignal) (ContentProviderNative.java:698)
      F io.welle.welle: java_vm_ext.cc:542] at android.content.res.AssetFileDescriptor android.content.ContentResolver.openTypedAssetFileDescriptor(android.net.Uri, java.lang.String, android.os.Bundle, android.os.CancellationSignal) (ContentResolver.java:1460)
      F io.welle.welle: java_vm_ext.cc:542] at android.content.res.AssetFileDescriptor android.content.ContentResolver.openAssetFileDescriptor(android.net.Uri, java.lang.String, android.os.CancellationSignal) (ContentResolver.java:1297)
      F io.welle.welle: java_vm_ext.cc:542] at android.os.ParcelFileDescriptor android.content.ContentResolver.openFileDescriptor(android.net.Uri, java.lang.String, android.os.CancellationSignal) (ContentResolver.java:1150)
      F io.welle.welle: java_vm_ext.cc:542] at android.os.ParcelFileDescriptor android.content.ContentResolver.openFileDescriptor(android.net.Uri, java.lang.String) (ContentResolver.java:1104)
      F io.welle.welle: java_vm_ext.cc:542] at int org.qtproject.qt5.android.QtNative.openFdForContentUrl(android.content.Context, java.lang.String, java.lang.String) (QtNative.java:177)
      F io.welle.welle: java_vm_ext.cc:542] at void org.qtproject.qt5.android.QtNative.startQtApplication() (QtNative.java:-2)
      F io.welle.welle: java_vm_ext.cc:542] at void org.qtproject.qt5.android.QtNative$7.run() (QtNative.java:387)
      F io.welle.welle: java_vm_ext.cc:542] at void org.qtproject.qt5.android.QtThread$1.run() (QtThread.java:61)
      F io.welle.welle: java_vm_ext.cc:542] at void java.lang.Thread.run() (Thread.java:764)
      F io.welle.welle: java_vm_ext.cc:542]
      F io.welle.welle: java_vm_ext.cc:542] in call to GetStaticMethodID
      F io.welle.welle: java_vm_ext.cc:542] from void org.qtproject.qt5.android.QtNative.startQtApplication()
      F io.welle.welle: java_vm_ext.cc:542] "qtMainLoopThread" prio=5 tid=12 Runnable
      F io.welle.welle: java_vm_ext.cc:542] | group="main" sCount=0 dsCount=0 flags=0 obj=0x12f037d0 self=0xe8cfce00
      F io.welle.welle: java_vm_ext.cc:542] | sysTid=10902 nice=0 cgrp=default sched=0/0 handle=0xce9ff970
      F io.welle.welle: java_vm_ext.cc:542] | state=R schedstat=( 1413494381 34489589 310 ) utm=129 stm=12 core=7 HZ=100
      F io.welle.welle: java_vm_ext.cc:542] | stack=0xce8fc000-0xce8fe000 stackSize=1042KB
      F io.welle.welle: java_vm_ext.cc:542] | held mutexes= "mutator lock"(shared held)
      F io.welle.welle: java_vm_ext.cc:542] native: #00 pc 002e0bb3 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+134)
      F io.welle.welle: java_vm_ext.cc:542] native: #01 pc 0037861b /system/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+210)
      F io.welle.welle: java_vm_ext.cc:542] native: #02 pc 00374c37 /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+34)
      F io.welle.welle: java_vm_ext.cc:542] native: #03 pc 00235a81 /system/lib/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+720)
      F io.welle.welle: java_vm_ext.cc:542] native: #04 pc 00235de7 /system/lib/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, std::__va_list)+58)
      F io.welle.welle: java_vm_ext.cc:542] native: #05 pc 000c4e89 /system/lib/libart.so (art::(anonymous namespace)::ScopedCheck::AbortF(char const*, ...)+48)
      F io.welle.welle: java_vm_ext.cc:542] native: #06 pc 000c3b35 /system/lib/libart.so (art::(anonymous namespace)::ScopedCheck::CheckPossibleHeapValue(art::ScopedObjectAccess&, char, art::(anonymous namespace)::JniValueType)+1072)
      F io.welle.welle: java_vm_ext.cc:542] native: #07 pc 000c3025 /system/lib/libart.so (art::(anonymous namespace)::ScopedCheck::Check(art::ScopedObjectAccess&, bool, char const*, art::(anonymous namespace)::JniValueType*)+624)
      F io.welle.welle: java_vm_ext.cc:542] native: #08 pc 000c65ff /system/lib/libart.so (art::(anonymous namespace)::CheckJNI::GetMethodIDInternal(char const*, _JNIEnv*, _jclass*, char const*, char const*, bool)+538)
      F io.welle.welle: java_vm_ext.cc:542] native: #09 pc 000b8f6d /system/lib/libart.so (art::(anonymous namespace)::CheckJNI::GetStaticMethodID(_JNIEnv*, _jclass*, char const*, char const*)+24)
      F io.welle.welle: java_vm_ext.cc:542] native: #10 pc 0017a63d /data/app/io.welle.welle-DYbLGgVCSPxawaN9D9amGQ==/lib/arm/libQt5Core.so (???)
      F io.welle.welle: java_vm_ext.cc:542] native: #11 pc 0017b041 /data/app/io.welle.welle-DYbLGgVCSPxawaN9D9amGQ==/lib/arm/libQt5Core.so (void QJNIObjectPrivate::callStaticMethodV<void>(_jclass*, char const*, char const*, std::__va_list)+44)
      F io.welle.welle: java_vm_ext.cc:542] native: #12 pc 0017b08d /data/app/io.welle.welle-DYbLGgVCSPxawaN9D9amGQ==/lib/arm/libQt5Core.so (void QJNIObjectPrivate::callStaticMethod<void>(_jclass*, char const*, char const*, ...)+28)
      F io.welle.welle: java_vm_ext.cc:542] native: #13 pc 00020bb7 /data/data/io.welle.welle/qt-reserved-files/plugins/platforms/android/libqtforandroid.so (???)
      F io.welle.welle: java_vm_ext.cc:542] at org.qtproject.qt5.android.QtNative.startQtApplication(Native method)
      F io.welle.welle: java_vm_ext.cc:542] at org.qtproject.qt5.android.QtNative$7.run(QtNative.java:387)
      F io.welle.welle: java_vm_ext.cc:542] at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61)
      F io.welle.welle: java_vm_ext.cc:542] at java.lang.Thread.run(Thread.java:764)
      F io.welle.welle: java_vm_ext.cc:542]
      F io.welle.welle: runtime.cc:558] Runtime aborting...
      

       

       

       

      Attachments

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

        Activity

          People

            andysh Andy Shaw
            albrechtl albrechtl
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes