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

帐滓Android的BinderProxy和Binder??

 2010-05-31 14:28:00 来源:WEB开发网   
核心提示:env, kBinderPathName,gBinderMethods, NELEM(gBinderMethods));}?含有:jobject javaObjectForIBinder(JNIEnv* env, const sp& val){if (val == NULL) return NULL;if (val-&

env, kBinderPathName,

gBinderMethods, NELEM(gBinderMethods));

}

?含有:

jobject javaObjectForIBinder(JNIEnv* env, const sp& val)

{

if (val == NULL) return NULL;

if (val->checkSubclass(&gBinderOffsets)) {

// One of our own!

jobject object = static_cast(val.get())->object();

//printf("objectForBinder %p: it's our own %p! ", val.get(), object);

return object;

}

// For the rest of the function we will hold this lock, to serialize

// looking/creation of Java proxies for native Binder proxies.

AutoMutex _l(mProxyLock);

// Someone else's... do we know about it?

jobject object = (jobject)val->findObject(&gBinderProxyOffsets);

if (object != NULL) {

jobject res = env->CallObjectMethod(object, gWeakReferenceOffsets.mGet);

if (res != NULL) {

LOGV("objectForBinder %p: found existing %p! ", val.get(), res);

return res;

}

LOGV("Proxy object %p of IBinder %p no longer in working set!!!", object, val.get());

android_atomic_dec(&gNumProxyRefs);

val->detachObject(&gBinderProxyOffsets);

env->DeleteGlobalRef(object);

}

object = env->NewObject(gBinderProxyOffsets.mClass, gBinderProxyOffsets.mConstructor);

if (object != NULL) {

LOGV("objectForBinder %p: created new %p! ", val.get(), object);

// The proxy holds a reference to the native object.

env->SetIntField(object, gBinderProxyOffsets.mObject, (int)val.get());

val->incStrong(object);

// The native object needs to hold a weak reference back to the

// proxy, so we can retrieve the same proxy if it is still active.

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

Tags:Android BinderProxy Binder

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接