Merge "Update required due to framework API change."
diff --git a/build/sdk.atree b/build/sdk.atree
index 355fa1a..7ece62d 100644
--- a/build/sdk.atree
+++ b/build/sdk.atree
@@ -218,3 +218,4 @@
 ##############################################################################
 framework/layoutlib-tests.jar tests/libtests/layoutlib-tests.jar
 system/app/ConnectivityTest.apk tests/emulator-test-apps/ConnectivityTest.apk
+system/app/GpsLocationTest.apk test/emulator-test-apps/GpsLocationTest.apk
diff --git a/ndk/platforms/android-3/include/jni.h b/ndk/platforms/android-3/include/jni.h
index ad954c8..495902c 100644
--- a/ndk/platforms/android-3/include/jni.h
+++ b/ndk/platforms/android-3/include/jni.h
@@ -1,13 +1,28 @@
 /*
- * Copyright 2006 The Android Open Source Project
+ * Copyright (C) 2006 The Android Open Source Project
  *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
  * JNI specification, as defined by Sun:
  * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html
  *
  * Everything here is expected to be VM-neutral.
  */
-#ifndef _JNI_H
-#define _JNI_H
+
+#ifndef JNI_H_
+#define JNI_H_
 
 #include <stdarg.h>
 
@@ -124,10 +139,10 @@
     JNIWeakGlobalRefType = 3
 } jobjectRefType;
 
-typedef struct { 
-    const char* name; 
-    const char* signature; 
-    void*       fnPtr; 
+typedef struct {
+    const char* name;
+    const char* signature;
+    void*       fnPtr;
 } JNINativeMethod;
 
 struct _JNIEnv;
@@ -1037,7 +1052,7 @@
     void*       reserved0;
     void*       reserved1;
     void*       reserved2;
- 
+
     jint        (*DestroyJavaVM)(JavaVM*);
     jint        (*AttachCurrentThread)(JavaVM*, JNIEnv**, void*);
     jint        (*DetachCurrentThread)(JavaVM*);
@@ -1097,16 +1112,22 @@
  *
  * Note these are the only symbols exported for JNI by the VM.
  */
+#if 0  /* In practice, these are not exported by the NDK so don't declare them */
 jint JNI_GetDefaultJavaVMInitArgs(void*);
 jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*);
 jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*);
+#endif
+
+#define JNIIMPORT
+#define JNIEXPORT  __attribute__ ((visibility ("default")))
+#define JNICALL
 
 /*
  * Prototypes for functions exported by loadable shared libs.  These are
  * called by JNI, not provided by JNI.
  */
-jint JNI_OnLoad(JavaVM* vm, void* reserved);
-void JNI_OnUnload(JavaVM* vm, void* reserved);
+JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved);
+JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved);
 
 #ifdef __cplusplus
 }
@@ -1132,9 +1153,4 @@
 #define JNI_COMMIT      1           /* copy content, do not free buffer */
 #define JNI_ABORT       2           /* free buffer w/o copying back */
 
-/* need these for Windows-aware headers */
-#define JNIIMPORT
-#define JNIEXPORT
-#define JNICALL
-
-#endif /*_JNI_H*/
+#endif  /* JNI_H_ */
diff --git a/samples/SampleSyncAdapter/Android.mk b/samples/SampleSyncAdapter/Android.mk
index 0f87c17..eec507b 100644
--- a/samples/SampleSyncAdapter/Android.mk
+++ b/samples/SampleSyncAdapter/Android.mk
@@ -10,8 +10,6 @@
 
 LOCAL_SDK_VERSION := current
 
-LOCAL_DX_FLAGS=--target-api=11
-
 include $(BUILD_PACKAGE)
 
 # Use the folloing include to make our test apk.
diff --git a/testrunner/coverage_targets.xml b/testrunner/coverage_targets.xml
index 9a50da3..8966700 100644
--- a/testrunner/coverage_targets.xml
+++ b/testrunner/coverage_targets.xml
@@ -106,8 +106,6 @@
         build_path="frameworks/base/packages/SettingsProvider" type="APPS" />
     <coverage_target name="TelephonyProvider"
         build_path="packages/providers/telephony" type="APPS" />
-    <coverage_target name="VoicemailProvider"
-        build_path="packages/providers/VoicemailProvider" type="APPS" />
 
     <!-- input methods -->
     <coverage_target name="LatinIME" build_path="packages/inputmethods/LatinIME"
diff --git a/testrunner/test_defs.xml b/testrunner/test_defs.xml
index d1e4f4e..cbe75b7 100644
--- a/testrunner/test_defs.xml
+++ b/testrunner/test_defs.xml
@@ -446,12 +446,6 @@
     coverage_target="CalendarProvider"
     continuous="true" />
 
-<test name="voicemailprovider"
-    build_path="packages/providers/VoicemailProvider"
-    package="com.android.providers.voicemail.tests"
-    coverage_target="VoicemailProvider"
-    continuous="true" />
-
 <test name="contactsprov"
     build_path="packages/providers/ContactsProvider"
     package="com.android.providers.contacts.tests"
diff --git a/tools/emulator/opengl/Android.mk b/tools/emulator/opengl/Android.mk
index cd5b1b7..a67facb 100644
--- a/tools/emulator/opengl/Android.mk
+++ b/tools/emulator/opengl/Android.mk
@@ -9,6 +9,15 @@
 #
 ifeq (true,$(BUILD_EMULATOR_OPENGL))
 
+# By default, always build the gralloc.goldfish support library to ensure
+# that SurfaceFlinger always uses our GLES emulation libraries. If you
+# don't want this, explicitely set BUILD_EMULATOR_OPENGL_DRIVER to 'false'
+# in your environment or your BoardConfig.mk. For the record, this should
+# only be done for debugging specific applications and requires remoting
+# the GL window from the emulator UI to be usable.
+#
+BUILD_EMULATOR_OPENGL_DRIVER ?= true
+
 # Top-level for all modules
 EMUGL_PATH := $(call my-dir)
 
@@ -24,6 +33,10 @@
 #
 EMUGL_COMMON_CFLAGS := -DWITH_GLES2
 
+# Uncomment the following line if you want to enable debug traces
+# in the GLES emulation libraries.
+# EMUGL_COMMON_CFLAGS += -DEMUGL_DEBUG=1
+
 # Include common definitions used by all the modules included later
 # in this build file. This contains the definition of all useful
 # emugl-xxxx functions.
@@ -57,15 +70,18 @@
 include $(EMUGL_PATH)/system/GLESv2_enc/Android.mk
 include $(EMUGL_PATH)/system/renderControl_enc/Android.mk
 include $(EMUGL_PATH)/system/OpenglSystemCommon/Android.mk
-include $(EMUGL_PATH)/tests/ut_rendercontrol_enc/Android.mk
 
 # System shared libraries
 include $(EMUGL_PATH)/system/GLESv1/Android.mk
 include $(EMUGL_PATH)/system/GLESv2/Android.mk
-include $(EMUGL_PATH)/system/egl/Android.mk
-include $(EMUGL_PATH)/tests/gles_android_wrapper/Android.mk
 
-include $(EMUGL_PATH)/system/gralloc/Android.mk
+ifeq (false,$(BUILD_EMULATOR_OPENGL_DRIVER))
+  include $(EMUGL_PATH)/tests/ut_rendercontrol_enc/Android.mk
+  include $(EMUGL_PATH)/tests/gles_android_wrapper/Android.mk
+else
+  include $(EMUGL_PATH)/system/gralloc/Android.mk
+  include $(EMUGL_PATH)/system/egl/Android.mk
+endif
 
 # Host static libraries
 include $(EMUGL_PATH)/host/libs/GLESv1_dec/Android.mk
diff --git a/tools/emulator/opengl/common.mk b/tools/emulator/opengl/common.mk
index b0b7e5c..82f652d 100644
--- a/tools/emulator/opengl/common.mk
+++ b/tools/emulator/opengl/common.mk
@@ -109,6 +109,7 @@
     $(eval _mod = $(_emugl_MODULE)) \
     $(eval _emugl.$(_mod).type := $(patsubst HOST_%,%,$2))\
     $(eval _emugl.$(_mod).imports :=) \
+    $(eval _emugl,$(_mod).moved :=) \
     $(foreach _type,$(EMUGL_EXPORT_TYPES),\
         $(eval _emugl.$(_mod).export.$(_type) :=)\
     )
@@ -156,7 +157,9 @@
                 $(eval LOCAL_STATIC_LIBRARIES := $(1:HOST_%=%) $(LOCAL_STATIC_LIBRARIES))\
             )\
             $(if $(filter SHARED_LIBRARY,$(_emugl.$1.type)),\
-                $(eval LOCAL_SHARED_LIBRARIES := $(1:HOST_%=%) $(LOCAL_SHARED_LIBRARIES))\
+                $(if $(_emugl.$1.moved),,\
+                  $(eval LOCAL_SHARED_LIBRARIES := $(1:HOST_%=%) $(LOCAL_SHARED_LIBRARIES))\
+                )\
             )\
         )\
     )
@@ -332,5 +335,7 @@
 # For example: $(call emugl-set-shared-library-subpath,egl)
 emugl-set-shared-library-subpath = \
     $(eval LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/$1)\
+    $(eval LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/$1)\
+    $(eval _emugl.$(LOCAL_MODULE).moved := true)\
     $(call emugl-export-outer,ADDITIONAL_DEPENDENCIES,$(LOCAL_MODULE_PATH)/$(LOCAL_MODULE)$(TARGET_SHLIB_SUFFIX))
 
diff --git a/tools/emulator/opengl/host/libs/GLESv1_dec/Android.mk b/tools/emulator/opengl/host/libs/GLESv1_dec/Android.mk
index ba62949..5f134fc 100644
--- a/tools/emulator/opengl/host/libs/GLESv1_dec/Android.mk
+++ b/tools/emulator/opengl/host/libs/GLESv1_dec/Android.mk
@@ -1,6 +1,6 @@
 LOCAL_PATH := $(call my-dir)
 
-$(call emugl-begin-host-shared-library,libGLESv1_dec)
+$(call emugl-begin-host-static-library,libGLESv1_dec)
 
 $(call emugl-import, libOpenglCodecCommon libOpenglOsUtils)
 $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
diff --git a/tools/emulator/opengl/host/libs/GLESv2_dec/Android.mk b/tools/emulator/opengl/host/libs/GLESv2_dec/Android.mk
index 009d47b..a66c6ce 100644
--- a/tools/emulator/opengl/host/libs/GLESv2_dec/Android.mk
+++ b/tools/emulator/opengl/host/libs/GLESv2_dec/Android.mk
@@ -1,6 +1,6 @@
 LOCAL_PATH := $(call my-dir)
 
-$(call emugl-begin-host-shared-library,libGLESv2_dec)
+$(call emugl-begin-host-static-library,libGLESv2_dec)
 $(call emugl-import, libOpenglCodecCommon libOpenglOsUtils)
 $(call emugl-gen-decoder,$(EMUGL_PATH)/system/GLESv2_enc,gl2)
 
diff --git a/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp b/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
index 0457fdc..e867cf8 100644
--- a/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
+++ b/tools/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
@@ -43,7 +43,7 @@
 
         m_GL2library = osUtils::dynLibrary::open(libname);
         if (m_GL2library == NULL) {
-            fprintf(stderr, "Couldn't find %s \n", libname);
+            fprintf(stderr, "%s: Couldn't find %s \n", __FUNCTION__, libname);
             return -1;
         }
         this->initDispatchByName(s_getProc, this);
@@ -77,7 +77,7 @@
     int nFormats;
     ctx->glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &nFormats);
     if (nFormats > count) {
-        fprintf(stderr, "GetCompressedTextureFormats: The requested number of formats does not match the number that is reported by OpenGL\n");
+        fprintf(stderr, "%s: GetCompressedTextureFormats: The requested number of formats does not match the number that is reported by OpenGL\n", __FUNCTION__);
     } else {
         ctx->glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);
     }
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp
index c2ea4a7..bc33f1f 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglContext.cpp
@@ -38,7 +38,7 @@
 m_mngr(mngr)
 {
     m_shareGroup = shared_context.Ptr()?
-                   mngr->attachShareGroup(context,shared_context.Ptr()->getShareGroup().Ptr()):
+                   mngr->attachShareGroup(context,shared_context->nativeType()):
                    mngr->createShareGroup(context);
     m_hndl = ++s_nextContextHndl;
 }
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
index e446249..c11c547 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
@@ -17,6 +17,7 @@
 #include <windows.h>
 #include <wingdi.h>
 #include <GL/wglext.h>
+#include <stdio.h>
 
 #define IS_TRUE(a) \
         if(a != true) return false;
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index d768dd4..3c48a43 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -317,6 +317,7 @@
 GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target){
     GET_CTX_RET(GL_FRAMEBUFFER_COMPLETE);
     RET_AND_SET_ERROR_IF(!GLESv2Validate::framebufferTarget(target),GL_INVALID_ENUM,GL_FRAMEBUFFER_COMPLETE);
+    ctx->drawValidate();
     return ctx->dispatcher().glCheckFramebufferStatusEXT(target);
 }
 
diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
index 956220d..abed760 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
@@ -37,7 +37,7 @@
     static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("opengl32");
     ret = (GL_FUNC_PTR)wglGetProcAddress(funcName);
 #elif defined(__APPLE__)
-    static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("libGL.dylib");
+    static osUtils::dynLibrary* libGL = osUtils::dynLibrary::open("/System/Library/Frameworks/OpenGL.framework/OpenGL");
 #endif
     if(!ret && libGL){
         ret = libGL->findSymbol(funcName);
diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
index c39dac3..9facb6c 100644
--- a/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
+++ b/tools/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
@@ -93,13 +93,13 @@
 
     if (fb->getCaps().has_eglimage_texture_2d) {
         cb->m_eglImage = s_egl.eglCreateImageKHR(fb->getDisplay(),
-                                                 fb->getContext(),
+                                                 s_egl.eglGetCurrentContext(),
                                                  EGL_GL_TEXTURE_2D_KHR,
                                                  (EGLClientBuffer)cb->m_tex,
                                                  NULL);
 
         cb->m_blitEGLImage = s_egl.eglCreateImageKHR(fb->getDisplay(),
-                                                 fb->getContext(),
+                                                 s_egl.eglGetCurrentContext(),
                                                  EGL_GL_TEXTURE_2D_KHR,
                                                  (EGLClientBuffer)cb->m_blitTex,
                                                  NULL);
@@ -254,6 +254,8 @@
 
             // render m_blitTex
             s_gl.glBindTexture(GL_TEXTURE_2D, m_blitTex);
+            s_gl.glEnable(GL_TEXTURE_2D);
+            s_gl.glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
             drawTexQuad();  // this will render the texture flipped
 
             // unbind the fbo
@@ -353,6 +355,7 @@
 {
     s_gl.glBindTexture(GL_TEXTURE_2D, m_tex);
     s_gl.glEnable(GL_TEXTURE_2D);
+    s_gl.glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
     drawTexQuad();
 
     return true;
diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
index 3609a77..acc472a 100644
--- a/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
+++ b/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
@@ -93,7 +93,9 @@
         s_theFrameBuffer->m_colorbuffers.clear();
         s_theFrameBuffer->m_windows.clear();
         s_theFrameBuffer->m_contexts.clear();
+        s_egl.eglMakeCurrent(s_theFrameBuffer->m_eglDisplay, NULL, NULL, NULL);
         s_egl.eglDestroyContext(s_theFrameBuffer->m_eglDisplay,s_theFrameBuffer->m_eglContext);
+        s_egl.eglDestroyContext(s_theFrameBuffer->m_eglDisplay,s_theFrameBuffer->m_pbufContext);
         s_egl.eglDestroySurface(s_theFrameBuffer->m_eglDisplay,s_theFrameBuffer->m_pbufSurface);
         s_theFrameBuffer = NULL;
     }
@@ -222,6 +224,23 @@
     }
 
     //
+    // Create another context which shares with the eglContext to be used
+    // when we bind the pbuffer. That prevent switching drawable binding
+    // back and forth on framebuffer context.
+    // The main purpose of it is to solve a "blanking" behaviour we see on
+    // on Mac platform when switching binded drawable for a context however
+    // it is more efficient on other platforms as well.
+    //
+    fb->m_pbufContext = s_egl.eglCreateContext(fb->m_eglDisplay, fb->m_eglConfig,
+                                               fb->m_eglContext,
+                                               glContextAttribs);
+    if (fb->m_pbufContext == EGL_NO_CONTEXT) {
+        printf("Failed to create Pbuffer Context 0x%x\n", s_egl.eglGetError());
+        delete fb;
+        return false;
+    }
+
+    //
     // create a 1x1 pbuffer surface which will be used for binding
     // the FB context.
     // The FB output will go to a subwindow, if one exist.
@@ -329,13 +348,9 @@
     }
 
     //
-    // Initialize some GL state
+    // Initialize some GL state in the pbuffer context
     //
-    s_gl.glMatrixMode(GL_PROJECTION);
-    s_gl.glLoadIdentity();
-    s_gl.glOrthof(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
-    s_gl.glMatrixMode(GL_MODELVIEW);
-    s_gl.glLoadIdentity();
+    fb->initGLState();
 
     // release the FB context
     fb->unbind_locked();
@@ -353,6 +368,7 @@
     m_eglDisplay(EGL_NO_DISPLAY),
     m_eglSurface(EGL_NO_SURFACE),
     m_eglContext(EGL_NO_CONTEXT),
+    m_pbufContext(EGL_NO_CONTEXT),
     m_prevContext(EGL_NO_CONTEXT),
     m_prevReadSurf(EGL_NO_SURFACE),
     m_prevDrawSurf(EGL_NO_SURFACE),
@@ -360,6 +376,7 @@
     m_subWinDisplay(NULL),
     m_lastPostedColorBuffer(0),
     m_zRot(0.0f),
+    m_eglContextInitialized(false),
     m_statsNumFrames(0),
     m_statsStartTime(0LL)
 {
@@ -695,7 +712,7 @@
     EGLSurface prevDrawSurf = s_egl.eglGetCurrentSurface(EGL_DRAW);
 
     if (!s_egl.eglMakeCurrent(m_eglDisplay, m_pbufSurface,
-                              m_pbufSurface, m_eglContext)) {
+                              m_pbufSurface, m_pbufContext)) {
         ERR("eglMakeCurrent failed\n");
         return false;
     }
@@ -718,6 +735,14 @@
         return false;
     }
 
+    //
+    // initialize GL state in eglContext if not yet initilaized
+    //
+    if (!m_eglContextInitialized) {
+        initGLState();
+        m_eglContextInitialized = true;
+    }
+
     m_prevContext = prevContext;
     m_prevReadSurf = prevReadSurf;
     m_prevDrawSurf = prevDrawSurf;
@@ -806,3 +831,12 @@
     }
     return false;
 }
+
+void FrameBuffer::initGLState()
+{
+    s_gl.glMatrixMode(GL_PROJECTION);
+    s_gl.glLoadIdentity();
+    s_gl.glOrthof(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
+    s_gl.glMatrixMode(GL_MODELVIEW);
+    s_gl.glLoadIdentity();
+}
diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h b/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
index b415efe..4725317 100644
--- a/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
+++ b/tools/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
@@ -75,7 +75,6 @@
     bool repost();
 
     EGLDisplay getDisplay() const { return m_eglDisplay; }
-    EGLContext getContext() const { return m_eglContext; }
     EGLNativeWindowType getSubWindow() const { return m_subWin; }
     bool bind_locked();
     bool unbind_locked();
@@ -90,6 +89,7 @@
     ~FrameBuffer();
     HandleType genHandle();
     bool bindSubwin_locked();
+    void initGLState();
 
 private:
     static FrameBuffer *s_theFrameBuffer;
@@ -109,6 +109,7 @@
     EGLSurface m_eglSurface;
     EGLContext m_eglContext;
     EGLSurface m_pbufSurface;
+    EGLContext m_pbufContext;
 
     EGLContext m_prevContext;
     EGLSurface m_prevReadSurf;
@@ -118,6 +119,7 @@
     EGLConfig  m_eglConfig;
     HandleType m_lastPostedColorBuffer;
     float      m_zRot;
+    bool       m_eglContextInitialized;
 
     int m_statsNumFrames;
     long long m_statsStartTime;
diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/RenderServer.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/RenderServer.cpp
index 3046db7..31f59c1 100644
--- a/tools/emulator/opengl/host/libs/libOpenglRender/RenderServer.cpp
+++ b/tools/emulator/opengl/host/libs/libOpenglRender/RenderServer.cpp
@@ -103,7 +103,7 @@
         // insert the added thread to the list
         threads.insert(rt);
 
-        printf("Started new RenderThread\n");
+        DBG("Started new RenderThread\n");
     }
 
     //
diff --git a/tools/emulator/opengl/host/libs/renderControl_dec/Android.mk b/tools/emulator/opengl/host/libs/renderControl_dec/Android.mk
index 889b5dd..4d07938 100644
--- a/tools/emulator/opengl/host/libs/renderControl_dec/Android.mk
+++ b/tools/emulator/opengl/host/libs/renderControl_dec/Android.mk
@@ -1,6 +1,6 @@
 LOCAL_PATH := $(call my-dir)
 
-$(call emugl-begin-host-shared-library,lib_renderControl_dec)
+$(call emugl-begin-host-static-library,lib_renderControl_dec)
 $(call emugl-import,libOpenglCodecCommon)
 $(call emugl-gen-decoder,$(EMUGL_PATH)/system/renderControl_enc,renderControl)
 # For renderControl_types.h
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h b/tools/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h
index 8502bb0..5e9c7b3 100644
--- a/tools/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h
@@ -19,11 +19,19 @@
 #if (HAVE_ANDROID_OS == 1)
 #    include <cutils/log.h>
 #    define ERR(...)    LOGE(__VA_ARGS__)
-#    define DBG(...)    LOGD(__VA_ARGS__)
+#    ifdef EMUGL_DEBUG
+#        define DBG(...)    LOGD(__VA_ARGS__)
+#    else
+#        define DBG(...)    ((void)0)
+#    endif
 #else
 #     include <stdio.h>
 #    define ERR(...)    fprintf(stderr, __VA_ARGS__)
-#    define DBG(...)    fprintf(stderr, __VA_ARGS__)
+#    ifdef EMUGL_DEBUG
+#        define DBG(...)    fprintf(stderr, __VA_ARGS__)
+#    else
+#        define DBG(...)    ((void)0)
+#    endif
 #endif
 
 #endif
diff --git a/tools/emulator/opengl/system/GLESv1/Android.mk b/tools/emulator/opengl/system/GLESv1/Android.mk
index 9d45694..97356b7 100644
--- a/tools/emulator/opengl/system/GLESv1/Android.mk
+++ b/tools/emulator/opengl/system/GLESv1/Android.mk
@@ -10,47 +10,3 @@
 LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
 
 $(call emugl-end-module)
-
-#
-# include $(CLEAR_VARS)
-#
-# # add additional depencies to ensure that the generated code that we depend on
-# # is generated
-# LOCAL_ADDITIONAL_DEPENDENCIES := \
-# 	$(TARGET_OUT_SHARED_LIBRARIES)/lib_renderControl_enc$(TARGET_SHLIB_SUFFIX) \
-# 	$(TARGET_OUT_SHARED_LIBRARIES)/libGLESv1_enc$(TARGET_SHLIB_SUFFIX)
-#
-# LOCAL_SRC_FILES := \
-#         gl.cpp
-#
-#
-# LOCAL_PRELINK_MODULE := false
-# LOCAL_CFLAGS += -DLOG_TAG=\"GLES_emulation\" -DGL_GLEXT_PROTOTYPES
-# LOCAL_C_INCLUDES +=  \
-#         $(emulatorOpengl)/host/include/libOpenglRender \
-#         $(emulatorOpengl)/shared/OpenglCodecCommon \
-#         $(emulatorOpengl)/system/OpenglSystemCommon \
-#         $(emulatorOpengl)/system/GLESv1_enc \
-#         $(emulatorOpengl)/system/renderControl_enc \
-# 		$(call intermediates-dir-for, SHARED_LIBRARIES, lib_renderControl_enc) \
-# 		$(call intermediates-dir-for, SHARED_LIBRARIES, libGLESv1_enc)
-#
-# LOCAL_MODULE_TAGS := debug
-# LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
-# LOCAL_MODULE := libGLESv1_CM_emulation
-# LOCAL_MODULE_CLASS := SHARED_LIBRARIES
-#
-#
-# LOCAL_STATIC_LIBRARIES := \
-#     libOpenglCodecCommon  \
-#
-# LOCAL_SHARED_LIBRARIES := \
-#     libcutils \
-# 	libutils \
-# 	libdl \
-#     libOpenglSystemCommon \
-# 	libGLESv1_enc	\
-# 	lib_renderControl_enc
-#
-#
-# include $(BUILD_SHARED_LIBRARY)
diff --git a/tools/emulator/opengl/system/egl/Android.mk b/tools/emulator/opengl/system/egl/Android.mk
index 49b967a..867773f 100644
--- a/tools/emulator/opengl/system/egl/Android.mk
+++ b/tools/emulator/opengl/system/egl/Android.mk
@@ -1,57 +1,24 @@
-ifneq (,$(BUILD_EMULATOR_OPENGL_DRIVER))
+ifneq (false,$(BUILD_EMULATOR_OPENGL_DRIVER))
 
 LOCAL_PATH := $(call my-dir)
-emulatorOpengl := $(LOCAL_PATH)/../..
 
-### EGL implementation ###########################################
-include $(CLEAR_VARS)
+$(call emugl-begin-shared-library,libEGL_emulation)
+$(call emugl-import,libOpenglSystemCommon)
+$(call emugl-set-shared-library-subpath,egl)
 
-# add additional depencies to ensure that the generated code that we depend on
-# is generated
-LOCAL_ADDITIONAL_DEPENDENCIES := \
-	$(TARGET_OUT_SHARED_LIBRARIES)/lib_renderControl_enc$(TARGET_SHLIB_SUFFIX) \
-	$(TARGET_OUT_SHARED_LIBRARIES)/libGLESv1_enc$(TARGET_SHLIB_SUFFIX)
+LOCAL_CFLAGS += -DLOG_TAG=\"EGL_emulation\" -DEGL_EGLEXT_PROTOTYPES -DWITH_GLES2
 
 LOCAL_SRC_FILES := \
-        eglDisplay.cpp \
-        egl.cpp \
-        ClientAPIExts.cpp
+    eglDisplay.cpp \
+    egl.cpp \
+    ClientAPIExts.cpp
 
+LOCAL_SHARED_LIBRARIES += libdl
+
+# Used to access the Bionic private OpenGL TLS slot
 LOCAL_C_INCLUDES += bionic/libc/private
 
-LOCAL_PRELINK_MODULE := false
-LOCAL_CFLAGS += -DLOG_TAG=\"EGL_emulation\" -DEGL_EGLEXT_PROTOTYPES -DWITH_GLES2
-LOCAL_C_INCLUDES +=  \
-        $(emulatorOpengl)/host/include/libOpenglRender \
-        $(emulatorOpengl)/shared/OpenglCodecCommon \
-        $(emulatorOpengl)/system/OpenglSystemCommon \
-        $(emulatorOpengl)/system/GLESv1_enc \
-        $(emulatorOpengl)/system/GLESv2_enc \
-        $(emulatorOpengl)/system/renderControl_enc \
-		$(call intermediates-dir-for, SHARED_LIBRARIES, lib_renderControl_enc) \
-		$(call intermediates-dir-for, SHARED_LIBRARIES, libGLESv1_enc)  \
-		$(call intermediates-dir-for, SHARED_LIBRARIES, libGLESv2_enc)
-
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
-LOCAL_MODULE := libEGL_emulation
-LOCAL_MODULE_CLASS := SHARED_LIBRARIES
-LOCAL_PRELINK_MODULE := false
-
-LOCAL_STATIC_LIBRARIES := \
-    libOpenglCodecCommon
-
-LOCAL_SHARED_LIBRARIES := \
-    libcutils \
-	libutils \
-	libdl	\
-    libGLESv1_enc \
-    libGLESv2_enc \
-    libOpenglSystemCommon \
-    lib_renderControl_enc
-
-
-include $(BUILD_SHARED_LIBRARY)
+$(call emugl-end-module)
 
 #### egl.cfg ####
 
@@ -70,6 +37,6 @@
 LOCAL_MODULE_CLASS := ETC
 
 include $(BUILD_PREBUILT)
-endif # TARGET_PRODUCT in 'full sdk full_x86 sdk_x86'
+endif # TARGET_PRODUCT in 'full sdk full_x86 sdk_x86)
 
-endif # of ifneq (,$(BUILD_EMULATOR_OPENGL_DRIVER))
+endif # BUILD_EMULATOR_OPENGL_DRIVER != false
diff --git a/tools/emulator/opengl/system/gralloc/Android.mk b/tools/emulator/opengl/system/gralloc/Android.mk
index 6e64537..810f812 100644
--- a/tools/emulator/opengl/system/gralloc/Android.mk
+++ b/tools/emulator/opengl/system/gralloc/Android.mk
@@ -1,46 +1,19 @@
-ifneq (,$(BUILD_EMULATOR_OPENGL_DRIVER))
+ifneq (false,$(BUILD_EMULATOR_OPENGL_DRIVER))
 
 LOCAL_PATH := $(call my-dir)
-emulatorOpengl := $(LOCAL_PATH)/../..
 
-### OpenglSystemCommon ##############################################
-include $(CLEAR_VARS)
+$(call emugl-begin-shared-library,gralloc.goldfish)
+$(call emugl-import,libGLESv1_enc lib_renderControl_enc libOpenglSystemCommon)
+$(call emugl-set-shared-library-subpath,hw)
 
-# add additional depencies to ensure that the generated code that we depend on
-# is generated
-LOCAL_ADDITIONAL_DEPENDENCIES := \
-	$(TARGET_OUT_SHARED_LIBRARIES)/lib_renderControl_enc$(TARGET_SHLIB_SUFFIX) \
-	$(TARGET_OUT_SHARED_LIBRARIES)/libGLESv1_enc$(TARGET_SHLIB_SUFFIX)
+LOCAL_CFLAGS += -DLOG_TAG=\"gralloc_goldfish\"
 
-LOCAL_SRC_FILES := \
-        gralloc.cpp
+LOCAL_SRC_FILES := gralloc.cpp
 
+# Need to access the special OPENGL TLS Slot
 LOCAL_C_INCLUDES += bionic/libc/private
 
-LOCAL_C_INCLUDES += \
-        $(emulatorOpengl)/host/include/libOpenglRender \
-        $(emulatorOpengl)/shared/OpenglCodecCommon \
-        $(emulatorOpengl)/system/OpenglSystemCommon \
-        $(emulatorOpengl)/system/GLESv1_enc \
-        $(emulatorOpengl)/system/renderControl_enc \
-		$(call intermediates-dir-for, SHARED_LIBRARIES, lib_renderControl_enc) \
-		$(call intermediates-dir-for, SHARED_LIBRARIES, libGLESv1_enc)
 
-LOCAL_MODULE_TAGS := debug
-LOCAL_PRELINK_MODULE := false
-LOCAL_CFLAGS:= -DLOG_TAG=\"gralloc_goldfish\"
-LOCAL_MODULE_PATH = $(TARGET_OUT_SHARED_LIBRARIES)/hw
-LOCAL_MODULE := gralloc.goldfish
+$(call emugl-end-module)
 
-LOCAL_STATIC_LIBRARIES := \
-    libOpenglCodecCommon
-
-LOCAL_SHARED_LIBRARIES := \
-    libcutils \
-    libOpenglSystemCommon \
-    libGLESv1_enc \
-    lib_renderControl_enc
-
-include $(BUILD_SHARED_LIBRARY)
-
-endif # of ifneq (,$(GEODON_DRIVER))
+endif # BUILD_EMULATOR_OPENGL_DRIVER != false
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk b/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk
index 8aee204..f7c8fed 100644
--- a/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk
@@ -16,43 +16,6 @@
 ## comment for no debug
 #debugFlags = -g -O0
 
-#### libGLESv1_CM_emul.so
-# include $(CLEAR_VARS)
-#
-#
-#
-# LOCAL_MODULE := libGLESv1_CM_emul
-# LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
-# LOCAL_MODULE_CLASS := SHARED_LIBRARIES
-# LOCAL_SRC_FILES := glesv1_emul_ifc.cpp
-#
-# LOCAL_PRELINK_MODULE := false
-# LOCAL_MODULE_TAGS := debug
-# LOCAL_SHARED_LIBRARIES := libdl libcutils
-# LOCAL_CFLAGS += $(debugFlags)
-#
-# LOCAL_C_INCLUDES += \
-# 	$(emulatorOpengl)/system/GLESv1_enc \
-# 	$(emulatorOpengl)/shared/OpenglCodecCommon
-#
-# glesv1_emul_intermediates := $(local-intermediates-dir)
-#
-# GEN_GLESv1_emul := \
-# 	$(glesv1_emul_intermediates)/gl_wrapper_entry.cpp \
-# 	$(glesv1_emul_intermediates)/gl_wrapper_context.cpp
-# $(GEN_GLESv1_emul) : PRIVATE_PATH := $(LOCAL_PATH)
-# $(GEN_GLESv1_emul) : PRIVATE_CUSTOM_TOOL := \
-# 	$(EMUGEN) -W $(glesv1_emul_intermediates) -i $(emulatorOpengl)/system/GLESv1_enc gl
-# $(GEN_GLESv1_emul) : $(EMUGEN) \
-# 	$(emulatorOpengl)/system/GLESv1_enc/gl.in \
-# 	$(emulatorOpengl)/system/GLESv1_enc/gl.attrib \
-# 	$(emulatorOpengl)/system/GLESv1_enc/gl.types
-# 	$(transform-generated-source)
-#
-# LOCAL_GENERATED_SOURCES += $(GEN_GLESv1_emul)
-#
-# include $(BUILD_SHARED_LIBRARY)
-
 #### libGLESv2_CM_emul.so
 $(call emugl-begin-shared-library, libGLESv2_emul)
 $(call emugl-import,libGLESv2_enc)
@@ -61,61 +24,15 @@
 $(call emugl-set-shared-library-subpath,egl)
 $(call emugl-end-module)
 
-# include $(CLEAR_VARS)
-#
-# LOCAL_MODULE := libGLESv2_emul
-# LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
-# LOCAL_MODULE_CLASS := SHARED_LIBRARIES
-# LOCAL_SRC_FILES := glesv2_emul_ifc.cpp
-#
-# LOCAL_PRELINK_MODULE := false
-# LOCAL_MODULE_TAGS := debug
-# LOCAL_SHARED_LIBRARIES := libdl libcutils
-# LOCAL_CFLAGS += $(debugFlags)
-#
-# LOCAL_C_INCLUDES += \
-# 	$(emulatorOpengl)/system/GLESv2_enc \
-# 	$(emulatorOpengl)/shared/OpenglCodecCommon
-#
-# glesv2_emul_intermediates := $(local-intermediates-dir)
-#
-# GEN_GLESv2_emul := \
-# 	$(glesv2_emul_intermediates)/gl2_wrapper_entry.cpp \
-# 	$(glesv2_emul_intermediates)/gl2_wrapper_context.cpp
-#
-# $(GEN_GLESv2_emul) : PRIVATE_PATH := $(LOCAL_PATH)
-# $(GEN_GLESv2_emul) : PRIVATE_CUSTOM_TOOL := \
-# 	$(EMUGEN) -W $(glesv2_emul_intermediates) -i $(emulatorOpengl)/system/GLESv2_enc gl2
-# $(GEN_GLESv2_emul) : $(EMUGEN) \
-# 	$(emulatorOpengl)/system/GLESv2_enc/gl2.in \
-# 	$(emulatorOpengl)/system/GLESv2_enc/gl2.attrib \
-# 	$(emulatorOpengl)/system/GLESv2_enc/gl2.types
-# 	$(transform-generated-source)
-#
-# LOCAL_GENERATED_SOURCES += $(GEN_GLESv2_emul)
-#
-# include $(BUILD_SHARED_LIBRARY)
-
-
 ##### libEGL_emul.so ###########
 
 # THE FOLLOWING DOESN'T WORK YET
 #
-# $(call emugl-begin-shared-library,libEGL_emul)
-# $(call emugl-import,libut_rendercontrol_enc libGLESv1_enc libGLESv2_enc libOpenglSystemCommon)
-#
-# $(call emugl-set-shared-library-subpath,egl)
-# LOCAL_CFLAGS += $(logTag)
-#
-# LOCAL_SRC_FILES :=  \
-#         egl.cpp \
-#         egl_dispatch.cpp \
-#         ServerConnection.cpp \
-#         ThreadInfo.cpp
-#
-# $(call emugl-end-module)
+$(call emugl-begin-shared-library,libEGL_emul)
+$(call emugl-import,libut_rendercontrol_enc libGLESv1_CM_emul libGLESv2_emul libOpenglSystemCommon)
 
-include $(CLEAR_VARS)
+$(call emugl-set-shared-library-subpath,egl)
+LOCAL_CFLAGS += $(logTag)
 
 LOCAL_SRC_FILES :=  \
         egl.cpp \
@@ -123,50 +40,7 @@
         ServerConnection.cpp \
         ThreadInfo.cpp
 
-# add additional depencies to ensure that the generated code that we depend on
-# is generated
-LOCAL_ADDITIONAL_DEPENDENCIES := \
-	$(TARGET_OUT_SHARED_LIBRARIES)/libut_rendercontrol_enc$(TARGET_SHLIB_SUFFIX) \
-	$(TARGET_OUT_SHARED_LIBRARIES)/libGLESv1_enc$(TARGET_SHLIB_SUFFIX) \
-	$(TARGET_OUT_SHARED_LIBRARIES)/libGLESv2_enc$(TARGET_SHLIB_SUFFIX) \
-	$(TARGET_OUT_SHARED_LIBRARIES)/egl/libGLESv1_CM_emul$(TARGET_SHLIB_SUFFIX) \
-	$(TARGET_OUT_SHARED_LIBRARIES)/egl/libGLESv2_emul$(TARGET_SHLIB_SUFFIX)
-
-
-
-LOCAL_C_INCLUDES := $(emulatorOpengl)/shared/OpenglCodecCommon \
-        $(emulatorOpengl)/host/include/libOpenglRender \
-        $(emulatorOpengl)/system/OpenglSystemCommon \
-		$(call intermediates-dir-for, SHARED_LIBRARIES, libut_rendercontrol_enc) \
-		$(call intermediates-dir-for, SHARED_LIBRARIES, libGLESv1_enc) \
-		$(call intermediates-dir-for, SHARED_LIBRARIES, libGLESv2_enc) \
-		$(call intermediates-dir-for, SHARED_LIBRARIES, libGLESv1_CM_emul) \
-		$(call intermediates-dir-for, SHARED_LIBRARIES, libGLESv2_emul) \
-        $(emulatorOpengl)/system/GLESv1_enc \
-        $(emulatorOpengl)/system/GLESv2_enc \
-        $(emulatorOpengl)/tests/ut_rendercontrol_enc
-
-
-LOCAL_CFLAGS := $(logTag)
-LOCAL_CFLAGS += $(debugFlags)
-
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
-LOCAL_MODULE := libEGL_emul
-LOCAL_MODULE_TAGS := debug
-LOCAL_PRELINK_MODULE := false
-
-#LOCAL_LDLIBS := -lpthread -ldl
-LOCAL_SHARED_LIBRARIES := libdl \
-	libcutils \
-	libGLESv1_enc \
-	libGLESv2_enc \
-	libOpenglSystemCommon \
-	libut_rendercontrol_enc
-
-LOCAL_STATIC_LIBRARIES := libOpenglCodecCommon
-
-include $(BUILD_SHARED_LIBRARY)
+$(call emugl-end-module)
 
 #### egl.cfg ####
 
diff --git a/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk b/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk
index c1cda0a..deb11b6 100644
--- a/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk
+++ b/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk
@@ -4,15 +4,15 @@
 $(call emugl-import,libEGL_translator libGLES_CM_translator)
 
 PREBUILT := $(HOST_PREBUILT_TAG)
-SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
-SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
-SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
+LOCAL_SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
+LOCAL_SDL_CFLAGS := $(shell $(LOCAL_SDL_CONFIG) --cflags)
+LOCAL_SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(LOCAL_SDL_CONFIG) --static-libs))
 
 LOCAL_SRC_FILES:= \
         triangleCM.cpp
 
-LOCAL_CFLAGS += $(SDL_CFLAGS) -g -O0
-LOCAL_LDLIBS += $(SDL_LDLIBS)
+LOCAL_CFLAGS += $(LOCAL_SDL_CFLAGS) -g -O0
+LOCAL_LDLIBS += $(LOCAL_SDL_LDLIBS)
 
 LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
 
@@ -21,40 +21,3 @@
 endif
 
 $(call emugl-end-module)
-
-# include $(CLEAR_VARS)
-#
-# translator_path := $(LOCAL_PATH)/../../../host/libs/Translator
-#
-# PREBUILT := $(HOST_PREBUILT_TAG)
-# SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
-# SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
-# SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
-#
-# LOCAL_SRC_FILES:= \
-#         triangleCM.cpp
-#
-#
-# LOCAL_SHARED_LIBRARIES := \
-#     libEGL_translator     \
-#     libGLES_CM_translator
-#
-# LOCAL_CFLAGS += $(SDL_CFLAGS) -g -O0
-# LOCAL_LDLIBS += $(SDL_LDLIBS)
-#
-#
-# LOCAL_MODULE:= triangleCM
-# LOCAL_MODULE_TAGS := debug
-# LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
-#
-# ifeq ($(HOST_OS),darwin)
-#
-# LOCAL_LDLIBS += -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit
-# LOCAL_STATIC_LIBRARIES += libMac_view
-# LOCAL_C_INCLUDES += \
-#                  $(LOCAL_PATH)/../MacCommon \
-#                  $(translator_path)/include
-# endif
-#
-# include $(BUILD_HOST_EXECUTABLE)
-
diff --git a/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk b/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk
index 8edea7a..ae0064f 100644
--- a/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk
+++ b/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk
@@ -4,15 +4,15 @@
 $(call emugl-import,libEGL_translator libGLES_V2_translator)
 
 PREBUILT := $(HOST_PREBUILT_TAG)
-SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
-SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
-SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
+LOCAL_SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
+LOCAL_SDL_CFLAGS := $(shell $(LOCAL_SDL_CONFIG) --cflags)
+LOCAL_SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(LOCAL_SDL_CONFIG) --static-libs))
 
 LOCAL_SRC_FILES:= \
         triangleV2.cpp
 
-LOCAL_CFLAGS += $(SDL_CFLAGS) -g -O0
-LOCAL_LDLIBS += $(SDL_LDLIBS)
+LOCAL_CFLAGS += $(LOCAL_SDL_CFLAGS) -g -O0
+LOCAL_LDLIBS += $(LOCAL_SDL_LDLIBS)
 
 LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
 
@@ -22,40 +22,3 @@
 
 $(call emugl-end-module)
 
-# include $(CLEAR_VARS)
-#
-# translator_path := $(LOCAL_PATH)/../../../host/libs/Translator
-#
-# PREBUILT := $(HOST_PREBUILT_TAG)
-# SDL_CONFIG ?= prebuilt/$(PREBUILT)/sdl/bin/sdl-config
-# SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
-# SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(SDL_CONFIG) --static-libs))
-#
-# LOCAL_SRC_FILES:= \
-#         triangleV2.cpp
-#
-#
-# LOCAL_SHARED_LIBRARIES := \
-#     libEGL_translator     \
-#     libGLES_V2_translator
-#
-# LOCAL_CFLAGS += $(SDL_CFLAGS) -g -O0
-# LOCAL_LDLIBS += $(SDL_LDLIBS)
-#
-#
-# LOCAL_MODULE:= triangleV2
-# LOCAL_MODULE_TAGS := debug
-# LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
-#
-# ifeq ($(HOST_OS),darwin)
-#
-# LOCAL_LDLIBS += -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit
-# LOCAL_C_INCLUDES += \
-#                  $(translator_path)/include \
-#                  $(LOCAL_PATH)/../MacCommon
-# LOCAL_STATIC_LIBRARIES += libMac_view
-#
-# endif
-#
-# include $(BUILD_HOST_EXECUTABLE)
-
diff --git a/tools/emulator/opengl/tests/translator_tests/MacCommon/Android.mk b/tools/emulator/opengl/tests/translator_tests/MacCommon/Android.mk
index 6e849a1..4c4ae6b 100644
--- a/tools/emulator/opengl/tests/translator_tests/MacCommon/Android.mk
+++ b/tools/emulator/opengl/tests/translator_tests/MacCommon/Android.mk
@@ -11,20 +11,3 @@
 LOCAL_CFLAGS += -g -O0
 $(call emugl-end-module)
 endif # HOST_OS == darwin
-
-# include $(CLEAR_VARS)
-#
-#
-# LOCAL_LDLIBS := -Wl,-framework,AppKit
-#
-# LOCAL_SRC_FILES :=  setup_gl.m
-#
-#
-#
-# LOCAL_CFLAGS := -g -O0
-# LOCAL_MODULE_TAGS := debug
-# LOCAL_MODULE := libMac_view
-#
-#
-# include $(BUILD_HOST_STATIC_LIBRARY)
-# endif