summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2022-10-21 02:20:09 +0300
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2022-10-21 16:54:29 +0300
commit89f89cedc0e62f4b66de340da57d6c56dc61baf0 (patch)
treee3db216f0a7e01a5b71f1a1e2420dcdc98ed8aba /src/plugins/platforms/android
parentd59b2fde5eef39cc1735cadf2327f99ca6055306 (diff)
Android: fix Android assets handler not listing dirs with only sub dirs
Amends edd983071e0a90ee8665d2f45916fb575fc25857. Remove redundant calls to AAssetDir_getNextFileName() in AndroidAbstractFileEngine::setFileName(). It's enough to check if AAssetManager_open() returns null and AAssetManager_openDir() is valid for the provided asset file name. As part of this fix, add some unit tests to cover/ensure assets listing/iterating works as expected. Fixes: QTBUG-107627 Pick-to: 6.4 6.2 5.15 Change-Id: I37ae9cb64fbbc60699bb748895f77fd6a34fae1f Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/plugins/platforms/android')
-rw-r--r--src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
index bd1619e6db..5bff4206e6 100644
--- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
+++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp
@@ -108,10 +108,12 @@ public:
FolderIterator(const QString &path)
: m_path(path)
{
+ // Note that empty dirs in the assets dir before the build are not going to be
+ // included in the final apk, so no empty folders should expected to be listed.
QJniObject files = QJniObject::callStaticObjectMethod(QtAndroid::applicationClass(),
- "listAssetContent",
- "(Landroid/content/res/AssetManager;Ljava/lang/String;)[Ljava/lang/String;",
- QtAndroid::assets(), QJniObject::fromString(path).object());
+ "listAssetContent",
+ "(Landroid/content/res/AssetManager;Ljava/lang/String;)[Ljava/lang/String;",
+ QtAndroid::assets(), QJniObject::fromString(path).object());
if (files.isValid()) {
QJniEnvironment env;
jobjectArray jFiles = files.object<jobjectArray>();
@@ -350,8 +352,7 @@ public:
} else {
auto *assetDir = AAssetManager_openDir(m_assetManager, m_fileName.toUtf8());
if (assetDir) {
- if (AAssetDir_getNextFileName(assetDir))
- m_assetInfo->type = AssetItem::Type::Folder;
+ m_assetInfo->type = AssetItem::Type::Folder;
AAssetDir_close(assetDir);
}
}