Android: Register a default keyboard

When QWindowSystemInterface::handleKeyEvent() is called under
QtAndroidInput's keyDown() JNI native method callback, it throws
the following warning:

 W Gallery : QObject: Cannot create children for a parent that is in a
different thread.
 W Gallery : (Parent is QGuiApplication(0x707968a2e0), parent's thread
is QThread(0x70d6477280), current thread is QThread(0x70d18ff790)

when no keyboard QInputDevice has been registered, this behavior is
present at least on Android Emulators.

Task-number: QTBUG-46412
Fixes: QTBUG-106928
Fixes: QTBUG-118421
Change-Id: Iec1c6e3a599e1e553d049df3021653a0d4197e7d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit d48e81f7a46e7cf968fa5bc88296eb8de8dc77c5)
This commit is contained in:
Assam Boudjelthia 2023-11-21 21:43:57 +02:00
parent 25d0afd3f9
commit 37c29fca7d

View File

@ -269,6 +269,10 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList &para
maxTouchPoints,
0);
QWindowSystemInterface::registerInputDevice(m_touchDevice);
QWindowSystemInterface::registerInputDevice(
new QInputDevice("Virtual keyboard"_L1, 0, QInputDevice::DeviceType::Keyboard,
{}, qApp));
}
auto contentResolver = javaActivity.callObjectMethod("getContentResolver", "()Landroid/content/ContentResolver;");