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

Android Permission Result wrong value

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.0.0
    • 5.12.0
    • Extras: Android
    • None
    • Android
    • 2020wk22

    Description

      In Qt ( http://doc.qt.io/qt-5/qtandroid.html#PermissionResult-enum ):

      enum QtAndroid::PermissionResult {
      Granted = 0,
      Denied =  1
      }
      

      Meanwhile:
      https://developer.android.com/reference/android/content/pm/PackageManager#PERMISSION_DENIED

      public static final int PERMISSION_DENIED = -1;
      

      While it's best practice to use enums, using the platform value is also best practice.
      In this way, the only portable code can only ever == Granted or != Granted, and checking for equivalency of Denied is not the same thing as checking for Permission.PERMISSION_DENIED - it is now a thing that will never work.

      You can use

      enum QtAndroid::PermissionResult {
        Denied =  -1,
        Granted = 0
      }
      

      Now there is code that translates 1>1 and any apps that are sharing these results between Qt and Android SDK have to implement that too.

      Attachments

        Issue Links

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

          Activity

            People

              assam Assam Boudjelthia
              scorp1us Jason Hihn
              Santtu Ahonen Santtu Ahonen
              Rami Potinkara Rami Potinkara
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes