summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2012-08-04 20:09:03 -0700
committerMathias Agopian <mathias@google.com>2012-08-04 20:09:48 -0700
commitc1d359d42b753fcc2426d66a0f782f7c300893bc (patch)
treecae68eea0d4603d9690f65dceca80394c21a701f
parent92efd84f37ce5a8aae74dc9086f825a67b6894e9 (diff)
downloadframeworks_native-c1d359d42b753fcc2426d66a0f782f7c300893bc.zip
frameworks_native-c1d359d42b753fcc2426d66a0f782f7c300893bc.tar.gz
frameworks_native-c1d359d42b753fcc2426d66a0f782f7c300893bc.tar.bz2
break SF dependencies on libdvm and libandroid_runtime
these libraries are only needed for debugging and are now linked at runtime if needed. Change-Id: I03f138523c6de166a1e2700d4454d4a854aee145
-rw-r--r--services/surfaceflinger/Android.mk9
-rw-r--r--services/surfaceflinger/DdmConnection.cpp41
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp8
3 files changed, 41 insertions, 17 deletions
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 1f7affd..dd0dc16 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -3,6 +3,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
Client.cpp \
+ DdmConnection.cpp \
DisplayDevice.cpp \
EventThread.cpp \
Layer.cpp \
@@ -39,6 +40,7 @@ endif
LOCAL_SHARED_LIBRARIES := \
libcutils \
+ libdl \
libhardware \
libutils \
libEGL \
@@ -47,13 +49,6 @@ LOCAL_SHARED_LIBRARIES := \
libui \
libgui
-# this is only needed for DDMS debugging
-ifneq ($(TARGET_BUILD_PDK),true)
- LOCAL_SHARED_LIBRARIES += libdvm libandroid_runtime
- LOCAL_CFLAGS += -DDDMS_DEBUGGING
- LOCAL_SRC_FILES += DdmConnection.cpp
-endif
-
LOCAL_MODULE:= libsurfaceflinger
include $(BUILD_SHARED_LIBRARY)
diff --git a/services/surfaceflinger/DdmConnection.cpp b/services/surfaceflinger/DdmConnection.cpp
index 467a915..0b895e2 100644
--- a/services/surfaceflinger/DdmConnection.cpp
+++ b/services/surfaceflinger/DdmConnection.cpp
@@ -14,16 +14,16 @@
* limitations under the License.
*/
+#include <dlfcn.h>
+
#include <android_runtime/AndroidRuntime.h>
#include "jni.h"
#include "DdmConnection.h"
-extern "C" jint Java_com_android_internal_util_WithFramework_registerNatives(
- JNIEnv* env, jclass clazz);
-
namespace android {
+
void DdmConnection::start(const char* name) {
JavaVM* vm;
JNIEnv* env;
@@ -40,12 +40,36 @@ void DdmConnection::start(const char* name) {
args.nOptions = 1;
args.ignoreUnrecognized = JNI_FALSE;
+
+ void* libdvm_dso = dlopen("libdvm.so", RTLD_NOW);
+ ALOGE_IF(!libdvm_dso, "DdmConnection: %s", dlerror());
+
+ void* libandroid_runtime_dso = dlopen("libandroid_runtime.so", RTLD_NOW);
+ ALOGE_IF(!libandroid_runtime_dso, "DdmConnection: %s", dlerror());
+
+ if (!libdvm_dso || !libandroid_runtime_dso) {
+ goto error;
+ }
+
+ jint (*JNI_CreateJavaVM)(JavaVM** p_vm, JNIEnv** p_env, void* vm_args);
+ JNI_CreateJavaVM = (typeof JNI_CreateJavaVM)dlsym(libdvm_dso, "JNI_CreateJavaVM");
+ ALOGE_IF(!JNI_CreateJavaVM, "DdmConnection: %s", dlerror());
+
+ jint (*registerNatives)(JNIEnv* env, jclass clazz);
+ registerNatives = (typeof registerNatives)dlsym(libandroid_runtime_dso,
+ "Java_com_android_internal_util_WithFramework_registerNatives");
+ ALOGE_IF(!registerNatives, "DdmConnection: %s", dlerror());
+
+ if (!JNI_CreateJavaVM || !registerNatives) {
+ goto error;
+ }
+
if (JNI_CreateJavaVM(&vm, &env, &args) == 0) {
jclass startClass;
jmethodID startMeth;
// register native code
- if (Java_com_android_internal_util_WithFramework_registerNatives(env, 0) == 0) {
+ if (registerNatives(env, 0) == 0) {
// set our name by calling DdmHandleAppName.setAppName()
startClass = env->FindClass("android/ddm/DdmHandleAppName");
if (startClass) {
@@ -70,6 +94,15 @@ void DdmConnection::start(const char* name) {
}
}
}
+ return;
+
+error:
+ if (libandroid_runtime_dso) {
+ dlclose(libandroid_runtime_dso);
+ }
+ if (libdvm_dso) {
+ dlclose(libdvm_dso);
+ }
}
}; // namespace android
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index c64515d..382e013 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -105,18 +105,14 @@ SurfaceFlinger::SurfaceFlinger()
property_get("debug.sf.showupdates", value, "0");
mDebugRegion = atoi(value);
-#ifdef DDMS_DEBUGGING
property_get("debug.sf.ddms", value, "0");
mDebugDDMS = atoi(value);
if (mDebugDDMS) {
DdmConnection::start(getServiceName());
}
-#else
-#warning "DDMS_DEBUGGING disabled"
-#endif
- ALOGI_IF(mDebugRegion, "showupdates enabled");
- ALOGI_IF(mDebugDDMS, "DDMS debugging enabled");
+ ALOGI_IF(mDebugRegion, "showupdates enabled");
+ ALOGI_IF(mDebugDDMS, "DDMS debugging enabled");
}
void SurfaceFlinger::onFirstRef()