Revert "Drop locks before interacting with ANativeWindow"

This reverts commit 0edb6468a56b1f471770b2b18bf2f65d7889c1ed.
diff --git a/guest/libs/eglwrapper/Android.mk b/guest/libs/eglwrapper/Android.mk
index 571027b..00fa5da 100644
--- a/guest/libs/eglwrapper/Android.mk
+++ b/guest/libs/eglwrapper/Android.mk
@@ -27,9 +27,7 @@
     egl_wrapper_context.cpp \
     egl_wrapper_entry.cpp
 LOCAL_CFLAGS := -Wall -Werror
-LOCAL_C_INCLUDES := \
-	frameworks/native/opengl/include \
-	external/swiftshader
+LOCAL_C_INCLUDES := frameworks/native/opengl/include
 LOCAL_SHARED_LIBRARIES := libdl
 
 LOCAL_VENDOR_MODULE := true
diff --git a/guest/libs/eglwrapper/egl.cpp b/guest/libs/eglwrapper/egl.cpp
index c4edac4..f8ae96e 100644
--- a/guest/libs/eglwrapper/egl.cpp
+++ b/guest/libs/eglwrapper/egl.cpp
@@ -17,14 +17,13 @@
 #include "egl_wrapper_context.h"
 #undef GET_CONTEXT
 
-#include <mutex>
 #include <dlfcn.h>
 
 egl_wrapper_context_t* (*getEGLContext)(void) = NULL;
 
 static egl_wrapper_context_t g_egl_wrapper_context;
 
-static egl_wrapper_context_t *egl_context(void) {
+static egl_wrapper_context_t *egl(void) {
 	return &g_egl_wrapper_context;
 }
 
@@ -32,35 +31,7 @@
 	getEGLContext = f;
 }
 
-static std::mutex context_mutex;
-thread_local std::unique_lock<std::mutex> g_current_txn(
-		context_mutex, std::defer_lock);
-
-ScopedTxn::ScopedTxn() {
-	g_current_txn.lock();
-}
-
-ScopedTxn::~ScopedTxn() {
-	if (g_current_txn.owns_lock()) {
-	  g_current_txn.unlock();
-	}
-}
-
-
-static int nativeWindowHook(NativeWindowRequest* request) {
-	static t_nativeWindowFunction next = nullptr;
-	if (request->command == RegisterInnerFunction) {
-		next = request->inner_function;
-		return 0;
-	}
-	if (!next) {
-		return 0;
-	}
-	if (g_current_txn.owns_lock()) {
-	  g_current_txn.unlock();
-	}
-	return next(request);
-}
+std::mutex g_context_mutex;
 
 static void *getProc(const char *name, void *userData) {
 	return dlsym(userData, name);
@@ -69,11 +40,5 @@
 __attribute__((constructor)) void setup() {
 	void *egl_handle = dlopen("/vendor/lib/gl_impl/swiftshader/libEGL_swiftshader.so", RTLD_NOW);
 	g_egl_wrapper_context.initDispatchByName(getProc, egl_handle);
-	g_egl_wrapper_context.setContextAccessor(egl_context);
-	t_nativeWindowFunction (*hook)(t_nativeWindowFunction) =
-		(t_nativeWindowFunction (*)(t_nativeWindowFunction))
-		g_egl_wrapper_context.eglGetProcAddress("eglHookNativeWindow");
-	if (hook) {
-		hook(nativeWindowHook);
-	}
+	g_egl_wrapper_context.setContextAccessor(egl);
 }
diff --git a/guest/libs/eglwrapper/egl_types.h b/guest/libs/eglwrapper/egl_types.h
index 190c4c1..7a22e5f 100644
--- a/guest/libs/eglwrapper/egl_types.h
+++ b/guest/libs/eglwrapper/egl_types.h
@@ -22,14 +22,15 @@
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
 
-#include "scoped_txn.h"
-#include "src/Main/FrameBufferAndroidHook.hpp"
+#include <mutex>
+
+extern std::mutex g_context_mutex;
 
 struct egl_wrapper_context_t;
 extern egl_wrapper_context_t* (*getEGLContext)(void);
 
 #define GET_CONTEXT \
-	ScopedTxn lock; \
+	std::lock_guard<std::mutex> lock(g_context_mutex); \
 	egl_wrapper_context_t *ctx = getEGLContext()
 
 #endif
diff --git a/guest/libs/eglwrapper/gles1_types.h b/guest/libs/eglwrapper/gles1_types.h
index 79ff083..2456f09 100644
--- a/guest/libs/eglwrapper/gles1_types.h
+++ b/guest/libs/eglwrapper/gles1_types.h
@@ -20,13 +20,15 @@
 #include <GLES/gl.h>
 #include <GLES/glext.h>
 
-#include "scoped_txn.h"
+#include <mutex>
+
+extern std::mutex g_context_mutex;
 
 struct gles1_wrapper_context_t;
 extern gles1_wrapper_context_t* (*getGLES1Context)(void);
 
 #define GET_CONTEXT \
-	ScopedTxn lock; \
+	std::lock_guard<std::mutex> lock(g_context_mutex); \
 	gles1_wrapper_context_t *ctx = getGLES1Context()
 
 #endif
diff --git a/guest/libs/eglwrapper/gles3_types.h b/guest/libs/eglwrapper/gles3_types.h
index dd0767d..4e33844 100644
--- a/guest/libs/eglwrapper/gles3_types.h
+++ b/guest/libs/eglwrapper/gles3_types.h
@@ -22,13 +22,15 @@
 
 #include <GLES3/gl3.h>
 
-#include "scoped_txn.h"
+#include <mutex>
+
+extern std::mutex g_context_mutex;
 
 struct gles3_wrapper_context_t;
 extern gles3_wrapper_context_t* (*getGLES3Context)(void);
 
 #define GET_CONTEXT \
-	ScopedTxn lock; \
+	std::lock_guard<std::mutex> lock(g_context_mutex); \
 	gles3_wrapper_context_t *ctx = getGLES3Context()
 
 #endif
diff --git a/guest/libs/eglwrapper/scoped_txn.h b/guest/libs/eglwrapper/scoped_txn.h
deleted file mode 100644
index e400cec..0000000
--- a/guest/libs/eglwrapper/scoped_txn.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#pragma once
-
-class ScopedTxn {
-public:
-	ScopedTxn();
-	~ScopedTxn();
-};