More JNI exception-throwing cleanup.

There are a few (unimportant) bug fixes here. There were several attempts to
throw exceptions in situations where there's already a pending exception.

There were also cases where the code was wrong; it was checking for a NULL
return from Get*ArrayElements and throwing NPE, but passing NULL is an error
that causes a crash and a NULL return means an exception has already been
thrown. I didn't want to get into the Scoped* classes just yet, but that
was by far the easiest way to fix this.

Change-Id: I0b31160ee51b96e82539f6514b8412b149dba7c3
diff --git a/core/jni/android_media_ToneGenerator.cpp b/core/jni/android_media_ToneGenerator.cpp
index 50aa967..fdd586b 100644
--- a/core/jni/android_media_ToneGenerator.cpp
+++ b/core/jni/android_media_ToneGenerator.cpp
@@ -44,7 +44,7 @@
     ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz,
             fields.context);
     if (lpToneGen == NULL) {
-        jniThrowException(env, "java/lang/RuntimeException", "Method called after release()");
+        jniThrowRuntimeException(env, "Method called after release()");
         return false;
     }
 
@@ -59,7 +59,7 @@
 
     LOGV("ToneGenerator lpToneGen: %x\n", (unsigned int)lpToneGen);
     if (lpToneGen == NULL) {
-        jniThrowException(env, "java/lang/RuntimeException", "Method called after release()");
+        jniThrowRuntimeException(env, "Method called after release()");
         return;
     }
     lpToneGen->stopTone();
@@ -94,7 +94,7 @@
 
     if (!lpToneGen->isInited()) {
         LOGE("ToneGenerator init failed \n");
-        jniThrowException(env, "java/lang/RuntimeException", "Init failed");
+        jniThrowRuntimeException(env, "Init failed");
         return;
     }