android/source/build.gradle | 7 +++++++ sal/osl/unx/file.cxx | 24 +++++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-)
New commits: commit d495eb9f78fe72176c756e0c159d2edc04bec522 Author: Christian Lohmaier <[email protected]> AuthorDate: Mon Nov 18 17:08:00 2019 +0100 Commit: Michael Meeks <[email protected]> CommitDate: Fri Jan 3 12:31:12 2020 +0100 tdf#128101 android: fix documents with manual page break code reads a .ui file to show a menu to edit/delete that pagebreak. That file was not packaged in the Android viewer and causes an exception that is not handled and ultimately results in a crash. Change-Id: Ie73d886daf9202ba12e1b5a241bc7b6d184ae770 Reviewed-on: https://gerrit.libreoffice.org/83104 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86165 Reviewed-by: Michael Meeks <[email protected]> Tested-by: Michael Meeks <[email protected]> diff --git a/android/source/build.gradle b/android/source/build.gradle index a5fd073f7aeb..03fe251d6a9b 100644 --- a/android/source/build.gradle +++ b/android/source/build.gradle @@ -149,6 +149,13 @@ task copyUnpackAssets(type: Copy) { ) } } + // documents with manual page break trigger attempt to read the ui file + // would trigger a css::container::NoSuchElementException with osl_File_E_NOENT + // if not present and since it is not caught would crash the app... + into('config') { + from "${liboInstdir}/share/config" + include '**/pagebreakmenu.ui' + } } task copyAssets(type: Copy) { diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index 9e3a1c7b272f..f6832f1aef63 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -888,13 +888,23 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle, { OString aData; bool bCache = true; - AndroidFileCache::Entry *pHit = AndroidFileCache::getHitCache().find(cpFilePath); + + const char *cpAssetsPath = cpFilePath + sizeof("/assets/") - 1; + // some requests are /assets//foo... + if (cpAssetsPath[0] == '/') + { + __android_log_print(ANDROID_LOG_DEBUG,"libo:sal/osl/unx/file", "double-slash in path: %s", cpFilePath); + cpAssetsPath++; + } + + AndroidFileCache::Entry *pHit = AndroidFileCache::getHitCache().find(cpAssetsPath); if (pHit) aData = pHit->maData; + else { bCache = false; - AndroidFileCache::Entry *pMiss = AndroidFileCache::getMissCache().find(cpFilePath); + AndroidFileCache::Entry *pMiss = AndroidFileCache::getMissCache().find(cpAssetsPath); if (pMiss) { errno = ENOENT; @@ -902,10 +912,10 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle, return osl_File_E_NOENT; } AAssetManager* mgr = lo_get_native_assetmgr(); - AAsset* asset = AAssetManager_open(mgr, cpFilePath + sizeof("/assets/")-1, AASSET_MODE_BUFFER); + AAsset* asset = AAssetManager_open(mgr, cpAssetsPath, AASSET_MODE_BUFFER); if (!asset) { - AndroidFileCache::getMissCache().insert(cpFilePath, aData); + AndroidFileCache::getMissCache().insert(cpAssetsPath, aData); errno = ENOENT; __android_log_print(ANDROID_LOG_ERROR,"libo:sal/osl/unx/file", "failed to open %s", cpFilePath); return osl_File_E_NOENT; @@ -922,7 +932,7 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle, aData = OString(pData, SAL_NO_ACQUIRE); if (pData->length < 50 * 1024) - AndroidFileCache::getHitCache().insert(cpFilePath, aData); + AndroidFileCache::getHitCache().insert(cpAssetsPath, aData); } } @@ -933,8 +943,8 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle, // loading a document from /assets fails with that idiotic // "General Error" dialog... } - SAL_WARN("sal.file", "osl_openFile(" << cpFilePath << ") => " << aData.getLength() << - " bytes from file " << (bCache ? "cache" : "system")); + SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ") => '" << cpAssetsPath << "'" + << aData.getLength() << " bytes from file " << (bCache ? "cache" : "system")); return openMemoryAsFile(aData, pHandle, cpFilePath); } #endif _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
