Add Android service check on quit app

When quitApp() delegates the quit action to runAction(), this
function only checks if an activity exists. If the process is
a service, rather than an activity, it has no activity, so the
action is skipped and the service is not exited.

Check in runAction() for a service as well as an activity.

Pick-to: 6.2
Change-Id: Iec6f0550064506a780892d3d840f7488fc894569
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Fabio Falsini 2021-07-19 21:16:52 +02:00
parent 8f75ab231f
commit 7d7f09d556

View File

@ -559,8 +559,8 @@ public class QtNative
synchronized (m_mainActivityMutex) {
final Looper mainLooper = Looper.getMainLooper();
final Handler handler = new Handler(mainLooper);
final boolean actionIsQueued = !m_activityPaused && m_activity != null && mainLooper != null && handler.post(action);
if (!actionIsQueued)
final boolean active = (m_activity != null && !m_activityPaused) || m_service != null;
if (!active || mainLooper == null || !handler.post(action))
m_lostActions.add(action);
}
}