| 77 | } |
| 78 | |
| 79 | int ContentDataSource::Read(void *buf, size_t nbyte) { |
| 80 | JniEnv env{}; |
| 81 | JNIEnv *pEnv = env.getEnv(); |
| 82 | if (pEnv == nullptr) { |
| 83 | return -EINVAL; |
| 84 | } |
| 85 | |
| 86 | jbyteArray buffer = pEnv->NewByteArray((jsize) nbyte); |
| 87 | int readSize = (int) pEnv->CallIntMethod(mJContentDataSource, jContentDataSource_read, buffer); |
| 88 | if (readSize <= 0) { |
| 89 | return readSize; |
| 90 | } |
| 91 | jboolean isCopy = false; |
| 92 | jbyte *jBytes = pEnv->GetByteArrayElements(buffer, &isCopy); |
| 93 | memcpy(buf, jBytes, readSize); |
| 94 | |
| 95 | pEnv->ReleaseByteArrayElements(buffer, jBytes, 0); |
| 96 | pEnv->DeleteLocalRef(buffer); |
| 97 | return readSize; |
| 98 | } |
| 99 | void ContentDataSource::Interrupt(bool interrupt) { |
| 100 | IDataSource::Interrupt(interrupt); |
| 101 | } |
nothing calls this directly
no test coverage detected