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

Feature Request: Provide lightweight qtforandroid alternative for non gui services

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.13
    • QPA: Android
    • None
    • Android
    • 2024wk4Xs3FOQtforAndroid

    Description

      [Feature Request] that QT provide a light weight alternative to using qtforandroid plugin (1Mb) + qtgui (5Mb) to launch non gui services on android.

      We have a light weight service which has no dependency on QtGui - yet we must include QtGui lib in our apk because it is needed by qtforandroid plugin.

      It seems qtforandroid plugin is the middle man between QtNative, and our service.
      We discovered that we could eliminate qtforandroid (and thus qtgui) by stubbing/implementing the following ** (JNI) methods directly in our service :

      bool startQtAndroidPlugin(string, string env); // set cwd from env.HOME
      void setDisplayMetrics(int, int, int, int, double, double, double, double, float) {} // stub (n/a)
      void startQtApplication(); // call services main()
      void waitForServiceSetup(); // wait for services main thread event loop running
      QAndroidBinder& onBind(const QAndroidIntent&); // call services onBind()

      This seems a simple solution - but our concerns are:

      • It relies on QT undocumented internals. i.e. This works in QT5.15.13 - but may not work in other versions (without needing changes).
      • We might have missed methods - which if called by QtNative will crash our service.
      • We might not have done everything intended in our implementation.

      Simple Proposal - QT document this API - so we can safely and confidently implement what is necessary in our service to eliminate qtforandroid plugin.

      Alternative Proposal - QT provide an alternative plugin "qtforandroid_lite" - which does not depend on QtGui and only does the bare minimum to launch a non gui service.

       

      Note: Found a project doing something very similar on github: https://github.com/halybang/qt-android-helper/blob/master/README.md

      Attachments

        Issue Links

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

          Activity

            People

              qtandroidteam Qt Android Team
              stevenr3 Steve Rossen
              Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes