| 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); |
| 697 | if (kv && oKey) { |
| 698 | string key = jstring2string(env, oKey); |
| 699 | if (oValue) { |
| 700 | MMBuffer value(0); |
| 701 | { |
| 702 | jsize len = env->GetArrayLength(oValue); |
| 703 | void *bufferPtr = env->GetPrimitiveArrayCritical(oValue, nullptr); |
| 704 | if (bufferPtr) { |
| 705 | value = MMBuffer(bufferPtr, len); |
| 706 | env->ReleasePrimitiveArrayCritical(oValue, bufferPtr, JNI_ABORT); |
| 707 | } else { |
| 708 | MMKVError("fail to get array: %s=%p", key.c_str(), oValue); |
| 709 | } |
| 710 | } |
| 711 | return (jboolean) kv->set(value, key, (uint32_t) expiration); |
| 712 | } else { |
| 713 | kv->removeValueForKey(key); |
| 714 | return (jboolean) true; |
| 715 | } |
| 716 | } |
| 717 | return (jboolean) false; |
| 718 | } |
| 719 | |
| 720 | MMKV_JNI jbyteArray decodeBytes(JNIEnv *env, jobject obj, jlong handle, jstring oKey) { |
| 721 | MMKV *kv = reinterpret_cast<MMKV *>(handle); |
nothing calls this directly
no test coverage detected