diff --git a/Android/MMKV/build.gradle b/Android/MMKV/build.gradle index f6b5ef58..bdf5a2c8 100644 --- a/Android/MMKV/build.gradle +++ b/Android/MMKV/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.72' + ext.kotlin_version = '1.4.10' repositories { google() diff --git a/Android/MMKV/gradle.properties b/Android/MMKV/gradle.properties index 5c6a19db..e7b9e9d3 100644 --- a/Android/MMKV/gradle.properties +++ b/Android/MMKV/gradle.properties @@ -14,6 +14,6 @@ org.gradle.jvmargs=-Xmx1536m # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME_PREFIX=1.2.3 +VERSION_NAME_PREFIX=1.2.4 #VERSION_NAME_SUFFIX=-SNAPSHOT VERSION_NAME_SUFFIX= \ No newline at end of file diff --git a/Android/MMKV/mmkv/build.gradle b/Android/MMKV/mmkv/build.gradle index c3f83731..7518405f 100644 --- a/Android/MMKV/mmkv/build.gradle +++ b/Android/MMKV/mmkv/build.gradle @@ -1,8 +1,8 @@ apply from: rootProject.file('gradle/build_library.gradle') android { -// defaultPublishConfig "StaticCppRelease" - defaultPublishConfig "SharedCppRelease" + defaultPublishConfig "StaticCppRelease" +// defaultPublishConfig "SharedCppRelease" defaultConfig { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" externalNativeBuild { diff --git a/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKV.java b/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKV.java index f24b1fce..01abd003 100644 --- a/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKV.java +++ b/Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKV.java @@ -98,9 +98,9 @@ public static String initialize(String rootDir, LibLoader loader, MMKVLogLevel l } System.loadLibrary("mmkv"); } + jniInitialize(rootDir, logLevel2Int(logLevel)); MMKV.rootDir = rootDir; - jniInitialize(MMKV.rootDir, logLevel2Int(logLevel)); - return rootDir; + return MMKV.rootDir; } static private String rootDir = null; diff --git a/Android/MMKV/mmkvdemo/build.gradle b/Android/MMKV/mmkvdemo/build.gradle index b0a6d4fa..9587a8a2 100644 --- a/Android/MMKV/mmkvdemo/build.gradle +++ b/Android/MMKV/mmkvdemo/build.gradle @@ -82,8 +82,8 @@ repositories { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation project(':mmkv') -// implementation 'com.tencent:mmkv:1.2.3' -// implementation 'com.tencent:mmkv-static:1.2.3' +// implementation 'com.tencent:mmkv:1.2.4' +// implementation 'com.tencent:mmkv-static:1.2.4' implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.2' testImplementation 'junit:junit:4.12' diff --git a/CHANGELOG.md b/CHANGELOG.md index 1116f0e9..8198d82a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # MMKV Change Log +## v1.2.4 / 2020-10-21 +This is a hotfix mainly for iOS. + +### iOS / macOS +* Fix a decode error of encrypted MMKV on some devices. + +### Android +* Fix a potential issue on checking `rootDir` in multi-thread while MMKV initialization is not finished. + ## v1.2.3 / 2020-10-16 ### Changes for All platforms * Fix a potential crash on 32-bit devices due to pointer alignment issue. diff --git a/Core/KeyValueHolder.cpp b/Core/KeyValueHolder.cpp index 6bb5ab4a..638ae030 100644 --- a/Core/KeyValueHolder.cpp +++ b/Core/KeyValueHolder.cpp @@ -165,7 +165,7 @@ MMBuffer KeyValueHolderCrypt::toMMBuffer(const void *basePtr, const AESCrypt *cr } // namespace mmkv -#if !defined(MMKV_DISABLE_CRYPT) && !defined(NDEBUG) +#if !defined(MMKV_DISABLE_CRYPT) && defined(MMKV_DEBUG) # include "CodedInputData.h" # include "CodedOutputData.h" # include "MMKVLog.h" diff --git a/Core/KeyValueHolder.h b/Core/KeyValueHolder.h index 6051581f..5f4cebf4 100644 --- a/Core/KeyValueHolder.h +++ b/Core/KeyValueHolder.h @@ -103,7 +103,7 @@ struct KeyValueHolderCrypt { explicit KeyValueHolderCrypt(const KeyValueHolderCrypt &other) = delete; KeyValueHolderCrypt &operator=(const KeyValueHolderCrypt &other) = delete; -#ifndef NDEBUG +#ifdef MMKV_DEBUG static void testAESToMMBuffer(); #endif }; diff --git a/Core/MMKV.cpp b/Core/MMKV.cpp index 75a28aab..7c8a7a64 100644 --- a/Core/MMKV.cpp +++ b/Core/MMKV.cpp @@ -179,7 +179,7 @@ void initialize() { # endif // MMKV_USE_ARMV8_CRC32 #endif // __aarch64__ && defined(__linux__) -#if !defined(NDEBUG) && !defined(MMKV_DISABLE_CRYPT) +#if defined(MMKV_DEBUG) && !defined(MMKV_DISABLE_CRYPT) AESCrypt::testAESCrypt(); KeyValueHolderCrypt::testAESToMMBuffer(); #endif diff --git a/Core/MMKVLog.cpp b/Core/MMKVLog.cpp index 5747958a..34131148 100644 --- a/Core/MMKVLog.cpp +++ b/Core/MMKVLog.cpp @@ -22,7 +22,7 @@ MMKV_NAMESPACE_BEGIN -#ifndef NDEBUG +#ifdef MMKV_DEBUG MMKVLogLevel g_currentLogLevel = MMKVLogDebug; #else MMKVLogLevel g_currentLogLevel = MMKVLogInfo; diff --git a/Core/MMKVLog.h b/Core/MMKVLog.h index f55f0ee9..5627ccdd 100644 --- a/Core/MMKVLog.h +++ b/Core/MMKVLog.h @@ -48,7 +48,7 @@ extern mmkv::LogHandler g_logHandler; # define MMKVInfo(format, ...) \ _MMKVLogWithLevel(MMKV_NAMESPACE_PREFIX::MMKVLogInfo, __FILE__, __func__, __LINE__, format, ##__VA_ARGS__) -# ifndef NDEBUG +# ifdef MMKV_DEBUG # define MMKVDebug(format, ...) \ _MMKVLogWithLevel(MMKV_NAMESPACE_PREFIX::MMKVLogDebug, __FILE__, __func__, __LINE__, format, ##__VA_ARGS__) # else diff --git a/Core/MMKVPredef.h b/Core/MMKVPredef.h index 8579c44c..2f21b575 100755 --- a/Core/MMKVPredef.h +++ b/Core/MMKVPredef.h @@ -33,7 +33,15 @@ #include #include -constexpr auto MMKV_VERSION = "v1.2.2"; +constexpr auto MMKV_VERSION = "v1.2.4"; + +#ifdef DEBUG +# define MMKV_DEBUG +#endif + +#ifdef NDEBUG +# undef MMKV_DEBUG +#endif #ifdef __ANDROID__ # define MMKV_ANDROID @@ -186,7 +194,7 @@ constexpr size_t AES_KEY_BITSET_LEN = 128; } // namespace mmkv -#ifndef NDEBUG +#ifdef MMKV_DEBUG # include # define MMKV_ASSERT(var) assert(var) #else diff --git a/Core/MiniPBCoder_OSX.cpp b/Core/MiniPBCoder_OSX.cpp index 27a956dd..d6244102 100644 --- a/Core/MiniPBCoder_OSX.cpp +++ b/Core/MiniPBCoder_OSX.cpp @@ -136,7 +136,7 @@ void MiniPBCoder::decodeOneMap(MMKVMapCrypt &dic, size_t position, bool greedy) const auto &key = m_inputDataDecrpt->readString(kvHolder); if (key.length > 0) { m_inputDataDecrpt->readData(kvHolder); - if (kvHolder.valueSize > 0) { + if (kvHolder.realValueSize() > 0) { dictionary[key] = move(kvHolder); [key retain]; } else { diff --git a/Core/aes/AESCrypt.cpp b/Core/aes/AESCrypt.cpp index b71e99b1..a7615602 100644 --- a/Core/aes/AESCrypt.cpp +++ b/Core/aes/AESCrypt.cpp @@ -163,7 +163,7 @@ AESCrypt AESCrypt::cloneWithStatus(const AESCryptStatus &status) const { } // namespace mmkv -# ifndef NDEBUG +# ifdef MMKV_DEBUG # include "../MMKVLog.h" # include "../MemoryFile.h" @@ -252,5 +252,5 @@ void AESCrypt::testAESCrypt() { } // namespace mmkv -# endif // NDEBUG +# endif // MMKV_DEBUG #endif // MMKV_DISABLE_CRYPT diff --git a/Core/aes/AESCrypt.h b/Core/aes/AESCrypt.h index e5b78dc0..0596f1c2 100644 --- a/Core/aes/AESCrypt.h +++ b/Core/aes/AESCrypt.h @@ -94,7 +94,7 @@ class AESCrypt { friend CodedInputDataCrypt; -#ifndef NDEBUG +#ifdef MMKV_DEBUG // check if AESCrypt is encrypt-decrypt full-duplex static void testAESCrypt(); #endif diff --git a/README.md b/README.md index 05a258ce..6bc18b56 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![license](https://img.shields.io/badge/license-BSD_3-brightgreen.svg?style=flat)](https://github.com/Tencent/MMKV/blob/master/LICENSE.TXT) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/MMKV/pulls) -[![Release Version](https://img.shields.io/badge/release-1.2.3-brightgreen.svg)](https://github.com/Tencent/MMKV/releases) +[![Release Version](https://img.shields.io/badge/release-1.2.4-brightgreen.svg)](https://github.com/Tencent/MMKV/releases) [![Platform](https://img.shields.io/badge/Platform-%20Android%20%7C%20iOS%2FmacOS%20%7C%20Win32%20%7C%20POSIX-brightgreen.svg)](https://github.com/Tencent/MMKV/wiki/home) 中文版本请参看[这里](./readme_cn.md) @@ -28,8 +28,8 @@ Add the following lines to `build.gradle` on your app module: ```gradle dependencies { - implementation 'com.tencent:mmkv-static:1.2.3' - // replace "1.2.3" with any available version + implementation 'com.tencent:mmkv-static:1.2.4' + // replace "1.2.4" with any available version } ``` diff --git a/iOS/MMKV/MMKV.xcodeproj/project.pbxproj b/iOS/MMKV/MMKV.xcodeproj/project.pbxproj index a722a6bf..dde5693c 100644 --- a/iOS/MMKV/MMKV.xcodeproj/project.pbxproj +++ b/iOS/MMKV/MMKV.xcodeproj/project.pbxproj @@ -485,7 +485,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.3; + MARKETING_VERSION = 1.2.4; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, @@ -531,7 +531,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.3; + MARKETING_VERSION = 1.2.4; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, @@ -742,7 +742,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.3; + MARKETING_VERSION = 1.2.4; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, @@ -782,7 +782,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.3; + MARKETING_VERSION = 1.2.4; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, @@ -829,7 +829,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.3; + MARKETING_VERSION = 1.2.4; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, @@ -878,7 +878,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.2.3; + MARKETING_VERSION = 1.2.4; "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-framework", UIKit, diff --git a/readme_cn.md b/readme_cn.md index 4e94462d..a6f555bd 100644 --- a/readme_cn.md +++ b/readme_cn.md @@ -22,8 +22,8 @@ MMKV 是基于 mmap 内存映射的 key-value 组件,底层序列化/反序列 ```gradle dependencies { - implementation 'com.tencent:mmkv-static:1.2.3' - // replace "1.2.3" with any available version + implementation 'com.tencent:mmkv-static:1.2.4' + // replace "1.2.4" with any available version } ```