Remove dependencies on headers outside UI module

This includes AndroidRuntime and core_jni_helper.h

Bug: 137655431
Test: CtsUiRenderingTestCases
Change-Id: If3d26f41eaf4981505ee47634097f3645fd563fd
diff --git a/libs/hwui/jni/FontFamily.cpp b/libs/hwui/jni/FontFamily.cpp
index f0cdb5e..a2fef1e 100644
--- a/libs/hwui/jni/FontFamily.cpp
+++ b/libs/hwui/jni/FontFamily.cpp
@@ -17,9 +17,6 @@
 #undef LOG_TAG
 #define LOG_TAG "Minikin"
 
-#include <nativehelper/JNIHelp.h>
-#include <core_jni_helpers.h>
-
 #include "SkData.h"
 #include "SkFontMgr.h"
 #include "SkRefCnt.h"
@@ -27,7 +24,6 @@
 #include "GraphicsJNI.h"
 #include <nativehelper/ScopedPrimitiveArray.h>
 #include <nativehelper/ScopedUtfChars.h>
-#include <android_runtime/AndroidRuntime.h>
 #include "Utils.h"
 #include "FontUtils.h"
 
@@ -145,15 +141,11 @@
 }
 
 static void release_global_ref(const void* /*data*/, void* context) {
-    JNIEnv* env = AndroidRuntime::getJNIEnv();
+    JNIEnv* env = GraphicsJNI::getJNIEnv();
     bool needToAttach = (env == NULL);
     if (needToAttach) {
-        JavaVMAttachArgs args;
-        args.version = JNI_VERSION_1_4;
-        args.name = "release_font_data";
-        args.group = NULL;
-        jint result = AndroidRuntime::getJavaVM()->AttachCurrentThread(&env, &args);
-        if (result != JNI_OK) {
+        env = GraphicsJNI::attachJNIEnv("release_font_data");
+        if (env == nullptr) {
             ALOGE("failed to attach to thread to release global ref.");
             return;
         }
@@ -163,7 +155,7 @@
     env->DeleteGlobalRef(obj);
 
     if (needToAttach) {
-       AndroidRuntime::getJavaVM()->DetachCurrentThread();
+       GraphicsJNI::detachJNIEnv();
     }
 }