| 668 | } |
| 669 | |
| 670 | MMKV_JNI jboolean encodeBytes(JNIEnv *env, jobject, jlong handle, jstring oKey, jbyteArray oValue) { |
| 671 | MMKV *kv = reinterpret_cast<MMKV *>(handle); |
| 672 | if (kv && oKey) { |
| 673 | string key = jstring2string(env, oKey); |
| 674 | if (oValue) { |
| 675 | MMBuffer value(0); |
| 676 | { |
| 677 | jsize len = env->GetArrayLength(oValue); |
| 678 | void *bufferPtr = env->GetPrimitiveArrayCritical(oValue, nullptr); |
| 679 | if (bufferPtr) { |
| 680 | value = MMBuffer(bufferPtr, len); |
| 681 | env->ReleasePrimitiveArrayCritical(oValue, bufferPtr, JNI_ABORT); |
| 682 | } else { |
| 683 | MMKVError("fail to get array: %s=%p", key.c_str(), oValue); |
| 684 | } |
| 685 | } |
| 686 | return (jboolean) kv->set(value, key); |
| 687 | } else { |
| 688 | kv->removeValueForKey(key); |
| 689 | return (jboolean) true; |
| 690 | } |
| 691 | } |
| 692 | return (jboolean) false; |
| 693 | } |
| 694 | |
| 695 | MMKV_JNI jboolean encodeBytes_2(JNIEnv *env, jobject, jlong handle, jstring oKey, jbyteArray oValue, jint expiration) { |
| 696 | MMKV *kv = reinterpret_cast<MMKV *>(handle); |
nothing calls this directly
no test coverage detected