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

QDir entries is always empty with Android/Downloads

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.15.1
    • Fix Version/s: 5.15.1
    • Component/s: Core: I/O
    • Labels:
      None
    • Environment:
      Android 10
    • Platform/s:
      Android
    • Commits:
      ac17e62f6512eed6e5c63263fab0bf3c896761aa (qt/qtbase/dev) bb1d888e8e4a38d48f3cfdf7dbc6f14647b12f04 (qt/qtbase/5.15)

      Description

      Hello,

      QDir seems to have a problem to list entries into Android/Download directory, but only from Android 10 (Specifically, on a OnePlus smartphone).

      This code returns always an empty "entries" list:

      // Of course, this is added to manifest:
      <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE "/>
      ...
      
      // Runtime permissions, as suggested by Android guidelines
      const QVector<QString> permissions({"android.permission.WRITE_EXTERNAL_STORAGE",
                                              "android.permission.READ_EXTERNAL_STORAGE"});
          for(const QString &permission : permissions){
              auto result = QtAndroid::checkPermission(permission);
              if(result == QtAndroid::PermissionResult::Denied){
                  QtAndroid::requestPermissionsSync(QStringList({permission}));
              }
          }
      
      // Try to read entries
      QDir directory;
      directory.setPath(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
      auto entries = directory.entryInfoList({"*.bin", "*.json"}, QDir::NoDotAndDotDot | QDir::AllEntries);
      

      But this works fine on older Android versions with others smartphones.
      (and of course i ensured to put *.bin files into Download)

       

      EDIT Sept 14h 2020: the pb is still here on a OnePlus 8 even with Qt 5.15.1:

      ALL files in "/storage/emulated/0/Download" = ()

        Attachments

        For Gerrit Dashboard: QTBUG-85538
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            taipan BogDan Vatra
            Reporter:
            jean-noel Jean-Noël Pioche
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes