Normally, the app's main library's name is read from a metadata field
in the AndroidManifest.xml file, which is filled out by
androiddeployqt.
Add a protected variable in QtLoader for the app main library name
that can be set to provide the library name without the metadata field.
This is useful in cases where we don't have a manifest file filled
by androiddeployqt, for example when embedding QML to an existing
Android app.
As a side effect, change the name of existing variable for the main
library and the method to access it to make it more explicit they refer
to the library's absolute path.
Pick-to: 6.7
Change-Id: I869547818f4d0272668a1052d7bc6916b7bf5a98
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This is useful for example the embedded QML case, where we want to
make sure everything from Qt side is ready before we start to create
Qt windows.
Pick-to: 6.7
Change-Id: I8148405e35cc8ebb89110f05e07cef06f8ff3709
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This reverts commit 3bae65e7d6.
Reason for revert: This version requires API >= 34 but we have AGP
7.4.1 which was tested against API 33 max, and updating it to version
8.x is blocked by QTBUG-106907. So, this will be re-stated AGP update
is done.
Task-number: QTBUG-106907
Pick-to: 6.7
Change-Id: I1551ace76392a0532e1ecf431d03afbbd9d4a300
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
The default value in the default manifest has been for few
releases, set as minimal, and since Widgets Android style
is not fully supported anymore, we can set this to default
to minimal under the hood as well to avoid needing to always
explicitly needing to set it to minimal.
Pick-to: 6.7
Change-Id: Id0b2134c572694be1e190347ff75f51ade65f0c4
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Otheriwse Qt C++ code will not be able to find it.
Task-number: QTBUG-115016
Pick-to: 6.7
Change-Id: Id3a2efb1f33cb60a523359e1ad646a394e24397e
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Janne Juntunen <janne.juntunen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
To avoid exceptions if the metadata is a non-string like boolean
or integer.
Task-number: QTBUG-115016
Pick-to: 6.7
Change-Id: I104e6b2954873e74bc100cb965ee8ea9b6d14568
Reviewed-by: Janne Juntunen <janne.juntunen@qt.io>
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
since m_service will not be yet set, m_context should be used here.
Task-number: QTBUG-115016
Pick-to: 6.7
Change-Id: Ie259e703da1d8aac23117f032b7d146f7060aac2
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Janne Juntunen <janne.juntunen@qt.io>
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
In QtServiceBase setApplicationState() is being called before
the Qt libs are loaded and that call invokes a native method,
so that leads to a crash/exception for UnsatisfiedLinkError.
Pick-to: 6.7
Change-Id: I879d120f0cc2985ab49f7402a65f171950451914
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Janne Juntunen <janne.juntunen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
The table had the wrong row span making it malfomatted.
Task-number: QTBUG-115020
Pick-to: 6.7
Change-Id: Icc35df3cd7dcdad2407d4c93d7a2a8d3d1701275
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
The SurfaceView class is not the best option for when we
have multiple windows, as the created Surface can only
either be below the window or on top of it, it is not a
part of the view hierarchy.
Replace the SurfaceView with TextureView when there are
more than one window. This way the surface will be a part
of the view hierarchy, and will respect z-ordering.
When there is only one window, keep using the SurfaceView
approach to limit the effect on existing apps, as well
as enable some of the benefits SurfaceView has for e.g.
game and multimedia apps, such as HDR ability.
Move touch handling from QtSurface to QtWindow, so
touches are handled also when using TextureView instead
of QtSurface aka SurfaceView.
Pick-to: 6.7
Task-number: QTBUG-118142
Change-Id: I37dcaf0fb656cfc1ff2eca0a3bfe7259f607411c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
The layout is a ViewGroup, and should be created in the Android UI
thread, while for ease of use on C++ side we should be able to
construct the Java object in the platform window constructor to
avoid later calls not having a valid object reference. Trying to
make a blocking call to Android thread from Qt thread can lead to
dead locks, so move only the creation of the layout itself into
Android thread, making the QtWindow a wrapper for it, which we can
immediately return to C++/Qt thread. Most of the calls made to
QtWindow are anyway already passed to the Android UI thread.
As a drive by, add a missing QtNative.runAction() to
bringChildToFront().
Change-Id: Ib2495ddda8267384656557cbe40be5da869f82c3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Update the manual test case for embedded windows to have
native window on Android.
There are still some sharp corners, for example:
* The windows are implemented with SurfaceViews, which makes
z-ordering with multiple of them a bit tricky. The Surfaces
they instantiate are basically z-ordered to either be below
everything, with a hole punched in the window, or on top of
everything, with the Surfaces created later on top of the
ones created earlier. Also, with the foreign views it looks
like the native view is on top of the Surface, because it
is created later. And since the child windows create their
Surfaces before the parent, they would be behind the parent
window, currently circumventing this with letting the
parent be z-ordered behind everything, and the children
on top of everything. A follow up commit addresses this by
changing the native view class to TextureView when multiple
windows are present.
* Parent window always gets the touch events - fixed in
a follow up commit
* If a child window has a text edit, it does not receive
focus when clicking on it
Task-number: QTBUG-116187
Change-Id: I32188ec5e3d3fce9fd8e3a931e317d1e081f691c
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
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>
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>
Move the orientation change handling to the display manager
and call it from the relevant places to repeated and scattered
code for the same functionality.
Bring back part of 072387edec
which checks discard a resize event that's not valid that
reports not up to date layout size.
If DisplayManager.DisplayListener.onDisplay() initiates the
orientation change, handle it immediately if we don't expect
the size to change, i.e. if the orientation is changing from
portrait to inverted portrait and vise versa for landscape.
Otherwise, expect the change to be initiated again shortly
after from QtLayout.onSizeChanged().
Also, add improve the unit test of the orientation change,
and test for the widget size after such changes to make
sure QTBUG-94459 is not reached again.
Fixes: QTBUG-119430
Task-number: QTBUG-115019
Task-number: QTBUG-94459
Change-Id: I5f060d91531af677ddf891f2af360d5f399e26e5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
The commit 41765ef3e2 tried to
fix a deprecation warning by using the wrong API replacement,
this fixes that. Check the Android docs for the replacement API.
https://developer.android.com/reference/android/view/accessibility/
AccessibilityNodeInfo#addAction(int)
Task-number: QTBUG-118077
Change-Id: I2621d47fa4425cc1056fc995ea458a798160a6a0
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
android.content.ClipboardManager is the replacement for the
deprecated android.text.ClipboardManager API.
Task-number: QTBUG-118077
Change-Id: I14038ee4b21150d8bcb9f5bfeb82369347d7f215
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
And minor warning fixes for unused imports.
Task-number: QTBUG-118077
Change-Id: I8296ae019da9d40692687e49ac926f96af901870
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
The requirement for separating the app args by tabs only is not
justified, since the the args are passed as a string to C++ where
QProcess::splitCommand() is used to get a list of single args and
that knows how to handle the parsing properly anyway.
As for env vars, QtLoader currently expects env vars to be separated
by tabs only, however, to account for different use cases, it should
handle both tabs and spaces.
Task-number: QTBUG-115016
Task-number: QTBUG-106478
Task-number: QTQAINFRA-5703
Change-Id: I58258861477776b82294a4c2603b230f178f16a6
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Since we expect soon to support embedding of Qt from native
Android apps, and allowing native apps to access some Qt java
classes as API to enbale the embedding, it's needed now to
set the visibility to public only to classes that are meant
to be public.
Task-number: QTBUG-115017
Change-Id: Iec73f8d39bf9c5f7d303176b2b345d5928fb46c7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Unregister the display manager listener onPause or onStop
and register again when onResume is called.
Task-number: QTBUG-118077
Change-Id: Ic48defda019fb132ef22a8229c4b549b0414b100
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Since the display manager is mainly created by the Activity delegate
and lives with it, so pass the Actitivy and use it internally,
instead of passing it to every method.
Task-number: QTBUG-118077
Change-Id: I7761490ac8746cc6dad3bd59514a54da18519990
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Starting the native application is not the responsibility of QtLayout
instead it makes more sense to be done under QtActivityDelegate so
move that logic there and avoid keeping its runnable inside the
QtLayout.
Task-number: QTBUG-118077
Change-Id: I4869cb5aa741289ed0e9ccaa1cf2ae42c9dd4791
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
System UI visibility is saved under onSaveInstanceState()
but never restored under onRestoreInstanceState().
Task-number: QTBUG-118077
Change-Id: Ic9956a4aca9e0b9bb5fefa37d7229dd0d52c7344
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
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>
Cleanup 'isStarted' and state management logic and move it
to QtNative. Currently, it's spread between QtActivityDelegate and
QtNative where multiple variables are used for overlapping use
cases.
Task-number: QTBUG-118077
Change-Id: I2c98b48be78809c30636bfdf6d6640317470cec6
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
No one is using that return code, instead print an error when the
call to startQtAndroidPlugin() fails.
Task-number: QTBUG-118077
Change-Id: I98c8e4ca9af5f1c45af36044336d461bed6acdc9
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
use -classpath instead of -bootclasspath param to allow
javac to use the default boot class path to support
building lambdas, pass the user Android class via -classpath.
Task-number: QTBUG-118077
Change-Id: I1ba8274d57e1bd528a1d5b7d779191e7f1412184
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Wrap the activity and service static objects with
a WeakReference to fix a potential memory leak warning.
Task-number: QTBUG-118077
Change-Id: Ifafd137cc49ec5ea23d8425b6bd58b43573970b9
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Rename m_quitApp to m_retainNonConfigurationInstance and keep it
inside QtActivityBase since it's only used there based on whether
onRetainNonConfigurationInstance() is called, in wish case,
onDestroy() would skip the Qt specific app destruction/exit logic.
Task-number: QTBUG-118077
Change-Id: I1cf03bd6f5266a9283660db7943d053a9dba889c
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
To get rid of unused method warnings in Java code for methods used only
from C++ code and make it more visible which methods are used by native
code.
This annotation would need to be added to the relevant methods in this
patch or future one.
Use this annotation for all methods called from native code. And along
the way remove few methods that are not used anywhere.
Task-number: QTBUG-118077
Change-Id: Ie493fb057f4a93aff513f85e0936bc65a9bb304c
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
the QtDisplayManager listener uses m_layout but it can be called
before m_layout is actually initialized, so set the listener after
the layout has been initialized.
Task-number: QTBUG-118077
Fixes: QTBUG-119007
Fixes: QTBUG-119134
Change-Id: Icebc350f09210c12dbd011f86ce88a90b6f27d12
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
This variable supposedly holds a list of environment variables that will
be set by the Qt app, however, if a user needs to set an env variable,
it can be already done either in C++:
qputenv(key, value);
Or in Java via (the same method that Qt plugin use):
android.system.Os.setenv(key, value, override);
Thus, such field just makes things more confusing overall only.
Task-number: QTBUG-115017
Task-number: QTBUG-114593
Change-Id: I14856ed0720bfa2605da9c7d51173703df52bc58
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Instead of having to set a field of the class QtActivity to set extra
app parameters (i.e. passed when calling main()), make it doable via
a new API call appendApplicationParameters(). Note that this is
equivalent to setting the manifest metadata "android.app.arguments".
Providing a dedicated method for this makes it cleaner and is the
expected way.
Task-number: QTBUG-115017
Task-number: QTBUG-114593
Change-Id: I407cb68e57fa9a1be24586e42cb947f9c7f4037e
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Currently the default theme is looked for using reflection in the
android.R package to get an id and then it's set. This is not needed
if we set the theme directly in the user's QtActivity which would have
access to that id directly pre-deployment.
To make setting a theme more in line with Android, retreat to using
setTheme() call directly for user projects instead of having to maintain
some internal field to store the theme name and have the user set that
if they want a different theme for their app.
Also, the Android plugin seems to set an env var for QT_ANDROID_THEME
with that default theme's name and that's used in QAndroidPlatformTheme
to check a theme specific extracted theme style.json, however, the Java
side doesn't seem to ever write to such a path, making this approach
totally redundant. For that reason, this code path is now removed.
Fixes: QTBUG-114075
Task-number: QTBUG-115017
Task-number: QTBUG-114593
Change-Id: I9ab3c025626aac2c09bc19eb7d846eca14a45070
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
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>
It's not immediately clear why setApplicationDisplayMetrics()
is called from within QtNative.startApplication() while it's also
called by QtLayout.onSizeChanged(), it seems to be a redundant call
when starting the native Qt app because QtLayout takes care of it
already.
Task-number: QTBUG-115016
Task-number: QTBUG-118077
Change-Id: I54e8af6356226ca5f1b849ef323be9659b9db663
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
The flags were not set to the system UI with Android APIs.
Amends 58c7249ee8.
Task-number: QTBUG-118077
Change-Id: I30fb5272bdb5d7a3a3a82708b9a1604753fc4e6c
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>