Fix EGL JNI bugs
Bug #3461349

Before this change, eglGetCurrent*() could not be used to compare
contexts, displays and surfaces at the Dalvik level.

Change-Id: I442037dae37bc357b64810ab10c779b5754e9153
diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
index e7ea8c8..3d24bee 100644
--- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
@@ -400,7 +400,7 @@
 }
 
 static jint jni_eglGetCurrentSurface(JNIEnv *_env, jobject _this, jint readdraw) {
-    if (!(readdraw == EGL_READ) || (readdraw == EGL_DRAW)) {
+    if ((readdraw != EGL_READ) && (readdraw != EGL_DRAW)) {
         doThrow(_env, "java/lang/IllegalArgumentException");
         return 0;
     }
diff --git a/opengl/java/com/google/android/gles_jni/EGLContextImpl.java b/opengl/java/com/google/android/gles_jni/EGLContextImpl.java
index 9cf5de7..cd36099 100644
--- a/opengl/java/com/google/android/gles_jni/EGLContextImpl.java
+++ b/opengl/java/com/google/android/gles_jni/EGLContextImpl.java
@@ -32,4 +32,19 @@
     public GL getGL() {
         return mGLContext;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        EGLContextImpl that = (EGLContextImpl) o;
+
+        return mEGLContext == that.mEGLContext;
+    }
+
+    @Override
+    public int hashCode() {
+        return mEGLContext;
+    }
 }
diff --git a/opengl/java/com/google/android/gles_jni/EGLDisplayImpl.java b/opengl/java/com/google/android/gles_jni/EGLDisplayImpl.java
index cb94888..e6c9817 100644
--- a/opengl/java/com/google/android/gles_jni/EGLDisplayImpl.java
+++ b/opengl/java/com/google/android/gles_jni/EGLDisplayImpl.java
@@ -24,4 +24,20 @@
     public EGLDisplayImpl(int dpy) {
         mEGLDisplay = dpy;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        EGLDisplayImpl that = (EGLDisplayImpl) o;
+
+        return mEGLDisplay == that.mEGLDisplay;
+
+    }
+
+    @Override
+    public int hashCode() {
+        return mEGLDisplay;
+    }
 }
diff --git a/opengl/java/com/google/android/gles_jni/EGLSurfaceImpl.java b/opengl/java/com/google/android/gles_jni/EGLSurfaceImpl.java
index f6b90ab..e7f15dc 100644
--- a/opengl/java/com/google/android/gles_jni/EGLSurfaceImpl.java
+++ b/opengl/java/com/google/android/gles_jni/EGLSurfaceImpl.java
@@ -29,4 +29,20 @@
         mEGLSurface = surface;
         mNativePixelRef = 0;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        EGLSurfaceImpl that = (EGLSurfaceImpl) o;
+
+        return mEGLSurface == that.mEGLSurface;
+
+    }
+
+    @Override
+    public int hashCode() {
+        return mEGLSurface;
+    }
 }