add libsurfaceflinger_ddmconnection for PDK build

- the library is dlopened from libsurfaceflinger
- the library built only when libnativehelper exists

Bug: 7089510
Change-Id: Ib3ea1029d7e8f6e055f4b759d0bf68f5123fa8a1
This commit is contained in:
Keun young Park 2012-08-31 10:53:36 -07:00 committed by Android (Google) Code Review
parent c397360883
commit 63f165fd6b
5 changed files with 47 additions and 2 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -20,6 +20,7 @@
#include <sys/types.h>
#include <errno.h>
#include <math.h>
#include <dlfcn.h>
#include <EGL/egl.h>
#include <GLES/gl.h>
@ -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)
{

View File

@ -388,6 +388,7 @@ private:
void clearStatsLocked(const Vector<String16>& 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