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>
This commit is contained in:
Assam Boudjelthia 2023-11-21 21:43:57 +02:00
parent 8c14b0c02f
commit d48e81f7a4

View File

@ -270,6 +270,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;");