Merge changes Idcb03342,I75925f9f into main

* changes:
  Make mmapedOffset one uint64_t instead of a pair of uint32_t
  Make usage uint64_t in cb_handle_t
diff --git a/common/end2end/Android.bp b/common/end2end/Android.bp
index c2fcddb..4ec4200 100644
--- a/common/end2end/Android.bp
+++ b/common/end2end/Android.bp
@@ -38,12 +38,12 @@
         "libGLESv2_emulation_with_host",
     ],
     shared_libs: [
-        "libandroidemu",
         "libOpenglSystemCommonWithHost",
         "liblog",
         "libvirtgpu_kumquat_ffi",
     ],
     static_libs: [
+        "libgfxstream_androidemu_static",
         "libgfxstream_common_image",
         "libgfxstream_common_utils",
         "libgfxstream_guest_android_with_host",
diff --git a/guest/GLESv1/Android.bp b/guest/GLESv1/Android.bp
index 166e5bd..ac884a5 100644
--- a/guest/GLESv1/Android.bp
+++ b/guest/GLESv1/Android.bp
@@ -26,6 +26,9 @@
     defaults: [
         "libgfxstream_guest_cc_defaults",
     ],
+    header_libs: [
+        "libgfxstream_egl_headers",
+    ],
     shared_libs: [
         "liblog",
         "lib_renderControl_enc",
diff --git a/guest/GLESv1_enc/Android.bp b/guest/GLESv1_enc/Android.bp
index 2489667..ec3925e 100644
--- a/guest/GLESv1_enc/Android.bp
+++ b/guest/GLESv1_enc/Android.bp
@@ -30,8 +30,10 @@
         "libgfxstream_guest_graphics_headers",
         "libgfxstream_guest_iostream",
     ],
+    static_libs: [
+        "libgfxstream_androidemu_static",
+    ],
     shared_libs: [
-        "libandroidemu",
         "liblog",
         "libOpenglCodecCommon",
     ],
diff --git a/guest/GLESv2/Android.bp b/guest/GLESv2/Android.bp
index f4728d5..cd921dd 100644
--- a/guest/GLESv2/Android.bp
+++ b/guest/GLESv2/Android.bp
@@ -26,6 +26,12 @@
     defaults: [
         "libgfxstream_guest_cc_defaults",
     ],
+    header_libs: [
+        "libgfxstream_egl_headers",
+    ],
+    static_libs: [
+        "libgfxstream_androidemu_static",
+    ],
     shared_libs: [
         "liblog",
         "lib_renderControl_enc",
diff --git a/guest/GLESv2_enc/Android.bp b/guest/GLESv2_enc/Android.bp
index 0ea4aeb..5ed3b0f 100644
--- a/guest/GLESv2_enc/Android.bp
+++ b/guest/GLESv2_enc/Android.bp
@@ -45,7 +45,6 @@
         "libgfxstream_guest_iostream",
     ],
     shared_libs: [
-        "libandroidemu",
         "liblog",
         "libOpenglCodecCommon",
     ],
@@ -53,6 +52,7 @@
         "libOpenglCodecCommon",
     ],
     static_libs: [
+        "libgfxstream_androidemu_static",
         "libgfxstream_gles2_encoder_program_binary_proto",
         "libprotobuf-cpp-lite",
     ],
diff --git a/guest/OpenglSystemCommon/Android.bp b/guest/OpenglSystemCommon/Android.bp
index a7d9dc1..1f867f2 100644
--- a/guest/OpenglSystemCommon/Android.bp
+++ b/guest/OpenglSystemCommon/Android.bp
@@ -116,10 +116,8 @@
     defaults: [
         "libOpenglSystemCommonDefaults",
     ],
-    shared_libs: [
-        "libandroidemu",
-    ],
     static_libs: [
+        "libgfxstream_androidemu_static",
         "libgfxstream_guest_android",
         "libmesa_util_gfxstream",
         "libmesa_util_c11_gfxstream",
@@ -146,10 +144,10 @@
         "libOpenglSystemCommonDefaults",
     ],
     shared_libs: [
-        "libandroidemu",
         "libvirtgpu_kumquat_ffi",
     ],
     static_libs: [
+        "libgfxstream_androidemu_static",
         "libgfxstream_guest_android_with_host",
         "libgfxstream_guest_vulkan_encoder_with_host",
         "libmesa_util_gfxstream",
diff --git a/guest/OpenglSystemCommon/HostConnection.cpp b/guest/OpenglSystemCommon/HostConnection.cpp
index be8a733..9ce74da 100644
--- a/guest/OpenglSystemCommon/HostConnection.cpp
+++ b/guest/OpenglSystemCommon/HostConnection.cpp
@@ -69,14 +69,9 @@
 #include "VirtioGpuPipeStream.h"
 
 #if defined(__linux__) || defined(__ANDROID__)
-#include "virtgpu_drm.h"
 #include <fstream>
 #include <string>
 #include <unistd.h>
-
-static const size_t kPageSize = getpagesize();
-#else
-constexpr size_t kPageSize = PAGE_SIZE;
 #endif
 
 #undef LOG_TAG
@@ -84,7 +79,6 @@
 #include <cutils/log.h>
 
 #define STREAM_BUFFER_SIZE  (4*1024*1024)
-#define STREAM_PORT_NUM     22468
 
 constexpr const auto kEglProp = "ro.hardware.egl";
 
@@ -323,7 +317,7 @@
 GLEncoder *HostConnection::glEncoder()
 {
     if (!m_glEnc) {
-        m_glEnc = std::make_unique<GLEncoder>(m_stream, checksumHelper());
+        m_glEnc = std::make_unique<GLEncoder>(m_stream, &m_checksumHelper);
         DBG("HostConnection::glEncoder new encoder %p, tid %lu", m_glEnc, getCurrentThreadId());
         m_glEnc->setContextAccessor(s_getGLContext);
     }
@@ -333,8 +327,7 @@
 GL2Encoder *HostConnection::gl2Encoder()
 {
     if (!m_gl2Enc) {
-        m_gl2Enc =
-            std::make_unique<GL2Encoder>(m_stream, checksumHelper());
+        m_gl2Enc = std::make_unique<GL2Encoder>(m_stream, &m_checksumHelper);
         DBG("HostConnection::gl2Encoder new encoder %p, tid %lu", m_gl2Enc, getCurrentThreadId());
         m_gl2Enc->setContextAccessor(s_getGL2Context);
         m_gl2Enc->setNoHostError(m_noHostError);
@@ -356,8 +349,7 @@
 ExtendedRCEncoderContext *HostConnection::rcEncoder()
 {
     if (!m_rcEnc) {
-        m_rcEnc = std::make_unique<ExtendedRCEncoderContext>(m_stream,
-                                                             checksumHelper());
+        m_rcEnc = std::make_unique<ExtendedRCEncoderContext>(m_stream, &m_checksumHelper);
 
         ExtendedRCEncoderContext* rcEnc = m_rcEnc.get();
         setChecksumHelper(rcEnc);
diff --git a/guest/OpenglSystemCommon/HostConnection.h b/guest/OpenglSystemCommon/HostConnection.h
index bb09e76..be01b18 100644
--- a/guest/OpenglSystemCommon/HostConnection.h
+++ b/guest/OpenglSystemCommon/HostConnection.h
@@ -136,10 +136,6 @@
     gfxstream::vk::VkEncoder *vkEncoder();
     ExtendedRCEncoderContext *rcEncoder();
 
-    int getRendernodeFd() { return m_rendernodeFd; }
-
-    gfxstream::guest::ChecksumCalculator *checksumHelper() { return &m_checksumHelper; }
-
 #if defined(ANDROID)
     gfxstream::ANativeWindowHelper* anwHelper() { return m_anwHelper.get(); }
     gfxstream::Gralloc* grallocHelper() { return m_grallocHelper.get(); }
diff --git a/guest/android-emu/aemu/base/Tracing.cpp b/guest/android-emu/aemu/base/Tracing.cpp
index c651759..c53d988 100644
--- a/guest/android-emu/aemu/base/Tracing.cpp
+++ b/guest/android-emu/aemu/base/Tracing.cpp
@@ -31,35 +31,18 @@
 namespace guest {
 
 bool isTracingEnabled() {
-#if defined(__ANDROID__)
-    return atrace_is_tag_enabled(TRACE_TAG);
-#else
     // TODO: Fuchsia + Linux
     return false;
-#endif
 }
 
 void ScopedTraceGuest::beginTraceImpl(const char* name) {
-#if defined(__ANDROID__)
-    atrace_begin(TRACE_TAG, name);
-#elif defined(__Fuchsia__) && !defined(FUCHSIA_NO_TRACE)
-    TRACE_DURATION_BEGIN(TRACE_TAG, name);
-#else
     // No-op
     (void)name;
-#endif
 }
 
 void ScopedTraceGuest::endTraceImpl(const char* name) {
-#if defined(__ANDROID__)
-    (void)name;
-    atrace_end(TRACE_TAG);
-#elif defined(__Fuchsia__) && !defined(FUCHSIA_NO_TRACE)
-    TRACE_DURATION_END(TRACE_TAG, name);
-#else
     // No-op
     (void)name;
-#endif
 }
 
 } // namespace base
diff --git a/guest/egl/Android.bp b/guest/egl/Android.bp
index 3b07122..1cd8c71 100644
--- a/guest/egl/Android.bp
+++ b/guest/egl/Android.bp
@@ -19,6 +19,15 @@
     default_applicable_licenses: ["hardware_google_gfxstream_license"],
 }
 
+cc_library_headers {
+    host_supported: true,
+    vendor: true,
+    name: "libgfxstream_egl_headers",
+    export_include_dirs: [
+        ".",
+    ],
+}
+
 cc_defaults {
     name: "libgfxstream_guest_egl_defaults",
     host_supported: true,
@@ -34,13 +43,13 @@
         "libgfxstream_guest_graphics_headers",
     ],
     shared_libs: [
-        "libandroidemu",
         "libcutils",
         "libdrm",
         "liblog",
         "libOpenglCodecCommon",
     ],
     static_libs: [
+        "libgfxstream_androidemu_static",
         "libarect",
         "libqemupipe.ranchu",
     ],
diff --git a/guest/OpenglSystemCommon/EGLClientIface.h b/guest/egl/EGLClientIface.h
similarity index 100%
rename from guest/OpenglSystemCommon/EGLClientIface.h
rename to guest/egl/EGLClientIface.h
diff --git a/guest/OpenglSystemCommon/EGLImage.h b/guest/egl/EGLImage.h
similarity index 100%
rename from guest/OpenglSystemCommon/EGLImage.h
rename to guest/egl/EGLImage.h
diff --git a/guest/qemupipe/Android.bp b/guest/qemupipe/Android.bp
index b199e34..4fbd9e5 100644
--- a/guest/qemupipe/Android.bp
+++ b/guest/qemupipe/Android.bp
@@ -32,21 +32,10 @@
     vendor_available: true,
     srcs: [
         "qemu_pipe_common.cpp",
+        "qemu_pipe_guest.cpp",
     ],
     header_libs: ["libqemupipe-types.ranchu"],
     export_header_lib_headers: ["libqemupipe-types.ranchu"],
     shared_libs: ["liblog"],
     export_include_dirs: ["include"],
-    target: {
-        android: {
-            srcs: [
-                "qemu_pipe_guest.cpp",
-            ],
-        },
-        host: {
-            srcs: [
-                "qemu_pipe_stub.cpp",
-            ],
-        },
-    },
 }
diff --git a/guest/qemupipe/qemu_pipe_stub.cpp b/guest/qemupipe/qemu_pipe_stub.cpp
deleted file mode 100644
index 0e1c14d..0000000
--- a/guest/qemupipe/qemu_pipe_stub.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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.
-
-extern "C" {
-
-int qemu_pipe_open_ns(const char*, const char*, int) {
-    return -1;
-}
-
-int qemu_pipe_open(const char*) {
-    return -1;
-}
-
-void qemu_pipe_close(int) {
-}
-
-int qemu_pipe_read(int, void*, int) {
-    return -1;
-}
-
-int qemu_pipe_write(int, const void*, int) {
-    return -1;
-}
-
-int qemu_pipe_try_again(int) {
-    return -1;
-}
-
-void qemu_pipe_print_error(int) {
-}
-
-}  // extern "C"
\ No newline at end of file
diff --git a/guest/renderControl_enc/Android.bp b/guest/renderControl_enc/Android.bp
index 5f346a3..c58a292 100644
--- a/guest/renderControl_enc/Android.bp
+++ b/guest/renderControl_enc/Android.bp
@@ -46,8 +46,10 @@
         "libgfxstream_guest_graphics_headers",
         "libgfxstream_guest_iostream",
     ],
+    static_libs: [
+        "libgfxstream_androidemu_static",
+    ],
     shared_libs: [
-        "libandroidemu",
         "liblog",
         "libOpenglCodecCommon",
     ],