From 63f165fd6b86d04be94d4023e845e98560504a96 Mon Sep 17 00:00:00 2001 From: Keun young Park Date: Fri, 31 Aug 2012 10:53:36 -0700 Subject: [PATCH] add libsurfaceflinger_ddmconnection for PDK build - the library is dlopened from libsurfaceflinger - the library built only when libnativehelper exists Bug: 7089510 Change-Id: Ib3ea1029d7e8f6e055f4b759d0bf68f5123fa8a1 --- services/surfaceflinger/Android.mk | 16 ++++++++++++++ services/surfaceflinger/DdmConnection.cpp | 4 ++++ services/surfaceflinger/DdmConnection.h | 3 +++ services/surfaceflinger/SurfaceFlinger.cpp | 25 ++++++++++++++++++++-- services/surfaceflinger/SurfaceFlinger.h | 1 + 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index dd0dc1662..07002cc88 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -52,3 +52,19 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_MODULE:= libsurfaceflinger include $(BUILD_SHARED_LIBRARY) + +############################################################### +# uses jni which may not be available in PDK +ifneq ($(wildcard libnativehelper/include),) +include $(CLEAR_VARS) +LOCAL_SRC_FILES:= \ + DdmConnection.cpp + +LOCAL_SHARED_LIBRARIES := \ + libcutils \ + libdl + +LOCAL_MODULE:= libsurfaceflinger_ddmconnection + +include $(BUILD_SHARED_LIBRARY) +endif # libnativehelper diff --git a/services/surfaceflinger/DdmConnection.cpp b/services/surfaceflinger/DdmConnection.cpp index 433b38e54..ece965cf4 100644 --- a/services/surfaceflinger/DdmConnection.cpp +++ b/services/surfaceflinger/DdmConnection.cpp @@ -23,6 +23,10 @@ namespace android { +void DdmConnection_start(const char* name) { + ALOGI("DdmConnection_start"); + DdmConnection::start(name); +} void DdmConnection::start(const char* name) { JavaVM* vm; diff --git a/services/surfaceflinger/DdmConnection.h b/services/surfaceflinger/DdmConnection.h index 91b737c92..b6b088bf1 100644 --- a/services/surfaceflinger/DdmConnection.h +++ b/services/surfaceflinger/DdmConnection.h @@ -19,6 +19,9 @@ namespace android { +// wrapper for dlsym +extern "C" void DdmConnection_start(const char* name); + class DdmConnection { public: static void start(const char* name); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 7124b0cc7..ee653f3c0 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -108,9 +109,11 @@ SurfaceFlinger::SurfaceFlinger() property_get("debug.sf.ddms", value, "0"); mDebugDDMS = atoi(value); if (mDebugDDMS) { - DdmConnection::start(getServiceName()); + if (!startDdmConnection()) { + // start failed, and DDMS debugging not enabled + mDebugDDMS = 0; + } } - ALOGI_IF(mDebugRegion, "showupdates enabled"); ALOGI_IF(mDebugDDMS, "DDMS debugging enabled"); } @@ -2061,6 +2064,24 @@ void SurfaceFlinger::dumpAllLocked( hw->dump(result); } +bool SurfaceFlinger::startDdmConnection() +{ + void* libddmconnection_dso = + dlopen("libsurfaceflinger_ddmconnection.so", RTLD_NOW); + if (!libddmconnection_dso) { + return false; + } + void (*DdmConnection_start)(const char* name); + DdmConnection_start = + (typeof DdmConnection_start)dlsym(libddmconnection_dso, "DdmConnection_start"); + if (!DdmConnection_start) { + dlclose(libddmconnection_dso); + return false; + } + (*DdmConnection_start)(getServiceName()); + return true; +} + status_t SurfaceFlinger::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 50fef009d..9db6b2d78 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -388,6 +388,7 @@ private: void clearStatsLocked(const Vector& args, size_t& index, String8& result, char* buffer, size_t SIZE) const; void dumpAllLocked(String8& result, char* buffer, size_t SIZE) const; + bool startDdmConnection(); /* ------------------------------------------------------------------------ * Attributes