Repository navigation
android: Fix resource extraction on Android 10 and shallow CI builds - #1867
arsdragonfly wants to merge 1 commit into
Conversation
- Use QStandardPaths::standardLocations(QStandardPaths::AppDataLocation) (selecting Context.getExternalFilesDir(null), with fallback to internal AppDataLocation) instead of GenericDataLocation. In Qt 6, GenericDataLocation returns /storage/emulated/0 on Android <= 10 (API < 30), where extraction fails without runtime storage permissions. - Require both help and config/library.csv plus a non-empty .assets-version stamp before skipping extraction, and unify the stamp check between sim-main.cpp and sim-window.cpp so resources are not extracted twice and empty DB48X_VERSION strings on shallow checkouts do not skip first-run extraction. - Fall back to git rev-parse --short HEAD for VERSION in Makefile and fetch full history in Android CI jobs, and make sim/help/img.qrc depend on help/$(NAME).md so help/img/*.bmp is populated first. Fixes: c3d#1863 Fixes: c3d#1864 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
This looks very promising (impression after a first read of the above and the code). I knew #1816 could perhaps cause problems for older Android versions. But what exactly and how to fix wasn't clear to me (yet). Considering declining usage of older versions getting USB/PC access in, had priority. About I don't know why Jean chose a file If there is a Supersedes a few changes I sneaked into #1865 in addition to the fix for the subject. Will look into that. I would appreciate your feedback on that PR, in particular on the documentation. I intend to take your contribution for some tests. @Wiljea chime in please. |
|
Thanks @arsdragonfly, and thanks Ed for asking. Why a file. .assets-version was added because the old !QDir(files).exists() test never fired on Android, since the Qt bootstrap creates the directory first. The AssetVersion QSetting already existed then, and only copied the help files. I would keep the file: it lives inside the tree it describes, so if that tree is deleted, for instance over USB since #1816, the stamp goes with it and extraction runs again. A QSetting would still say that everything is up to date. The criterion. I agree with Ed: the stamp alone should decide. Extract when it is missing or differs from the wanted version. Since it is written after the copy, an interrupted extraction runs again. Checking two particular files adds little, and the non-empty stamp already covers the case of an empty version. A ..._read_stamp would also make this simpler. One remaining weakness. copy() ignores the result of sim_install_copy_file, so the stamp is written even if extraction failed, for instance on a full disk. It would be better to write it only after a complete copy. Directories. I read qstandardpaths_android.cpp in Qt 6.8: it matches the description. GenericDataLocation returns the external files directory only from API 30, and index 1 of standardLocations(AppDataLocation) is that same directory. So nothing moves on Android 11 and later. Our builds use Qt 6.10.3, which I have not checked. I have not run this PR yet. I can test an update in place on Android 13. The Android 10 test has to come from the reporter of c3d/db48x#1864. Author & design: Jean Wilson |
|
I took the Makefile and build.yml changes from this PR to build Android only. Results are here. Installed the db50x artifact on my Pixel 10, Android version = 17. |
Tried also on my Samsung Galaxy S10e, Android version = 12. I had to allow Google drive as a source for where the App comes from. During install a dialog about the Play Store scan flashes by. Did not get a chance to tap Skip. Then it kept Installing for ages. Couldn't Cancel. Eventually swiped it away. Tried again ... same effect. |
This time I used the Chrome browser to surf to the Artifacts. After logging in to GitHub I could download db50x.apk. I had to allow Chrome as a source for apps. This time the scan dialog did allow me to skip. The App installs and works (limited testing) like on my Pixel 10. |
|
See #1864 (comment) and later, for info on testing on Android 10. |
Summary
Fixes #1864 and #1863 by correcting the Android data directory selection across API levels and ensuring bundled resources (
help/,config/,library/) are always extracted on first run even in shallow CI builds.Root Causes
#1864): Commitab0bfa67(#1816) switchedAppDataLocationtoQStandardPaths::writableLocation(QStandardPaths::GenericDataLocation). In Qt'sqstandardpaths_android.cpp,GenericDataLocationonly returnsContext.getExternalFilesDir(null)(.../Android/data/<package>/files) whensdkVersion() >= 30(Android 11+). On Android 10 and older (sdkVersion() < 30),GenericDataLocationreturnsEnvironment.getExternalStorageDirectory()(/storage/emulated/0), which fails withEACCESwithout runtime permission requests and leavesAndroid/data/<package>/filesempty.#1863/#1864):actions/checkout@v6defaults tofetch-depth: 1(no tags), sogit describefails andDB48X_VERSIONis""..assets-version(insim-main.cpp) andQSettings"AssetVersion"(insim-window.cpp) do not exist yet,foundandsavedAssetVersionboth default to"". Comparingfound != wanted("" != "") evaluated tofalse, completely skipping resource extraction on first launch.sim/help/img.qrcdid not depend onhelp/$(NAME).md(which populateshelp/img/*.bmpfromdoc/img/*.bmp).sim-main.cppandsim-window.cppused separate stamp mechanisms (.assets-versionvsQSettings), causing the 4.6 MB resource tree to be extracted twice on every version update.Changes
sim/sim-install.h&sim/sim-install.cpp:sim_install_data_dir()which selectsContext.getExternalFilesDir(null)viaQStandardPaths::standardLocations(QStandardPaths::AppDataLocation)(available at index 1 on all Android API levels without runtime permissions) and falls back towritableLocation(QStandardPaths::AppDataLocation)if external storage is unavailable.sim_install_needed()andsim_install_write_stamp()which verify thatHELPFILE_NAME,config/library.csv, and a non-empty.assets-versionstamp exist on disk before skipping extraction.sim/sim-main.cpp&sim/sim-window.cpp:sim_install_data_dir(),sim_install_needed(), andsim_install_write_stamp()consistently so resources are extracted once and never skipped on fresh installs.Makefile&.github/workflows/build.yml:git rev-parse --short HEADwhengit describefails, passfetch-depth: 0in Android CI jobs, and makesim/help/img.qrcdepend onhelp/$(NAME).md.