Android: Prevent Qt apps from running in the background
Previously, the environment variable QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED was set to an empty string, which allowed QAndroidEventDispatcherStopper to keep the application running in the background when it entered the suspended state (onStop). To address this issue, the isBackgroundRunningBlocked() function has been added to validate the proper value when getMetaData(..) returns a value. Fixes: QTBUG-125496 Pick-to: 6.7 Change-Id: I541af3bb1f4e239ee8ba2be32583b91afc7a43e2 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io> (cherry picked from commit 1f1f726c79ca4d539932e078857a36e8836d474b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
1e6950fd77
commit
53c7eb49b7
@ -107,12 +107,18 @@ abstract class QtLoader {
|
||||
setEnvironmentVariable("QT_ANDROID_FONTS_SERIF", "Droid Serif");
|
||||
setEnvironmentVariable("HOME", m_context.getFilesDir().getAbsolutePath());
|
||||
setEnvironmentVariable("TMPDIR", m_context.getCacheDir().getAbsolutePath());
|
||||
String backgroundRunning = getMetaData("android.app.background_running");
|
||||
setEnvironmentVariable("QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED", backgroundRunning);
|
||||
setEnvironmentVariable("QT_BLOCK_EVENT_LOOPS_WHEN_SUSPENDED", isBackgroundRunningBlocked());
|
||||
setEnvironmentVariable("QTRACE_LOCATION", getMetaData("android.app.trace_location"));
|
||||
appendApplicationParameters(getMetaData("android.app.arguments"));
|
||||
}
|
||||
|
||||
private String isBackgroundRunningBlocked() {
|
||||
final String backgroundRunning = getMetaData("android.app.background_running");
|
||||
if (backgroundRunning.compareTo("true") == 0)
|
||||
return "0";
|
||||
return "1";
|
||||
}
|
||||
|
||||
private ArrayList<String> preferredAbiLibs(String[] libs) {
|
||||
HashMap<String, ArrayList<String>> abiLibs = new HashMap<>();
|
||||
for (String lib : libs) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user