Sanity checks in JNI code for script groups

b/20728113

This is copying the fix I made in native implementation.
(https://android-review.googlesource.com/148980)

Change-Id: I231c0d20c41ee53342d8a975c2db5a31854b9d40
(cherry picked from commit 6d26e4f14a1874eb247542d98bb1554405e50377)
2 files changed