am 2c596a53: Merge "Frameworks/base: Consistency in core/jni"

* commit '2c596a533488320444e28bbe37b7032589a0c5dd':
  Frameworks/base: Consistency in core/jni
This commit is contained in:
Andreas Gampe
2014-11-21 18:22:36 +00:00
committed by Android Git Automerger
104 changed files with 884 additions and 1193 deletions

View File

@@ -265,6 +265,10 @@ LOCAL_MODULE:= libandroid_runtime
# off a GCC warning that Clang doesn't know.
LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code -Wno-unknown-pragmas
# -Wno-c++11-extensions: Clang warns about Skia using the C++11 override keyword, but this project
# is not being compiled with that level. Remove once this has changed.
LOCAL_CFLAGS += -Wno-c++11-extensions
include $(BUILD_SHARED_LIBRARY)
include $(call all-makefiles-under,$(LOCAL_PATH))

View File

@@ -1,5 +1,5 @@
#ifndef AutoDecodeCancel_DEFINED
#define AutoDecodeCancel_DEFINED
#ifndef _ANDROID_GRAPHICS_AUTO_DECODE_CANCEL_H_
#define _ANDROID_GRAPHICS_AUTO_DECODE_CANCEL_H_
#include <jni.h>
#include "SkImageDecoder.h"
@@ -24,4 +24,4 @@ private:
#endif
};
#endif
#endif // _ANDROID_GRAPHICS_AUTO_DECODE_CANCEL_H_

View File

@@ -15,16 +15,12 @@
#include "android_nio_utils.h"
#include "CreateJavaOutputStreamAdaptor.h"
#include "core_jni_helpers.h"
#include <jni.h>
#include <Caches.h>
#if 0
#define TRACE_BITMAP(code) code
#else
#define TRACE_BITMAP(code)
#endif
///////////////////////////////////////////////////////////////////////////////
// Conversions to/from SkColor, for get/setPixels, and the create method, which
// is basically like setPixels
@@ -876,8 +872,6 @@ static void Bitmap_prepareToDraw(JNIEnv* env, jobject, jlong bitmapHandle) {
///////////////////////////////////////////////////////////////////////////////
#include <android_runtime/AndroidRuntime.h>
static JNINativeMethod gBitmapMethods[] = {
{ "nativeCreate", "([IIIIIIZ)Landroid/graphics/Bitmap;",
(void*)Bitmap_creator },
@@ -917,10 +911,8 @@ static JNINativeMethod gBitmapMethods[] = {
{ "nativePrepareToDraw", "(J)V", (void*)Bitmap_prepareToDraw },
};
#define kClassPathName "android/graphics/Bitmap"
int register_android_graphics_Bitmap(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
gBitmapMethods, SK_ARRAY_COUNT(gBitmapMethods));
return android::RegisterMethodsOrDie(env, "android/graphics/Bitmap", gBitmapMethods,
NELEM(gBitmapMethods));
}

View File

@@ -15,7 +15,7 @@
#include "JNIHelp.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <androidfw/Asset.h>
#include <androidfw/ResourceTypes.h>
#include <cutils/compiler.h>
@@ -573,52 +573,40 @@ static JNINativeMethod gOptionsMethods[] = {
{ "requestCancel", "()V", (void*)nativeRequestCancel }
};
static jfieldID getFieldIDCheck(JNIEnv* env, jclass clazz,
const char fieldname[], const char type[]) {
jfieldID id = env->GetFieldID(clazz, fieldname, type);
SkASSERT(id);
return id;
}
int register_android_graphics_BitmapFactory(JNIEnv* env) {
jclass options_class = env->FindClass("android/graphics/BitmapFactory$Options");
SkASSERT(options_class);
gOptions_bitmapFieldID = getFieldIDCheck(env, options_class, "inBitmap",
jclass options_class = FindClassOrDie(env, "android/graphics/BitmapFactory$Options");
gOptions_bitmapFieldID = GetFieldIDOrDie(env, options_class, "inBitmap",
"Landroid/graphics/Bitmap;");
gOptions_justBoundsFieldID = getFieldIDCheck(env, options_class, "inJustDecodeBounds", "Z");
gOptions_sampleSizeFieldID = getFieldIDCheck(env, options_class, "inSampleSize", "I");
gOptions_configFieldID = getFieldIDCheck(env, options_class, "inPreferredConfig",
gOptions_justBoundsFieldID = GetFieldIDOrDie(env, options_class, "inJustDecodeBounds", "Z");
gOptions_sampleSizeFieldID = GetFieldIDOrDie(env, options_class, "inSampleSize", "I");
gOptions_configFieldID = GetFieldIDOrDie(env, options_class, "inPreferredConfig",
"Landroid/graphics/Bitmap$Config;");
gOptions_premultipliedFieldID = getFieldIDCheck(env, options_class, "inPremultiplied", "Z");
gOptions_mutableFieldID = getFieldIDCheck(env, options_class, "inMutable", "Z");
gOptions_ditherFieldID = getFieldIDCheck(env, options_class, "inDither", "Z");
gOptions_preferQualityOverSpeedFieldID = getFieldIDCheck(env, options_class,
gOptions_premultipliedFieldID = GetFieldIDOrDie(env, options_class, "inPremultiplied", "Z");
gOptions_mutableFieldID = GetFieldIDOrDie(env, options_class, "inMutable", "Z");
gOptions_ditherFieldID = GetFieldIDOrDie(env, options_class, "inDither", "Z");
gOptions_preferQualityOverSpeedFieldID = GetFieldIDOrDie(env, options_class,
"inPreferQualityOverSpeed", "Z");
gOptions_scaledFieldID = getFieldIDCheck(env, options_class, "inScaled", "Z");
gOptions_densityFieldID = getFieldIDCheck(env, options_class, "inDensity", "I");
gOptions_screenDensityFieldID = getFieldIDCheck(env, options_class, "inScreenDensity", "I");
gOptions_targetDensityFieldID = getFieldIDCheck(env, options_class, "inTargetDensity", "I");
gOptions_widthFieldID = getFieldIDCheck(env, options_class, "outWidth", "I");
gOptions_heightFieldID = getFieldIDCheck(env, options_class, "outHeight", "I");
gOptions_mimeFieldID = getFieldIDCheck(env, options_class, "outMimeType", "Ljava/lang/String;");
gOptions_mCancelID = getFieldIDCheck(env, options_class, "mCancel", "Z");
gOptions_scaledFieldID = GetFieldIDOrDie(env, options_class, "inScaled", "Z");
gOptions_densityFieldID = GetFieldIDOrDie(env, options_class, "inDensity", "I");
gOptions_screenDensityFieldID = GetFieldIDOrDie(env, options_class, "inScreenDensity", "I");
gOptions_targetDensityFieldID = GetFieldIDOrDie(env, options_class, "inTargetDensity", "I");
gOptions_widthFieldID = GetFieldIDOrDie(env, options_class, "outWidth", "I");
gOptions_heightFieldID = GetFieldIDOrDie(env, options_class, "outHeight", "I");
gOptions_mimeFieldID = GetFieldIDOrDie(env, options_class, "outMimeType", "Ljava/lang/String;");
gOptions_mCancelID = GetFieldIDOrDie(env, options_class, "mCancel", "Z");
jclass bitmap_class = env->FindClass("android/graphics/Bitmap");
SkASSERT(bitmap_class);
gBitmap_nativeBitmapFieldID = getFieldIDCheck(env, bitmap_class, "mNativeBitmap", "J");
gBitmap_ninePatchInsetsFieldID = getFieldIDCheck(env, bitmap_class, "mNinePatchInsets",
jclass bitmap_class = FindClassOrDie(env, "android/graphics/Bitmap");
gBitmap_nativeBitmapFieldID = GetFieldIDOrDie(env, bitmap_class, "mNativeBitmap", "J");
gBitmap_ninePatchInsetsFieldID = GetFieldIDOrDie(env, bitmap_class, "mNinePatchInsets",
"Landroid/graphics/NinePatch$InsetStruct;");
gInsetStruct_class = (jclass) env->NewGlobalRef(env->FindClass("android/graphics/NinePatch$InsetStruct"));
gInsetStruct_constructorMethodID = env->GetMethodID(gInsetStruct_class, "<init>", "(IIIIIIIIFIF)V");
gInsetStruct_class = MakeGlobalRefOrDie(env, FindClassOrDie(env,
"android/graphics/NinePatch$InsetStruct"));
gInsetStruct_constructorMethodID = GetMethodIDOrDie(env, gInsetStruct_class, "<init>",
"(IIIIIIIIFIF)V");
int ret = AndroidRuntime::registerNativeMethods(env,
"android/graphics/BitmapFactory$Options",
gOptionsMethods,
SK_ARRAY_COUNT(gOptionsMethods));
if (ret) {
return ret;
}
return android::AndroidRuntime::registerNativeMethods(env, "android/graphics/BitmapFactory",
gMethods, SK_ARRAY_COUNT(gMethods));
android::RegisterMethodsOrDie(env, "android/graphics/BitmapFactory$Options",
gOptionsMethods, NELEM(gOptionsMethods));
return android::RegisterMethodsOrDie(env, "android/graphics/BitmapFactory",
gMethods, NELEM(gMethods));
}

View File

@@ -1,5 +1,5 @@
#ifndef BitmapFactory_DEFINE
#define BitmapFactory_DEFINE
#ifndef _ANDROID_GRAPHICS_BITMAP_FACTORY_H_
#define _ANDROID_GRAPHICS_BITMAP_FACTORY_H_
#include "GraphicsJNI.h"
@@ -21,4 +21,4 @@ extern jfieldID gOptions_bitmapFieldID;
jstring getMimeTypeString(JNIEnv* env, SkImageDecoder::Format format);
#endif
#endif // _ANDROID_GRAPHICS_BITMAP_FACTORY_H_

View File

@@ -30,7 +30,7 @@
#include "Utils.h"
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "android_util_Binder.h"
#include "android_nio_utils.h"
#include "CreateJavaOutputStreamAdaptor.h"
@@ -40,12 +40,6 @@
#include <androidfw/Asset.h>
#include <sys/stat.h>
#if 0
#define TRACE_BITMAP(code) code
#else
#define TRACE_BITMAP(code)
#endif
using namespace android;
class SkBitmapRegionDecoder {
@@ -273,8 +267,6 @@ static void nativeClean(JNIEnv* env, jobject, jlong brdHandle) {
///////////////////////////////////////////////////////////////////////////////
#include <android_runtime/AndroidRuntime.h>
static JNINativeMethod gBitmapRegionDecoderMethods[] = {
{ "nativeDecodeRegion",
"(JIIIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;",
@@ -307,10 +299,8 @@ static JNINativeMethod gBitmapRegionDecoderMethods[] = {
},
};
#define kClassPathName "android/graphics/BitmapRegionDecoder"
int register_android_graphics_BitmapRegionDecoder(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
gBitmapRegionDecoderMethods, SK_ARRAY_COUNT(gBitmapRegionDecoderMethods));
return android::RegisterMethodsOrDie(env, "android/graphics/BitmapRegionDecoder",
gBitmapRegionDecoderMethods, NELEM(gBitmapRegionDecoderMethods));
}

View File

@@ -1,5 +1,5 @@
#include "jni.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "SkCamera.h"
@@ -137,16 +137,8 @@ static JNINativeMethod gCameraMethods[] = {
};
int register_android_graphics_Camera(JNIEnv* env) {
jclass clazz = env->FindClass("android/graphics/Camera");
if (clazz == 0) {
return -1;
}
gNativeInstanceFieldID = env->GetFieldID(clazz, "native_instance", "J");
if (gNativeInstanceFieldID == 0) {
return -1;
}
return android::AndroidRuntime::registerNativeMethods(env,
"android/graphics/Camera",
gCameraMethods,
SK_ARRAY_COUNT(gCameraMethods));
jclass clazz = android::FindClassOrDie(env, "android/graphics/Camera");
gNativeInstanceFieldID = android::GetFieldIDOrDie(env, clazz, "native_instance", "J");
return android::RegisterMethodsOrDie(env, "android/graphics/Camera", gCameraMethods,
NELEM(gCameraMethods));
}

View File

@@ -17,16 +17,20 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include "Paint.h"
#include <android_runtime/AndroidRuntime.h>
#include <core_jni_helpers.h>
#include <utils/RefBase.h>
#include <CanvasProperty.h>
namespace android {
using namespace uirenderer;
#ifdef USE_OPENGL_RENDERER
static const bool kUseOpenGLRenderer = true;
#else
static const bool kUseOpenGLRenderer = false;
#endif
using namespace uirenderer;
static jlong createFloat(JNIEnv* env, jobject clazz, jfloat initialValue) {
return reinterpret_cast<jlong>(new CanvasPropertyPrimitive(initialValue));
@@ -37,23 +41,21 @@ static jlong createPaint(JNIEnv* env, jobject clazz, jlong paintPtr) {
return reinterpret_cast<jlong>(new CanvasPropertyPaint(*paint));
}
#endif
// ----------------------------------------------------------------------------
// JNI Glue
// ----------------------------------------------------------------------------
const char* const kClassPathName = "android/graphics/CanvasProperty";
static JNINativeMethod gMethods[] = {
#ifdef USE_OPENGL_RENDERER
{ "nCreateFloat", "(F)J", (void*) createFloat },
{ "nCreatePaint", "(J)J", (void*) createPaint },
#endif
};
int register_android_graphics_CanvasProperty(JNIEnv* env) {
return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods));
if (kUseOpenGLRenderer) {
return RegisterMethodsOrDie(env, "android/graphics/CanvasProperty", gMethods,
NELEM(gMethods));
}
return 0;
}
}; // namespace android

View File

@@ -17,7 +17,7 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "SkColorFilter.h"
#include "SkColorMatrixFilter.h"
@@ -74,18 +74,15 @@ static JNINativeMethod colormatrix_methods[] = {
{ "nativeColorMatrixFilter", "([F)J", (void*) SkColorFilterGlue::CreateColorMatrixFilter },
};
#define REG(env, name, array) \
result = android::AndroidRuntime::registerNativeMethods(env, name, array, \
SK_ARRAY_COUNT(array)); \
if (result < 0) return result
int register_android_graphics_ColorFilter(JNIEnv* env) {
int result;
REG(env, "android/graphics/ColorFilter", colorfilter_methods);
REG(env, "android/graphics/PorterDuffColorFilter", porterduff_methods);
REG(env, "android/graphics/LightingColorFilter", lighting_methods);
REG(env, "android/graphics/ColorMatrixColorFilter", colormatrix_methods);
android::RegisterMethodsOrDie(env, "android/graphics/ColorFilter", colorfilter_methods,
NELEM(colorfilter_methods));
android::RegisterMethodsOrDie(env, "android/graphics/PorterDuffColorFilter", porterduff_methods,
NELEM(porterduff_methods));
android::RegisterMethodsOrDie(env, "android/graphics/LightingColorFilter", lighting_methods,
NELEM(lighting_methods));
android::RegisterMethodsOrDie(env, "android/graphics/ColorMatrixColorFilter",
colormatrix_methods, NELEM(colormatrix_methods));
return 0;
}

View File

@@ -1,5 +1,5 @@
#ifndef CreateJavaOutputStream_DEFINED
#define CreateJavaOutputStream_DEFINED
#ifndef _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_
#define _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_
//#include <android_runtime/AndroidRuntime.h>
#include "jni.h"
@@ -38,4 +38,5 @@ SkStreamRewindable* CopyJavaInputStream(JNIEnv* env, jobject stream,
SkWStream* CreateJavaOutputStreamAdaptor(JNIEnv* env, jobject stream,
jbyteArray storage);
#endif
#endif // _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_

View File

@@ -24,6 +24,8 @@
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "SkDrawFilter.h"
#include "SkPaintFlagsDrawFilter.h"
#include "SkPaint.h"
@@ -103,16 +105,11 @@ static JNINativeMethod paintflags_methods[] = {
{"nativeConstructor","(II)J", (void*) SkDrawFilterGlue::CreatePaintFlagsDF}
};
#define REG(env, name, array) \
result = android::AndroidRuntime::registerNativeMethods(env, name, array, SK_ARRAY_COUNT(array)); \
if (result < 0) return result
int register_android_graphics_DrawFilter(JNIEnv* env) {
int result;
REG(env, "android/graphics/DrawFilter", drawfilter_methods);
REG(env, "android/graphics/PaintFlagsDrawFilter", paintflags_methods);
int result = RegisterMethodsOrDie(env, "android/graphics/DrawFilter", drawfilter_methods,
NELEM(drawfilter_methods));
result |= RegisterMethodsOrDie(env, "android/graphics/PaintFlagsDrawFilter", paintflags_methods,
NELEM(paintflags_methods));
return 0;
}

View File

@@ -17,7 +17,7 @@
#define LOG_TAG "Minikin"
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <core_jni_helpers.h>
#include "SkTypeface.h"
#include "GraphicsJNI.h"
@@ -125,9 +125,8 @@ static JNINativeMethod gFontFamilyMethods[] = {
int register_android_graphics_FontFamily(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env,
"android/graphics/FontFamily",
gFontFamilyMethods, NELEM(gFontFamilyMethods));
return RegisterMethodsOrDie(env, "android/graphics/FontFamily", gFontFamilyMethods,
NELEM(gFontFamilyMethods));
}
}

View File

@@ -1,5 +1,5 @@
#ifndef GraphicsJNI_DEFINED
#define GraphicsJNI_DEFINED
#ifndef _ANDROID_GRAPHICS_GRAPHICS_JNI_H_
#define _ANDROID_GRAPHICS_GRAPHICS_JNI_H_
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
@@ -292,4 +292,4 @@ void doThrowIOE(JNIEnv* env, const char* msg = NULL); // IO Exception
#define NPE_CHECK_RETURN_VOID(env, object) \
do { if (NULL == (object)) { doThrowNPE(env); return; } } while (0)
#endif
#endif // _ANDROID_GRAPHICS_GRAPHICS_JNI_H_

View File

@@ -44,6 +44,8 @@
namespace android {
static const bool kDebugGlyphs = false;
// Our implementation of the callbacks which Harfbuzz requires by using Skia
// calls. See the Harfbuzz source for references about what these callbacks do.
@@ -62,9 +64,9 @@ static void SkiaGetGlyphWidthAndExtents(SkPaint* paint, hb_codepoint_t codepoint
uint16_t glyph = codepoint;
paint->getTextWidths(&glyph, sizeof(glyph), &skWidth, &skBounds);
#if DEBUG_GLYPHS
ALOGD("returned glyph for %i: width = %f", codepoint, skWidth);
#endif
if (kDebugGlyphs) {
ALOGD("returned glyph for %i: width = %f", codepoint, skWidth);
}
if (width)
*width = SkScalarToHBFixed(skWidth);
if (extents) {

View File

@@ -24,8 +24,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef HarfBuzzNGFaceSkia_h
#define HarfBuzzNGFaceSkia_h
#ifndef _ANDROID_GRAPHICS_HARF_BUZZ_NG_FACE_SKIA_H_
#define _ANDROID_GRAPHICS_HARF_BUZZ_NG_FACE_SKIA_H_
#include <SkScalar.h>
#include <SkPaint.h>
@@ -56,4 +56,4 @@ hb_font_t* createFont(hb_face_t* face, SkPaint* paint, float sizeX, float sizeY)
} // namespace android
#endif
#endif // _ANDROID_GRAPHICS_HARF_BUZZ_NG_FACE_SKIA_H_

View File

@@ -1,5 +1,5 @@
#include "jni.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "GraphicsJNI.h"
#include "SkInterpolator.h"
@@ -83,8 +83,6 @@ static JNINativeMethod gInterpolatorMethods[] = {
int register_android_graphics_Interpolator(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env,
"android/graphics/Interpolator",
gInterpolatorMethods,
SK_ARRAY_COUNT(gInterpolatorMethods));
return android::RegisterMethodsOrDie(env, "android/graphics/Interpolator",
gInterpolatorMethods, NELEM(gInterpolatorMethods));
}

View File

@@ -4,6 +4,8 @@
#include "SkBlurMaskFilter.h"
#include "SkTableMaskFilter.h"
#include "core_jni_helpers.h"
#include <jni.h>
static void ThrowIAE_IfNull(JNIEnv* env, void* ptr) {
@@ -77,20 +79,16 @@ static JNINativeMethod gTableMaskFilterMethods[] = {
{ "nativeNewGamma", "(F)J", (void*)SkMaskFilterGlue::createGammaTable }
};
#include <android_runtime/AndroidRuntime.h>
#define REG(env, name, array) \
result = android::AndroidRuntime::registerNativeMethods(env, name, array, SK_ARRAY_COUNT(array)); \
if (result < 0) return result
int register_android_graphics_MaskFilter(JNIEnv* env)
{
int result;
REG(env, "android/graphics/MaskFilter", gMaskFilterMethods);
REG(env, "android/graphics/BlurMaskFilter", gBlurMaskFilterMethods);
REG(env, "android/graphics/EmbossMaskFilter", gEmbossMaskFilterMethods);
REG(env, "android/graphics/TableMaskFilter", gTableMaskFilterMethods);
android::RegisterMethodsOrDie(env, "android/graphics/MaskFilter", gMaskFilterMethods,
NELEM(gMaskFilterMethods));
android::RegisterMethodsOrDie(env, "android/graphics/BlurMaskFilter", gBlurMaskFilterMethods,
NELEM(gBlurMaskFilterMethods));
android::RegisterMethodsOrDie(env, "android/graphics/EmbossMaskFilter",
gEmbossMaskFilterMethods, NELEM(gEmbossMaskFilterMethods));
android::RegisterMethodsOrDie(env, "android/graphics/TableMaskFilter", gTableMaskFilterMethods,
NELEM(gTableMaskFilterMethods));
return 0;
}

View File

@@ -17,7 +17,7 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include <core_jni_helpers.h>
#include "SkMatrix.h"
#include "SkTemplates.h"
@@ -353,11 +353,10 @@ static JNINativeMethod methods[] = {
static jfieldID sNativeInstanceField;
int register_android_graphics_Matrix(JNIEnv* env) {
int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/Matrix", methods,
sizeof(methods) / sizeof(methods[0]));
int result = RegisterMethodsOrDie(env, "android/graphics/Matrix", methods, NELEM(methods));
jclass clazz = env->FindClass("android/graphics/Matrix");
sNativeInstanceField = env->GetFieldID(clazz, "native_instance", "J");
jclass clazz = FindClassOrDie(env, "android/graphics/Matrix");
sNativeInstanceField = GetFieldIDOrDie(env, clazz, "native_instance", "J");
return result;
}

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef _ANDROID_GRAPHICS_MATRIX_H
#define _ANDROID_GRAPHICS_MATRIX_H
#ifndef _ANDROID_GRAPHICS_MATRIX_H_
#define _ANDROID_GRAPHICS_MATRIX_H_
#include "jni.h"
#include "SkMatrix.h"
@@ -27,4 +27,4 @@ extern SkMatrix* android_graphics_Matrix_getSkMatrix(JNIEnv* env, jobject matrix
} // namespace android
#endif // _ANDROID_GRAPHICS_MATRIX_H
#endif // _ANDROID_GRAPHICS_MATRIX_H_

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef ANDROID_MINIKIN_SKIA_H
#define ANDROID_MINIKIN_SKIA_H
#ifndef _ANDROID_GRAPHICS_MINIKIN_SKIA_H_
#define _ANDROID_GRAPHICS_MINIKIN_SKIA_H_
#include <minikin/MinikinFont.h>
@@ -54,4 +54,4 @@ private:
} // namespace android
#endif // ANDROID_MINIKIN_SKIA_H
#endif // _ANDROID_GRAPHICS_MINIKIN_SKIA_H_

View File

@@ -21,8 +21,8 @@
// TODO: does this really need to be separate from MinikinSkia?
#ifndef ANDROID_MINIKIN_UTILS_H
#define ANDROID_MINIKIN_UTILS_H
#ifndef _ANDROID_GRAPHICS_MINIKIN_UTILS_H_
#define _ANDROID_GRAPHICS_MINIKIN_UTILS_H_
#include <minikin/Layout.h>
#include "Paint.h"
@@ -81,4 +81,4 @@ public:
} // namespace android
#endif // ANDROID_MINIKIN_UTILS_H
#endif // _ANDROID_GRAPHICS_MINIKIN_UTILS_H_

View File

@@ -13,11 +13,7 @@
#include <androidfw/ResourceTypes.h>
#include <netinet/in.h>
#if 0
#define TRACE_BITMAP(code) code
#else
#define TRACE_BITMAP(code)
#endif
#include "core_jni_helpers.h"
static jclass gMovie_class;
static jmethodID gMovie_constructorMethodID;
@@ -138,8 +134,6 @@ static void movie_destructor(JNIEnv* env, jobject, jlong movieHandle) {
//////////////////////////////////////////////////////////////////////////////////////////////
#include <android_runtime/AndroidRuntime.h>
static JNINativeMethod gMethods[] = {
{ "width", "()I", (void*)movie_width },
{ "height", "()I", (void*)movie_height },
@@ -157,22 +151,14 @@ static JNINativeMethod gMethods[] = {
(void*)movie_decodeByteArray },
};
#define kClassPathName "android/graphics/Movie"
#define RETURN_ERR_IF_NULL(value) do { if (!(value)) { assert(0); return -1; } } while (false)
int register_android_graphics_Movie(JNIEnv* env)
{
gMovie_class = env->FindClass(kClassPathName);
RETURN_ERR_IF_NULL(gMovie_class);
gMovie_class = (jclass)env->NewGlobalRef(gMovie_class);
gMovie_class = android::FindClassOrDie(env, "android/graphics/Movie");
gMovie_class = android::MakeGlobalRefOrDie(env, gMovie_class);
gMovie_constructorMethodID = env->GetMethodID(gMovie_class, "<init>", "(J)V");
RETURN_ERR_IF_NULL(gMovie_constructorMethodID);
gMovie_constructorMethodID = android::GetMethodIDOrDie(env, gMovie_class, "<init>", "(J)V");
gMovie_nativeInstanceID = env->GetFieldID(gMovie_class, "mNativeMovie", "J");
RETURN_ERR_IF_NULL(gMovie_nativeInstanceID);
gMovie_nativeInstanceID = android::GetFieldIDOrDie(env, gMovie_class, "mNativeMovie", "J");
return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
gMethods, SK_ARRAY_COUNT(gMethods));
return android::RegisterMethodsOrDie(env, "android/graphics/Movie", gMethods, NELEM(gMethods));
}

View File

@@ -30,6 +30,7 @@
#include "GraphicsJNI.h"
#include "JNIHelp.h"
#include "core_jni_helpers.h"
extern void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds, const SkBitmap& bitmap,
const android::Res_png_9patch& chunk, const SkPaint* paint, SkRegion** outRegion);
@@ -176,8 +177,6 @@ public:
/////////////////////////////////////////////////////////////////////////////////////////
#include <android_runtime/AndroidRuntime.h>
static JNINativeMethod gNinePatchMethods[] = {
{ "isNinePatchChunk", "([B)Z", (void*) SkNinePatchGlue::isNinePatchChunk },
{ "validateNinePatchChunk", "(J[B)J", (void*) SkNinePatchGlue::validateNinePatchChunk },
@@ -189,6 +188,6 @@ static JNINativeMethod gNinePatchMethods[] = {
};
int register_android_graphics_NinePatch(JNIEnv* env) {
return android::AndroidRuntime::registerNativeMethods(env,
"android/graphics/NinePatch", gNinePatchMethods, SK_ARRAY_COUNT(gNinePatchMethods));
return android::RegisterMethodsOrDie(env,
"android/graphics/NinePatch", gNinePatchMethods, NELEM(gNinePatchMethods));
}

View File

@@ -23,20 +23,16 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
#include "SkNinePatch.h"
#include "SkPaint.h"
#include "SkUnPreMultiply.h"
#define USE_TRACE
#ifdef USE_TRACE
static bool gTrace;
#endif
#include "SkColorPriv.h"
#include <utils/Log.h>
static const bool kUseTrace = true;
static bool gTrace = false;
static bool getColor(const SkBitmap& bitmap, int x, int y, SkColor* c) {
switch (bitmap.colorType()) {
case kN32_SkColorType:
@@ -128,37 +124,34 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds,
return;
}
#ifdef USE_TRACE
gTrace = true;
#endif
if (kUseTrace) {
gTrace = true;
}
SkASSERT(canvas || outRegion);
#ifdef USE_TRACE
if (canvas) {
const SkMatrix& m = canvas->getTotalMatrix();
ALOGV("ninepatch [%g %g %g] [%g %g %g]\n",
SkScalarToFloat(m[0]), SkScalarToFloat(m[1]), SkScalarToFloat(m[2]),
SkScalarToFloat(m[3]), SkScalarToFloat(m[4]), SkScalarToFloat(m[5]));
}
#endif
if (kUseTrace) {
if (canvas) {
const SkMatrix& m = canvas->getTotalMatrix();
ALOGV("ninepatch [%g %g %g] [%g %g %g]\n",
SkScalarToFloat(m[0]), SkScalarToFloat(m[1]), SkScalarToFloat(m[2]),
SkScalarToFloat(m[3]), SkScalarToFloat(m[4]), SkScalarToFloat(m[5]));
}
#ifdef USE_TRACE
if (gTrace) {
ALOGV("======== ninepatch bounds [%g %g]\n", SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height()));
ALOGV("======== ninepatch bounds [%g %g]\n", SkScalarToFloat(bounds.width()),
SkScalarToFloat(bounds.height()));
ALOGV("======== ninepatch paint bm [%d,%d]\n", bitmap.width(), bitmap.height());
ALOGV("======== ninepatch xDivs [%d,%d]\n", xDivs[0], xDivs[1]);
ALOGV("======== ninepatch yDivs [%d,%d]\n", yDivs[0], yDivs[1]);
}
#endif
if (bounds.isEmpty() ||
bitmap.width() == 0 || bitmap.height() == 0 ||
(paint && paint->getXfermode() == NULL && paint->getAlpha() == 0))
{
#ifdef USE_TRACE
if (gTrace) ALOGV("======== abort ninepatch draw\n");
#endif
if (kUseTrace) {
ALOGV("======== abort ninepatch draw\n");
}
return;
}
@@ -202,13 +195,13 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds,
}
int numFixedYPixelsRemaining = bitmapHeight - numStretchyYPixelsRemaining;
#ifdef USE_TRACE
ALOGV("NinePatch [%d %d] bounds [%g %g %g %g] divs [%d %d]\n",
bitmap.width(), bitmap.height(),
SkScalarToFloat(bounds.fLeft), SkScalarToFloat(bounds.fTop),
SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height()),
numXDivs, numYDivs);
#endif
if (kUseTrace) {
ALOGV("NinePatch [%d %d] bounds [%g %g %g %g] divs [%d %d]\n",
bitmap.width(), bitmap.height(),
SkScalarToFloat(bounds.fLeft), SkScalarToFloat(bounds.fTop),
SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height()),
numXDivs, numYDivs);
}
src.fTop = 0;
dst.fTop = bounds.fTop;
@@ -307,15 +300,15 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds,
goto nextDiv;
}
if (canvas) {
#ifdef USE_TRACE
ALOGV("-- src [%d %d %d %d] dst [%g %g %g %g]\n",
src.fLeft, src.fTop, src.width(), src.height(),
SkScalarToFloat(dst.fLeft), SkScalarToFloat(dst.fTop),
SkScalarToFloat(dst.width()), SkScalarToFloat(dst.height()));
if (2 == src.width() && SkIntToScalar(5) == dst.width()) {
ALOGV("--- skip patch\n");
if (kUseTrace) {
ALOGV("-- src [%d %d %d %d] dst [%g %g %g %g]\n",
src.fLeft, src.fTop, src.width(), src.height(),
SkScalarToFloat(dst.fLeft), SkScalarToFloat(dst.fTop),
SkScalarToFloat(dst.width()), SkScalarToFloat(dst.height()));
if (2 == src.width() && SkIntToScalar(5) == dst.width()) {
ALOGV("--- skip patch\n");
}
}
#endif
drawStretchyPatch(canvas, src, dst, bitmap, *paint, initColor,
color, hasXfer);
}

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef NinePatchPeeker_h
#define NinePatchPeeker_h
#ifndef _ANDROID_GRAPHICS_NINE_PATCH_PEEKER_H_
#define _ANDROID_GRAPHICS_NINE_PATCH_PEEKER_H_
#include "SkImageDecoder.h"
#include <androidfw/ResourceTypes.h>
@@ -53,4 +53,4 @@ public:
uint8_t mOutlineAlpha;
};
#endif // NinePatchPeeker_h
#endif // _ANDROID_GRAPHICS_NINE_PATCH_PEEKER_H_

View File

@@ -21,7 +21,7 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <ScopedUtfChars.h>
#include "SkBlurDrawLooper.h"
@@ -1018,35 +1018,26 @@ static JNINativeMethod methods[] = {
{"native_hasShadowLayer", "(J)Z", (void*)PaintGlue::hasShadowLayer}
};
static jfieldID req_fieldID(jfieldID id) {
SkASSERT(id);
return id;
}
int register_android_graphics_Paint(JNIEnv* env) {
gFontMetrics_class = env->FindClass("android/graphics/Paint$FontMetrics");
SkASSERT(gFontMetrics_class);
gFontMetrics_class = (jclass)env->NewGlobalRef(gFontMetrics_class);
gFontMetrics_class = FindClassOrDie(env, "android/graphics/Paint$FontMetrics");
gFontMetrics_class = MakeGlobalRefOrDie(env, gFontMetrics_class);
gFontMetrics_fieldID.top = req_fieldID(env->GetFieldID(gFontMetrics_class, "top", "F"));
gFontMetrics_fieldID.ascent = req_fieldID(env->GetFieldID(gFontMetrics_class, "ascent", "F"));
gFontMetrics_fieldID.descent = req_fieldID(env->GetFieldID(gFontMetrics_class, "descent", "F"));
gFontMetrics_fieldID.bottom = req_fieldID(env->GetFieldID(gFontMetrics_class, "bottom", "F"));
gFontMetrics_fieldID.leading = req_fieldID(env->GetFieldID(gFontMetrics_class, "leading", "F"));
gFontMetrics_fieldID.top = GetFieldIDOrDie(env, gFontMetrics_class, "top", "F");
gFontMetrics_fieldID.ascent = GetFieldIDOrDie(env, gFontMetrics_class, "ascent", "F");
gFontMetrics_fieldID.descent = GetFieldIDOrDie(env, gFontMetrics_class, "descent", "F");
gFontMetrics_fieldID.bottom = GetFieldIDOrDie(env, gFontMetrics_class, "bottom", "F");
gFontMetrics_fieldID.leading = GetFieldIDOrDie(env, gFontMetrics_class, "leading", "F");
gFontMetricsInt_class = env->FindClass("android/graphics/Paint$FontMetricsInt");
SkASSERT(gFontMetricsInt_class);
gFontMetricsInt_class = (jclass)env->NewGlobalRef(gFontMetricsInt_class);
gFontMetricsInt_class = FindClassOrDie(env, "android/graphics/Paint$FontMetricsInt");
gFontMetricsInt_class = MakeGlobalRefOrDie(env, gFontMetricsInt_class);
gFontMetricsInt_fieldID.top = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "top", "I"));
gFontMetricsInt_fieldID.ascent = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "ascent", "I"));
gFontMetricsInt_fieldID.descent = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "descent", "I"));
gFontMetricsInt_fieldID.bottom = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "bottom", "I"));
gFontMetricsInt_fieldID.leading = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "leading", "I"));
gFontMetricsInt_fieldID.top = GetFieldIDOrDie(env, gFontMetricsInt_class, "top", "I");
gFontMetricsInt_fieldID.ascent = GetFieldIDOrDie(env, gFontMetricsInt_class, "ascent", "I");
gFontMetricsInt_fieldID.descent = GetFieldIDOrDie(env, gFontMetricsInt_class, "descent", "I");
gFontMetricsInt_fieldID.bottom = GetFieldIDOrDie(env, gFontMetricsInt_class, "bottom", "I");
gFontMetricsInt_fieldID.leading = GetFieldIDOrDie(env, gFontMetricsInt_class, "leading", "I");
int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/Paint", methods,
sizeof(methods) / sizeof(methods[0]));
return result;
return RegisterMethodsOrDie(env, "android/graphics/Paint", methods, NELEM(methods));
}
}

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef ANDROID_GRAPHICS_PAINT_H
#define ANDROID_GRAPHICS_PAINT_H
#ifndef ANDROID_GRAPHICS_PAINT_H_
#define ANDROID_GRAPHICS_PAINT_H_
#include <SkPaint.h>
#include <string>
@@ -78,4 +78,4 @@ private:
} // namespace android
#endif // ANDROID_GRAPHICS_PAINT_H
#endif // ANDROID_GRAPHICS_PAINT_H_

View File

@@ -22,7 +22,7 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "SkPath.h"
#include "SkPathOps.h"
@@ -520,9 +520,7 @@ static JNINativeMethod methods[] = {
};
int register_android_graphics_Path(JNIEnv* env) {
int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/Path", methods,
sizeof(methods) / sizeof(methods[0]));
return result;
return RegisterMethodsOrDie(env, "android/graphics/Path", methods, NELEM(methods));
}
}

View File

@@ -1,6 +1,8 @@
#include <jni.h>
#include "GraphicsJNI.h"
#include "core_jni_helpers.h"
#include "SkPathEffect.h"
#include "SkCornerPathEffect.h"
#include "SkDashPathEffect.h"
@@ -97,24 +99,22 @@ static JNINativeMethod gDiscretePathEffectMethods[] = {
{ "nativeCreate", "(FF)J", (void*)SkPathEffectGlue::Discrete_constructor }
};
#include <android_runtime/AndroidRuntime.h>
#define REG(env, name, array) \
result = android::AndroidRuntime::registerNativeMethods(env, name, array, \
SK_ARRAY_COUNT(array)); \
if (result < 0) return result
int register_android_graphics_PathEffect(JNIEnv* env)
{
int result;
REG(env, "android/graphics/PathEffect", gPathEffectMethods);
REG(env, "android/graphics/ComposePathEffect", gComposePathEffectMethods);
REG(env, "android/graphics/SumPathEffect", gSumPathEffectMethods);
REG(env, "android/graphics/DashPathEffect", gDashPathEffectMethods);
REG(env, "android/graphics/PathDashPathEffect", gPathDashPathEffectMethods);
REG(env, "android/graphics/CornerPathEffect", gCornerPathEffectMethods);
REG(env, "android/graphics/DiscretePathEffect", gDiscretePathEffectMethods);
android::RegisterMethodsOrDie(env, "android/graphics/PathEffect", gPathEffectMethods,
NELEM(gPathEffectMethods));
android::RegisterMethodsOrDie(env, "android/graphics/ComposePathEffect",
gComposePathEffectMethods, NELEM(gComposePathEffectMethods));
android::RegisterMethodsOrDie(env, "android/graphics/SumPathEffect", gSumPathEffectMethods,
NELEM(gSumPathEffectMethods));
android::RegisterMethodsOrDie(env, "android/graphics/DashPathEffect", gDashPathEffectMethods,
NELEM(gDashPathEffectMethods));
android::RegisterMethodsOrDie(env, "android/graphics/PathDashPathEffect",
gPathDashPathEffectMethods, NELEM(gPathDashPathEffectMethods));
android::RegisterMethodsOrDie(env, "android/graphics/CornerPathEffect",
gCornerPathEffectMethods, NELEM(gCornerPathEffectMethods));
android::RegisterMethodsOrDie(env, "android/graphics/DiscretePathEffect",
gDiscretePathEffectMethods, NELEM(gDiscretePathEffectMethods));
return 0;
}

View File

@@ -17,7 +17,7 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include <core_jni_helpers.h>
#include "SkPathMeasure.h"
@@ -156,9 +156,7 @@ static JNINativeMethod methods[] = {
};
int register_android_graphics_PathMeasure(JNIEnv* env) {
int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/PathMeasure", methods,
sizeof(methods) / sizeof(methods[0]));
return result;
return RegisterMethodsOrDie(env, "android/graphics/PathMeasure", methods, NELEM(methods));
}
}

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef ANDROID_GRAPHICS_PICTURE_H
#define ANDROID_GRAPHICS_PICTURE_H
#ifndef ANDROID_GRAPHICS_PICTURE_H_
#define ANDROID_GRAPHICS_PICTURE_H_
#include "SkPicture.h"
#include "SkPictureRecorder.h"
@@ -63,4 +63,4 @@ private:
};
}; // namespace android
#endif // ANDROID_GRAPHICS_PICTURE_H
#endif // ANDROID_GRAPHICS_PICTURE_H_

View File

@@ -22,7 +22,7 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "SkPorterDuff.h"
@@ -43,10 +43,7 @@ static JNINativeMethod methods[] = {
};
int register_android_graphics_PorterDuff(JNIEnv* env) {
int result = AndroidRuntime::registerNativeMethods(env,
"android/graphics/PorterDuffXfermode", methods,
sizeof(methods) / sizeof(methods[0]));
return result;
return RegisterMethodsOrDie(env, "android/graphics/PorterDuffXfermode", methods, NELEM(methods));
}
}

View File

@@ -24,7 +24,7 @@
#include "GraphicsJNI.h"
#include "Paint.h"
#include "SkLayerRasterizer.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
// Rasterizer.java holds a pointer (jlong) to this guy
class NativeRasterizer {
@@ -59,7 +59,6 @@ public:
static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) {
delete reinterpret_cast<NativeRasterizer *>(objHandle);
}
};
static JNINativeMethod gRasterizerMethods[] = {
@@ -67,9 +66,8 @@ static JNINativeMethod gRasterizerMethods[] = {
};
int register_android_graphics_Rasterizer(JNIEnv* env) {
int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/Rasterizer", gRasterizerMethods,
sizeof(gRasterizerMethods) / sizeof(gRasterizerMethods[0]));
return result;
return RegisterMethodsOrDie(env, "android/graphics/Rasterizer", gRasterizerMethods,
NELEM(gRasterizerMethods));
}
class SkLayerRasterizerGlue {
@@ -94,10 +92,8 @@ static JNINativeMethod gLayerRasterizerMethods[] = {
int register_android_graphics_LayerRasterizer(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env,
"android/graphics/LayerRasterizer",
gLayerRasterizerMethods,
SK_ARRAY_COUNT(gLayerRasterizerMethods));
return RegisterMethodsOrDie(env, "android/graphics/LayerRasterizer",
gLayerRasterizerMethods, NELEM(gLayerRasterizerMethods));
}
}

View File

@@ -23,7 +23,7 @@
#include "android_util_Binder.h"
#include <jni.h>
#include <android_runtime/AndroidRuntime.h>
#include <core_jni_helpers.h>
namespace android {
@@ -325,19 +325,13 @@ static JNINativeMethod gRegionMethods[] = {
int register_android_graphics_Region(JNIEnv* env)
{
jclass clazz = env->FindClass("android/graphics/Region");
SkASSERT(clazz);
jclass clazz = FindClassOrDie(env, "android/graphics/Region");
gRegion_nativeInstanceFieldID = env->GetFieldID(clazz, "mNativeRegion", "J");
SkASSERT(gRegion_nativeInstanceFieldID);
gRegion_nativeInstanceFieldID = GetFieldIDOrDie(env, clazz, "mNativeRegion", "J");
int result = android::AndroidRuntime::registerNativeMethods(env, "android/graphics/Region",
gRegionMethods, SK_ARRAY_COUNT(gRegionMethods));
if (result < 0)
return result;
return android::AndroidRuntime::registerNativeMethods(env, "android/graphics/RegionIterator",
gRegionIterMethods, SK_ARRAY_COUNT(gRegionIterMethods));
RegisterMethodsOrDie(env, "android/graphics/Region", gRegionMethods, NELEM(gRegionMethods));
return RegisterMethodsOrDie(env, "android/graphics/RegionIterator", gRegionIterMethods,
NELEM(gRegionIterMethods));
}
SkRegion* android_graphics_Region_getSkRegion(JNIEnv* env, jobject regionObj) {

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef _ANDROID_GRAPHICS_REGION_H
#define _ANDROID_GRAPHICS_REGION_H
#ifndef _ANDROID_GRAPHICS_REGION_H_
#define _ANDROID_GRAPHICS_REGION_H_
#include "jni.h"
#include "SkRegion.h"
@@ -27,4 +27,4 @@ extern SkRegion* android_graphics_Region_getSkRegion(JNIEnv* env, jobject region
} // namespace android
#endif // _ANDROID_GRAPHICS_REGION_H
#endif // _ANDROID_GRAPHICS_REGION_H_

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef ANDROID_RTL_PROPERTIES_H
#define ANDROID_RTL_PROPERTIES_H
#ifndef _ANDROID_GRAPHICS_RTL_PROPERTIES_H_
#define _ANDROID_GRAPHICS_RTL_PROPERTIES_H_
#include <cutils/properties.h>
#include <stdlib.h>
@@ -45,11 +45,5 @@ static RtlDebugLevel readRtlDebugLevel() {
return kRtlDebugDisabled;
}
// Define if we want (1) to have Advances debug values or not (0)
#define DEBUG_ADVANCES 0
// Define if we want (1) to have Glyphs debug values or not (0)
#define DEBUG_GLYPHS 0
} // namespace android
#endif // ANDROID_RTL_PROPERTIES_H
#endif // _ANDROID_GRAPHICS_RTL_PROPERTIES_H_

View File

@@ -11,6 +11,8 @@
#include <SkiaShader.h>
#include <Caches.h>
#include "core_jni_helpers.h"
using namespace android::uirenderer;
static void ThrowIAE_IfNull(JNIEnv* env, void* ptr) {
@@ -260,23 +262,22 @@ static JNINativeMethod gComposeShaderMethods[] = {
{ "nativeCreate2", "(JJI)J", (void*)ComposeShader_create2 },
};
#include <android_runtime/AndroidRuntime.h>
#define REG(env, name, array) \
result = android::AndroidRuntime::registerNativeMethods(env, name, array, SK_ARRAY_COUNT(array)); \
if (result < 0) return result
int register_android_graphics_Shader(JNIEnv* env)
{
int result;
android::RegisterMethodsOrDie(env, "android/graphics/Color", gColorMethods,
NELEM(gColorMethods));
android::RegisterMethodsOrDie(env, "android/graphics/Shader", gShaderMethods,
NELEM(gShaderMethods));
android::RegisterMethodsOrDie(env, "android/graphics/BitmapShader", gBitmapShaderMethods,
NELEM(gBitmapShaderMethods));
android::RegisterMethodsOrDie(env, "android/graphics/LinearGradient", gLinearGradientMethods,
NELEM(gLinearGradientMethods));
android::RegisterMethodsOrDie(env, "android/graphics/RadialGradient", gRadialGradientMethods,
NELEM(gRadialGradientMethods));
android::RegisterMethodsOrDie(env, "android/graphics/SweepGradient", gSweepGradientMethods,
NELEM(gSweepGradientMethods));
android::RegisterMethodsOrDie(env, "android/graphics/ComposeShader", gComposeShaderMethods,
NELEM(gComposeShaderMethods));
REG(env, "android/graphics/Color", gColorMethods);
REG(env, "android/graphics/Shader", gShaderMethods);
REG(env, "android/graphics/BitmapShader", gBitmapShaderMethods);
REG(env, "android/graphics/LinearGradient", gLinearGradientMethods);
REG(env, "android/graphics/RadialGradient", gRadialGradientMethods);
REG(env, "android/graphics/SweepGradient", gSweepGradientMethods);
REG(env, "android/graphics/ComposeShader", gComposeShaderMethods);
return result;
return 0;
}

View File

@@ -24,7 +24,7 @@
#include <gui/GLConsumer.h>
#include <gui/Surface.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <utils/Log.h>
#include <utils/misc.h>
@@ -359,10 +359,8 @@ static JNINativeMethod gSurfaceTextureMethods[] = {
int register_android_graphics_SurfaceTexture(JNIEnv* env)
{
int err = 0;
err = AndroidRuntime::registerNativeMethods(env, kSurfaceTextureClassPathName,
gSurfaceTextureMethods, NELEM(gSurfaceTextureMethods));
return err;
return RegisterMethodsOrDie(env, kSurfaceTextureClassPathName, gSurfaceTextureMethods,
NELEM(gSurfaceTextureMethods));
}
} // namespace android

View File

@@ -15,7 +15,7 @@
*/
#include "jni.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "GraphicsJNI.h"
#include <ScopedPrimitiveArray.h>
@@ -81,8 +81,6 @@ static JNINativeMethod gTypefaceMethods[] = {
int register_android_graphics_Typeface(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env,
"android/graphics/Typeface",
gTypefaceMethods,
SK_ARRAY_COUNT(gTypefaceMethods));
return RegisterMethodsOrDie(env, "android/graphics/Typeface", gTypefaceMethods,
NELEM(gTypefaceMethods));
}

View File

@@ -15,8 +15,8 @@
*/
#ifndef ANDROID_TYPEFACE_IMPL_H
#define ANDROID_TYPEFACE_IMPL_H
#ifndef _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_
#define _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_
#include "jni.h" // for jlong, eventually remove
#include "SkTypeface.h"
@@ -62,4 +62,4 @@ void TypefaceImpl_setDefault(TypefaceImpl* face);
}
#endif // ANDROID_TYPEFACE_IMPL_H
#endif // _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef UTILS_DEFINED
#define UTILS_DEFINED
#ifndef _ANDROID_GRAPHICS_UTILS_H_
#define _ANDROID_GRAPHICS_UTILS_H_
#include "SkStream.h"
@@ -89,4 +89,4 @@ jobject nullObjectReturn(const char msg[]);
}; // namespace android
#endif
#endif // _ANDROID_GRAPHICS_UTILS_H_

View File

@@ -16,7 +16,7 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "SkAvoidXfermode.h"
#include "SkPixelXorXfermode.h"
@@ -59,19 +59,15 @@ static JNINativeMethod gPixelXorMethods[] = {
{"nativeCreate", "(I)J", (void*) SkXfermodeGlue::pixelxor_create}
};
#include <android_runtime/AndroidRuntime.h>
#define REG(env, name, array) \
result = android::AndroidRuntime::registerNativeMethods(env, name, array, \
SK_ARRAY_COUNT(array)); \
if (result < 0) return result
int register_android_graphics_Xfermode(JNIEnv* env) {
int result;
REG(env, "android/graphics/Xfermode", gXfermodeMethods);
REG(env, "android/graphics/AvoidXfermode", gAvoidMethods);
REG(env, "android/graphics/PixelXorXfermode", gPixelXorMethods);
android::RegisterMethodsOrDie(env, "android/graphics/Xfermode", gXfermodeMethods,
NELEM(gXfermodeMethods));
android::RegisterMethodsOrDie(env, "android/graphics/Xfermode", gXfermodeMethods,
NELEM(gXfermodeMethods));
android::RegisterMethodsOrDie(env, "android/graphics/AvoidXfermode", gAvoidMethods,
NELEM(gAvoidMethods));
android::RegisterMethodsOrDie(env, "android/graphics/PixelXorXfermode", gPixelXorMethods,
NELEM(gPixelXorMethods));
return 0;
}

View File

@@ -4,6 +4,8 @@
#include <ui/PixelFormat.h>
#include <hardware/hardware.h>
#include "core_jni_helpers.h"
#include <jni.h>
YuvToJpegEncoder* YuvToJpegEncoder::create(int format, int* strides) {
@@ -241,17 +243,13 @@ static jboolean YuvImage_compressToJpeg(JNIEnv* env, jobject, jbyteArray inYuv,
}
///////////////////////////////////////////////////////////////////////////////
#include <android_runtime/AndroidRuntime.h>
static JNINativeMethod gYuvImageMethods[] = {
{ "nativeCompressToJpeg", "([BIII[I[IILjava/io/OutputStream;[B)Z",
(void*)YuvImage_compressToJpeg }
};
#define kClassPathName "android/graphics/YuvImage"
int register_android_graphics_YuvImage(JNIEnv* env)
{
return android::AndroidRuntime::registerNativeMethods(env, kClassPathName,
gYuvImageMethods, SK_ARRAY_COUNT(gYuvImageMethods));
return android::RegisterMethodsOrDie(env, "android/graphics/YuvImage", gYuvImageMethods,
NELEM(gYuvImageMethods));
}

View File

@@ -1,5 +1,5 @@
#ifndef YuvToJpegEncoder_DEFINED
#define YuvToJpegEncoder_DEFINED
#ifndef _ANDROID_GRAPHICS_YUV_TO_JPEG_ENCODER_H_
#define _ANDROID_GRAPHICS_YUV_TO_JPEG_ENCODER_H_
#include "SkTypes.h"
#include "SkStream.h"
@@ -47,16 +47,16 @@ protected:
class Yuv420SpToJpegEncoder : public YuvToJpegEncoder {
public:
Yuv420SpToJpegEncoder(int* strides);
virtual ~Yuv420SpToJpegEncoder() {}
Yuv420SpToJpegEncoder(int* strides);
virtual ~Yuv420SpToJpegEncoder() {}
private:
void configSamplingFactors(jpeg_compress_struct* cinfo);
void deinterleaveYuv(uint8_t* yuv, int width, int height,
void configSamplingFactors(jpeg_compress_struct* cinfo);
void deinterleaveYuv(uint8_t* yuv, int width, int height,
uint8_t*& yPlanar, uint8_t*& uPlanar, uint8_t*& vPlanar);
void deinterleave(uint8_t* vuPlanar, uint8_t* uRows, uint8_t* vRows,
int rowIndex, int width, int height);
void compress(jpeg_compress_struct* cinfo, uint8_t* yuv, int* offsets);
void deinterleave(uint8_t* vuPlanar, uint8_t* uRows, uint8_t* vRows,
int rowIndex, int width, int height);
void compress(jpeg_compress_struct* cinfo, uint8_t* yuv, int* offsets);
};
class Yuv422IToJpegEncoder : public YuvToJpegEncoder {
@@ -71,4 +71,4 @@ private:
uint8_t* vRows, int rowIndex, int width, int height);
};
#endif
#endif // _ANDROID_GRAPHICS_YUV_TO_JPEG_ENCODER_H_

View File

@@ -16,7 +16,7 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <vector>
#include "Canvas.h"
@@ -164,10 +164,9 @@ static JNINativeMethod gPdfDocument_Methods[] = {
};
int register_android_graphics_pdf_PdfDocument(JNIEnv* env) {
int result = android::AndroidRuntime::registerNativeMethods(
return RegisterMethodsOrDie(
env, "android/graphics/pdf/PdfDocument", gPdfDocument_Methods,
NELEM(gPdfDocument_Methods));
return result;
}
};

View File

@@ -20,7 +20,7 @@
#include "fpdfedit.h"
#include "fpdfsave.h"
#include <android_runtime/AndroidRuntime.h>
#include <core_jni_helpers.h>
#include <vector>
#include <utils/Log.h>
#include <unistd.h>
@@ -153,7 +153,7 @@ static JNINativeMethod gPdfEditor_Methods[] = {
};
int register_android_graphics_pdf_PdfEditor(JNIEnv* env) {
return android::AndroidRuntime::registerNativeMethods(
return android::RegisterMethodsOrDie(
env, "android/graphics/pdf/PdfEditor", gPdfEditor_Methods,
NELEM(gPdfEditor_Methods));
};

View File

@@ -26,7 +26,7 @@
#include "fsdk_rendercontext.h"
#pragma GCC diagnostic pop
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <vector>
#include <utils/Log.h>
#include <unistd.h>
@@ -273,13 +273,13 @@ static JNINativeMethod gPdfRenderer_Methods[] = {
};
int register_android_graphics_pdf_PdfRenderer(JNIEnv* env) {
int result = android::AndroidRuntime::registerNativeMethods(
int result = RegisterMethodsOrDie(
env, "android/graphics/pdf/PdfRenderer", gPdfRenderer_Methods,
NELEM(gPdfRenderer_Methods));
jclass clazz = env->FindClass("android/graphics/Point");
gPointClassInfo.x = env->GetFieldID(clazz, "x", "I");
gPointClassInfo.y = env->GetFieldID(clazz, "y", "I");
jclass clazz = FindClassOrDie(env, "android/graphics/Point");
gPointClassInfo.x = GetFieldIDOrDie(env, clazz, "x", "I");
gPointClassInfo.y = GetFieldIDOrDie(env, clazz, "y", "I");
return result;
};

View File

@@ -29,7 +29,7 @@
#include <SkBitmap.h>
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#undef LOG_TAG
#define LOG_TAG "OpenGLUtil"
@@ -732,24 +732,22 @@ static jfieldID elementSizeShiftID;
/* Cache method IDs each time the class is loaded. */
static void
nativeClassInitBuffer(JNIEnv *_env)
nativeClassInitBuffer(JNIEnv *env)
{
jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess");
nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal);
jclass bufferClassLocal = _env->FindClass("java/nio/Buffer");
bufferClass = (jclass) _env->NewGlobalRef(bufferClassLocal);
getBasePointerID = _env->GetStaticMethodID(nioAccessClass,
jclass nioAccessClassLocal = FindClassOrDie(env, "java/nio/NIOAccess");
nioAccessClass = MakeGlobalRefOrDie(env, nioAccessClassLocal);
getBasePointerID = GetStaticMethodIDOrDie(env, nioAccessClass,
"getBasePointer", "(Ljava/nio/Buffer;)J");
getBaseArrayID = _env->GetStaticMethodID(nioAccessClass,
getBaseArrayID = GetStaticMethodIDOrDie(env, nioAccessClass,
"getBaseArray", "(Ljava/nio/Buffer;)Ljava/lang/Object;");
getBaseArrayOffsetID = _env->GetStaticMethodID(nioAccessClass,
getBaseArrayOffsetID = GetStaticMethodIDOrDie(env, nioAccessClass,
"getBaseArrayOffset", "(Ljava/nio/Buffer;)I");
positionID = _env->GetFieldID(bufferClass, "position", "I");
limitID = _env->GetFieldID(bufferClass, "limit", "I");
elementSizeShiftID =
_env->GetFieldID(bufferClass, "_elementSizeShift", "I");
jclass bufferClassLocal = FindClassOrDie(env, "java/nio/Buffer");
bufferClass = MakeGlobalRefOrDie(env, bufferClassLocal);
positionID = GetFieldIDOrDie(env, bufferClass, "position", "I");
limitID = GetFieldIDOrDie(env, bufferClass, "limit", "I");
elementSizeShiftID = GetFieldIDOrDie(env, bufferClass, "_elementSizeShift", "I");
}
static void *
@@ -1056,12 +1054,7 @@ int register_android_opengl_classes(JNIEnv* env)
int result = 0;
for (int i = 0; i < NELEM(gClasses); i++) {
ClassRegistrationInfo* cri = &gClasses[i];
result = AndroidRuntime::registerNativeMethods(env,
cri->classPath, cri->methods, cri->methodCount);
if (result < 0) {
ALOGE("Failed to register %s: %d", cri->classPath, result);
break;
}
result = RegisterMethodsOrDie(env, cri->classPath, cri->methods, cri->methodCount);
}
return result;
}

View File

@@ -18,7 +18,7 @@
#include <assert.h>
#include "jni.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <utils/misc.h>
// ----------------------------------------------------------------------------
@@ -168,8 +168,7 @@ static JNINativeMethod gMethods[] = {
int register_android_animation_PropertyValuesHolder(JNIEnv* env)
{
return AndroidRuntime::registerNativeMethods(env,
kClassPathName, gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
}
};

View File

@@ -42,12 +42,15 @@
#include "core_jni_helpers.h"
#define LOG_TRACE(...)
//#define LOG_TRACE(...) ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)
namespace android
{
static const bool kLogTrace = false;
static struct {
jmethodID finish;
jmethodID setWindowFlags;
@@ -77,8 +80,10 @@ static void write_work(int fd, int32_t cmd, int32_t arg1=0, int32_t arg2=0) {
work.cmd = cmd;
work.arg1 = arg1;
work.arg2 = arg2;
LOG_TRACE("write_work: cmd=%d", cmd);
if (kLogTrace) {
ALOGD("write_work: cmd=%d", cmd);
}
restart:
int res = write(fd, &work, sizeof(work));
@@ -208,7 +213,9 @@ static int mainWorkCallback(int fd, int events, void* data) {
return 1;
}
LOG_TRACE("mainWorkCallback: cmd=%d", work.cmd);
if (kLogTrace) {
ALOGD("mainWorkCallback: cmd=%d", work.cmd);
}
switch (work.cmd) {
case CMD_FINISH: {
@@ -251,7 +258,9 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName
jstring externalDataDir, jint sdkVersion,
jobject jAssetMgr, jbyteArray savedState)
{
LOG_TRACE("loadNativeCode_native");
if (kLogTrace) {
ALOGD("loadNativeCode_native");
}
const char* pathStr = env->GetStringUTFChars(path, NULL);
NativeCode* code = NULL;
@@ -360,7 +369,9 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jstring funcName
static void
unloadNativeCode_native(JNIEnv* env, jobject clazz, jlong handle)
{
LOG_TRACE("unloadNativeCode_native");
if (kLogTrace) {
ALOGD("unloadNativeCode_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
delete code;
@@ -370,7 +381,9 @@ unloadNativeCode_native(JNIEnv* env, jobject clazz, jlong handle)
static void
onStart_native(JNIEnv* env, jobject clazz, jlong handle)
{
LOG_TRACE("onStart_native");
if (kLogTrace) {
ALOGD("onStart_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->callbacks.onStart != NULL) {
@@ -382,7 +395,9 @@ onStart_native(JNIEnv* env, jobject clazz, jlong handle)
static void
onResume_native(JNIEnv* env, jobject clazz, jlong handle)
{
LOG_TRACE("onResume_native");
if (kLogTrace) {
ALOGD("onResume_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->callbacks.onResume != NULL) {
@@ -394,7 +409,9 @@ onResume_native(JNIEnv* env, jobject clazz, jlong handle)
static jbyteArray
onSaveInstanceState_native(JNIEnv* env, jobject clazz, jlong handle)
{
LOG_TRACE("onSaveInstanceState_native");
if (kLogTrace) {
ALOGD("onSaveInstanceState_native");
}
jbyteArray array = NULL;
@@ -421,7 +438,9 @@ onSaveInstanceState_native(JNIEnv* env, jobject clazz, jlong handle)
static void
onPause_native(JNIEnv* env, jobject clazz, jlong handle)
{
LOG_TRACE("onPause_native");
if (kLogTrace) {
ALOGD("onPause_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->callbacks.onPause != NULL) {
@@ -433,7 +452,9 @@ onPause_native(JNIEnv* env, jobject clazz, jlong handle)
static void
onStop_native(JNIEnv* env, jobject clazz, jlong handle)
{
LOG_TRACE("onStop_native");
if (kLogTrace) {
ALOGD("onStop_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->callbacks.onStop != NULL) {
@@ -445,7 +466,9 @@ onStop_native(JNIEnv* env, jobject clazz, jlong handle)
static void
onConfigurationChanged_native(JNIEnv* env, jobject clazz, jlong handle)
{
LOG_TRACE("onConfigurationChanged_native");
if (kLogTrace) {
ALOGD("onConfigurationChanged_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->callbacks.onConfigurationChanged != NULL) {
@@ -457,7 +480,9 @@ onConfigurationChanged_native(JNIEnv* env, jobject clazz, jlong handle)
static void
onLowMemory_native(JNIEnv* env, jobject clazz, jlong handle)
{
LOG_TRACE("onLowMemory_native");
if (kLogTrace) {
ALOGD("onLowMemory_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->callbacks.onLowMemory != NULL) {
@@ -469,7 +494,9 @@ onLowMemory_native(JNIEnv* env, jobject clazz, jlong handle)
static void
onWindowFocusChanged_native(JNIEnv* env, jobject clazz, jlong handle, jboolean focused)
{
LOG_TRACE("onWindowFocusChanged_native");
if (kLogTrace) {
ALOGD("onWindowFocusChanged_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->callbacks.onWindowFocusChanged != NULL) {
@@ -481,7 +508,9 @@ onWindowFocusChanged_native(JNIEnv* env, jobject clazz, jlong handle, jboolean f
static void
onSurfaceCreated_native(JNIEnv* env, jobject clazz, jlong handle, jobject surface)
{
LOG_TRACE("onSurfaceCreated_native");
if (kLogTrace) {
ALOGD("onSurfaceCreated_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
code->setSurface(surface);
@@ -502,7 +531,9 @@ static void
onSurfaceChanged_native(JNIEnv* env, jobject clazz, jlong handle, jobject surface,
jint format, jint width, jint height)
{
LOG_TRACE("onSurfaceChanged_native");
if (kLogTrace) {
ALOGD("onSurfaceChanged_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
sp<ANativeWindow> oldNativeWindow = code->nativeWindow;
@@ -542,7 +573,9 @@ onSurfaceChanged_native(JNIEnv* env, jobject clazz, jlong handle, jobject surfac
static void
onSurfaceRedrawNeeded_native(JNIEnv* env, jobject clazz, jlong handle)
{
LOG_TRACE("onSurfaceRedrawNeeded_native");
if (kLogTrace) {
ALOGD("onSurfaceRedrawNeeded_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->nativeWindow != NULL && code->callbacks.onNativeWindowRedrawNeeded != NULL) {
@@ -554,7 +587,9 @@ onSurfaceRedrawNeeded_native(JNIEnv* env, jobject clazz, jlong handle)
static void
onSurfaceDestroyed_native(JNIEnv* env, jobject clazz, jlong handle, jobject surface)
{
LOG_TRACE("onSurfaceDestroyed_native");
if (kLogTrace) {
ALOGD("onSurfaceDestroyed_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->nativeWindow != NULL && code->callbacks.onNativeWindowDestroyed != NULL) {
@@ -568,7 +603,9 @@ onSurfaceDestroyed_native(JNIEnv* env, jobject clazz, jlong handle, jobject surf
static void
onInputQueueCreated_native(JNIEnv* env, jobject clazz, jlong handle, jlong queuePtr)
{
LOG_TRACE("onInputChannelCreated_native");
if (kLogTrace) {
ALOGD("onInputChannelCreated_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->callbacks.onInputQueueCreated != NULL) {
@@ -581,7 +618,9 @@ onInputQueueCreated_native(JNIEnv* env, jobject clazz, jlong handle, jlong queue
static void
onInputQueueDestroyed_native(JNIEnv* env, jobject clazz, jlong handle, jlong queuePtr)
{
LOG_TRACE("onInputChannelDestroyed_native");
if (kLogTrace) {
ALOGD("onInputChannelDestroyed_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->callbacks.onInputQueueDestroyed != NULL) {
@@ -595,7 +634,9 @@ static void
onContentRectChanged_native(JNIEnv* env, jobject clazz, jlong handle,
jint x, jint y, jint w, jint h)
{
LOG_TRACE("onContentRectChanged_native");
if (kLogTrace) {
ALOGD("onContentRectChanged_native");
}
if (handle != 0) {
NativeCode* code = (NativeCode*)handle;
if (code->callbacks.onContentRectChanged != NULL) {

View File

@@ -18,7 +18,7 @@
#include <utils/Log.h>
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <androidfw/BackupHelpers.h>
@@ -106,7 +106,7 @@ static const JNINativeMethod g_methods[] = {
int register_android_backup_BackupDataOutput(JNIEnv* env)
{
//ALOGD("register_android_backup_BackupDataOutput");
return AndroidRuntime::registerNativeMethods(env, "android/app/backup/BackupDataOutput",
return RegisterMethodsOrDie(env, "android/app/backup/BackupDataOutput",
g_methods, NELEM(g_methods));
}

View File

@@ -18,7 +18,7 @@
#include <utils/Log.h>
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <androidfw/BackupHelpers.h>
@@ -118,7 +118,7 @@ static const JNINativeMethod g_methods[] = {
int register_android_backup_FileBackupHelperBase(JNIEnv* env)
{
return AndroidRuntime::registerNativeMethods(env, "android/app/backup/FileBackupHelperBase",
return RegisterMethodsOrDie(env, "android/app/backup/FileBackupHelperBase",
g_methods, NELEM(g_methods));
}

View File

@@ -18,7 +18,7 @@
#include <jni.h>
#include <JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <sqlite3.h>
#include <sqlite3_android.h>
@@ -74,15 +74,14 @@ static jint nativeReleaseMemory(JNIEnv* env, jclass clazz) {
static JNINativeMethod sMethods[] =
{
/* name, signature, funcPtr */
{ "nativeReleaseMemory", "()I",
(void*)nativeReleaseMemory },
{ "nativeReleaseMemory", "()I", (void*)nativeReleaseMemory },
};
int register_android_database_SQLiteGlobal(JNIEnv *env)
{
sqliteInitialize();
return AndroidRuntime::registerNativeMethods(env, "android/database/sqlite/SQLiteGlobal",
return RegisterMethodsOrDie(env, "android/database/sqlite/SQLiteGlobal",
sMethods, NELEM(sMethods));
}

View File

@@ -20,7 +20,7 @@
#include <JNIHelp.h>
#include <jni.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <utils/Log.h>
#include <utils/String8.h>
@@ -110,7 +110,8 @@ static JNINativeMethod method_table[] = {
};
int register_android_ddm_DdmHandleNativeHeap(JNIEnv* env) {
return AndroidRuntime::registerNativeMethods(env, "android/ddm/DdmHandleNativeHeap", method_table, NELEM(method_table));
return RegisterMethodsOrDie(env, "android/ddm/DdmHandleNativeHeap", method_table,
NELEM(method_table));
}
};

View File

@@ -16,7 +16,7 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "Canvas.h"
#include "SkDrawFilter.h"
@@ -700,7 +700,7 @@ static JNINativeMethod gMethods[] = {
};
int register_android_graphics_Canvas(JNIEnv* env) {
return AndroidRuntime::registerNativeMethods(env, "android/graphics/Canvas", gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, "android/graphics/Canvas", gMethods, NELEM(gMethods));
}
}; // namespace android

View File

@@ -16,7 +16,7 @@
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "Picture.h"
@@ -106,7 +106,7 @@ static JNINativeMethod gMethods[] = {
};
int register_android_graphics_Picture(JNIEnv* env) {
return AndroidRuntime::registerNativeMethods(env, "android/graphics/Picture", gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, "android/graphics/Picture", gMethods, NELEM(gMethods));
}
}; // namespace android

View File

@@ -21,7 +21,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include <android_runtime/android_graphics_SurfaceTexture.h>
#include <android_runtime/android_view_Surface.h>
@@ -991,26 +991,14 @@ struct field {
jfieldID *jfield;
};
static int find_fields(JNIEnv *env, field *fields, int count)
static void find_fields(JNIEnv *env, field *fields, int count)
{
for (int i = 0; i < count; i++) {
field *f = &fields[i];
jclass clazz = env->FindClass(f->class_name);
if (clazz == NULL) {
ALOGE("Can't find %s", f->class_name);
return -1;
}
jfieldID field = env->GetFieldID(clazz, f->field_name, f->field_type);
if (field == NULL) {
ALOGE("Can't find %s.%s", f->class_name, f->field_name);
return -1;
}
jclass clazz = FindClassOrDie(env, f->class_name);
jfieldID field = GetFieldIDOrDie(env, clazz, f->field_name, f->field_type);
*(f->jfield) = field;
}
return 0;
}
// Get all the required offsets in java class and register native functions
@@ -1030,32 +1018,18 @@ int register_android_hardware_Camera(JNIEnv *env)
{ "android/graphics/Rect", "bottom", "I", &fields.rect_bottom },
};
if (find_fields(env, fields_to_find, NELEM(fields_to_find)) < 0)
return -1;
find_fields(env, fields_to_find, NELEM(fields_to_find));
jclass clazz = env->FindClass("android/hardware/Camera");
fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative",
jclass clazz = FindClassOrDie(env, "android/hardware/Camera");
fields.post_event = GetStaticMethodIDOrDie(env, clazz, "postEventFromNative",
"(Ljava/lang/Object;IIILjava/lang/Object;)V");
if (fields.post_event == NULL) {
ALOGE("Can't find android/hardware/Camera.postEventFromNative");
return -1;
}
clazz = env->FindClass("android/graphics/Rect");
fields.rect_constructor = env->GetMethodID(clazz, "<init>", "()V");
if (fields.rect_constructor == NULL) {
ALOGE("Can't find android/graphics/Rect.Rect()");
return -1;
}
clazz = FindClassOrDie(env, "android/graphics/Rect");
fields.rect_constructor = GetMethodIDOrDie(env, clazz, "<init>", "()V");
clazz = env->FindClass("android/hardware/Camera$Face");
fields.face_constructor = env->GetMethodID(clazz, "<init>", "()V");
if (fields.face_constructor == NULL) {
ALOGE("Can't find android/hardware/Camera$Face.Face()");
return -1;
}
clazz = FindClassOrDie(env, "android/hardware/Camera$Face");
fields.face_constructor = GetMethodIDOrDie(env, clazz, "<init>", "()V");
// Register native functions
return AndroidRuntime::registerNativeMethods(env, "android/hardware/Camera",
camMethods, NELEM(camMethods));
return RegisterMethodsOrDie(env, "android/hardware/Camera", camMethods, NELEM(camMethods));
}

View File

@@ -20,7 +20,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include <stdio.h>
#include <sys/types.h>
@@ -260,17 +260,9 @@ static JNINativeMethod method_table[] = {
int register_android_hardware_SerialPort(JNIEnv *env)
{
jclass clazz = env->FindClass("android/hardware/SerialPort");
if (clazz == NULL) {
ALOGE("Can't find android/hardware/SerialPort");
return -1;
}
field_context = env->GetFieldID(clazz, "mNativeContext", "I");
if (field_context == NULL) {
ALOGE("Can't find SerialPort.mNativeContext");
return -1;
}
jclass clazz = FindClassOrDie(env, "android/hardware/SerialPort");
field_context = GetFieldIDOrDie(env, clazz, "mNativeContext", "I");
return AndroidRuntime::registerNativeMethods(env, "android/hardware/SerialPort",
return RegisterMethodsOrDie(env, "android/hardware/SerialPort",
method_table, NELEM(method_table));
}

View File

@@ -21,7 +21,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include <system/sound_trigger.h>
#include <soundtrigger/SoundTriggerCallback.h>
#include <soundtrigger/SoundTrigger.h>
@@ -798,112 +798,102 @@ static JNINativeMethod gModuleMethods[] = {
int register_android_hardware_SoundTrigger(JNIEnv *env)
{
jclass arrayListClass = env->FindClass("java/util/ArrayList");
gArrayListClass = (jclass) env->NewGlobalRef(arrayListClass);
gArrayListMethods.add = env->GetMethodID(arrayListClass, "add", "(Ljava/lang/Object;)Z");
jclass arrayListClass = FindClassOrDie(env, "java/util/ArrayList");
gArrayListClass = MakeGlobalRefOrDie(env, arrayListClass);
gArrayListMethods.add = GetMethodIDOrDie(env, arrayListClass, "add", "(Ljava/lang/Object;)Z");
jclass uuidClass = env->FindClass("java/util/UUID");
gUUIDClass = (jclass) env->NewGlobalRef(uuidClass);
gUUIDMethods.toString = env->GetMethodID(uuidClass, "toString", "()Ljava/lang/String;");
jclass uuidClass = FindClassOrDie(env, "java/util/UUID");
gUUIDClass = MakeGlobalRefOrDie(env, uuidClass);
gUUIDMethods.toString = GetMethodIDOrDie(env, uuidClass, "toString", "()Ljava/lang/String;");
jclass lClass = env->FindClass(kSoundTriggerClassPathName);
gSoundTriggerClass = (jclass) env->NewGlobalRef(lClass);
jclass lClass = FindClassOrDie(env, kSoundTriggerClassPathName);
gSoundTriggerClass = MakeGlobalRefOrDie(env, lClass);
jclass moduleClass = env->FindClass(kModuleClassPathName);
gModuleClass = (jclass) env->NewGlobalRef(moduleClass);
gPostEventFromNative = env->GetStaticMethodID(moduleClass, "postEventFromNative",
"(Ljava/lang/Object;IIILjava/lang/Object;)V");
gModuleFields.mNativeContext = env->GetFieldID(moduleClass, "mNativeContext", "J");
gModuleFields.mId = env->GetFieldID(moduleClass, "mId", "I");
jclass moduleClass = FindClassOrDie(env, kModuleClassPathName);
gModuleClass = MakeGlobalRefOrDie(env, moduleClass);
gPostEventFromNative = GetStaticMethodIDOrDie(env, moduleClass, "postEventFromNative",
"(Ljava/lang/Object;IIILjava/lang/Object;)V");
gModuleFields.mNativeContext = GetFieldIDOrDie(env, moduleClass, "mNativeContext", "J");
gModuleFields.mId = GetFieldIDOrDie(env, moduleClass, "mId", "I");
jclass modulePropertiesClass = FindClassOrDie(env, kModulePropertiesClassPathName);
gModulePropertiesClass = MakeGlobalRefOrDie(env, modulePropertiesClass);
gModulePropertiesCstor = GetMethodIDOrDie(env, modulePropertiesClass, "<init>",
"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIIIZIZIZ)V");
jclass modulePropertiesClass = env->FindClass(kModulePropertiesClassPathName);
gModulePropertiesClass = (jclass) env->NewGlobalRef(modulePropertiesClass);
gModulePropertiesCstor = env->GetMethodID(modulePropertiesClass, "<init>",
"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIIIZIZIZ)V");
jclass soundModelClass = FindClassOrDie(env, kSoundModelClassPathName);
gSoundModelClass = MakeGlobalRefOrDie(env, soundModelClass);
gSoundModelFields.uuid = GetFieldIDOrDie(env, soundModelClass, "uuid", "Ljava/util/UUID;");
gSoundModelFields.vendorUuid = GetFieldIDOrDie(env, soundModelClass, "vendorUuid",
"Ljava/util/UUID;");
gSoundModelFields.data = GetFieldIDOrDie(env, soundModelClass, "data", "[B");
jclass soundModelClass = env->FindClass(kSoundModelClassPathName);
gSoundModelClass = (jclass) env->NewGlobalRef(soundModelClass);
gSoundModelFields.uuid = env->GetFieldID(soundModelClass, "uuid", "Ljava/util/UUID;");
gSoundModelFields.vendorUuid = env->GetFieldID(soundModelClass, "vendorUuid", "Ljava/util/UUID;");
gSoundModelFields.data = env->GetFieldID(soundModelClass, "data", "[B");
jclass keyphraseClass = FindClassOrDie(env, kKeyphraseClassPathName);
gKeyphraseClass = MakeGlobalRefOrDie(env, keyphraseClass);
gKeyphraseFields.id = GetFieldIDOrDie(env, keyphraseClass, "id", "I");
gKeyphraseFields.recognitionModes = GetFieldIDOrDie(env, keyphraseClass, "recognitionModes",
"I");
gKeyphraseFields.locale = GetFieldIDOrDie(env, keyphraseClass, "locale", "Ljava/lang/String;");
gKeyphraseFields.text = GetFieldIDOrDie(env, keyphraseClass, "text", "Ljava/lang/String;");
gKeyphraseFields.users = GetFieldIDOrDie(env, keyphraseClass, "users", "[I");
jclass keyphraseClass = env->FindClass(kKeyphraseClassPathName);
gKeyphraseClass = (jclass) env->NewGlobalRef(keyphraseClass);
gKeyphraseFields.id = env->GetFieldID(keyphraseClass, "id", "I");
gKeyphraseFields.recognitionModes = env->GetFieldID(keyphraseClass, "recognitionModes", "I");
gKeyphraseFields.locale = env->GetFieldID(keyphraseClass, "locale", "Ljava/lang/String;");
gKeyphraseFields.text = env->GetFieldID(keyphraseClass, "text", "Ljava/lang/String;");
gKeyphraseFields.users = env->GetFieldID(keyphraseClass, "users", "[I");
jclass keyphraseSoundModelClass = env->FindClass(kKeyphraseSoundModelClassPathName);
gKeyphraseSoundModelClass = (jclass) env->NewGlobalRef(keyphraseSoundModelClass);
gKeyphraseSoundModelFields.keyphrases = env->GetFieldID(keyphraseSoundModelClass,
jclass keyphraseSoundModelClass = FindClassOrDie(env, kKeyphraseSoundModelClassPathName);
gKeyphraseSoundModelClass = MakeGlobalRefOrDie(env, keyphraseSoundModelClass);
gKeyphraseSoundModelFields.keyphrases = GetFieldIDOrDie(env, keyphraseSoundModelClass,
"keyphrases",
"[Landroid/hardware/soundtrigger/SoundTrigger$Keyphrase;");
jclass recognitionEventClass = env->FindClass(kRecognitionEventClassPathName);
gRecognitionEventClass = (jclass) env->NewGlobalRef(recognitionEventClass);
gRecognitionEventCstor = env->GetMethodID(recognitionEventClass, "<init>",
jclass recognitionEventClass = FindClassOrDie(env, kRecognitionEventClassPathName);
gRecognitionEventClass = MakeGlobalRefOrDie(env, recognitionEventClass);
gRecognitionEventCstor = GetMethodIDOrDie(env, recognitionEventClass, "<init>",
"(IIZIIIZLandroid/media/AudioFormat;[B)V");
jclass keyphraseRecognitionEventClass = env->FindClass(kKeyphraseRecognitionEventClassPathName);
gKeyphraseRecognitionEventClass = (jclass) env->NewGlobalRef(keyphraseRecognitionEventClass);
gKeyphraseRecognitionEventCstor = env->GetMethodID(keyphraseRecognitionEventClass, "<init>",
jclass keyphraseRecognitionEventClass = FindClassOrDie(env,
kKeyphraseRecognitionEventClassPathName);
gKeyphraseRecognitionEventClass = MakeGlobalRefOrDie(env, keyphraseRecognitionEventClass);
gKeyphraseRecognitionEventCstor = GetMethodIDOrDie(env, keyphraseRecognitionEventClass, "<init>",
"(IIZIIIZLandroid/media/AudioFormat;[B[Landroid/hardware/soundtrigger/SoundTrigger$KeyphraseRecognitionExtra;)V");
jclass keyRecognitionConfigClass = env->FindClass(kRecognitionConfigClassPathName);
gRecognitionConfigClass = (jclass) env->NewGlobalRef(keyRecognitionConfigClass);
gRecognitionConfigFields.captureRequested = env->GetFieldID(keyRecognitionConfigClass,
"captureRequested",
"Z");
gRecognitionConfigFields.keyphrases = env->GetFieldID(keyRecognitionConfigClass,
"keyphrases",
"[Landroid/hardware/soundtrigger/SoundTrigger$KeyphraseRecognitionExtra;");
gRecognitionConfigFields.data = env->GetFieldID(keyRecognitionConfigClass,
"data",
"[B");
jclass keyRecognitionConfigClass = FindClassOrDie(env, kRecognitionConfigClassPathName);
gRecognitionConfigClass = MakeGlobalRefOrDie(env, keyRecognitionConfigClass);
gRecognitionConfigFields.captureRequested = GetFieldIDOrDie(env, keyRecognitionConfigClass,
"captureRequested", "Z");
gRecognitionConfigFields.keyphrases = GetFieldIDOrDie(env, keyRecognitionConfigClass,
"keyphrases", "[Landroid/hardware/soundtrigger/SoundTrigger$KeyphraseRecognitionExtra;");
gRecognitionConfigFields.data = GetFieldIDOrDie(env, keyRecognitionConfigClass, "data", "[B");
jclass keyphraseRecognitionExtraClass = env->FindClass(kKeyphraseRecognitionExtraClassPathName);
gKeyphraseRecognitionExtraClass = (jclass) env->NewGlobalRef(keyphraseRecognitionExtraClass);
gKeyphraseRecognitionExtraCstor = env->GetMethodID(keyphraseRecognitionExtraClass, "<init>",
"(III[Landroid/hardware/soundtrigger/SoundTrigger$ConfidenceLevel;)V");
gKeyphraseRecognitionExtraFields.id = env->GetFieldID(gKeyphraseRecognitionExtraClass, "id", "I");
gKeyphraseRecognitionExtraFields.recognitionModes = env->GetFieldID(gKeyphraseRecognitionExtraClass,
"recognitionModes", "I");
gKeyphraseRecognitionExtraFields.coarseConfidenceLevel = env->GetFieldID(gKeyphraseRecognitionExtraClass,
"coarseConfidenceLevel", "I");
gKeyphraseRecognitionExtraFields.confidenceLevels = env->GetFieldID(gKeyphraseRecognitionExtraClass,
"confidenceLevels",
"[Landroid/hardware/soundtrigger/SoundTrigger$ConfidenceLevel;");
jclass keyphraseRecognitionExtraClass = FindClassOrDie(env,
kKeyphraseRecognitionExtraClassPathName);
gKeyphraseRecognitionExtraClass = MakeGlobalRefOrDie(env, keyphraseRecognitionExtraClass);
gKeyphraseRecognitionExtraCstor = GetMethodIDOrDie(env, keyphraseRecognitionExtraClass,
"<init>", "(III[Landroid/hardware/soundtrigger/SoundTrigger$ConfidenceLevel;)V");
gKeyphraseRecognitionExtraFields.id = GetFieldIDOrDie(env, gKeyphraseRecognitionExtraClass,
"id", "I");
gKeyphraseRecognitionExtraFields.recognitionModes = GetFieldIDOrDie(env,
gKeyphraseRecognitionExtraClass, "recognitionModes", "I");
gKeyphraseRecognitionExtraFields.coarseConfidenceLevel = GetFieldIDOrDie(env,
gKeyphraseRecognitionExtraClass, "coarseConfidenceLevel", "I");
gKeyphraseRecognitionExtraFields.confidenceLevels = GetFieldIDOrDie(env,
gKeyphraseRecognitionExtraClass, "confidenceLevels",
"[Landroid/hardware/soundtrigger/SoundTrigger$ConfidenceLevel;");
jclass confidenceLevelClass = env->FindClass(kConfidenceLevelClassPathName);
gConfidenceLevelClass = (jclass) env->NewGlobalRef(confidenceLevelClass);
gConfidenceLevelCstor = env->GetMethodID(confidenceLevelClass, "<init>", "(II)V");
gConfidenceLevelFields.userId = env->GetFieldID(confidenceLevelClass, "userId", "I");
gConfidenceLevelFields.confidenceLevel = env->GetFieldID(confidenceLevelClass,
jclass confidenceLevelClass = FindClassOrDie(env, kConfidenceLevelClassPathName);
gConfidenceLevelClass = MakeGlobalRefOrDie(env, confidenceLevelClass);
gConfidenceLevelCstor = GetMethodIDOrDie(env, confidenceLevelClass, "<init>", "(II)V");
gConfidenceLevelFields.userId = GetFieldIDOrDie(env, confidenceLevelClass, "userId", "I");
gConfidenceLevelFields.confidenceLevel = GetFieldIDOrDie(env, confidenceLevelClass,
"confidenceLevel", "I");
jclass audioFormatClass = env->FindClass(kAudioFormatClassPathName);
gAudioFormatClass = (jclass) env->NewGlobalRef(audioFormatClass);
gAudioFormatCstor = env->GetMethodID(audioFormatClass, "<init>", "(III)V");
jclass audioFormatClass = FindClassOrDie(env, kAudioFormatClassPathName);
gAudioFormatClass = MakeGlobalRefOrDie(env, audioFormatClass);
gAudioFormatCstor = GetMethodIDOrDie(env, audioFormatClass, "<init>", "(III)V");
jclass soundModelEventClass = env->FindClass(kSoundModelEventClassPathName);
gSoundModelEventClass = (jclass) env->NewGlobalRef(soundModelEventClass);
gSoundModelEventCstor = env->GetMethodID(soundModelEventClass, "<init>",
"(II[B)V");
jclass soundModelEventClass = FindClassOrDie(env, kSoundModelEventClassPathName);
gSoundModelEventClass = MakeGlobalRefOrDie(env, soundModelEventClass);
gSoundModelEventCstor = GetMethodIDOrDie(env, soundModelEventClass, "<init>", "(II[B)V");
int status = AndroidRuntime::registerNativeMethods(env,
kSoundTriggerClassPathName, gMethods, NELEM(gMethods));
if (status == 0) {
status = AndroidRuntime::registerNativeMethods(env,
kModuleClassPathName, gModuleMethods, NELEM(gModuleMethods));
}
return status;
RegisterMethodsOrDie(env, kSoundTriggerClassPathName, gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, kModuleClassPathName, gModuleMethods, NELEM(gModuleMethods));
}

View File

@@ -20,7 +20,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include <usbhost/usbhost.h>
@@ -54,6 +54,6 @@ static JNINativeMethod method_table[] = {
int register_android_hardware_UsbDevice(JNIEnv *env)
{
return AndroidRuntime::registerNativeMethods(env, "android/hardware/usb/UsbDevice",
return RegisterMethodsOrDie(env, "android/hardware/usb/UsbDevice",
method_table, NELEM(method_table));
}

View File

@@ -20,7 +20,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include <usbhost/usbhost.h>
@@ -268,17 +268,9 @@ static JNINativeMethod method_table[] = {
int register_android_hardware_UsbDeviceConnection(JNIEnv *env)
{
jclass clazz = env->FindClass("android/hardware/usb/UsbDeviceConnection");
if (clazz == NULL) {
ALOGE("Can't find android/hardware/usb/UsbDeviceConnection");
return -1;
}
field_context = env->GetFieldID(clazz, "mNativeContext", "J");
if (field_context == NULL) {
ALOGE("Can't find UsbDeviceConnection.mNativeContext");
return -1;
}
jclass clazz = FindClassOrDie(env, "android/hardware/usb/UsbDeviceConnection");
field_context = GetFieldIDOrDie(env, clazz, "mNativeContext", "J");
return AndroidRuntime::registerNativeMethods(env, "android/hardware/usb/UsbDeviceConnection",
return RegisterMethodsOrDie(env, "android/hardware/usb/UsbDeviceConnection",
method_table, NELEM(method_table));
}

View File

@@ -20,7 +20,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include <usbhost/usbhost.h>
@@ -215,7 +215,7 @@ int register_android_hardware_UsbRequest(JNIEnv *env)
return -1;
}
return AndroidRuntime::registerNativeMethods(env, "android/hardware/usb/UsbRequest",
return RegisterMethodsOrDie(env, "android/hardware/usb/UsbRequest",
method_table, NELEM(method_table));
}

View File

@@ -16,7 +16,6 @@
*/
// #define LOG_NDEBUG 0
// #define LOG_NNDEBUG 0
#define LOG_TAG "CameraMetadata-JNI"
#include <utils/Errors.h>
#include <utils/Log.h>
@@ -29,7 +28,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include "android_os_Parcel.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include "android_runtime/android_hardware_camera2_CameraMetadata.h"
#include <binder/IServiceManager.h>
@@ -42,13 +41,7 @@
#include <sys/types.h> // for socketpair
#include <sys/socket.h> // for socketpair
#if defined(LOG_NNDEBUG)
#if !LOG_NNDEBUG
#define ALOGVV ALOGV
#endif
#else
#define ALOGVV(...)
#endif
static const bool kIsDebug = false;
// fully-qualified class name
#define CAMERA_METADATA_CLASS_NAME "android/hardware/camera2/impl/CameraMetadataNative"
@@ -596,7 +589,7 @@ static int find_fields(JNIEnv *env, field *fields, int count)
int register_android_hardware_camera2_CameraMetadata(JNIEnv *env)
{
// Register native functions
return AndroidRuntime::registerNativeMethods(env,
return RegisterMethodsOrDie(env,
CAMERA_METADATA_CLASS_NAME,
gCameraMetadataMethods,
NELEM(gCameraMetadataMethods));
@@ -650,12 +643,15 @@ static jint CameraMetadata_getTagFromKey(JNIEnv *env, jobject thiz, jstring keyN
const char *str = (i < ANDROID_SECTION_COUNT) ? camera_metadata_section_names[i] :
vendorSections[i - ANDROID_SECTION_COUNT].string();
ALOGVV("%s: Trying to match against section '%s'",
__FUNCTION__, str);
if (kIsDebug) {
ALOGV("%s: Trying to match against section '%s'", __FUNCTION__, str);
}
if (strstr(key, str) == key) { // key begins with the section name
size_t strLength = strlen(str);
ALOGVV("%s: Key begins with section name", __FUNCTION__);
if (kIsDebug) {
ALOGV("%s: Key begins with section name", __FUNCTION__);
}
// section name is the longest we've found so far
if (section == NULL || sectionLength < strLength) {
@@ -663,7 +659,9 @@ static jint CameraMetadata_getTagFromKey(JNIEnv *env, jobject thiz, jstring keyN
sectionIndex = i;
sectionLength = strLength;
ALOGVV("%s: Found new best section (%s)", __FUNCTION__, section);
if (kIsDebug) {
ALOGV("%s: Found new best section (%s)", __FUNCTION__, section);
}
}
}
}

View File

@@ -36,7 +36,7 @@
#include <img_utils/Input.h>
#include <img_utils/StripSource.h>
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include "android_runtime/android_hardware_camera2_CameraMetadata.h"
#include <jni.h>
@@ -803,29 +803,20 @@ static TiffWriter* DngCreator_getCreator(JNIEnv* env, jobject thiz) {
static void DngCreator_nativeClassInit(JNIEnv* env, jclass clazz) {
ALOGV("%s:", __FUNCTION__);
gDngCreatorClassInfo.mNativeContext = env->GetFieldID(clazz,
ANDROID_DNGCREATOR_CTX_JNI_ID, "J");
LOG_ALWAYS_FATAL_IF(gDngCreatorClassInfo.mNativeContext == NULL,
"can't find android/hardware/camera2/DngCreator.%s",
ANDROID_DNGCREATOR_CTX_JNI_ID);
gDngCreatorClassInfo.mNativeContext = GetFieldIDOrDie(env,
clazz, ANDROID_DNGCREATOR_CTX_JNI_ID, "J");
jclass outputStreamClazz = env->FindClass("java/io/OutputStream");
LOG_ALWAYS_FATAL_IF(outputStreamClazz == NULL, "Can't find java/io/OutputStream class");
gOutputStreamClassInfo.mWriteMethod = env->GetMethodID(outputStreamClazz, "write", "([BII)V");
LOG_ALWAYS_FATAL_IF(gOutputStreamClassInfo.mWriteMethod == NULL, "Can't find write method");
jclass outputStreamClazz = FindClassOrDie(env, "java/io/OutputStream");
gOutputStreamClassInfo.mWriteMethod = GetMethodIDOrDie(env,
outputStreamClazz, "write", "([BII)V");
jclass inputStreamClazz = env->FindClass("java/io/InputStream");
LOG_ALWAYS_FATAL_IF(inputStreamClazz == NULL, "Can't find java/io/InputStream class");
gInputStreamClassInfo.mReadMethod = env->GetMethodID(inputStreamClazz, "read", "([BII)I");
LOG_ALWAYS_FATAL_IF(gInputStreamClassInfo.mReadMethod == NULL, "Can't find read method");
gInputStreamClassInfo.mSkipMethod = env->GetMethodID(inputStreamClazz, "skip", "(J)J");
LOG_ALWAYS_FATAL_IF(gInputStreamClassInfo.mSkipMethod == NULL, "Can't find skip method");
jclass inputStreamClazz = FindClassOrDie(env, "java/io/InputStream");
gInputStreamClassInfo.mReadMethod = GetMethodIDOrDie(env, inputStreamClazz, "read", "([BII)I");
gInputStreamClassInfo.mSkipMethod = GetMethodIDOrDie(env, inputStreamClazz, "skip", "(J)J");
jclass inputBufferClazz = env->FindClass("java/nio/ByteBuffer");
LOG_ALWAYS_FATAL_IF(inputBufferClazz == NULL, "Can't find java/nio/ByteBuffer class");
gInputByteBufferClassInfo.mGetMethod = env->GetMethodID(inputBufferClazz, "get",
"([BII)Ljava/nio/ByteBuffer;");
LOG_ALWAYS_FATAL_IF(gInputByteBufferClassInfo.mGetMethod == NULL, "Can't find get method");
jclass inputBufferClazz = FindClassOrDie(env, "java/nio/ByteBuffer");
gInputByteBufferClassInfo.mGetMethod = GetMethodIDOrDie(env,
inputBufferClazz, "get", "([BII)Ljava/nio/ByteBuffer;");
}
static void DngCreator_init(JNIEnv* env, jobject thiz, jobject characteristicsPtr,
@@ -1985,7 +1976,6 @@ static JNINativeMethod gDngCreatorMethods[] = {
};
int register_android_hardware_camera2_DngCreator(JNIEnv *env) {
return AndroidRuntime::registerNativeMethods(env,
"android/hardware/camera2/DngCreator", gDngCreatorMethods,
NELEM(gDngCreatorMethods));
return RegisterMethodsOrDie(env,
"android/hardware/camera2/DngCreator", gDngCreatorMethods, NELEM(gDngCreatorMethods));
}

View File

@@ -23,7 +23,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include "android_runtime/android_view_Surface.h"
#include "android_runtime/android_graphics_SurfaceTexture.h"
@@ -719,7 +719,7 @@ static JNINativeMethod gCameraDeviceMethods[] = {
int register_android_hardware_camera2_legacy_LegacyCameraDevice(JNIEnv* env)
{
// Register native functions
return AndroidRuntime::registerNativeMethods(env,
return RegisterMethodsOrDie(env,
CAMERA_DEVICE_CLASS_NAME,
gCameraDeviceMethods,
NELEM(gCameraDeviceMethods));

View File

@@ -22,7 +22,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include <ui/GraphicBuffer.h>
#include <system/window.h>
@@ -328,7 +328,7 @@ static JNINativeMethod gPerfMeasurementMethods[] = {
int register_android_hardware_camera2_legacy_PerfMeasurement(JNIEnv* env)
{
// Register native functions
return AndroidRuntime::registerNativeMethods(env,
return RegisterMethodsOrDie(env,
PERF_MEASUREMENT_CLASS_NAME,
gPerfMeasurementMethods,
NELEM(gPerfMeasurementMethods));

View File

@@ -21,7 +21,7 @@
#include <inttypes.h>
#include <jni.h>
#include <JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <utils/Log.h>
#include <media/AudioRecord.h>
@@ -605,59 +605,28 @@ int register_android_media_AudioRecord(JNIEnv *env)
// Get the AudioRecord class
jclass audioRecordClass = env->FindClass(kClassPathName);
if (audioRecordClass == NULL) {
ALOGE("Can't find %s", kClassPathName);
return -1;
}
jclass audioRecordClass = FindClassOrDie(env, kClassPathName);
// Get the postEvent method
javaAudioRecordFields.postNativeEventInJava = env->GetStaticMethodID(
audioRecordClass,
JAVA_POSTEVENT_CALLBACK_NAME, "(Ljava/lang/Object;IIILjava/lang/Object;)V");
if (javaAudioRecordFields.postNativeEventInJava == NULL) {
ALOGE("Can't find AudioRecord.%s", JAVA_POSTEVENT_CALLBACK_NAME);
return -1;
}
javaAudioRecordFields.postNativeEventInJava = GetStaticMethodIDOrDie(env,
audioRecordClass, JAVA_POSTEVENT_CALLBACK_NAME,
"(Ljava/lang/Object;IIILjava/lang/Object;)V");
// Get the variables
// mNativeRecorderInJavaObj
javaAudioRecordFields.nativeRecorderInJavaObj =
env->GetFieldID(audioRecordClass,
JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME, "J");
if (javaAudioRecordFields.nativeRecorderInJavaObj == NULL) {
ALOGE("Can't find AudioRecord.%s", JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME);
return -1;
}
javaAudioRecordFields.nativeRecorderInJavaObj = GetFieldIDOrDie(env,
audioRecordClass, JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME, "J");
// mNativeCallbackCookie
javaAudioRecordFields.nativeCallbackCookie = env->GetFieldID(
audioRecordClass,
JAVA_NATIVECALLBACKINFO_FIELD_NAME, "J");
if (javaAudioRecordFields.nativeCallbackCookie == NULL) {
ALOGE("Can't find AudioRecord.%s", JAVA_NATIVECALLBACKINFO_FIELD_NAME);
return -1;
}
javaAudioRecordFields.nativeCallbackCookie = GetFieldIDOrDie(env,
audioRecordClass, JAVA_NATIVECALLBACKINFO_FIELD_NAME, "J");
// Get the AudioAttributes class and fields
jclass audioAttrClass = env->FindClass(kAudioAttributesClassPathName);
if (audioAttrClass == NULL) {
ALOGE("Can't find %s", kAudioAttributesClassPathName);
return -1;
}
jclass audioAttributesClassRef = (jclass)env->NewGlobalRef(audioAttrClass);
javaAudioAttrFields.fieldRecSource = env->GetFieldID(audioAttributesClassRef, "mSource", "I");
javaAudioAttrFields.fieldFlags = env->GetFieldID(audioAttributesClassRef, "mFlags", "I");
javaAudioAttrFields.fieldFormattedTags =
env->GetFieldID(audioAttributesClassRef, "mFormattedTags", "Ljava/lang/String;");
env->DeleteGlobalRef(audioAttributesClassRef);
if (javaAudioAttrFields.fieldRecSource == NULL
|| javaAudioAttrFields.fieldFlags == NULL
|| javaAudioAttrFields.fieldFormattedTags == NULL) {
ALOGE("Can't initialize AudioAttributes fields");
return -1;
}
jclass audioAttrClass = FindClassOrDie(env, kAudioAttributesClassPathName);
javaAudioAttrFields.fieldRecSource = GetFieldIDOrDie(env, audioAttrClass, "mSource", "I");
javaAudioAttrFields.fieldFlags = GetFieldIDOrDie(env, audioAttrClass, "mFlags", "I");
javaAudioAttrFields.fieldFormattedTags = GetFieldIDOrDie(env,
audioAttrClass, "mFormattedTags", "Ljava/lang/String;");
return AndroidRuntime::registerNativeMethods(env,
kClassPathName, gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
}
// ----------------------------------------------------------------------------

View File

@@ -22,7 +22,7 @@
#include <jni.h>
#include <JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <media/AudioSystem.h>
@@ -1357,99 +1357,94 @@ static JNINativeMethod gEventHandlerMethods[] = {
int register_android_media_AudioSystem(JNIEnv *env)
{
jclass arrayListClass = FindClassOrDie(env, "java/util/ArrayList");
gArrayListClass = MakeGlobalRefOrDie(env, arrayListClass);
gArrayListMethods.add = GetMethodIDOrDie(env, arrayListClass, "add", "(Ljava/lang/Object;)Z");
jclass arrayListClass = env->FindClass("java/util/ArrayList");
gArrayListClass = (jclass) env->NewGlobalRef(arrayListClass);
gArrayListMethods.add = env->GetMethodID(arrayListClass, "add", "(Ljava/lang/Object;)Z");
jclass audioHandleClass = FindClassOrDie(env, "android/media/AudioHandle");
gAudioHandleClass = MakeGlobalRefOrDie(env, audioHandleClass);
gAudioHandleCstor = GetMethodIDOrDie(env, audioHandleClass, "<init>", "(I)V");
gAudioHandleFields.mId = GetFieldIDOrDie(env, audioHandleClass, "mId", "I");
jclass audioHandleClass = env->FindClass("android/media/AudioHandle");
gAudioHandleClass = (jclass) env->NewGlobalRef(audioHandleClass);
gAudioHandleCstor = env->GetMethodID(audioHandleClass, "<init>", "(I)V");
gAudioHandleFields.mId = env->GetFieldID(audioHandleClass, "mId", "I");
jclass audioPortClass = env->FindClass("android/media/AudioPort");
gAudioPortClass = (jclass) env->NewGlobalRef(audioPortClass);
gAudioPortCstor = env->GetMethodID(audioPortClass, "<init>",
"(Landroid/media/AudioHandle;I[I[I[I[Landroid/media/AudioGain;)V");
gAudioPortFields.mHandle = env->GetFieldID(audioPortClass, "mHandle",
jclass audioPortClass = FindClassOrDie(env, "android/media/AudioPort");
gAudioPortClass = MakeGlobalRefOrDie(env, audioPortClass);
gAudioPortCstor = GetMethodIDOrDie(env, audioPortClass, "<init>",
"(Landroid/media/AudioHandle;I[I[I[I[Landroid/media/AudioGain;)V");
gAudioPortFields.mHandle = GetFieldIDOrDie(env, audioPortClass, "mHandle",
"Landroid/media/AudioHandle;");
gAudioPortFields.mRole = env->GetFieldID(audioPortClass, "mRole", "I");
gAudioPortFields.mGains = env->GetFieldID(audioPortClass, "mGains",
gAudioPortFields.mRole = GetFieldIDOrDie(env, audioPortClass, "mRole", "I");
gAudioPortFields.mGains = GetFieldIDOrDie(env, audioPortClass, "mGains",
"[Landroid/media/AudioGain;");
gAudioPortFields.mActiveConfig = env->GetFieldID(audioPortClass, "mActiveConfig",
"Landroid/media/AudioPortConfig;");
gAudioPortFields.mActiveConfig = GetFieldIDOrDie(env, audioPortClass, "mActiveConfig",
"Landroid/media/AudioPortConfig;");
jclass audioPortConfigClass = env->FindClass("android/media/AudioPortConfig");
gAudioPortConfigClass = (jclass) env->NewGlobalRef(audioPortConfigClass);
gAudioPortConfigCstor = env->GetMethodID(audioPortConfigClass, "<init>",
"(Landroid/media/AudioPort;IIILandroid/media/AudioGainConfig;)V");
gAudioPortConfigFields.mPort = env->GetFieldID(audioPortConfigClass, "mPort",
jclass audioPortConfigClass = FindClassOrDie(env, "android/media/AudioPortConfig");
gAudioPortConfigClass = MakeGlobalRefOrDie(env, audioPortConfigClass);
gAudioPortConfigCstor = GetMethodIDOrDie(env, audioPortConfigClass, "<init>",
"(Landroid/media/AudioPort;IIILandroid/media/AudioGainConfig;)V");
gAudioPortConfigFields.mPort = GetFieldIDOrDie(env, audioPortConfigClass, "mPort",
"Landroid/media/AudioPort;");
gAudioPortConfigFields.mSamplingRate = env->GetFieldID(audioPortConfigClass,
gAudioPortConfigFields.mSamplingRate = GetFieldIDOrDie(env, audioPortConfigClass,
"mSamplingRate", "I");
gAudioPortConfigFields.mChannelMask = env->GetFieldID(audioPortConfigClass,
gAudioPortConfigFields.mChannelMask = GetFieldIDOrDie(env, audioPortConfigClass,
"mChannelMask", "I");
gAudioPortConfigFields.mFormat = env->GetFieldID(audioPortConfigClass, "mFormat", "I");
gAudioPortConfigFields.mGain = env->GetFieldID(audioPortConfigClass, "mGain",
gAudioPortConfigFields.mFormat = GetFieldIDOrDie(env, audioPortConfigClass, "mFormat", "I");
gAudioPortConfigFields.mGain = GetFieldIDOrDie(env, audioPortConfigClass, "mGain",
"Landroid/media/AudioGainConfig;");
gAudioPortConfigFields.mConfigMask = env->GetFieldID(audioPortConfigClass, "mConfigMask", "I");
gAudioPortConfigFields.mConfigMask = GetFieldIDOrDie(env, audioPortConfigClass, "mConfigMask",
"I");
jclass audioDevicePortConfigClass = env->FindClass("android/media/AudioDevicePortConfig");
gAudioDevicePortConfigClass = (jclass) env->NewGlobalRef(audioDevicePortConfigClass);
gAudioDevicePortConfigCstor = env->GetMethodID(audioDevicePortConfigClass, "<init>",
"(Landroid/media/AudioDevicePort;IIILandroid/media/AudioGainConfig;)V");
jclass audioDevicePortConfigClass = FindClassOrDie(env, "android/media/AudioDevicePortConfig");
gAudioDevicePortConfigClass = MakeGlobalRefOrDie(env, audioDevicePortConfigClass);
gAudioDevicePortConfigCstor = GetMethodIDOrDie(env, audioDevicePortConfigClass, "<init>",
"(Landroid/media/AudioDevicePort;IIILandroid/media/AudioGainConfig;)V");
jclass audioMixPortConfigClass = env->FindClass("android/media/AudioMixPortConfig");
gAudioMixPortConfigClass = (jclass) env->NewGlobalRef(audioMixPortConfigClass);
gAudioMixPortConfigCstor = env->GetMethodID(audioMixPortConfigClass, "<init>",
"(Landroid/media/AudioMixPort;IIILandroid/media/AudioGainConfig;)V");
jclass audioMixPortConfigClass = FindClassOrDie(env, "android/media/AudioMixPortConfig");
gAudioMixPortConfigClass = MakeGlobalRefOrDie(env, audioMixPortConfigClass);
gAudioMixPortConfigCstor = GetMethodIDOrDie(env, audioMixPortConfigClass, "<init>",
"(Landroid/media/AudioMixPort;IIILandroid/media/AudioGainConfig;)V");
jclass audioDevicePortClass = env->FindClass("android/media/AudioDevicePort");
gAudioDevicePortClass = (jclass) env->NewGlobalRef(audioDevicePortClass);
gAudioDevicePortCstor = env->GetMethodID(audioDevicePortClass, "<init>",
"(Landroid/media/AudioHandle;[I[I[I[Landroid/media/AudioGain;ILjava/lang/String;)V");
jclass audioDevicePortClass = FindClassOrDie(env, "android/media/AudioDevicePort");
gAudioDevicePortClass = MakeGlobalRefOrDie(env, audioDevicePortClass);
gAudioDevicePortCstor = GetMethodIDOrDie(env, audioDevicePortClass, "<init>",
"(Landroid/media/AudioHandle;[I[I[I[Landroid/media/AudioGain;ILjava/lang/String;)V");
jclass audioMixPortClass = env->FindClass("android/media/AudioMixPort");
gAudioMixPortClass = (jclass) env->NewGlobalRef(audioMixPortClass);
gAudioMixPortCstor = env->GetMethodID(audioMixPortClass, "<init>",
"(Landroid/media/AudioHandle;I[I[I[I[Landroid/media/AudioGain;)V");
jclass audioMixPortClass = FindClassOrDie(env, "android/media/AudioMixPort");
gAudioMixPortClass = MakeGlobalRefOrDie(env, audioMixPortClass);
gAudioMixPortCstor = GetMethodIDOrDie(env, audioMixPortClass, "<init>",
"(Landroid/media/AudioHandle;I[I[I[I[Landroid/media/AudioGain;)V");
jclass audioGainClass = env->FindClass("android/media/AudioGain");
gAudioGainClass = (jclass) env->NewGlobalRef(audioGainClass);
gAudioGainCstor = env->GetMethodID(audioGainClass, "<init>", "(IIIIIIIII)V");
jclass audioGainClass = FindClassOrDie(env, "android/media/AudioGain");
gAudioGainClass = MakeGlobalRefOrDie(env, audioGainClass);
gAudioGainCstor = GetMethodIDOrDie(env, audioGainClass, "<init>", "(IIIIIIIII)V");
jclass audioGainConfigClass = env->FindClass("android/media/AudioGainConfig");
gAudioGainConfigClass = (jclass) env->NewGlobalRef(audioGainConfigClass);
gAudioGainConfigCstor = env->GetMethodID(audioGainConfigClass, "<init>",
jclass audioGainConfigClass = FindClassOrDie(env, "android/media/AudioGainConfig");
gAudioGainConfigClass = MakeGlobalRefOrDie(env, audioGainConfigClass);
gAudioGainConfigCstor = GetMethodIDOrDie(env, audioGainConfigClass, "<init>",
"(ILandroid/media/AudioGain;II[II)V");
gAudioGainConfigFields.mIndex = env->GetFieldID(gAudioGainConfigClass, "mIndex", "I");
gAudioGainConfigFields.mMode = env->GetFieldID(audioGainConfigClass, "mMode", "I");
gAudioGainConfigFields.mChannelMask = env->GetFieldID(audioGainConfigClass, "mChannelMask",
gAudioGainConfigFields.mIndex = GetFieldIDOrDie(env, gAudioGainConfigClass, "mIndex", "I");
gAudioGainConfigFields.mMode = GetFieldIDOrDie(env, audioGainConfigClass, "mMode", "I");
gAudioGainConfigFields.mChannelMask = GetFieldIDOrDie(env, audioGainConfigClass, "mChannelMask",
"I");
gAudioGainConfigFields.mValues = env->GetFieldID(audioGainConfigClass, "mValues", "[I");
gAudioGainConfigFields.mRampDurationMs = env->GetFieldID(audioGainConfigClass,
gAudioGainConfigFields.mValues = GetFieldIDOrDie(env, audioGainConfigClass, "mValues", "[I");
gAudioGainConfigFields.mRampDurationMs = GetFieldIDOrDie(env, audioGainConfigClass,
"mRampDurationMs", "I");
jclass audioPatchClass = env->FindClass("android/media/AudioPatch");
gAudioPatchClass = (jclass) env->NewGlobalRef(audioPatchClass);
gAudioPatchCstor = env->GetMethodID(audioPatchClass, "<init>",
jclass audioPatchClass = FindClassOrDie(env, "android/media/AudioPatch");
gAudioPatchClass = MakeGlobalRefOrDie(env, audioPatchClass);
gAudioPatchCstor = GetMethodIDOrDie(env, audioPatchClass, "<init>",
"(Landroid/media/AudioHandle;[Landroid/media/AudioPortConfig;[Landroid/media/AudioPortConfig;)V");
gAudioPatchFields.mHandle = env->GetFieldID(audioPatchClass, "mHandle",
gAudioPatchFields.mHandle = GetFieldIDOrDie(env, audioPatchClass, "mHandle",
"Landroid/media/AudioHandle;");
jclass eventHandlerClass = env->FindClass(kEventHandlerClassPathName);
gPostEventFromNative = env->GetStaticMethodID(eventHandlerClass, "postEventFromNative",
"(Ljava/lang/Object;IIILjava/lang/Object;)V");
jclass eventHandlerClass = FindClassOrDie(env, kEventHandlerClassPathName);
gPostEventFromNative = GetStaticMethodIDOrDie(env, eventHandlerClass, "postEventFromNative",
"(Ljava/lang/Object;IIILjava/lang/Object;)V");
AudioSystem::setErrorCallback(android_media_AudioSystem_error_callback);
int status = AndroidRuntime::registerNativeMethods(env,
kClassPathName, gMethods, NELEM(gMethods));
if (status == 0) {
status = AndroidRuntime::registerNativeMethods(env,
kEventHandlerClassPathName, gEventHandlerMethods, NELEM(gEventHandlerMethods));
}
return status;
RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, kEventHandlerClassPathName, gEventHandlerMethods,
NELEM(gEventHandlerMethods));
}

View File

@@ -19,7 +19,7 @@
#include <JNIHelp.h>
#include <JniConstants.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "ScopedBytes.h"
@@ -1062,68 +1062,34 @@ int register_android_media_AudioTrack(JNIEnv *env)
javaAudioTrackFields.postNativeEventInJava = NULL;
// Get the AudioTrack class
jclass audioTrackClass = env->FindClass(kClassPathName);
if (audioTrackClass == NULL) {
ALOGE("Can't find %s", kClassPathName);
return -1;
}
jclass audioTrackClass = FindClassOrDie(env, kClassPathName);
// Get the postEvent method
javaAudioTrackFields.postNativeEventInJava = env->GetStaticMethodID(
audioTrackClass,
JAVA_POSTEVENT_CALLBACK_NAME, "(Ljava/lang/Object;IIILjava/lang/Object;)V");
if (javaAudioTrackFields.postNativeEventInJava == NULL) {
ALOGE("Can't find AudioTrack.%s", JAVA_POSTEVENT_CALLBACK_NAME);
return -1;
}
javaAudioTrackFields.postNativeEventInJava = GetStaticMethodIDOrDie(env,
audioTrackClass, JAVA_POSTEVENT_CALLBACK_NAME,
"(Ljava/lang/Object;IIILjava/lang/Object;)V");
// Get the variables fields
// nativeTrackInJavaObj
javaAudioTrackFields.nativeTrackInJavaObj = env->GetFieldID(
audioTrackClass,
JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME, "J");
if (javaAudioTrackFields.nativeTrackInJavaObj == NULL) {
ALOGE("Can't find AudioTrack.%s", JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME);
return -1;
}
javaAudioTrackFields.nativeTrackInJavaObj = GetFieldIDOrDie(env,
audioTrackClass, JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME, "J");
// jniData
javaAudioTrackFields.jniData = env->GetFieldID(
audioTrackClass,
JAVA_JNIDATA_FIELD_NAME, "J");
if (javaAudioTrackFields.jniData == NULL) {
ALOGE("Can't find AudioTrack.%s", JAVA_JNIDATA_FIELD_NAME);
return -1;
}
javaAudioTrackFields.jniData = GetFieldIDOrDie(env,
audioTrackClass, JAVA_JNIDATA_FIELD_NAME, "J");
// fieldStreamType
javaAudioTrackFields.fieldStreamType = env->GetFieldID(audioTrackClass,
JAVA_STREAMTYPE_FIELD_NAME, "I");
if (javaAudioTrackFields.fieldStreamType == NULL) {
ALOGE("Can't find AudioTrack.%s", JAVA_STREAMTYPE_FIELD_NAME);
return -1;
}
javaAudioTrackFields.fieldStreamType = GetFieldIDOrDie(env,
audioTrackClass, JAVA_STREAMTYPE_FIELD_NAME, "I");
// Get the AudioAttributes class and fields
jclass audioAttrClass = env->FindClass(kAudioAttributesClassPathName);
if (audioAttrClass == NULL) {
ALOGE("Can't find %s", kAudioAttributesClassPathName);
return -1;
}
jclass audioAttributesClassRef = (jclass)env->NewGlobalRef(audioAttrClass);
javaAudioAttrFields.fieldUsage = env->GetFieldID(audioAttributesClassRef, "mUsage", "I");
javaAudioAttrFields.fieldContentType
= env->GetFieldID(audioAttributesClassRef, "mContentType", "I");
javaAudioAttrFields.fieldFlags = env->GetFieldID(audioAttributesClassRef, "mFlags", "I");
javaAudioAttrFields.fieldFormattedTags =
env->GetFieldID(audioAttributesClassRef, "mFormattedTags", "Ljava/lang/String;");
env->DeleteGlobalRef(audioAttributesClassRef);
if (javaAudioAttrFields.fieldUsage == NULL || javaAudioAttrFields.fieldContentType == NULL
|| javaAudioAttrFields.fieldFlags == NULL
|| javaAudioAttrFields.fieldFormattedTags == NULL) {
ALOGE("Can't initialize AudioAttributes fields");
return -1;
}
jclass audioAttrClass = FindClassOrDie(env, kAudioAttributesClassPathName);
javaAudioAttrFields.fieldUsage = GetFieldIDOrDie(env, audioAttrClass, "mUsage", "I");
javaAudioAttrFields.fieldContentType = GetFieldIDOrDie(env,
audioAttrClass, "mContentType", "I");
javaAudioAttrFields.fieldFlags = GetFieldIDOrDie(env, audioAttrClass, "mFlags", "I");
javaAudioAttrFields.fieldFormattedTags = GetFieldIDOrDie(env,
audioAttrClass, "mFormattedTags", "Ljava/lang/String;");
return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
}

View File

@@ -24,7 +24,7 @@
#include <jni.h>
#include <JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <utils/Log.h>
#include <media/JetPlayer.h>
@@ -517,36 +517,22 @@ static JNINativeMethod gMethods[] = {
int register_android_media_JetPlayer(JNIEnv *env)
{
jclass jetPlayerClass = NULL;
javaJetPlayerFields.jetClass = NULL;
javaJetPlayerFields.postNativeEventInJava = NULL;
javaJetPlayerFields.nativePlayerInJavaObj = NULL;
// Get the JetPlayer java class
jetPlayerClass = env->FindClass(kClassPathName);
if (jetPlayerClass == NULL) {
ALOGE("Can't find %s", kClassPathName);
return -1;
}
javaJetPlayerFields.jetClass = (jclass)env->NewGlobalRef(jetPlayerClass);
jclass jetPlayerClass = FindClassOrDie(env, kClassPathName);
javaJetPlayerFields.jetClass = MakeGlobalRefOrDie(env, jetPlayerClass);
// Get the mNativePlayerInJavaObj variable field
javaJetPlayerFields.nativePlayerInJavaObj = env->GetFieldID(
jetPlayerClass,
JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME, "J");
if (javaJetPlayerFields.nativePlayerInJavaObj == NULL) {
ALOGE("Can't find JetPlayer.%s", JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME);
return -1;
}
javaJetPlayerFields.nativePlayerInJavaObj = GetFieldIDOrDie(env,
jetPlayerClass, JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME, "J");
// Get the callback to post events from this native code to Java
javaJetPlayerFields.postNativeEventInJava = env->GetStaticMethodID(javaJetPlayerFields.jetClass,
JAVA_NATIVEJETPOSTEVENT_CALLBACK_NAME, "(Ljava/lang/Object;III)V");
if (javaJetPlayerFields.postNativeEventInJava == NULL) {
ALOGE("Can't find Jet.%s", JAVA_NATIVEJETPOSTEVENT_CALLBACK_NAME);
return -1;
}
javaJetPlayerFields.postNativeEventInJava = GetStaticMethodIDOrDie(env,
javaJetPlayerFields.jetClass, JAVA_NATIVEJETPOSTEVENT_CALLBACK_NAME,
"(Ljava/lang/Object;III)V");
return AndroidRuntime::registerNativeMethods(env,
kClassPathName, gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
}

View File

@@ -22,7 +22,7 @@
#include "android_os_Parcel.h"
#include "android_util_Binder.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/Log.h>
@@ -188,17 +188,15 @@ static JNINativeMethod gMethods[] = {
int register_android_media_RemoteDisplay(JNIEnv* env)
{
int err = AndroidRuntime::registerNativeMethods(env, "android/media/RemoteDisplay",
gMethods, NELEM(gMethods));
int err = RegisterMethodsOrDie(env, "android/media/RemoteDisplay", gMethods, NELEM(gMethods));
jclass clazz = env->FindClass("android/media/RemoteDisplay");
gRemoteDisplayClassInfo.notifyDisplayConnected =
env->GetMethodID(clazz, "notifyDisplayConnected",
"(Landroid/view/Surface;IIII)V");
gRemoteDisplayClassInfo.notifyDisplayDisconnected =
env->GetMethodID(clazz, "notifyDisplayDisconnected", "()V");
gRemoteDisplayClassInfo.notifyDisplayError =
env->GetMethodID(clazz, "notifyDisplayError", "(I)V");
jclass clazz = FindClassOrDie(env, "android/media/RemoteDisplay");
gRemoteDisplayClassInfo.notifyDisplayConnected = GetMethodIDOrDie(env,
clazz, "notifyDisplayConnected", "(Landroid/view/Surface;IIII)V");
gRemoteDisplayClassInfo.notifyDisplayDisconnected = GetMethodIDOrDie(env,
clazz, "notifyDisplayDisconnected", "()V");
gRemoteDisplayClassInfo.notifyDisplayError = GetMethodIDOrDie(env,
clazz, "notifyDisplayError", "(I)V");
return err;
}

View File

@@ -23,7 +23,7 @@
#include <jni.h>
#include <JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <utils/Log.h>
#include <media/AudioSystem.h>
@@ -134,21 +134,10 @@ static JNINativeMethod gMethods[] = {
int register_android_media_ToneGenerator(JNIEnv *env) {
jclass clazz;
jclass clazz = FindClassOrDie(env, "android/media/ToneGenerator");
clazz = env->FindClass("android/media/ToneGenerator");
if (clazz == NULL) {
ALOGE("Can't find %s", "android/media/ToneGenerator");
return -1;
}
fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
if (fields.context == NULL) {
ALOGE("Can't find ToneGenerator.mNativeContext");
return -1;
}
fields.context = GetFieldIDOrDie(env, clazz, "mNativeContext", "J");
ALOGV("register_android_media_ToneGenerator ToneGenerator fields.context: %p", fields.context);
return AndroidRuntime::registerNativeMethods(env,
"android/media/ToneGenerator", gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, "android/media/ToneGenerator", gMethods, NELEM(gMethods));
}

View File

@@ -23,7 +23,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <jni.h>
#include <ScopedUtfChars.h>
#include <utils/misc.h>
@@ -192,8 +192,7 @@ static JNINativeMethod gMethods[] = {
};
int register_android_net_TrafficStats(JNIEnv* env) {
return AndroidRuntime::registerNativeMethods(env, "android/net/TrafficStats",
gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, "android/net/TrafficStats", gMethods, NELEM(gMethods));
}
}

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef android_nio_utils_DEFINED
#define android_nio_utils_DEFINED
#ifndef _ANDROID_NIO_UTILS_H_
#define _ANDROID_NIO_UTILS_H_
#include <android_runtime/AndroidRuntime.h>
@@ -70,4 +70,4 @@ private:
} /* namespace android */
#endif
#endif // _ANDROID_NIO_UTILS_H_

View File

@@ -18,7 +18,7 @@
#include <utils/Log.h>
#include <cutils/ashmem.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "JNIHelp.h"
#include <unistd.h>
#include <sys/mman.h>
@@ -151,9 +151,7 @@ static const JNINativeMethod methods[] = {
int register_android_os_MemoryFile(JNIEnv* env)
{
return AndroidRuntime::registerNativeMethods(
env, "android/os/MemoryFile",
methods, NELEM(methods));
return RegisterMethodsOrDie(env, "android/os/MemoryFile", methods, NELEM(methods));
}
}

View File

@@ -19,7 +19,7 @@
#include "JNIHelp.h"
#include "jni.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include "selinux/selinux.h"
#include "selinux/android.h"
#include <errno.h>
@@ -469,8 +469,7 @@ int register_android_os_SELinux(JNIEnv *env) {
isSELinuxDisabled = (is_selinux_enabled() != 1) ? true : false;
return AndroidRuntime::registerNativeMethods(env, "android/os/SELinux", method_table,
NELEM(method_table));
return RegisterMethodsOrDie(env, "android/os/SELinux", method_table, NELEM(method_table));
}
}

View File

@@ -27,7 +27,7 @@
#include "JNIHelp.h"
#include "jni.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include <sys/time.h>
#include <time.h>
@@ -135,8 +135,7 @@ static JNINativeMethod gMethods[] = {
};
int register_android_os_SystemClock(JNIEnv* env)
{
return AndroidRuntime::registerNativeMethods(env,
"android/os/SystemClock", gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, "android/os/SystemClock", gMethods, NELEM(gMethods));
}
}; // namespace android

View File

@@ -21,7 +21,7 @@
#include "utils/misc.h"
#include <utils/Log.h>
#include "jni.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include <nativehelper/JNIHelp.h>
namespace android
@@ -239,9 +239,8 @@ static JNINativeMethod method_table[] = {
int register_android_os_SystemProperties(JNIEnv *env)
{
return AndroidRuntime::registerNativeMethods(
env, "android/os/SystemProperties",
method_table, NELEM(method_table));
return RegisterMethodsOrDie(env, "android/os/SystemProperties", method_table,
NELEM(method_table));
}
};

View File

@@ -22,7 +22,7 @@
#include "hardware_legacy/uevent.h"
#include "jni.h"
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include <utils/Mutex.h>
#include <utils/Vector.h>
@@ -117,16 +117,9 @@ static JNINativeMethod gMethods[] = {
int register_android_os_UEventObserver(JNIEnv *env)
{
jclass clazz;
FindClassOrDie(env, "android/os/UEventObserver");
clazz = env->FindClass("android/os/UEventObserver");
if (clazz == NULL) {
ALOGE("Can't find android/os/UEventObserver");
return -1;
}
return AndroidRuntime::registerNativeMethods(env,
"android/os/UEventObserver", gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, "android/os/UEventObserver", gMethods, NELEM(gMethods));
}
} // namespace android

View File

@@ -26,7 +26,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
static void dumpOneStack(int tid, int outFd) {
char buf[64];
@@ -106,8 +106,7 @@ static const JNINativeMethod g_methods[] = {
};
int register_android_server_Watchdog(JNIEnv* env) {
return AndroidRuntime::registerNativeMethods(env, "com/android/server/Watchdog",
g_methods, NELEM(g_methods));
return RegisterMethodsOrDie(env, "com/android/server/Watchdog", g_methods, NELEM(g_methods));
}
}

View File

@@ -18,7 +18,7 @@
#define LOG_TAG "AndroidUnicode"
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "utils/misc.h"
#include "utils/Log.h"
#include "unicode/ubidi.h"
@@ -57,14 +57,12 @@ static jint runBidi(JNIEnv* env, jobject obj, jint dir, jcharArray chsArray,
}
static JNINativeMethod gMethods[] = {
{ "runBidi", "(I[C[BIZ)I",
(void*) runBidi }
{ "runBidi", "(I[C[BIZ)I", (void*) runBidi }
};
int register_android_text_AndroidBidi(JNIEnv* env)
{
return AndroidRuntime::registerNativeMethods(env, "android/text/AndroidBidi",
gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, "android/text/AndroidBidi", gMethods, NELEM(gMethods));
}
}

View File

@@ -19,7 +19,7 @@
#include "JNIHelp.h"
#include "ScopedPrimitiveArray.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "utils/misc.h"
#include "utils/Log.h"
#include "unicode/uchar.h"
@@ -193,8 +193,7 @@ static JNINativeMethod gMethods[] = {
int register_android_text_AndroidCharacter(JNIEnv* env)
{
return AndroidRuntime::registerNativeMethods(env, "android/text/AndroidCharacter",
gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, "android/text/AndroidCharacter", gMethods, NELEM(gMethods));
}
}

View File

@@ -23,7 +23,7 @@
#include "utils/Log.h"
#include "ScopedPrimitiveArray.h"
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <vector>
namespace android {
@@ -103,8 +103,7 @@ static JNINativeMethod gMethods[] = {
int register_android_text_StaticLayout(JNIEnv* env)
{
return AndroidRuntime::registerNativeMethods(env, "android/text/StaticLayout",
gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, "android/text/StaticLayout", gMethods, NELEM(gMethods));
}
}

View File

@@ -46,8 +46,6 @@
#include <ScopedUtfChars.h>
#include <ScopedLocalRef.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
//#undef ALOGV
@@ -834,7 +832,7 @@ static int int_register_android_os_Binder(JNIEnv* env)
gBinderOffsets.mExecTransact = GetMethodIDOrDie(env, clazz, "execTransact", "(IJJI)Z");
gBinderOffsets.mObject = GetFieldIDOrDie(env, clazz, "mObject", "J");
return AndroidRuntime::registerNativeMethods(
return RegisterMethodsOrDie(
env, kBinderPathName,
gBinderMethods, NELEM(gBinderMethods));
}
@@ -909,7 +907,7 @@ static int int_register_android_os_BinderInternal(JNIEnv* env)
gBinderInternalOffsets.mClass = MakeGlobalRefOrDie(env, clazz);
gBinderInternalOffsets.mForceGc = GetStaticMethodIDOrDie(env, clazz, "forceBinderGc", "()V");
return AndroidRuntime::registerNativeMethods(
return RegisterMethodsOrDie(
env, kBinderInternalPathName,
gBinderInternalMethods, NELEM(gBinderInternalMethods));
}
@@ -1240,7 +1238,7 @@ static int int_register_android_os_BinderProxy(JNIEnv* env)
clazz = FindClassOrDie(env, "java/lang/Class");
gClassOffsets.mGetName = GetMethodIDOrDie(env, clazz, "getName", "()Ljava/lang/String;");
return AndroidRuntime::registerNativeMethods(
return RegisterMethodsOrDie(
env, kBinderProxyPathName,
gBinderProxyMethods, NELEM(gBinderProxyMethods));
}

View File

@@ -17,7 +17,7 @@
#include <fcntl.h>
#include "JNIHelp.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include "jni.h"
#include "log/logger.h"
@@ -263,33 +263,21 @@ static struct { jclass *c; const char *name, *mt; jmethodID *id; } gMethods[] =
int register_android_util_EventLog(JNIEnv* env) {
for (int i = 0; i < NELEM(gClasses); ++i) {
jclass clazz = env->FindClass(gClasses[i].name);
if (clazz == NULL) {
ALOGE("Can't find class: %s\n", gClasses[i].name);
return -1;
}
*gClasses[i].clazz = (jclass) env->NewGlobalRef(clazz);
jclass clazz = FindClassOrDie(env, gClasses[i].name);
*gClasses[i].clazz = MakeGlobalRefOrDie(env, clazz);
}
for (int i = 0; i < NELEM(gFields); ++i) {
*gFields[i].id = env->GetFieldID(
*gFields[i].id = GetFieldIDOrDie(env,
*gFields[i].c, gFields[i].name, gFields[i].ft);
if (*gFields[i].id == NULL) {
ALOGE("Can't find field: %s\n", gFields[i].name);
return -1;
}
}
for (int i = 0; i < NELEM(gMethods); ++i) {
*gMethods[i].id = env->GetMethodID(
*gMethods[i].id = GetMethodIDOrDie(env,
*gMethods[i].c, gMethods[i].name, gMethods[i].mt);
if (*gMethods[i].id == NULL) {
ALOGE("Can't find method: %s\n", gMethods[i].name);
return -1;
}
}
return AndroidRuntime::registerNativeMethods(
return RegisterMethodsOrDie(
env,
"android/util/EventLog",
gRegisterMethods, NELEM(gRegisterMethods));

View File

@@ -19,7 +19,7 @@
#include "jni.h"
#include "utils/Log.h"
#include "utils/misc.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include <stdio.h>
#include <stdlib.h>
@@ -138,24 +138,12 @@ static JNINativeMethod sMethods[] = {
int register_android_os_FileObserver(JNIEnv* env)
{
jclass clazz;
jclass clazz = FindClassOrDie(env, "android/os/FileObserver$ObserverThread");
clazz = env->FindClass("android/os/FileObserver$ObserverThread");
method_onEvent = GetMethodIDOrDie(env, clazz, "onEvent", "(IILjava/lang/String;)V");
if (clazz == NULL)
{
ALOGE("Can't find android/os/FileObserver$ObserverThread");
return -1;
}
method_onEvent = env->GetMethodID(clazz, "onEvent", "(IILjava/lang/String;)V");
if (method_onEvent == NULL)
{
ALOGE("Can't find FileObserver.onEvent(int, int, String)");
return -1;
}
return AndroidRuntime::registerNativeMethods(env, "android/os/FileObserver$ObserverThread", sMethods, NELEM(sMethods));
return RegisterMethodsOrDie(env, "android/os/FileObserver$ObserverThread", sMethods,
NELEM(sMethods));
}
} /* namespace android */

View File

@@ -26,11 +26,9 @@
#include "jni.h"
#include "JNIHelp.h"
#include "utils/misc.h"
#include "android_runtime/AndroidRuntime.h"
#include "core_jni_helpers.h"
#include "android_util_Log.h"
#define MIN(a,b) ((a<b)?a:b)
namespace android {
struct levels_t {
@@ -145,21 +143,16 @@ static JNINativeMethod gMethods[] = {
int register_android_util_Log(JNIEnv* env)
{
jclass clazz = env->FindClass("android/util/Log");
jclass clazz = FindClassOrDie(env, "android/util/Log");
if (clazz == NULL) {
ALOGE("Can't find android/util/Log");
return -1;
}
levels.verbose = env->GetStaticIntField(clazz, GetStaticFieldIDOrDie(env, clazz, "VERBOSE", "I"));
levels.debug = env->GetStaticIntField(clazz, GetStaticFieldIDOrDie(env, clazz, "DEBUG", "I"));
levels.info = env->GetStaticIntField(clazz, GetStaticFieldIDOrDie(env, clazz, "INFO", "I"));
levels.warn = env->GetStaticIntField(clazz, GetStaticFieldIDOrDie(env, clazz, "WARN", "I"));
levels.error = env->GetStaticIntField(clazz, GetStaticFieldIDOrDie(env, clazz, "ERROR", "I"));
levels.assert = env->GetStaticIntField(clazz, GetStaticFieldIDOrDie(env, clazz, "ASSERT", "I"));
levels.verbose = env->GetStaticIntField(clazz, env->GetStaticFieldID(clazz, "VERBOSE", "I"));
levels.debug = env->GetStaticIntField(clazz, env->GetStaticFieldID(clazz, "DEBUG", "I"));
levels.info = env->GetStaticIntField(clazz, env->GetStaticFieldID(clazz, "INFO", "I"));
levels.warn = env->GetStaticIntField(clazz, env->GetStaticFieldID(clazz, "WARN", "I"));
levels.error = env->GetStaticIntField(clazz, env->GetStaticFieldID(clazz, "ERROR", "I"));
levels.assert = env->GetStaticIntField(clazz, env->GetStaticFieldID(clazz, "ASSERT", "I"));
return AndroidRuntime::registerNativeMethods(env, "android/util/Log", gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, "android/util/Log", gMethods, NELEM(gMethods));
}
}; // namespace android

View File

@@ -26,7 +26,7 @@
#include <utils/Vector.h>
#include <processgroup/processgroup.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include "android_util_Binder.h"
#include "JNIHelp.h"
@@ -1054,11 +1054,7 @@ static const JNINativeMethod methods[] = {
{"removeAllProcessGroups", "()V", (void*)android_os_Process_removeAllProcessGroups},
};
const char* const kProcessPathName = "android/os/Process";
int register_android_os_Process(JNIEnv* env)
{
return AndroidRuntime::registerNativeMethods(
env, kProcessPathName,
methods, NELEM(methods));
return RegisterMethodsOrDie(env, "android/os/Process", methods, NELEM(methods));
}

View File

@@ -20,7 +20,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include <utils/misc.h>
#include <android_runtime/AndroidRuntime.h>
#include <core_jni_helpers.h>
#include <utils/Log.h>
#include <androidfw/ResourceTypes.h>
@@ -171,7 +171,7 @@ static JNINativeMethod gStringBlockMethods[] = {
int register_android_content_StringBlock(JNIEnv* env)
{
return AndroidRuntime::registerNativeMethods(env,
return RegisterMethodsOrDie(env,
"android/content/res/StringBlock", gStringBlockMethods, NELEM(gStringBlockMethods));
}

View File

@@ -19,7 +19,7 @@
#include "jni.h"
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
#include <core_jni_helpers.h>
#include <androidfw/AssetManager.h>
#include <androidfw/ResourceTypes.h>
#include <utils/Log.h>
@@ -412,7 +412,7 @@ static JNINativeMethod gXmlBlockMethods[] = {
int register_android_content_XmlBlock(JNIEnv* env)
{
return AndroidRuntime::registerNativeMethods(env,
return RegisterMethodsOrDie(env,
"android/content/res/XmlBlock", gXmlBlockMethods, NELEM(gXmlBlockMethods));
}

View File

@@ -52,6 +52,10 @@ namespace android {
using namespace uirenderer;
static struct {
jmethodID set;
} gRectClassInfo;
/**
* Note: DisplayListRenderer JNI layer is generated and compiled only on supported
* devices. This means all the logic must be compiled only when the
@@ -63,21 +67,7 @@ using namespace uirenderer;
// Defines
// ----------------------------------------------------------------------------
// Debug
#define DEBUG_RENDERER 0
// Debug
#if DEBUG_RENDERER
#define RENDERER_LOGD(...) ALOGD(__VA_ARGS__)
#else
#define RENDERER_LOGD(...)
#endif
// ----------------------------------------------------------------------------
static struct {
jmethodID set;
} gRectClassInfo;
static const bool kDebugRenderer = false;
// ----------------------------------------------------------------------------
// Constructors
@@ -86,7 +76,9 @@ static struct {
static void android_view_GLES20Canvas_destroyRenderer(JNIEnv* env, jobject clazz,
jlong rendererPtr) {
DisplayListRenderer* renderer = reinterpret_cast<DisplayListRenderer*>(rendererPtr);
RENDERER_LOGD("Destroy DisplayListRenderer");
if (kDebugRenderer) {
ALOGD("Destroy DisplayListRenderer");
}
delete renderer;
}
@@ -835,24 +827,30 @@ static void android_view_GLES20Canvas_drawLayer(JNIEnv* env, jobject clazz,
#endif // USE_OPENGL_RENDERER
#ifdef USE_OPENGL_RENDERER
static const bool kUseOpenGLRenderer = true;
#else
static const bool kUseOpenGLRenderer = false;
#endif
// ----------------------------------------------------------------------------
// Common
// ----------------------------------------------------------------------------
static jboolean android_view_GLES20Canvas_isAvailable(JNIEnv* env, jobject clazz) {
#ifdef USE_OPENGL_RENDERER
char prop[PROPERTY_VALUE_MAX];
if (property_get("ro.kernel.qemu", prop, NULL) == 0) {
// not in the emulator
return JNI_TRUE;
if (kUseOpenGLRenderer) {
char prop[PROPERTY_VALUE_MAX];
if (property_get("ro.kernel.qemu", prop, NULL) == 0) {
// not in the emulator
return JNI_TRUE;
}
// In the emulator this property will be set to 1 when hardware GLES is
// enabled, 0 otherwise. On old emulator versions it will be undefined.
property_get("ro.kernel.qemu.gles", prop, "0");
return atoi(prop) == 1 ? JNI_TRUE : JNI_FALSE;
} else {
return JNI_FALSE;
}
// In the emulator this property will be set to 1 when hardware GLES is
// enabled, 0 otherwise. On old emulator versions it will be undefined.
property_get("ro.kernel.qemu.gles", prop, "0");
return atoi(prop) == 1 ? JNI_TRUE : JNI_FALSE;
#else
return JNI_FALSE;
#endif
}
// ----------------------------------------------------------------------------
@@ -861,10 +859,10 @@ static jboolean android_view_GLES20Canvas_isAvailable(JNIEnv* env, jobject clazz
static void
android_app_ActivityThread_dumpGraphics(JNIEnv* env, jobject clazz, jobject javaFileDescriptor) {
#ifdef USE_OPENGL_RENDERER
int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor);
android::uirenderer::RenderNode::outputLogBuffer(fd);
#endif // USE_OPENGL_RENDERER
if (kUseOpenGLRenderer) {
int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor);
android::uirenderer::RenderNode::outputLogBuffer(fd);
}
}
// ----------------------------------------------------------------------------
@@ -974,18 +972,16 @@ static JNINativeMethod gActivityThreadMethods[] = {
};
int register_android_view_GLES20Canvas(JNIEnv* env) {
#ifdef USE_OPENGL_RENDERER
jclass clazz = FindClassOrDie(env, "android/graphics/Rect");
gRectClassInfo.set = GetMethodIDOrDie(env, clazz, "set", "(IIII)V");
#endif
if (kUseOpenGLRenderer) {
jclass clazz = FindClassOrDie(env, "android/graphics/Rect");
gRectClassInfo.set = GetMethodIDOrDie(env, clazz, "set", "(IIII)V");
}
return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
}
const char* const kActivityThreadPathName = "android/app/ActivityThread";
int register_android_app_ActivityThread(JNIEnv* env) {
return RegisterMethodsOrDie(env, kActivityThreadPathName,
return RegisterMethodsOrDie(env, "android/app/ActivityThread",
gActivityThreadMethods, NELEM(gActivityThreadMethods));
}

View File

@@ -47,16 +47,7 @@ namespace android {
// ----------------------------------------------------------------------------
// Debug
#define DEBUG_GRAPHIC_BUFFER 0
// Debug
#if DEBUG_GRAPHIC_BUFFER
#define GB_LOGD(...) ALOGD(__VA_ARGS__)
#define GB_LOGW(...) ALOGW(__VA_ARGS__)
#else
#define GB_LOGD(...)
#define GB_LOGW(...)
#endif
static const bool kDebugGraphicBuffer = false;
#define LOCK_CANVAS_USAGE GraphicBuffer::USAGE_SW_READ_OFTEN | GraphicBuffer::USAGE_SW_WRITE_OFTEN
@@ -118,14 +109,18 @@ static jlong android_view_GraphiceBuffer_create(JNIEnv* env, jobject clazz,
sp<ISurfaceComposer> composer(ComposerService::getComposerService());
sp<IGraphicBufferAlloc> alloc(composer->createGraphicBufferAlloc());
if (alloc == NULL) {
GB_LOGW("createGraphicBufferAlloc() failed in GraphicBuffer.create()");
if (kDebugGraphicBuffer) {
ALOGW("createGraphicBufferAlloc() failed in GraphicBuffer.create()");
}
return NULL;
}
status_t error;
sp<GraphicBuffer> buffer(alloc->createGraphicBuffer(width, height, format, usage, &error));
if (buffer == NULL) {
GB_LOGW("createGraphicBuffer() failed in GraphicBuffer.create()");
if (kDebugGraphicBuffer) {
ALOGW("createGraphicBuffer() failed in GraphicBuffer.create()");
}
return NULL;
}

View File

@@ -20,7 +20,7 @@
#include "GraphicsJNI.h"
#include <nativehelper/JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <android_runtime/android_graphics_SurfaceTexture.h>
#include <gui/GLConsumer.h>
@@ -117,7 +117,7 @@ static JNINativeMethod gMethods[] = {
};
int register_android_view_HardwareLayer(JNIEnv* env) {
return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
}
};

View File

@@ -18,10 +18,6 @@
//#define LOG_NDEBUG 0
// Log debug messages about the dispatch cycle.
#define DEBUG_DISPATCH_CYCLE 0
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
@@ -41,6 +37,8 @@
namespace android {
static const bool kDebugDispatchCycle = false;
static struct {
jclass clazz;
@@ -94,9 +92,9 @@ NativeInputEventReceiver::NativeInputEventReceiver(JNIEnv* env,
mReceiverWeakGlobal(env->NewGlobalRef(receiverWeak)),
mInputConsumer(inputChannel), mMessageQueue(messageQueue),
mBatchedInputEventPending(false), mFdEvents(0) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Initializing input event receiver.", getInputChannelName());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Initializing input event receiver.", getInputChannelName());
}
}
NativeInputEventReceiver::~NativeInputEventReceiver() {
@@ -110,25 +108,25 @@ status_t NativeInputEventReceiver::initialize() {
}
void NativeInputEventReceiver::dispose() {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Disposing input event receiver.", getInputChannelName());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Disposing input event receiver.", getInputChannelName());
}
setFdEvents(0);
}
status_t NativeInputEventReceiver::finishInputEvent(uint32_t seq, bool handled) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Finished input event.", getInputChannelName());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Finished input event.", getInputChannelName());
}
status_t status = mInputConsumer.sendFinishedSignal(seq, handled);
if (status) {
if (status == WOULD_BLOCK) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Could not send finished signal immediately. "
"Enqueued for later.", getInputChannelName());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Could not send finished signal immediately. "
"Enqueued for later.", getInputChannelName());
}
Finish finish;
finish.seq = seq;
finish.handled = handled;
@@ -158,13 +156,13 @@ void NativeInputEventReceiver::setFdEvents(int events) {
int NativeInputEventReceiver::handleEvent(int receiveFd, int events, void* data) {
if (events & (ALOOPER_EVENT_ERROR | ALOOPER_EVENT_HANGUP)) {
#if DEBUG_DISPATCH_CYCLE
// This error typically occurs when the publisher has closed the input channel
// as part of removing a window or finishing an IME session, in which case
// the consumer will soon be disposed as well.
ALOGD("channel '%s' ~ Publisher closed input channel or an error occurred. "
"events=0x%x", getInputChannelName(), events);
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Publisher closed input channel or an error occurred. "
"events=0x%x", getInputChannelName(), events);
}
return 0; // remove the callback
}
@@ -183,10 +181,10 @@ int NativeInputEventReceiver::handleEvent(int receiveFd, int events, void* data)
mFinishQueue.removeItemsAt(0, i);
if (status == WOULD_BLOCK) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Sent %u queued finish events; %u left.",
getInputChannelName(), i, mFinishQueue.size());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Sent %u queued finish events; %u left.",
getInputChannelName(), i, mFinishQueue.size());
}
return 1; // keep the callback, try again later
}
@@ -202,10 +200,10 @@ int NativeInputEventReceiver::handleEvent(int receiveFd, int events, void* data)
return 0; // remove the callback
}
}
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Sent %u queued finish events; none left.",
getInputChannelName(), mFinishQueue.size());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Sent %u queued finish events; none left.",
getInputChannelName(), mFinishQueue.size());
}
mFinishQueue.clear();
setFdEvents(ALOOPER_EVENT_INPUT);
return 1;
@@ -218,10 +216,10 @@ int NativeInputEventReceiver::handleEvent(int receiveFd, int events, void* data)
status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
bool consumeBatches, nsecs_t frameTime, bool* outConsumedBatch) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Consuming input events, consumeBatches=%s, frameTime=%lld.",
getInputChannelName(), consumeBatches ? "true" : "false", frameTime);
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Consuming input events, consumeBatches=%s, frameTime=%lld.",
getInputChannelName(), consumeBatches ? "true" : "false", frameTime);
}
if (consumeBatches) {
mBatchedInputEventPending = false;
@@ -252,10 +250,10 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
}
mBatchedInputEventPending = true;
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Dispatching batched input event pending notification.",
getInputChannelName());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Dispatching batched input event pending notification.",
getInputChannelName());
}
env->CallVoidMethod(receiverObj.get(),
gInputEventReceiverClassInfo.dispatchBatchedInputEventPending);
if (env->ExceptionCheck()) {
@@ -284,17 +282,17 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
jobject inputEventObj;
switch (inputEvent->getType()) {
case AINPUT_EVENT_TYPE_KEY:
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Received key event.", getInputChannelName());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Received key event.", getInputChannelName());
}
inputEventObj = android_view_KeyEvent_fromNative(env,
static_cast<KeyEvent*>(inputEvent));
break;
case AINPUT_EVENT_TYPE_MOTION: {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Received motion event.", getInputChannelName());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Received motion event.", getInputChannelName());
}
MotionEvent* motionEvent = static_cast<MotionEvent*>(inputEvent);
if ((motionEvent->getAction() & AMOTION_EVENT_ACTION_MOVE) && outConsumedBatch) {
*outConsumedBatch = true;
@@ -309,9 +307,9 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
}
if (inputEventObj) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Dispatching input event.", getInputChannelName());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Dispatching input event.", getInputChannelName());
}
env->CallVoidMethod(receiverObj.get(),
gInputEventReceiverClassInfo.dispatchInputEvent, seq, inputEventObj);
if (env->ExceptionCheck()) {

View File

@@ -18,10 +18,6 @@
//#define LOG_NDEBUG 0
// Log debug messages about the dispatch cycle.
#define DEBUG_DISPATCH_CYCLE 0
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
@@ -41,6 +37,9 @@
namespace android {
// Log debug messages about the dispatch cycle.
static const bool kDebugDispatchCycle = false;
static struct {
jclass clazz;
@@ -84,9 +83,9 @@ NativeInputEventSender::NativeInputEventSender(JNIEnv* env,
mSenderWeakGlobal(env->NewGlobalRef(senderWeak)),
mInputPublisher(inputChannel), mMessageQueue(messageQueue),
mNextPublishedSeq(1) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Initializing input event sender.", getInputChannelName());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Initializing input event sender.", getInputChannelName());
}
}
NativeInputEventSender::~NativeInputEventSender() {
@@ -101,17 +100,17 @@ status_t NativeInputEventSender::initialize() {
}
void NativeInputEventSender::dispose() {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Disposing input event sender.", getInputChannelName());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Disposing input event sender.", getInputChannelName());
}
mMessageQueue->getLooper()->removeFd(mInputPublisher.getChannel()->getFd());
}
status_t NativeInputEventSender::sendKeyEvent(uint32_t seq, const KeyEvent* event) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Sending key event, seq=%u.", getInputChannelName(), seq);
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Sending key event, seq=%u.", getInputChannelName(), seq);
}
uint32_t publishedSeq = mNextPublishedSeq++;
status_t status = mInputPublisher.publishKeyEvent(publishedSeq,
@@ -128,9 +127,9 @@ status_t NativeInputEventSender::sendKeyEvent(uint32_t seq, const KeyEvent* even
}
status_t NativeInputEventSender::sendMotionEvent(uint32_t seq, const MotionEvent* event) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Sending motion event, seq=%u.", getInputChannelName(), seq);
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Sending motion event, seq=%u.", getInputChannelName(), seq);
}
uint32_t publishedSeq;
for (size_t i = 0; i <= event->getHistorySize(); i++) {
@@ -155,13 +154,14 @@ status_t NativeInputEventSender::sendMotionEvent(uint32_t seq, const MotionEvent
int NativeInputEventSender::handleEvent(int receiveFd, int events, void* data) {
if (events & (ALOOPER_EVENT_ERROR | ALOOPER_EVENT_HANGUP)) {
#if DEBUG_DISPATCH_CYCLE
// This error typically occurs when the consumer has closed the input channel
// as part of finishing an IME session, in which case the publisher will
// soon be disposed as well.
ALOGD("channel '%s' ~ Consumer closed input channel or an error occurred. "
"events=0x%x", getInputChannelName(), events);
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Consumer closed input channel or an error occurred. "
"events=0x%x", getInputChannelName(), events);
}
return 0; // remove the callback
}
@@ -178,9 +178,9 @@ int NativeInputEventSender::handleEvent(int receiveFd, int events, void* data) {
}
status_t NativeInputEventSender::receiveFinishedSignals(JNIEnv* env) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Receiving finished signals.", getInputChannelName());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Receiving finished signals.", getInputChannelName());
}
ScopedLocalRef<jobject> senderObj(env, NULL);
bool skipCallbacks = false;
@@ -202,12 +202,12 @@ status_t NativeInputEventSender::receiveFinishedSignals(JNIEnv* env) {
uint32_t seq = mPublishedSeqMap.valueAt(index);
mPublishedSeqMap.removeItemsAt(index);
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ Received finished signal, seq=%u, handled=%s, "
"pendingEvents=%u.",
getInputChannelName(), seq, handled ? "true" : "false",
mPublishedSeqMap.size());
#endif
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Received finished signal, seq=%u, handled=%s, "
"pendingEvents=%u.",
getInputChannelName(), seq, handled ? "true" : "false",
mPublishedSeqMap.size());
}
if (!skipCallbacks) {
if (!senderObj.get()) {

View File

@@ -23,7 +23,7 @@
#include "android_os_Parcel.h"
#include "android/graphics/GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/android_graphics_SurfaceTexture.h>
#include <android_runtime/Log.h>
@@ -379,26 +379,26 @@ static JNINativeMethod gSurfaceMethods[] = {
int register_android_view_Surface(JNIEnv* env)
{
int err = AndroidRuntime::registerNativeMethods(env, "android/view/Surface",
int err = RegisterMethodsOrDie(env, "android/view/Surface",
gSurfaceMethods, NELEM(gSurfaceMethods));
jclass clazz = env->FindClass("android/view/Surface");
gSurfaceClassInfo.clazz = jclass(env->NewGlobalRef(clazz));
gSurfaceClassInfo.mNativeObject =
env->GetFieldID(gSurfaceClassInfo.clazz, "mNativeObject", "J");
gSurfaceClassInfo.mLock =
env->GetFieldID(gSurfaceClassInfo.clazz, "mLock", "Ljava/lang/Object;");
gSurfaceClassInfo.ctor = env->GetMethodID(gSurfaceClassInfo.clazz, "<init>", "(J)V");
jclass clazz = FindClassOrDie(env, "android/view/Surface");
gSurfaceClassInfo.clazz = MakeGlobalRefOrDie(env, clazz);
gSurfaceClassInfo.mNativeObject = GetFieldIDOrDie(env,
gSurfaceClassInfo.clazz, "mNativeObject", "J");
gSurfaceClassInfo.mLock = GetFieldIDOrDie(env,
gSurfaceClassInfo.clazz, "mLock", "Ljava/lang/Object;");
gSurfaceClassInfo.ctor = GetMethodIDOrDie(env, gSurfaceClassInfo.clazz, "<init>", "(J)V");
clazz = env->FindClass("android/graphics/Canvas");
gCanvasClassInfo.mSurfaceFormat = env->GetFieldID(clazz, "mSurfaceFormat", "I");
gCanvasClassInfo.setNativeBitmap = env->GetMethodID(clazz, "setNativeBitmap", "(J)V");
clazz = FindClassOrDie(env, "android/graphics/Canvas");
gCanvasClassInfo.mSurfaceFormat = GetFieldIDOrDie(env, clazz, "mSurfaceFormat", "I");
gCanvasClassInfo.setNativeBitmap = GetMethodIDOrDie(env, clazz, "setNativeBitmap", "(J)V");
clazz = env->FindClass("android/graphics/Rect");
gRectClassInfo.left = env->GetFieldID(clazz, "left", "I");
gRectClassInfo.top = env->GetFieldID(clazz, "top", "I");
gRectClassInfo.right = env->GetFieldID(clazz, "right", "I");
gRectClassInfo.bottom = env->GetFieldID(clazz, "bottom", "I");
clazz = FindClassOrDie(env, "android/graphics/Rect");
gRectClassInfo.left = GetFieldIDOrDie(env, clazz, "left", "I");
gRectClassInfo.top = GetFieldIDOrDie(env, clazz, "top", "I");
gRectClassInfo.right = GetFieldIDOrDie(env, clazz, "right", "I");
gRectClassInfo.bottom = GetFieldIDOrDie(env, clazz, "bottom", "I");
return err;
}

View File

@@ -26,7 +26,7 @@
#include "android/graphics/GraphicsJNI.h"
#include "android/graphics/Region.h"
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/android_view_SurfaceSession.h>
@@ -647,41 +647,44 @@ static JNINativeMethod sSurfaceControlMethods[] = {
int register_android_view_SurfaceControl(JNIEnv* env)
{
int err = AndroidRuntime::registerNativeMethods(env, "android/view/SurfaceControl",
int err = RegisterMethodsOrDie(env, "android/view/SurfaceControl",
sSurfaceControlMethods, NELEM(sSurfaceControlMethods));
jclass clazz = env->FindClass("android/view/SurfaceControl$PhysicalDisplayInfo");
gPhysicalDisplayInfoClassInfo.clazz = static_cast<jclass>(env->NewGlobalRef(clazz));
gPhysicalDisplayInfoClassInfo.ctor = env->GetMethodID(gPhysicalDisplayInfoClassInfo.clazz,
"<init>", "()V");
gPhysicalDisplayInfoClassInfo.width = env->GetFieldID(clazz, "width", "I");
gPhysicalDisplayInfoClassInfo.height = env->GetFieldID(clazz, "height", "I");
gPhysicalDisplayInfoClassInfo.refreshRate = env->GetFieldID(clazz, "refreshRate", "F");
gPhysicalDisplayInfoClassInfo.density = env->GetFieldID(clazz, "density", "F");
gPhysicalDisplayInfoClassInfo.xDpi = env->GetFieldID(clazz, "xDpi", "F");
gPhysicalDisplayInfoClassInfo.yDpi = env->GetFieldID(clazz, "yDpi", "F");
gPhysicalDisplayInfoClassInfo.secure = env->GetFieldID(clazz, "secure", "Z");
gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos = env->GetFieldID(clazz,
"appVsyncOffsetNanos", "J");
gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos = env->GetFieldID(clazz,
"presentationDeadlineNanos", "J");
jclass clazz = FindClassOrDie(env, "android/view/SurfaceControl$PhysicalDisplayInfo");
gPhysicalDisplayInfoClassInfo.clazz = MakeGlobalRefOrDie(env, clazz);
gPhysicalDisplayInfoClassInfo.ctor = GetMethodIDOrDie(env,
gPhysicalDisplayInfoClassInfo.clazz, "<init>", "()V");
gPhysicalDisplayInfoClassInfo.width = GetFieldIDOrDie(env, clazz, "width", "I");
gPhysicalDisplayInfoClassInfo.height = GetFieldIDOrDie(env, clazz, "height", "I");
gPhysicalDisplayInfoClassInfo.refreshRate = GetFieldIDOrDie(env, clazz, "refreshRate", "F");
gPhysicalDisplayInfoClassInfo.density = GetFieldIDOrDie(env, clazz, "density", "F");
gPhysicalDisplayInfoClassInfo.xDpi = GetFieldIDOrDie(env, clazz, "xDpi", "F");
gPhysicalDisplayInfoClassInfo.yDpi = GetFieldIDOrDie(env, clazz, "yDpi", "F");
gPhysicalDisplayInfoClassInfo.secure = GetFieldIDOrDie(env, clazz, "secure", "Z");
gPhysicalDisplayInfoClassInfo.appVsyncOffsetNanos = GetFieldIDOrDie(env,
clazz, "appVsyncOffsetNanos", "J");
gPhysicalDisplayInfoClassInfo.presentationDeadlineNanos = GetFieldIDOrDie(env,
clazz, "presentationDeadlineNanos", "J");
jclass rectClazz = env->FindClass("android/graphics/Rect");
gRectClassInfo.bottom = env->GetFieldID(rectClazz, "bottom", "I");
gRectClassInfo.left = env->GetFieldID(rectClazz, "left", "I");
gRectClassInfo.right = env->GetFieldID(rectClazz, "right", "I");
gRectClassInfo.top = env->GetFieldID(rectClazz, "top", "I");
jclass rectClazz = FindClassOrDie(env, "android/graphics/Rect");
gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClazz, "bottom", "I");
gRectClassInfo.left = GetFieldIDOrDie(env, rectClazz, "left", "I");
gRectClassInfo.right = GetFieldIDOrDie(env, rectClazz, "right", "I");
gRectClassInfo.top = GetFieldIDOrDie(env, rectClazz, "top", "I");
jclass frameStatsClazz = env->FindClass("android/view/FrameStats");
jfieldID undefined_time_nano_field = env->GetStaticFieldID(frameStatsClazz, "UNDEFINED_TIME_NANO", "J");
jclass frameStatsClazz = FindClassOrDie(env, "android/view/FrameStats");
jfieldID undefined_time_nano_field = GetStaticFieldIDOrDie(env,
frameStatsClazz, "UNDEFINED_TIME_NANO", "J");
nsecs_t undefined_time_nano = env->GetStaticLongField(frameStatsClazz, undefined_time_nano_field);
jclass contFrameStatsClazz = env->FindClass("android/view/WindowContentFrameStats");
gWindowContentFrameStatsClassInfo.init = env->GetMethodID(contFrameStatsClazz, "init", "(J[J[J[J)V");
jclass contFrameStatsClazz = FindClassOrDie(env, "android/view/WindowContentFrameStats");
gWindowContentFrameStatsClassInfo.init = GetMethodIDOrDie(env,
contFrameStatsClazz, "init", "(J[J[J[J)V");
gWindowContentFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano;
jclass animFrameStatsClazz = env->FindClass("android/view/WindowAnimationFrameStats");
gWindowAnimationFrameStatsClassInfo.init = env->GetMethodID(animFrameStatsClazz, "init", "(J[J)V");
jclass animFrameStatsClazz = FindClassOrDie(env, "android/view/WindowAnimationFrameStats");
gWindowAnimationFrameStatsClassInfo.init = GetMethodIDOrDie(env,
animFrameStatsClazz, "init", "(J[J)V");
gWindowAnimationFrameStatsClassInfo.UNDEFINED_TIME_NANO = undefined_time_nano;
return err;

View File

@@ -20,7 +20,7 @@
#include "jni.h"
#include <nativehelper/JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
@@ -454,7 +454,7 @@ static JNINativeMethod gMethods[] = {
};
int register_android_view_ThreadedRenderer(JNIEnv* env) {
return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env, kClassPathName, gMethods, NELEM(gMethods));
}
}; // namespace android

View File

@@ -17,7 +17,7 @@
#define LOG_TAG "NativeLibraryHelper"
//#define LOG_NDEBUG 0
#include <android_runtime/AndroidRuntime.h>
#include "core_jni_helpers.h"
#include <ScopedUtfChars.h>
#include <UniquePtr.h>
@@ -563,8 +563,8 @@ static JNINativeMethod gMethods[] = {
int register_com_android_internal_content_NativeLibraryHelper(JNIEnv *env)
{
return AndroidRuntime::registerNativeMethods(env,
"com/android/internal/content/NativeLibraryHelper", gMethods, NELEM(gMethods));
return RegisterMethodsOrDie(env,
"com/android/internal/content/NativeLibraryHelper", gMethods, NELEM(gMethods));
}
};

View File

@@ -21,7 +21,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <android_runtime/AndroidRuntime.h>
#include <core_jni_helpers.h>
#include <jni.h>
#include <ScopedUtfChars.h>
@@ -284,16 +284,6 @@ static int readNetworkStatsDetail(JNIEnv* env, jclass clazz, jobject stats,
return 0;
}
static jclass findClass(JNIEnv* env, const char* name) {
ScopedLocalRef<jclass> localClass(env, env->FindClass(name));
jclass result = reinterpret_cast<jclass>(env->NewGlobalRef(localClass.get()));
if (result == NULL) {
ALOGE("failed to find class '%s'", name);
abort();
}
return result;
}
static JNINativeMethod gMethods[] = {
{ "nativeReadNetworkStatsDetail",
"(Landroid/net/NetworkStats;Ljava/lang/String;I[Ljava/lang/String;I)I",
@@ -301,24 +291,25 @@ static JNINativeMethod gMethods[] = {
};
int register_com_android_internal_net_NetworkStatsFactory(JNIEnv* env) {
int err = AndroidRuntime::registerNativeMethods(env,
int err = RegisterMethodsOrDie(env,
"com/android/internal/net/NetworkStatsFactory", gMethods,
NELEM(gMethods));
gStringClass = findClass(env, "java/lang/String");
gStringClass = FindClassOrDie(env, "java/lang/String");
gStringClass = MakeGlobalRefOrDie(env, gStringClass);
jclass clazz = env->FindClass("android/net/NetworkStats");
gNetworkStatsClassInfo.size = env->GetFieldID(clazz, "size", "I");
gNetworkStatsClassInfo.capacity = env->GetFieldID(clazz, "capacity", "I");
gNetworkStatsClassInfo.iface = env->GetFieldID(clazz, "iface", "[Ljava/lang/String;");
gNetworkStatsClassInfo.uid = env->GetFieldID(clazz, "uid", "[I");
gNetworkStatsClassInfo.set = env->GetFieldID(clazz, "set", "[I");
gNetworkStatsClassInfo.tag = env->GetFieldID(clazz, "tag", "[I");
gNetworkStatsClassInfo.rxBytes = env->GetFieldID(clazz, "rxBytes", "[J");
gNetworkStatsClassInfo.rxPackets = env->GetFieldID(clazz, "rxPackets", "[J");
gNetworkStatsClassInfo.txBytes = env->GetFieldID(clazz, "txBytes", "[J");
gNetworkStatsClassInfo.txPackets = env->GetFieldID(clazz, "txPackets", "[J");
gNetworkStatsClassInfo.operations = env->GetFieldID(clazz, "operations", "[J");
jclass clazz = FindClassOrDie(env, "android/net/NetworkStats");
gNetworkStatsClassInfo.size = GetFieldIDOrDie(env, clazz, "size", "I");
gNetworkStatsClassInfo.capacity = GetFieldIDOrDie(env, clazz, "capacity", "I");
gNetworkStatsClassInfo.iface = GetFieldIDOrDie(env, clazz, "iface", "[Ljava/lang/String;");
gNetworkStatsClassInfo.uid = GetFieldIDOrDie(env, clazz, "uid", "[I");
gNetworkStatsClassInfo.set = GetFieldIDOrDie(env, clazz, "set", "[I");
gNetworkStatsClassInfo.tag = GetFieldIDOrDie(env, clazz, "tag", "[I");
gNetworkStatsClassInfo.rxBytes = GetFieldIDOrDie(env, clazz, "rxBytes", "[J");
gNetworkStatsClassInfo.rxPackets = GetFieldIDOrDie(env, clazz, "rxPackets", "[J");
gNetworkStatsClassInfo.txBytes = GetFieldIDOrDie(env, clazz, "txBytes", "[J");
gNetworkStatsClassInfo.txPackets = GetFieldIDOrDie(env, clazz, "txPackets", "[J");
gNetworkStatsClassInfo.operations = GetFieldIDOrDie(env, clazz, "operations", "[J");
return err;
}

Some files were not shown because too many files have changed in this diff Show More