From b6146caf368ac833c26eedd28fe57b1858bf61ab Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Mon, 21 Oct 2024 17:05:19 +0100 Subject: [PATCH] Fix for Android Qt6 --- sdrbase/util/android.cpp | 32 ++++++++++++++++++++++++++++++++ sdrgui/mainwindow.cpp | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/sdrbase/util/android.cpp b/sdrbase/util/android.cpp index 40f95d5b8..3e72ca855 100644 --- a/sdrbase/util/android.cpp +++ b/sdrbase/util/android.cpp @@ -95,6 +95,38 @@ void Android::moveTaskToBack() } } +void Android::acquireWakeLock() +{ + QJniObject activity = QJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;"); + if (activity.isValid()) { + activity.callMethod("acquireWakeLock"); + } +} + +void Android::releaseWakeLock() +{ + QJniObject activity = QJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;"); + if (activity.isValid()) { + activity.callMethod("releaseWakeLock"); + } +} + +void Android::acquireScreenLock() +{ + QJniObject activity = QJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;"); + if (activity.isValid()) { + activity.callMethod("acquireScreenLock"); + } +} + +void Android::releaseScreenLock() +{ + QJniObject activity = QJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;"); + if (activity.isValid()) { + activity.callMethod("releaseScreenLock"); + } +} + #else // QT_VERSION #include diff --git a/sdrgui/mainwindow.cpp b/sdrgui/mainwindow.cpp index ebe0071d8..1b265f560 100644 --- a/sdrgui/mainwindow.cpp +++ b/sdrgui/mainwindow.cpp @@ -1143,7 +1143,7 @@ void LoadConfigurationFSM::restoreGeometry() m_mainWindow->m_workspaces[i]->adjustSubWindowsAfterRestore(); #ifdef ANDROID // On Android, workspaces seem to be restored to 0,20, rather than 0,0 - m_mainWindow->m_workspaces[i]->move(m_workspaces[i]->pos().x(), 0); + m_mainWindow->m_workspaces[i]->move(m_mainWindow->m_workspaces[i]->pos().x(), 0); // Need to call updateGeometry, otherwise sometimes the layout is corrupted m_mainWindow->m_workspaces[i]->updateGeometry(); #endif