[RenderScript] Update the java API about Allocation copyTo & From FieldPacker

Change-Id: I4e1b911d4cdfec8a841bc5a8bc615c64c50e8fc8
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
index fa7b2bc..f2c9d31 100644
--- a/rs/jni/android_renderscript_RenderScript.cpp
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -1302,19 +1302,21 @@
 
 // Copies from the Element in the Allocation pointed to by _alloc into the Java array data.
 static void
-nAllocationElementRead(JNIEnv *_env, jobject _this, jlong con, jlong _alloc,
+nAllocationElementRead(JNIEnv *_env, jobject _this, jlong con, jlong alloc,
                        jint xoff, jint yoff, jint zoff,
-                       jint lod, jint compIdx, jobject data, jint sizeBytes, int dataType)
+                       jint lod, jint compIdx, jbyteArray data, jint sizeBytes)
 {
-    RsAllocation *alloc = (RsAllocation *)_alloc;
+    jint len = _env->GetArrayLength(data);
     if (kLogApi) {
-        ALOGD("nAllocationElementRead, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), "
-              "sizeBytes(%i)", (RsContext)con, alloc, xoff, yoff, zoff, compIdx, sizeBytes);
+        ALOGD("nAllocationElementRead, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), len(%i), "
+              "sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, compIdx, len,
+              sizeBytes);
     }
-    int mSize = sizeBytes;
-    int count = 0;
-    PER_ARRAY_TYPE(0, rsAllocationElementRead, false, (RsContext)con, alloc,
-                   xoff, yoff, zoff, lod, ptr, sizeBytes, compIdx);
+    jbyte *ptr = _env->GetByteArrayElements(data, nullptr);
+    rsAllocationElementRead((RsContext)con, (RsAllocation)alloc,
+                            xoff, yoff, zoff,
+                            lod, ptr, sizeBytes, compIdx);    
+    _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
 }
 
 // Copies from the Allocation pointed to by _alloc into the Java object data.
@@ -2377,7 +2379,7 @@
 {"rsnAllocationData3D",              "(JJIIIIIIIJIIII)V",                     (void*)nAllocationData3D_alloc },
 {"rsnAllocationRead",                "(JJLjava/lang/Object;IIZ)V",            (void*)nAllocationRead },
 {"rsnAllocationRead1D",              "(JJIIILjava/lang/Object;IIIZ)V",        (void*)nAllocationRead1D },
-{"rsnAllocationElementRead",         "(JJIIIIILjava/lang/Object;II)V",        (void*)nAllocationElementRead },
+{"rsnAllocationElementRead",         "(JJIIIII[BI)V",                         (void*)nAllocationElementRead },
 {"rsnAllocationRead2D",              "(JJIIIIIILjava/lang/Object;IIIZ)V",     (void*)nAllocationRead2D },
 {"rsnAllocationRead3D",              "(JJIIIIIIILjava/lang/Object;IIIZ)V",    (void*)nAllocationRead3D },
 {"rsnAllocationGetType",             "(JJ)J",                                 (void*)nAllocationGetType},