summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/androidjnimain.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Android: Do not wait for service onBind() in service embedding pathPetri Virkkunen10 days1-1/+1
| | | | | | | | | | | When embedding QML into an Android service, Qt is not actually running as a service. Avoid checking for QtAndroid::Service() and assuming that means we are running as a service. Task-number: QTBUG-118874 Change-Id: I5eea32b9fc200c4f34f1507d591aa1a483849118 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Propagate a11y ObjectShow events to screen readerJens Trillmann2024-04-251-0/+6
| | | | | | | | | | | | Sending an ObjectShow event, e.g. by setting QQuickItem::visible to true, has to trigger a refresh of the screen reader hierarchy. If the signal is ignored the source of the signal will be ignored by the screen reader. Fixes: QTBUG-122436 Pick-to: 6.5 6.7 Change-Id: I32ee2e8b2602cd0dd9b9a83ff1fe426d88d137a8 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* ColorScheme: clean up code to prepare adding a setterVolker Hilsheimer2024-04-231-1/+1
| | | | | | | | | | | | | | | | | | | The current QStyleHintsPrivate::setColorScheme is called when the system theme changes, handling the change and informing the application. It is not a setter. When we add a public setter, that setter will have to go through the QPlatformTheme to request an override for the application. That will then result in a call back to the QStyleHints to update the theme with the effective color scheme (or ignore the request for the override, on some platforms). Rename it (and similar misleading APIs in platform plugins) to updateColorScheme, and adjust outdated comments in some of the platform plugins. Task-number: QTBUG-124490 Change-Id: I6a852211254993df86acf2e2d42cf345e7401f4f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Doris Verria <doris.verria@qt.io>
* Android: Add classes to embed QML into native AndroidTinja Paavoseppä2024-01-301-9/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add classes that make it possible to add QML as a View into a native Android app: QtView: Base class for QtQuickView, handles non-Quick dependent operations. In essence a Java ViewGroup class which loads a QWindow and embeds it into itself. QtEmbeddedLoader: Extends QtLoader for embedded case, creates the embedded version of QtActivityDelegate and provides an embedded-specific path to loading Qt libraries (Mostly just allows users to set the name of the main lib) QtAndroidWindowEmbedding namespace: Deals with calls from QtEmbeddedDelegate to create/destroy QWindow and from QtView to show the window. Take the QtEmbeddedDelegate introduced in an earlier commit into use, and add functionality for loading QWindows for QtViews and managing QtViews into it. Add a factory for creating instances of QtEmbeddedDelegate. The factory holds a map of QtEmbeddedDelegate objects and creates them, with the Activity as the key. This is to make it so that the same delegate can be used by multiple views which share the same Context. Known issues left: * keyboard focus not working, as with other child windows Pick-to: 6.7 Task-number: QTBUG-118872 Change-Id: I94a5f9b4f904c05cc6368cf20f273fcf10d31f17 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Add a context delegate for embedding QML to native AndroidTinja Paavoseppä2024-01-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | When we are embedding a QML view to a non-Qt Android app, there are a lot of functionalities that are shared with the refular Qt Android app, but some are not. We should not, for example, try to control the hosting Activity. Create a base class that both the QtActivityDelegate, used for the standard Qt for Android app, and the delegate for the embedding case can extend. In this commit, the QtEmbeddedDelegate is very simple, the biggest difference to QtActivityDelegate being it does not create a QtLayout or instantiate a QtAccessibilityDelegate. It does start the Qt app, without waiting for a layout, and register to listen for changes in the state of the Qt app. Taking the embedded delegate into use, loading the embedded QML views and their handling is added in a follow up commit. Task-number: QTBUG-118872 Pick-to: 6.7 Change-Id: Id390a2b35c70b35880523886bf6fcf59d420cb42 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Differentiate between standalone Qt app and embedded viewTinja Paavoseppä2023-12-141-0/+26
| | | | | | | | | | | Add a helper method to tell whether the app is a standalone Qt for Android app, where also the Context is created by Qt, or whether Qt content is embedded as a View into a Context created by the user, i.e. a "native" Android app. Pick-to: 6.7 Change-Id: I618ba1c8cb40c9b132fc12a7ee6d54c071efa983 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Fix touch events for child windowsTinja Paavoseppä2023-12-141-0/+15
| | | | | | | | | | | | | | | In the touch dispatcher methods, all events were routed for the top level window at the position, which lead to all the events being delivered for the parent window. Since the JNI methods already have a parameter for window ID, take that into use and determine the window to deliver the events to by ID. Pick-to: 6.7 Change-Id: I07ad7851c32a3e633ee748036d6818b6d0fa5588 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Android: Make QtLayout per window instead of per screenTinja Paavoseppä2023-12-081-121/+2
| | | | | | | | | | | Each QAndroidPlatformWindow has its own QtLayout, instead of one for the whole app/screen. This paves the way for addition of child windows. Task-number: QTBUG-116187 Change-Id: I36c68cea1a5f27ded3696bcfc2fbc04d9a8ce79e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Give raster windows their own surface, and flush via RHITinja Paavoseppä2023-12-071-10/+10
| | | | | | | | | | | | | | Refactored platform windows on Android so that all window types, including raster windows, have their own surface to draw on. Raster windows now flush the backing-store via RHI/OpenGL. As a drive by, update to newer JNI syntax where appropriate. Task-number: QTBUG-116187 Change-Id: I3b764b7126abf53556750b0ccbb7d27efe007bc1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* AndroidTestRunner: fix args with quotes and spacesAssam Boudjelthia2023-12-051-3/+1
| | | | | | | | | | | | | | | | | | | | | | | First, replace double quote characters with 3 escaped double quotes to allow QProcess::splitCommand() to treat it as an actual quote character that's part of the tag. Then, escape single quote characters so they don't interfere with the shell command and also to be treated as part of the argument. Lastly, surround the args with escaped double quote so that args with spaces are also treated as one. Amends b044323c1656aeeec508afab8457755cc1e8c587. Example of this: tst_qkeyevent::modifiers("M","e","t","a") for double quotes tst_qunicodetools::wordBreakClass(two words) for spaces tst_QSpinBox::stepSelectAll("don't select all") for single quotes Task-number: QTQAINFRA-5703 Change-Id: Ie4317e4350bbac619bac41e41f42613f50cf1ad4 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* AndroidTestRunner: Fix treatement of quotes in test argsAssam Boudjelthia2023-11-301-3/+8
| | | | | | | | | | | | | This has two parts, under testrunner, make sure to pass test args that has quotes as \\\" so that the Android app gets a \" after parsing the intent extras. The app args are then is passed to C++ where QProcess::splitCommand() is used to parse the args string into a list, and to preserve the quotes in this case, the former call expects triple quotes to to get the quote character preserved in the split list. Fixes: QTQAINFRA-5703 Change-Id: Iad81cadf24a6def21ef1536c882ecd510c4426cf Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Android: rename isPluginRunning to isNativePluginIntegrationReadyAssam Boudjelthia2023-11-281-2/+5
| | | | | | | | | This has been used to notify that the platform integration is setup and ready, now the name is more descriptive of what it does. Task-number: QTBUG-118077 Change-Id: I9fab525f07433f9ec8057e2475a3b1e4658f84d9 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: print correct return code of main()Assam Boudjelthia2023-11-231-4/+3
| | | | | | | | ... and print it always after main() returns. Task-number: QTBUG-118077 Change-Id: I1f57b3f7a646d01eebf67d4a4ff6a8d9f6e82cc7 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Android: Fix broken insertNativeView() signatureTinja Paavoseppä2023-11-171-1/+1
| | | | | | | | | | Method is trying to infer the signature from the types of the arguments, but since the argument for the view is a plain jobject this signature is wrong, method is not found and the view is never inserted. Change-Id: I3cbf9bccbcb1e5526f843213ba0f66e5bd1e7107 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: don't call delegates outside of the ActivityAssam Boudjelthia2023-11-101-35/+9
| | | | | | | | | | | | | | | | | | | | | The delegate classes shouldn't be used outside of the Activity/Service classes, since they're practically private implementation, so don't use them anywhere outside Activity/Service. Since Qt Android apps still mainly support having one QtActivity/ QtService, QtNative heavily uses those objects to do various operations. For that reason, we still need to use the delegate there. The aim is to change that in future patches and do the operations where they make more sense for example directly under QtActivityBase/QtActivityDelegate or Service counterpart. The QtServiceDelegate is used no where and have no special implementation, so it's removed here. Task-number: QTBUG-118077 Change-Id: I5e106318169be19fec8163e8e500ee573af0e1bc Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Android: remove a11y methods from QtNative, call a11y delegate directAssam Boudjelthia2023-11-061-9/+31
| | | | | | | | | | | Remove yet another two layers of delegation, QtNative calling QtActivityDelegate and that in turn calls QtAccessibilityDelegate. Now from c++ native code, acquire the a11y delegate and use it to call a11y operations that live in QtAccessibilityDelegate. Task-number: QTBUG-118077 Change-Id: I9e84520c2caa281a6f786a687b0106d702f92a67 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* JNI: pass same QJniEnvironment object to QAndroidPlatformClipboardAssam Boudjelthia2023-11-021-1/+1
| | | | | | | ... registerNatives() call. Change-Id: I42539846249880ed4a215522bdcafb3a2ffa4d14 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Android: move display and screen management to new QtDisplayManagerAssam Boudjelthia2023-11-021-8/+28
| | | | | | | | | | Have all or most of Android code dealing with displays in QtDisplayManager. Also, simplify setApplicationDisplayMetrics() call and avoid caching any uneccessary members. Task-number: QTBUG-118077 Change-Id: I943069c24bb40ae3016db5896e553b501e700a6b Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: clean up error handling and native methods registrationVolker Hilsheimer2023-11-011-55/+51
| | | | | | | | | | | | Emit log output and return false immediately if we fail to get both the Activity and the Service objects. Standardize the registerNative methods to return bool and take a QJniEnvironment, and adjust the macros accordingly. Simplify the startup routine to use QJniEnvironment. Change-Id: I11be35426520dc803f5a07bbb495e908592f254e Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: Move clipboard management to own classAssam Boudjelthia2023-10-301-2/+3
| | | | | | | | | | | | | | | Move all clipboard management logic outside of QtNative and to own QtClipboardManager class. Also, don't keep any keep Activity objects under it to avoid memory leaks, the native c++ clipboard manager should be responsible of passing a context when needed instead. As a pass-by, use newer JNI APIs for C++ QtAndroidClipboard code. Task-number: QTBUG-118077 Change-Id: I61726e84a75918d80329f753e9e1c6ebde179bf4 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: don't rely on implicit cast of declared QtJniTypes to jobjectVolker Hilsheimer2023-10-271-1/+1
| | | | | | | | | | The operator jobject() should be removed from declared QtJniTypes in qtbase, as it's dangerous. Prepare for that by calling object(), which returns the wrapped jobject as well, or isValid() where previously the implicit conversion to jobject also enabled implicit conversion to bool. Change-Id: I00cf6f1463dd5ab5cbaf03d9e77bfff3bced9b15 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Android: replace QtAndroid::activity/service with QtAndroidPrivateVolker Hilsheimer2023-10-271-25/+11
| | | | | | | | | | | | | | | | | | | | | | | | | There's no need for both, and QtAndroidPrivate is a documented namespace. Replace all calls to QtAndroid::activity/service with QtAndroidPrivate equivalents, and drop the QtAndroid version. Since we no longer store a global copy of the activity and service, we can drop the reference right away. This comes with a bit of overhead - QtAndroid::activity returned a copy of a global static QJniObject (62cb5589b3723fe8162e190cd54d9c78929b98d2, after which declared QtJniTypes became QJniObjects), while QtAndroidPrivate::activity returns a newly created QtJniTypes::Activity on each call. This however makes it also safer, as the QJniObject is then associated with the calling thread's JNI environment, and we can optimize critical code paths where it's safe to do so later. Also, QtAndroid's activity object was never updated, while QtAndroidPrivate's activity is updated in the updateNativeActivity native method. Change-Id: I36c5b504eac52d9e28b4c6b265daab8fedc877e2 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Android: move input handling from QtActivityDelegate to separate classAssam Boudjelthia2023-10-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | To further simplify the code and logic of the delegate, move keyboard input code to separate class. Make an input delegate available under the QtActivityDelegate to allow classes like QtNative and the Activity to access that. For now, it's okay to leave access from QtNative to that, but for future even that should be simplified and the Activity should be accessing that directly. For the case where the QtInputDelegate needs access to QtActivityDelegate, for now namely updateFullScreen(), a new Listener is implemented to be implemented under QtActivityDelegate. Along the way use newer JNI APIs under C++ QtAndroidInput. Don't make them static methods, so that it can be possible later to do various keyboard operations to specific activity and not a global one. Task-number: QTBUG-114593 Task-number: QTBUG-118077 Change-Id: I110b897f6f16d0ae5f5a645551b4a82e8ad3f2fb Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
* Android: fix double-freeing of a global references on app exitJuha Vuolle2023-10-121-6/+2
| | | | | | | | | | | | | | | | | | | The m_activityObject and m_serviceObjects are no longer plain jobjects. Instead they are constructed with a jobject. The constructor makes it a global ref, which the destructor then frees. The destruction happens when the stdlib exit() is called. However, since the terminateQt() function already had released the global ref, the destruction of the objects crashes the application with a JNI APPLICATION ERROR in Android logs. In addition since the the code only ever freed the reference to a reference, the actual reference was leaked. Change-Id: I6bb637dba2de59e89436685a9d63950d36438fa5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* androidjnimain: use rvalue overloads moreAnton Kudryavtsev2023-09-191-1/+1
| | | | | Change-Id: Ib4f5bccbf4f384248e2651492337ff5e227adce1 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Rename Qt::Appearance to Qt::ColorSchemeTor Arne Vestbø2023-02-131-2/+2
| | | | | | | | | | | | Based on discussions in the 6.5 API review, where we concluded that 'appearance' is too general. Instead, we follow the CSS standard and use the term 'color scheme'. Pick-to: 6.5 Change-Id: I8ceaf4138ecadff5ccd962480e8e5beb39b556ec Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Jonas Kvinge <jonas@jkvinge.net> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Add handling of screen hotplugPiotr Mikolajczyk2022-12-131-1/+22
| | | | | | | | | | | When a display is connected to an Android device a notification is sent to the platform layer of the application. The QAndroidPlatformIntegration will create a platform screen and add it to QWindowSystem. Task-number: QAA-1257 Change-Id: Id2cf6b47363630c3b5c93c0bc778e2058d8372b3 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Replace QPlatformTheme::Appearance by Qt:AppearanceAxel Spoerl2022-09-201-1/+1
| | | | | | | | | | | | | With the introduction of Qt:Appearance, its predecessor in QPlatformTheme has become redundant. This patch replaces all occurrences of QPlatformTheme::Appearance with the new enum class. Task-number: QTBUG-106381 Change-Id: I5406f1b7c19f68571f074617c681318c96a6517e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Android: Fix flickering on window resize and show keyboardSamuel Mira2022-09-171-9/+12
| | | | | | | | | | | | | | | Changed to use display getMetrics which will return the size of the application window, and use getRealMetrics to obtain the size of the largest region accessible to the app. I updated the fullscreen mode to use the new sizes. Task-number: QTBUG-41170 Task-number: QTBUG-66727 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: Ic25555ed2e1b910b3fdbc0f3a31e3a19763a04eb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Android: Light/dark modes detectionBartlomiej Moskal2022-09-051-0/+7
| | | | | | | | | | | After commit: 2248487c6ca9d5459c70a16868d5aeee07d96157 light/dark mode detection is supported by Windows and macOS. This commit add similar implementation on the Android side. Task-number: QTBUG-83185 Pick-to: 6.4 6.3 6.2 Change-Id: Id1ece98e91a31759b58d651ef62b3715ea25d85f Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Apply Q_CONSTINIT where beneficialSona Kurazyan2022-09-011-2/+2
| | | | | | | | | | Applied Q_CONSTINIT to variables with static storage duration, but skipped the POD types with core constant initializers. Task-number: QTBUG-100486 Change-Id: Iaabf824e9cb0f29a405a149912200d4e4b3573c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Android A11Y: Notify android about scroll eventsJens Trillmann2022-08-291-0/+6
| | | | | | | | | | | | | | | | | | | | QtQuick Flickable has an issue that after a scroll the previously hidden items are not added to the A11Y hierarchy. That happens because Android has no ways to detect that something has changed. This patch uses the ScrollingEnd event to notify Android A11Y backend that the Flickable was scrolled, so that it could update the A11Y hierarchy and add the previously hidden nodes. The ScrollingEnd event generation is added to QQuickFlickable in a separate commit. Task-number: QTBUG-103513 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: Ie6cd688d56343bcfe7ce9580c0b9244dd6d6c068 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Samuel Mira <samuel.mira@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: handle quoted args passed to an appAssam Boudjelthia2022-08-111-3/+4
| | | | | | | | | | | | | | | | | | | | | | Currently, arguments passed to the app through applicationArguments extra bundle treat every space as an argument separator. This then doesn't handle the case where an argument is a space separated quoted multi-word. This is more apparent when androidtestrunner is passing test arguments to the app where an argument can be a test case with a data tag that contains a space, which then is treated as two separate tag names. This change makes sure that androidtestrunner quotes each argument, and the app doesn't split the arguments list by spaces, but rather passed the argument string directly to c++ where QProcess::splitCommand() is used to get the correct set of arguments that will be passed to main(). Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-104730 Change-Id: I45d8ca979d90f2a383c84623f0eb2eec29bba727 Reviewed-by: Dimitrios Apostolou <jimis@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Return specific types for frequently used Java objectsVolker Hilsheimer2022-05-171-4/+4
| | | | | | | | | | | | | | | | | | This allows us to specialize JNI type signature templates for e.g. the context object, which in Java signatures is "android/content/Context". Introduce a Q_DECLARE_JNI_TYPE macro that takes care of the plumbing. The types declared this way live in the QtJniTypes namespace, and transparently convert from and to jobject. Since jobject is a typedef to _jobject* we cannot create a subclass. Use a "Object" superclass that we can provide a QJniObject constructor for so that we don't require the QJniObject declaration to be able to use the macro. The APIs in the QNativeInterface namespace doesn't provide source or binary compatibility guarantees, so we can change the return types. Change-Id: I4cf9fa734ec9a5550b6fddeb14ef0ffd72663f29 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-39/+3
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Android A11Y: handle LocationChanged event only for focused elementIvan Solovev2022-05-161-2/+3
| | | | | | | | | | | | | | | | | | LocationChanged event unconditionally triggered invalidateVirtualViewId call. That call results in TYPE_WINDOW_CONTENT_CHANGED Android event, which causes a lot of background processing. That is not correct, because LocationChanged event is generated by every accessible element, not only the one that has A11Y focus. This patch checks event->uniqueId(), and processes only events that come from the focused accessible element. Done-with: Mike Achtelik <mike.achtelik@gmail.com> Task-number: QTBUG-102594 Pick-to: 6.3 6.2 5.15 Change-Id: I6b941733c9d215fed5ee5a7aeeb5be234add9ebe Reviewed-by: Mike Achtelik <mike.achtelik@gmail.com> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Android: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-141-1/+1
| | | | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: Iebcbdbd7cecac09d0a7039e3ef6a4509d33039ba Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: terminate argv passed to main() with nullptrAssam Boudjelthia2022-03-051-4/+6
| | | | | | | | | | | | the char array of argv passed to the app's main() function need to be null terminated [*] and argv to be **char. [*] http://eel.is/c++draft/basic.start.main#2 Fixes: QTBUG-101028 Pick-to: 6.2 6.3 5.15 Change-Id: I6e3a685f092a92a94f60d166357b75d2538af74c Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Android: make sure that orientationChange is reported after resizeIvan Solovev2022-03-041-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Android orientation changes are reported from the DisplayListener.onDisplayChanged() method, while the screen size changes are reported from QtLayout.onSizeChanged(). In practice these callbacks come in random order, so rotating the screen multiple times might result in inconsistent order of signals and events. This patch makes sure that size change events always happen before orientation changes. This is done by caching the new orientation values and reporting them only when needed. At this point we also need to use QMetaObject::invokeMethod() for orientation change, like it is done for geometry change. Otherwise the orientation update can still be processed earlier than the geometry change. Also note that at some point we might get an orientation change without a size change (for example Qt::LandscapeOrientation -> Qt::InvertedLandscapeOrientation). That is the reason for isSimilarRotation() helper function. As a drive-by: ignore size changes with inconsistent values when window size is reported to have old orientation, while the screen has already been rotated. In such cases a new size change will be triggered shortly with normal value. Task-number: QTBUG-94459 Pick-to: 6.3 6.2 5.15 Change-Id: I5c98e526d0370d380344b2297169d5e0c0ee8ea7 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: set all QScreen's geometry-related parameters togetherIvan Solovev2022-03-041-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | Screen has 3 parameters: - physical size - screen size (or screen geometry) - available geometry Before this patch, they were reported in 3 different methods. Screen size update and available geometry update both were generating the "screen geometry changed" event, that updated the user-visible parameters. As a result, at some point we could end up in an intermediate state, when screen size was already updated, but available geometry was not yet updated. This was specially visible while changing the screen orientation: at some point screen geometry could be reported for the new orientation, while the available geometry - still for old orientation. This patch introduces a new method to set all geometry-related parameters together and generate only one "screen geometry changed" event. This allows to maintain consistency between 'geometry' and 'availableGeometry' properties of QScreen. Task-number: QTBUG-94459 Pick-to: 6.3 6.2 5.15 Change-Id: I844f6d0db87df8d5e6e9bcce5d27126384a5a0de Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Fix issue in loading multimedia Android pluginSamuel Mira2022-03-021-13/+2
| | | | | | | | | | | | | | Qt projects on Android were failing to correctly load the plugin lib. The main reason is missing environment variables when the media integration starts. To make sure that the variables are loaded, I have change the setenv to be done in the java side instead of c++ side. Fixes: QTBUG-100299 Pick-to: 6.3 Change-Id: Iba0b6af40574be2d88824ebdcfb1626335cecf09 Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android A11Y: handle valueChanged eventsIvan Solovev2022-02-151-0/+6
| | | | | | | | | | | | | | | | | | | | | Before this patch Android A11Y implementation was missing ValueChanged event handling. As a result, no update was given when the element's value was changed. Handling these events allows us to announce value changes on such objects like Slider, SpinBox, etc... This is a universal method of value-change announcement, so it supports all sorts of A11Y gestures. On the Java side a new function was introduced to announce the values, because we need to use the actual element's *value*, not its accessible name or description. Task-number: QTBUG-93396 Pick-to: 6.3 6.2 5.15 Change-Id: Ic44abd5f01b9b6f5468962131466edaf6a49d498 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
* Android: extract parentId for hidden object in advanceIvan Solovev2022-02-091-2/+3
| | | | | | | | | | | | | | | | | | This commit amends 850a7f1238e84b6960a84e12687e40cf939a44d9. We can't extract the parentId for the hidden object on Java side, because the Java call is executed in a separate thread, so the original hidden object can be destroyed somewhere in the middle of parentId() call. As a workaround, we get the parentId in advance, on C++ side, and pass it as a parameter to JNI function. Task-number: QTBUG-95764 Pick-to: 6.3 6.2 5.15 Change-Id: Ied2ab4ab39b947f3f582575cf77cc76fbac9e274 Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* [Android]: Handle the screen name, modes and refreshRate properlyBogDan Vatra2022-01-281-28/+33
| | | | | | | | | Fixes: QTBUG-87136 Fixes: QTBUG-93823 Fixes: QTBUG-94959 Pick-to: 6.3 6.2 5.15 Change-Id: Id480e22611ec949b5e3ee780fc695fb502a5950c Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Use Android's View.generateViewId() for generating ids for views/surfacesMichał Cieślak2021-12-021-3/+7
| | | | | | | | | | | Qt Android was using consecutive numbers starting from 1 as ids for View.setId(int). The ids are used internally with an assumption that they are unique. It was potentially leading to collisions and unexpected behavior when adding custom views with id generated by View.generateViewId(). Task-number: QTBUG-98649 Pick-to: 5.15 6.2 Change-Id: I5bf2fe1d196c7adafeec544d8d945ebd82ba5cb6 Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Set sem_wait m_terminateSemaphore behind an atomic flagRami Potinkara2021-11-261-1/+7
| | | | | | | | | | | Prevents QML app using QtActivity never calling AndroidJniMain::startQt..'s to jam as ANR Pick-to: 6.2 5.15 Task-number: QTBUG-97115 Change-Id: Ibfe8579dbb701068f4896b6d826ff487094bdf56 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: Fix Application becomes unresponsive issuePekka Gehör2021-05-031-0/+5
| | | | | | | | | Block key events until the plugin is running. Fixes: QTBUG-67944 Pick-to: 5.15 6.1 Change-Id: Iea47f2e94d850141834a7e8fc26218be2cacf660 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Replace conversion operator by operator* in QJniEnvironmentAssam Boudjelthia2021-04-141-3/+3
| | | | | | | | | | | Since conversion operators do implicit conversion that might bring some potential issues while using the API, let's stick to having an operator* instead. Pick-to: 6.1 6.1.0 Change-Id: Ie7ad5537958944b8d1c11d69fbd30284b4b0344d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Android: make calling exit() conditional on an environment variableVille Voutilainen2021-03-031-2/+3
| | | | | | | | | Task-number: QTBUG-82617 Task-number: QTBUG-85449 Task-number: QTBUG-83043 Change-Id: I5ac67b5d57550e5a1f816e5db01f4aab31127283 Pick-to: 5.15 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: take JavaVM() from QJniEnvironment and not QtAndroidPrivateAssam Boudjelthia2021-02-111-2/+2
| | | | | | | Task-number: QTBUG-89482 Pick-to: 6.1 Change-Id: Idfd442afc90c00e672b28b43c78c789813f46c7d Reviewed-by: Alex Blasche <alexander.blasche@qt.io>