don't hardcode "mSurface" throughout our source code
this is used in a few places to get access to the android.view.Surface
native surface. use a macro instead. Also rename the field to mNativeSurface.
Change-Id: I1c6dea14abd6b8b1392c7f97b304115999355094
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 255e317..cde20e4 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -140,13 +140,13 @@
public static final int FLAGS_ORIENTATION_ANIMATION_DISABLE = 0x000000001;
@SuppressWarnings("unused")
- private int mSurface;
- @SuppressWarnings("unused")
private int mSurfaceControl;
@SuppressWarnings("unused")
private int mSaveCount;
@SuppressWarnings("unused")
private Canvas mCanvas;
+ @SuppressWarnings("unused")
+ private int mNativeSurface;
// The display metrics used to provide the pseudo canvas size for applications
// running in compatibility mode. This is set to null for non compatibility mode.
@@ -420,13 +420,13 @@
/* no user serviceable parts here ... */
@Override
protected void finalize() throws Throwable {
- if (mSurface != 0 || mSurfaceControl != 0) {
+ if (mNativeSurface != 0 || mSurfaceControl != 0) {
if (DEBUG_RELEASE) {
Log.w(LOG_TAG, "Surface.finalize() has work. You should have called release() ("
- + mSurface + ", " + mSurfaceControl + ")", mCreationStack);
+ + mNativeSurface + ", " + mSurfaceControl + ")", mCreationStack);
} else {
Log.w(LOG_TAG, "Surface.finalize() has work. You should have called release() ("
- + mSurface + ", " + mSurfaceControl + ")");
+ + mNativeSurface + ", " + mSurfaceControl + ")");
}
}
release();
diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp
index b85466b..6c27841 100644
--- a/core/jni/android_hardware_Camera.cpp
+++ b/core/jni/android_hardware_Camera.cpp
@@ -659,7 +659,7 @@
{
field fields_to_find[] = {
{ "android/hardware/Camera", "mNativeContext", "I", &fields.context },
- { "android/view/Surface", "mSurface", "I", &fields.surface }
+ { "android/view/Surface", ANDROID_VIEW_SURFACE_JNI_ID, "I", &fields.surface }
};
if (find_fields(env, fields_to_find, NELEM(fields_to_find)) < 0)
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index ed26cbe..817f0c5 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -19,6 +19,7 @@
#include "android_util_Binder.h"
#include <surfaceflinger/SurfaceComposerClient.h>
+#include <surfaceflinger/Surface.h>
#include <ui/Region.h>
#include <ui/Rect.h>
@@ -670,7 +671,7 @@
void nativeClassInit(JNIEnv* env, jclass clazz)
{
- so.surface = env->GetFieldID(clazz, "mSurface", "I");
+ so.surface = env->GetFieldID(clazz, ANDROID_VIEW_SURFACE_JNI_ID, "I");
so.surfaceControl = env->GetFieldID(clazz, "mSurfaceControl", "I");
so.saveCount = env->GetFieldID(clazz, "mSaveCount", "I");
so.canvas = env->GetFieldID(clazz, "mCanvas", "Landroid/graphics/Canvas;");
diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
index 6a8c4b9..01a1504 100644
--- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
@@ -96,7 +96,7 @@
gConfig_EGLConfigFieldID = _env->GetFieldID(gConfig_class, "mEGLConfig", "I");
jclass surface_class = _env->FindClass("android/view/Surface");
- gSurface_SurfaceFieldID = _env->GetFieldID(surface_class, "mSurface", "I");
+ gSurface_SurfaceFieldID = _env->GetFieldID(surface_class, ANDROID_VIEW_SURFACE_JNI_ID, "I");
jclass bitmap_class = _env->FindClass("android/graphics/Bitmap");
gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "I");
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index d8e0393..45cc72e 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -185,7 +185,7 @@
} else {
jclass surface_class = _env->FindClass("android/view/Surface");
- jfieldID surfaceFieldID = _env->GetFieldID(surface_class, "mSurface", "I");
+ jfieldID surfaceFieldID = _env->GetFieldID(surface_class, ANDROID_VIEW_SURFACE_JNI_ID, "I");
window = (Surface*)_env->GetIntField(wnd, surfaceFieldID);
}
diff --git a/include/surfaceflinger/Surface.h b/include/surfaceflinger/Surface.h
index 0279d84..4c8d023 100644
--- a/include/surfaceflinger/Surface.h
+++ b/include/surfaceflinger/Surface.h
@@ -30,6 +30,8 @@
#include <surfaceflinger/ISurface.h>
#include <surfaceflinger/ISurfaceFlingerClient.h>
+#define ANDROID_VIEW_SURFACE_JNI_ID "mNativeSurface"
+
namespace android {
// ---------------------------------------------------------------------------
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp
index 8ed3730..60ff264 100644
--- a/media/jni/android_media_MediaPlayer.cpp
+++ b/media/jni/android_media_MediaPlayer.cpp
@@ -636,7 +636,7 @@
return;
}
- fields.surface_native = env->GetFieldID(surface, "mSurface", "I");
+ fields.surface_native = env->GetFieldID(surface, ANDROID_VIEW_SURFACE_JNI_ID, "I");
if (fields.surface_native == NULL) {
jniThrowException(env, "java/lang/RuntimeException", "Can't find Surface.mSurface");
return;
diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp
index 00af3a2..8cf2e51 100644
--- a/media/jni/android_media_MediaRecorder.cpp
+++ b/media/jni/android_media_MediaRecorder.cpp
@@ -403,7 +403,7 @@
return;
}
- fields.surface_native = env->GetFieldID(surface, "mSurface", "I");
+ fields.surface_native = env->GetFieldID(surface, ANDROID_VIEW_SURFACE_JNI_ID, "I");
if (fields.surface_native == NULL) {
jniThrowException(env, "java/lang/RuntimeException", "Can't find Surface.mSurface");
return;
diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp
index 01b6737..f3804b8 100644
--- a/media/libmedia/IOMX.cpp
+++ b/media/libmedia/IOMX.cpp
@@ -57,7 +57,7 @@
return NULL;
}
- jfieldID surfaceID = env->GetFieldID(surfaceClass, "mSurface", "I");
+ jfieldID surfaceID = env->GetFieldID(surfaceClass, ANDROID_VIEW_SURFACE_JNI_ID, "I");
if (surfaceID == NULL) {
LOGE("Can't find Surface.mSurface");
return NULL;