diff options
Diffstat (limited to 'android')
6 files changed, 52 insertions, 59 deletions
diff --git a/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp b/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp index aa91a6c905..623738a941 100644 --- a/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp +++ b/android/jni/com/mapswithme/maps/DownloadResourcesActivity.cpp @@ -63,43 +63,26 @@ extern "C" // Check if we need to download mandatory resource file. bool NeedToDownload(Platform & pl, string const & name, int size) { - uint64_t originSize = 0; - if (!pl.GetFileSizeByName(name, originSize)) + try { - // no such file - return true; - } - - if (size == originSize) - { - // file is up-to-date - return false; - } + ModelReaderPtr reader(pl.GetReader(name)); - if (name == WORLD_FILE_NAME DATA_FILE_EXTENSION) - { - try + if (name == WORLD_FILE_NAME DATA_FILE_EXTENSION) { - FilesContainerR cont(pl.GetReader(name)); - if (cont.IsReaderExist(SEARCH_INDEX_FILE_TAG)) + FilesContainerR cont(reader); + if (!cont.IsReaderExist(SEARCH_INDEX_FILE_TAG)) { - // World.mwm file has search index - can skip new version. - return false; + // World.mwm file doesn't have search index - need to download new one. + return true; } } - catch (RootException const &) - { - // Some error occurred when loading file. - return true; - } + + // file exists - no need to download + return false; } - else if (name == WORLD_COASTS_FILE_NAME DATA_FILE_EXTENSION) + catch (RootException const &) { - // Skip WorldCoasts.mwm - return false; } - - // Do download otherwise. return true; } diff --git a/android/jni/com/mapswithme/maps/MWMApplication.cpp b/android/jni/com/mapswithme/maps/MWMApplication.cpp index 7ff0c77fbb..0afee794c6 100644 --- a/android/jni/com/mapswithme/maps/MWMApplication.cpp +++ b/android/jni/com/mapswithme/maps/MWMApplication.cpp @@ -21,18 +21,13 @@ extern "C" { JNIEXPORT void JNICALL - Java_com_mapswithme_maps_MWMApplication_nativeInit(JNIEnv * env, - jobject thiz, - jstring apkPath, - jstring storagePath, - jstring tmpPath, - jboolean isPro) + Java_com_mapswithme_maps_MWMApplication_nativeInit( + JNIEnv * env, jobject thiz, + jstring apkPath, jstring storagePath, jstring tmpPath, jstring obbGooglePath, + jboolean isPro) { - android::Platform::Instance().Initialize(env, - apkPath, - storagePath, - tmpPath, - isPro); + android::Platform::Instance().Initialize( + env, apkPath, storagePath, tmpPath, obbGooglePath, isPro); LOG(LDEBUG, ("Creating android::Framework instance ...")); @@ -43,8 +38,7 @@ extern "C" } JNIEXPORT jboolean JNICALL - Java_com_mapswithme_maps_MWMApplication_nativeIsBenchmarking(JNIEnv * env, - jobject thiz) + Java_com_mapswithme_maps_MWMApplication_nativeIsBenchmarking(JNIEnv * env, jobject thiz) { return static_cast<jboolean>(g_framework->NativeFramework()->IsBenchmarking()); } diff --git a/android/jni/com/mapswithme/maps/settings/StoragePathActivity.cpp b/android/jni/com/mapswithme/maps/settings/StoragePathActivity.cpp index ab904a6389..51dcaeac94 100644 --- a/android/jni/com/mapswithme/maps/settings/StoragePathActivity.cpp +++ b/android/jni/com/mapswithme/maps/settings/StoragePathActivity.cpp @@ -29,7 +29,9 @@ extern "C" Platform & pl = GetPlatform(); // Get regexp like this: (\.mwm$|\.ttf$) - string const regexp = "(" "\\"DATA_FILE_EXTENSION"$" "|" "\\"BOOKMARKS_FILE_EXTENSION"$" "|" "\\.ttf$" ")"; + string const regexp = "(" "\\"DATA_FILE_EXTENSION"$" "|" + "\\"BOOKMARKS_FILE_EXTENSION"$" "|" + "\\"FONT_FILE_EXTENSION"$" ")"; Platform::FilesList files; pl.GetFilesByRegExp(from, regexp, files); diff --git a/android/jni/com/mapswithme/platform/Platform.cpp b/android/jni/com/mapswithme/platform/Platform.cpp index 2bd970a28b..af122e59f9 100644 --- a/android/jni/com/mapswithme/platform/Platform.cpp +++ b/android/jni/com/mapswithme/platform/Platform.cpp @@ -3,7 +3,11 @@ #include "../core/jni_helper.hpp" #include "../../../../../platform/settings.hpp" + #include "../../../../../base/logging.hpp" +#include "../../../../../base/stl_add.hpp" + +#include "../../../../../std/algorithm.hpp" string Platform::UniqueClientId() const @@ -52,9 +56,8 @@ string Platform::UniqueClientId() const namespace android { void Platform::Initialize(JNIEnv * env, - jstring apkPath, - jstring storagePath, - jstring tmpPath, + jstring apkPath, jstring storagePath, + jstring tmpPath, jstring obbGooglePath, bool isPro) { m_resourcesDir = jni::ToNativeString(env, apkPath); @@ -75,10 +78,19 @@ namespace android m_isPro = isPro; - LOG(LDEBUG, ("Apk path = ", m_resourcesDir)); - LOG(LDEBUG, ("Writable path = ", m_writableDir)); - LOG(LDEBUG, ("Temporary path = ", m_tmpDir)); - LOG(LDEBUG, ("Settings path = ", m_settingsDir)); + string const obbPath = jni::ToNativeString(env, obbGooglePath); + Platform::FilesList files; + GetFilesByExt(obbPath, ".obb", files); + m_extResFiles.clear(); + for (size_t i = 0; i < files.size(); ++i) + m_extResFiles.push_back(obbPath + files[i]); + + LOG(LINFO, ("Apk path = ", m_resourcesDir)); + LOG(LINFO, ("Writable path = ", m_writableDir)); + LOG(LINFO, ("Temporary path = ", m_tmpDir)); + LOG(LINFO, ("Settings path = ", m_settingsDir)); + LOG(LINFO, ("OBB Google path = ", obbPath)); + LOG(LINFO, ("OBB Google files = ", files)); } void Platform::OnExternalStorageStatusChanged(bool isAvailable) diff --git a/android/jni/com/mapswithme/platform/Platform.hpp b/android/jni/com/mapswithme/platform/Platform.hpp index 355ad0a0b7..6d65b92212 100644 --- a/android/jni/com/mapswithme/platform/Platform.hpp +++ b/android/jni/com/mapswithme/platform/Platform.hpp @@ -11,9 +11,8 @@ namespace android public: void Initialize(JNIEnv * env, - jstring apkPath, - jstring storagePath, - jstring tmpPath, + jstring apkPath, jstring storagePath, + jstring tmpPath, jstring obbGooglePath, bool isPro); void OnExternalStorageStatusChanged(bool isAvailable); diff --git a/android/src/com/mapswithme/maps/MWMApplication.java b/android/src/com/mapswithme/maps/MWMApplication.java index 89a2a1e95a..a2dd3f86af 100644 --- a/android/src/com/mapswithme/maps/MWMApplication.java +++ b/android/src/com/mapswithme/maps/MWMApplication.java @@ -126,10 +126,8 @@ public class MWMApplication extends android.app.Application implements MapStorag new File(extTmpPath).mkdirs(); // init native framework - nativeInit(getApkPath(), - extStoragePath, - extTmpPath, - m_isProVersion); + nativeInit(getApkPath(), extStoragePath, extTmpPath, + getOBBGooglePath(), m_isProVersion); m_slotID = getMapStorage().subscribe(this); @@ -203,6 +201,12 @@ public class MWMApplication extends android.app.Application implements MapStorag return storagePath.concat(String.format("/Android/data/%s/%s/", getPackageName(), folder)); } + private String getOBBGooglePath() + { + final String storagePath = Environment.getExternalStorageDirectory().getAbsolutePath(); + return storagePath.concat(String.format("/Android/obb/%s/", getPackageName())); + } + /// Check if we have free space on storage (writable path). public native boolean hasFreeSpace(long size); @@ -241,9 +245,8 @@ public class MWMApplication extends android.app.Application implements MapStorag System.loadLibrary("mapswithme"); } - private native void nativeInit(String apkPath, - String storagePath, - String tmpPath, + private native void nativeInit(String apkPath, String storagePath, + String tmpPath, String obbGooglePath, boolean isPro); public native boolean nativeIsBenchmarking(); |