freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

android系統(tǒng)進程間通信binder機制在應(yīng)用程序框架層的java接口源代碼-預(yù)覽頁

2025-05-01 05:06 上一頁面

下一頁面
 

【正文】 G_FATAL_IF(clazzto21. 23. =envGetStaticMethodID(clazz,I)。33. =)。36. returnkBinderProxyPathName, {of3. jobjectit39。%p!\n,前面說過,這里傳進來的參數(shù)是一個BpBinder的指針,而BpBinder::checkSubclass繼承于父類IBinder::checkSubclass,它什么也不做就返回false。 = 于是函數(shù)又繼續(xù)往下執(zhí)行:view plain1. object 創(chuàng)建了之后,要把這個BpBinder對象和這個BinderProxy對象關(guān)聯(lián)起來:view plain1. envSetIntField(object, gBinderProxyOffsets,proxy_cleanup)。最后,就把這個BinderProxy返回到android_os_BinderInternal_getContextObject函數(shù),于是,我們就獲得一個BinderProxy對象了。 (())。相當于是:view plain1. sServiceManager class2. {4. staticobj)6. if{9. IServiceManager10. (IServiceManager)(descriptor)。(in17. ...... 這里的參數(shù)obj是一個BinderProxy對象,它的queryLocalInterface函數(shù)返回null。 (new 就相當于是:view plain1. sServiceManagerBinderProxy())??偨Y(jié)一下,就是在Java層,我們擁有了一個Service Manager遠程接口ServiceManagerProxy,而這個ServiceManagerProxy對象在JNI層有一個句柄值為0的BpBinder對象與之通過gBinderProxyOffsets關(guān)聯(lián)起來。 3. interface 這個服務(wù)接口很簡單,只有兩個函數(shù),分別用來讀寫硬件寄存器。 2. isNOTOriginal*/extendsimplementationclassimplementsstubto14. {17. Castinto20. *if22. publicobj)24. if25. return26. }=28. ifinstanceof29. return30. }(obj)。40. publicint(code)44. case47. return48. }()。TRANSACTION_getVal:60. (DESCRIPTOR)。_result63. (_result)。true。(code,69. class73. =77. }79. public80. {83. getInterfaceDescriptor()86. return87. }89. publicthrows()。_reply94. (DESCRIPTOR)。_reply,97. ()。100. ()。103. }105. public107. =109. int110. try_reply,113. ()。=115. }118. ()。final(TRANSACTION_getVal1)。voidgetVal()130. } 接下來的內(nèi)容。 在討論HelloService的啟動過程之前,我們先來看一下實現(xiàn)HelloService接口的Server是怎么定義的。 6. HelloServiceString10. HelloService()13. setVal(int15. setVal_native(val)。17. getVal()getVal_native()。staticnativenative這里,我們可以看到,它通過本地方法調(diào)用實現(xiàn)了getVal和setVal兩個函數(shù)。 在frameworks/base/services/java//android/server/,定義了SystemServer類。 extends2. ......4. Overriderun()10. 12. HelloService())。catchHello23. 25. }27. 29. SystemServer32. ......34. /**istoThisnativeAudioFlinger,started.willupstart38. */static41. ......43. publicinit2()Enteredserver!)。thr48. }50. } 這里我們關(guān)注把HelloService添加到Service Manager中去的代碼:view plain1. tryHello3. (hello,e)Failuree)。 我們先來看一下HelloService的創(chuàng)建過程:view plain1. new implements2. ......4. private11. ......13. 15. privateinit()。這里調(diào)用了一個JNI方法init來初始化這個Binder對象,這個JNI方法定義在frameworks/base/core/jni/:view plain1. staticjobjectnewNULL)java/lang/OutOfMemoryError,6. return。acquiringholder finalsServiceManager。addService(String{e)error14. }16. ......18. } 因此,:view plain1. class{remote)=4. }6. ......8. publicIBinderRemoteExceptiondata()。15. (ADD_SERVICE_TRANSACTION,18. }20. ......22. private 這里我們關(guān)注是如何把參數(shù)service寫到data這個Parcel對象中去的:view plain1. (service)。finalanparceldataPosition(),if8. publicwriteStrongBinder(IBinder9. 11. } voidclazz,2. {=NULL)status_tobject))。(err9. } 這里的clazz參數(shù)是一個Java語言實現(xiàn)的Parcel對象,通過parcelForJavaObject把它轉(zhuǎn)換成C++語言實現(xiàn)的Parcel對象。 env,2. {==5. if(JavaBBinderHolder*)!=:9. }11. if13. envGetIntField(obj,14. }16. LOGW(ibinderForJavaObject:a NULLNULL。這里就是jbhget這個語句了。 :2. {4. jobjectmObject(object)8. ......10. 12. env)15. AutoMutex16. spJavaBBinder==18. bmObject)。=20. ......22. 25. 27. 回到android_os_Parcel_writeStrongBinder函數(shù)中,下面這個語句:view plain1. constparcelwriteStrongBinder(ibinderForJavaObject(env, 相當于是:view plain1. constparcelwriteStrongBinder((JavaBBinderHodler*)())。這與我們前面介紹的Binder機制的C++實現(xiàn)是一致的。 BinderProxytransact(intParcelflags)jbooleanobj,jobjectreplyObj,4. {6. =NULL)JNI_FALSE。parcelForJavaObject(env,12. ifamp。!=13. return14. }16. IBinder*NULL)java/lang/IllegalStateException,finalized!)。JNI_FALSE。errreply,26. 28. ==30. return31. }==32. return33. }35. signalExceptionForError(env,這里傳進來的參數(shù)dataObj和replyObj是一個Java接口實現(xiàn)的Parcel類,由于這里是JNI層,需要把它轉(zhuǎn)換為C++實現(xiàn)的Parcel類,它們就是通過我們前面說的parcelForJavaObject函數(shù)進行轉(zhuǎn)換的。 =)。有了這個IBinder接口后,就和我們前面幾篇文章介紹Binder機制的C/C++實現(xiàn)一致了。 =flags)。需要注意的是,這里的data包含了一個JavaBBinderHolder類型的Binder實體對象,它就代表了我們上面創(chuàng)建的HelloService。 Client獲取HelloService的Java遠程接口的過程 在Hello這個Activity的onCreate函數(shù),:view plain1. publicActivity4. privatenull。void14. 16. } ServiceManagerProxy{remote。IBinderRemoteExceptiondata()。0)。binder16. ()。binder。IBinder23. } 我們在前面已經(jīng)介紹過了,這里的mRemote實際上是一個BinderProxy對象,它的transact成員函數(shù)是一個JNI方法,實現(xiàn)在frameworks/base/core/jni/。 errreply, 這里的reply變量里面就包括了一個HelloService的引用了。 reply, 接著,就通過下面語句將這個HelloService的引用讀出來:view plain1. IBinder class2. ......4. /**objectat6. */native它也是一個JNI方法,實現(xiàn)在frameworks/base/core/jni/:view plain1. staticjobjectparcelForJavaObject(env,4. if{
點擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1