WEB开发网
开发学院手机开发Android 开发 帐滓Android的BinderProxy和Binder?? 阅读

帐滓Android的BinderProxy和Binder??

 2010-05-31 14:28:00 来源:WEB开发网   
核心提示:}signalExceptionForError(env, obj, err);return JNI_FALSE;}?含有:sp ibinderForJavaObject(JNIEnv* env, jobject obj){if (obj == NULL) return NULL;if (env->IsInsta

}

signalExceptionForError(env, obj, err);

return JNI_FALSE;

}

?含有:

sp ibinderForJavaObject(JNIEnv* env, jobject obj)

{

if (obj == NULL) return NULL;

if (env->IsInstanceOf(obj, gBinderOffsets.mClass)) {

JavaBBinderHolder* jbh = (JavaBBinderHolder*)

env->GetIntField(obj, gBinderOffsets.mObject);

return jbh != NULL ? jbh->get(env) : NULL;

}

if (env->IsInstanceOf(obj, gBinderProxyOffsets.mClass)) {

return (IBinder*)

env->GetIntField(obj, gBinderProxyOffsets.mObject);

}

LOGW("ibinderForJavaObject: %p is not a Binder object", obj);

return NULL;

}

?含有:

static void android_os_Binder_init(JNIEnv* env, jobject clazz)

{

JavaBBinderHolder* jbh = new JavaBBinderHolder(env, clazz);

if (jbh == NULL) {

jniThrowException(env, "java/lang/OutOfMemoryError", NULL);

return;

}

LOGV("Java Binder %p: acquiring first ref on holder %p", clazz, jbh);

jbh->incStrong(clazz);

env->SetIntField(clazz, gBinderOffsets.mObject, (int)jbh);

}

static int int_register_android_os_Binder(JNIEnv* env)

{

jclass clazz;

clazz = env->FindClass(kBinderPathName);

LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.Binder");

gBinderOffsets.mClass = (jclass) env->NewGlobalRef(clazz);

gBinderOffsets.mExecTransact

= env->GetMethodID(clazz, "execTransact", "(IIII)Z");

assert(gBinderOffsets.mExecTransact);

gBinderOffsets.mObject

= env->GetFieldID(clazz, "mObject", "I");

assert(gBinderOffsets.mObject);

return AndroidRuntime::registerNativeMethods(

上一页  1 2 3 4 5 6  下一页

Tags:Android BinderProxy Binder

编辑录入:coldstar [复制链接] [打 印]
赞助商链接