forked from jbagg/QtZeroConf
Android: Call nsd.stopServiceDiscovery() when going to sleep
If Android is on it's way to suspend when stopBrowser() is called, we need to call nsd.stopServiceDiscovery() synchronously to force it to run before the device goes to sleep. Was an issue on Android 10 on Levono Tab M10 FHD Plus TB-X606FA_S300554-220630_BMP
This commit is contained in:
@ -123,9 +123,15 @@ void QZeroConfPrivate::startBrowser(QString type, QAbstractSocket::NetworkLayerP
|
||||
void QZeroConfPrivate::stopBrowser()
|
||||
{
|
||||
QAndroidJniObject ref(nsdManager);
|
||||
QtAndroid::runOnAndroidThread([ref]() {
|
||||
// If Android is on it's way to suspend when stopBrowser() is called, we need to call nsd.stopServiceDiscovery() synchronously
|
||||
// to force it to run before the device goes to sleep.
|
||||
if (qGuiApp->applicationState() == Qt::ApplicationSuspended) {
|
||||
ref.callMethod<void>("stopServiceDiscovery");
|
||||
});
|
||||
} else {
|
||||
QtAndroid::runOnAndroidThread([ref]() {
|
||||
ref.callMethod<void>("stopServiceDiscovery");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Callbacks will come in from the android thread. So we're never accessing any of our members directly but instead
|
||||
|
Reference in New Issue
Block a user