Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.11.2
-
None
-
* Host: Windows 10 64 bit
* Qt 5.11.2 Android x86 (official)
* NDK 16b
* SDK 28
* Target Android x86 8.1 - rc1 (running on VM on a host)
* Android API 21
-
-
13
-
Qt6_Foundation_Sprint 36
Description
This code (running as a service) does nothing:
#include <QAndroidService> #include <QGeoPositionInfoSource> #include <QLoggingCategory> #include <QTimer> Q_LOGGING_CATEGORY(APP, "bug.svc") int main(int argc, char *argv[]) { QAndroidService::setAttribute(Qt::AA_EnableHighDpiScaling); QAndroidService app(argc, argv); qCDebug(APP) << "I'm service"; const auto t = new QTimer(qApp); QCoreApplication::connect(t, &QTimer::timeout, []() { static int counter = 0; qCWarning(APP) << "CNT:" << counter; ++counter; }); t->start(1000); const auto ps = QGeoPositionInfoSource::createDefaultSource(qApp); if (!ps) { qCCritical(APP) << "OOPS, unable to create a position source"; } else { QCoreApplication::connect(ps, &QGeoPositionInfoSource::positionUpdated, [](const QGeoPositionInfo &update) { const auto coord = update.coordinate(); qCDebug(APP) << "CRD:" << coord; }); ps->setUpdateInterval(3000); ps->startUpdates(); } return app.exec(); }
I mean that:
1) I did not see any timer's counter traces in a console logcat output.
2) I did not see any position source traces in a console logcat output.
I have attached an compilable example which contains both app and service parts.
How to reproduce an issue:
- Run 'adb logcat'
- Startup an application.
- Make sure that "I'm application" trace is present.
- Make sure that all 'CNT' and 'CRD' traces are available (because an application running as an 'app' in that time).
- Go application to background (e.g. by clicking on 'HOME' button).
- Make sure that the 'Went to background' trace is present.
- Make sure that "I'm service" trace is present.
Next, observe that no any traces are present (after p.7), as no timer's traces andas no position source's traces (please, see an attached log)!
Seems, it is a bug!
PS: If to comments out a part of a code, related to the position source from the service, and repeat a previous points, then you can see that a timer's traces are available when a service is running.
UPD: To simulate a GPS coordinates (for Android x86 running on a VM) I use the "Fake GPS" application.
Attachments
Issue Links
- relates to
-
QTBUG-62961 QGeoPositionInfoSource positionUpdated not emitted
- Closed
-
QTBUG-61142 [Android]: If background mode is turned on and QtLocation is involved, then consider automatically making it a service
- Reported
- resulted in
-
QTBUG-94754 Possible deadlock while starting an Android service
- Reported