Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Custom android.permission defined in .PRO

Custom android.permission defined in .PRO

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 2 Posters 712 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wiru
    wrote on last edited by
    #1

    Hello.

    I'm trying to create a custom build option for android permissions depending on the build needs.

    I figured I could use .PRO for this by adding ANDROID_PERMISSIONS, which at first didn't add the permission to AndroidManifest.xml, till I added <!-- %%INSERT_PERMISSIONS --> to AndroidManifest.xml.

    Now all custom permissions defined with ANDROID_PERMISSIONS are added, but... it adds even more, which is the issue.
    I compared the 2 manifest files, one with <!-- %%INSERT_PERMISSIONS --> and one without.

    Turn out, qt also adds:

    <     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <     <uses-permission android:name="android.permission.CAMERA"/>
    <     <uses-permission android:name="android.permission.INTERNET"/>
    

    My question is, how to make it not add that, since it's not defined anywhere? Or if it is defined, I can't find it where.

    J.HilkJ 1 Reply Last reply
    0
    • W Wiru

      Hello.

      I'm trying to create a custom build option for android permissions depending on the build needs.

      I figured I could use .PRO for this by adding ANDROID_PERMISSIONS, which at first didn't add the permission to AndroidManifest.xml, till I added <!-- %%INSERT_PERMISSIONS --> to AndroidManifest.xml.

      Now all custom permissions defined with ANDROID_PERMISSIONS are added, but... it adds even more, which is the issue.
      I compared the 2 manifest files, one with <!-- %%INSERT_PERMISSIONS --> and one without.

      Turn out, qt also adds:

      <     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
      <     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
      <     <uses-permission android:name="android.permission.CAMERA"/>
      <     <uses-permission android:name="android.permission.INTERNET"/>
      

      My question is, how to make it not add that, since it's not defined anywhere? Or if it is defined, I can't find it where.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Wiru I don't know for sure, but they may be added automatically, depending on your modules used 🤷‍♂️

      what do you add with QT += moduleName

      and have checked: Add necessary permission in the project settings? Those may be at fault as well 🤔


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Wiru
        wrote on last edited by Wiru
        #3

        I guess that might be true,
        I have qml quick multimedia network quickcontrols2 sql websockets widgets

        So I guess it adds them by itself, which I wish it wouldn't because some are defined already

        I only ran a diff for the 2 files, reason it outputted this:

        <     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
        <     <uses-permission android:name="android.permission.CAMERA"/>
        <     <uses-permission android:name="android.permission.INTERNET"/>
        

        is because it added WRITE_EXTERNAL_STORAGE, ACCESS_NETWORK_STATE, INTERNET twice, once they are manually defined, and second is the automated one. so if I'd ignore the duplicates, only the CAMERA one is the issue. (ofc it would be nice if it didn't duplicate already existing permissions)

        I wanted to use this for CI, so it can be easily defined which additional permissions are needed for which project. Any other suggestion on how to handle it (I'd really love to skip patch files or script edits of manifest file)

        EDIT: where is the "Add necessary permission in the project settings", can't seem to find it under Projects > Build

        J.HilkJ 1 Reply Last reply
        0
        • W Wiru

          I guess that might be true,
          I have qml quick multimedia network quickcontrols2 sql websockets widgets

          So I guess it adds them by itself, which I wish it wouldn't because some are defined already

          I only ran a diff for the 2 files, reason it outputted this:

          <     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
          <     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
          <     <uses-permission android:name="android.permission.CAMERA"/>
          <     <uses-permission android:name="android.permission.INTERNET"/>
          

          is because it added WRITE_EXTERNAL_STORAGE, ACCESS_NETWORK_STATE, INTERNET twice, once they are manually defined, and second is the automated one. so if I'd ignore the duplicates, only the CAMERA one is the issue. (ofc it would be nice if it didn't duplicate already existing permissions)

          I wanted to use this for CI, so it can be easily defined which additional permissions are needed for which project. Any other suggestion on how to handle it (I'd really love to skip patch files or script edits of manifest file)

          EDIT: where is the "Add necessary permission in the project settings", can't seem to find it under Projects > Build

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @Wiru said in Custom android.permission defined in .PRO:

          EDIT: where is the "Add necessary permission in the project settings", can't seem to find it under Projects > Build

          actually, its inside the manifest.xml ui:
          cb1e7cff-8cf2-4920-bc2d-b0223b83b042-image.png

          I assume this is a setting in QtCreator/project.pro.user file

          Any other suggestion on how to handle it (I'd really love to skip patch files or script edits of manifest file

          Don't rely on the auto creation of the manifest file,
          make explicit (fixed) manifest files for your builds, and include them (in your pro) depending on the build.

          android {
          
          buildA: DISTFILES += builda/AndroidManifest.xml
          buildB: DISTFILES += buildb/AndroidManifest.xml
          

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          W 1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @Wiru said in Custom android.permission defined in .PRO:

            EDIT: where is the "Add necessary permission in the project settings", can't seem to find it under Projects > Build

            actually, its inside the manifest.xml ui:
            cb1e7cff-8cf2-4920-bc2d-b0223b83b042-image.png

            I assume this is a setting in QtCreator/project.pro.user file

            Any other suggestion on how to handle it (I'd really love to skip patch files or script edits of manifest file

            Don't rely on the auto creation of the manifest file,
            make explicit (fixed) manifest files for your builds, and include them (in your pro) depending on the build.

            android {
            
            buildA: DISTFILES += builda/AndroidManifest.xml
            buildB: DISTFILES += buildb/AndroidManifest.xml
            
            W Offline
            W Offline
            Wiru
            wrote on last edited by
            #5

            @J-Hilk said in Custom android.permission defined in .PRO:

            Don't rely on the auto creation of the manifest file,
            make explicit (fixed) manifest files for your builds, and include them (in your pro) depending on the build.

            This would require to have a complete manifest for each include? (which might be unnecessary)
            In my opinion it would be much better to just add permissions depending on needs, but I'll keep that as an option.

            For now I went the way I wanted to skip, writing a bash script to replace a placeholder in the manifest with needed permissions.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved