Merge changes from topic "gfxstream-end2end-tests" into main

* changes:
  Update namespace in libandroidemu to gfxstream::guest
  Migrate Gfxstream guest libraries to Android.bp
diff --git a/Android.mk b/Android.mk
index af4d859..05998f8 100644
--- a/Android.mk
+++ b/Android.mk
@@ -148,38 +148,10 @@
     include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/android-emu/Android.mk
 endif
 
-include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/OpenglCodecCommon/Android.mk
-
-# Encoder shared libraries
-include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/GLESv1_enc/Android.mk
-include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/GLESv2_enc/Android.mk
-include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/renderControl_enc/Android.mk
-
-ifeq (true,$(GFXSTREAM)) # Vulkan libs
-    include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/vulkan_enc/Android.mk
-endif
-
-include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/OpenglSystemCommon/Android.mk
-
-# Profiler library
-include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/profiler/Android.mk
-
-# System shared libraries
-include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/GLESv1/Android.mk
-include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/GLESv2/Android.mk
-
-include $(GOLDFISH_OPENGL_PATH)/system/gralloc/Android.mk
-
 ifneq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
 include $(GOLDFISH_OPENGL_PATH)/system/hals/Android.mk
 endif
 
-include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/egl/Android.mk
-
-ifeq (true,$(GFXSTREAM)) # Vulkan libs
-    include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/vulkan/Android.mk
-endif
-
 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 28 -o $(IS_AT_LEAST_QPR1) = true && echo isApi29OrHigher),isApi29OrHigher)
     include $(GOLDFISH_OPENGL_PATH)/system/hwc3/Android.mk
     # hardware codecs enabled after P
@@ -191,8 +163,4 @@
 
 endif
 
-ifeq (true,$(GFXSTREAM)) # Vulkan lib tests
-    include $(HARDWARE_GOOGLE_GFXSTREAM_PATH)/guest/vulkan_enc_unit_tests/Android.mk
-endif
-
 endif # ENABLE_GOLDFISH_OPENGL_FOLDER
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 17810e5..7a47aff 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,21 +2,9 @@
 # instead run make from .../device/generic/goldfish-opengl
 # which will re-generate this file.
 set(GOLDFISH_DEVICE_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
-android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/./Android.mk" "e1da88d802cf243b2d905163d80646bde992c778e7bed1d9ceb2358dfeeb4eaa")
+android_validate_sha256("${GOLDFISH_DEVICE_ROOT}/./Android.mk" "d683e4eb6b1b5bfe3243dd0c984a0997e20e83a3814aa70ed4ffe7f97e952034")
 add_subdirectory(../../../hardware/google/gfxstream/guest/qemupipe hardware-google-gfxstream-guest-qemupipe)
 add_subdirectory(../../../hardware/google/gfxstream/guest/gralloc_cb hardware-google-gfxstream-guest-gralloc_cb)
 add_subdirectory(../../../hardware/google/gfxstream/guest/GoldfishAddressSpace hardware-google-gfxstream-guest-goldfishaddressspace)
 add_subdirectory(../../../hardware/google/gfxstream/guest/platform hardware-google-gfxstream-guest-platform)
-add_subdirectory(../../../hardware/google/gfxstream/guest/android-emu hardware-google-gfxstream-guest-android-emu)
-add_subdirectory(../../../hardware/google/gfxstream/guest/OpenglCodecCommon hardware-google-gfxstream-guest-openglcodeccommon)
-add_subdirectory(../../../hardware/google/gfxstream/guest/GLESv1_enc hardware-google-gfxstream-guest-glesv1_enc)
-add_subdirectory(../../../hardware/google/gfxstream/guest/GLESv2_enc hardware-google-gfxstream-guest-glesv2_enc)
-add_subdirectory(../../../hardware/google/gfxstream/guest/renderControl_enc hardware-google-gfxstream-guest-rendercontrol_enc)
-add_subdirectory(../../../hardware/google/gfxstream/guest/vulkan_enc hardware-google-gfxstream-guest-vulkan_enc)
-add_subdirectory(../../../hardware/google/gfxstream/guest/OpenglSystemCommon hardware-google-gfxstream-guest-openglsystemcommon)
-add_subdirectory(../../../hardware/google/gfxstream/guest/profiler hardware-google-gfxstream-guest-profiler)
-add_subdirectory(../../../hardware/google/gfxstream/guest/GLESv1 hardware-google-gfxstream-guest-glesv1)
-add_subdirectory(../../../hardware/google/gfxstream/guest/GLESv2 hardware-google-gfxstream-guest-glesv2)
-add_subdirectory(system/gralloc)
-add_subdirectory(../../../hardware/google/gfxstream/guest/egl hardware-google-gfxstream-guest-egl)
-add_subdirectory(../../../hardware/google/gfxstream/guest/vulkan hardware-google-gfxstream-guest-vulkan)
\ No newline at end of file
+add_subdirectory(../../../hardware/google/gfxstream/guest/android-emu hardware-google-gfxstream-guest-android-emu)
\ No newline at end of file
diff --git a/system/gralloc/Android.bp b/system/gralloc/Android.bp
new file mode 100644
index 0000000..55cc085
--- /dev/null
+++ b/system/gralloc/Android.bp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+package {
+    default_applicable_licenses: ["device_generic_goldfish-opengl_license"],
+}
+
+cc_library_shared {
+    name: "gralloc.goldfish",
+    vendor: true,
+    relative_install_path: "hw",
+    defaults: [
+        "libgfxstream_guest_cc_defaults",
+    ],
+    shared_libs: [
+        "libcutils",
+        "libdl",
+        "libdrm",
+        "liblog",
+        "libGLESv1_enc",
+        "lib_renderControl_enc",
+        "libOpenglCodecCommon",
+        "libOpenglSystemCommon",
+    ],
+    static_libs: [
+        "libGoldfishAddressSpace",
+        "libqemupipe.ranchu",
+    ],
+    cflags: [
+        "-DVIRTIO_GPU",
+        "-DLOG_TAG=\"gralloc_goldfish\"",
+        "-Wno-missing-field-initializers",
+        "-Wno-gnu-designator"
+    ],
+    srcs: [
+        "gralloc_old.cpp",
+    ],
+}
+
+cc_library_shared {
+    name: "gralloc.ranchu",
+    vendor: true,
+    relative_install_path: "hw",
+    defaults: [
+        "libgfxstream_guest_cc_defaults",
+    ],
+    shared_libs: [
+        "libcutils",
+        "libdl",
+        "libdrm",
+        "liblog",
+        "libGLESv1_enc",
+        "lib_renderControl_enc",
+        "libOpenglCodecCommon",
+        "libOpenglSystemCommon",
+    ],
+    static_libs: [
+        "libGoldfishAddressSpace",
+        "libqemupipe.ranchu",
+    ],
+    cflags: [
+        "-DVIRTIO_GPU",
+        "-DLOG_TAG=\"gralloc_ranchu\"",
+        "-Wno-missing-field-initializers",
+        "-Wno-gnu-designator"
+    ],
+    srcs: [
+        "gralloc_old.cpp",
+    ],
+}
diff --git a/system/gralloc/Android.mk b/system/gralloc/Android.mk
deleted file mode 100644
index 20c7606..0000000
--- a/system/gralloc/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-ifneq (false,$(BUILD_EMULATOR_OPENGL_DRIVER))
-
-LOCAL_PATH := $(call my-dir)
-
-define gralloc_recipe
-$$(call emugl-begin-shared-library,gralloc.$(1))
-$$(call emugl-import,libGLESv1_enc lib_renderControl_enc libOpenglSystemCommon)
-$$(call emugl-set-shared-library-subpath,hw)
-
-LOCAL_CFLAGS += -DLOG_TAG=\"gralloc_$(1)\"
-LOCAL_CFLAGS += -Wno-missing-field-initializers
-LOCAL_CFLAGS += -Wno-gnu-designator
-
-LOCAL_SRC_FILES := gralloc_old.cpp
-
-ifneq (true,$(GOLDFISH_OPENGL_BUILD_FOR_HOST))
-LOCAL_SHARED_LIBRARIES += libdl
-
-ifeq (true,$(GFXSTREAM))
-LOCAL_CFLAGS += -DVIRTIO_GPU
-LOCAL_C_INCLUDES += external/libdrm external/minigbm/cros_gralloc
-LOCAL_SHARED_LIBRARIES += libdrm
-endif
-
-endif
-
-$$(call emugl-end-module)
-endef  # define gralloc_recipe
-
-$(eval $(call gralloc_recipe,goldfish))
-$(eval $(call gralloc_recipe,ranchu))
-ifeq ($(TARGET_BOARD_PLATFORM),brilloemulator)
-$(eval $(call gralloc_recipe,$(TARGET_BOARD_PLATFORM)))
-endif  # defined(BRILLO)
-
-endif # BUILD_EMULATOR_OPENGL_DRIVER != false
diff --git a/system/hwc3/DrmClient.cpp b/system/hwc3/DrmClient.cpp
index 4f417e5..618fe58 100644
--- a/system/hwc3/DrmClient.cpp
+++ b/system/hwc3/DrmClient.cpp
@@ -18,9 +18,9 @@
 
 #include <cros_gralloc_handle.h>
 
-using ::android::base::guest::AutoReadLock;
-using ::android::base::guest::AutoWriteLock;
-using ::android::base::guest::ReadWriteLock;
+using ::gfxstream::guest::AutoReadLock;
+using ::gfxstream::guest::AutoWriteLock;
+using ::gfxstream::guest::ReadWriteLock;
 
 namespace aidl::android::hardware::graphics::composer3::impl {
 
diff --git a/system/hwc3/DrmClient.h b/system/hwc3/DrmClient.h
index 7919cbf..ad0d6d0 100644
--- a/system/hwc3/DrmClient.h
+++ b/system/hwc3/DrmClient.h
@@ -98,7 +98,7 @@
     // Drm device.
     ::android::base::unique_fd mFd;
 
-    mutable ::android::base::guest::ReadWriteLock mDisplaysMutex;
+    mutable ::gfxstream::guest::ReadWriteLock mDisplaysMutex;
     std::vector<std::unique_ptr<DrmDisplay>> mDisplays;
 
     std::optional<HotplugCallback> mHotplugCallback;