Drive for better visionIInterface, BpRefBaseFebruary, 2012                         Himax Media                         Sol...
Class Hierarchy                                                   RefBase         IInterface                              ...
List of meta interfaces             IHolder                                 IMemoryHeap             IAudioFlinger      ...
class BpRefBase             功能                   與 RefBase 相同,能夠作為 strong/weak pointer 參考的物件                   可以額外儲存 r...
BpRefBase::BpRefBase(sp<IBinder> i)             功能                   初始化 BpRefBase             實作                   將 ...
BpRefBase::onFirstRef()             功能                   當第一個 strong pointer 參考時,會觸發此函式             實作                ...
BpRefBase::remote()             功能                   傳回所參考的 IBinder             實作                   return mRemote   ...
BpRefBase::onIncStrongAttempted()             功能                   不確定參考的目標是否還存在,呼叫 attemptIncStrong() 時                ...
BpRefBase::onLastStrongRef()             功能                   當最後一個 strong pointer 消失時,會觸發此函式             實作           ...
BpRefBase::~BpRefBase()             功能                   刪除物件時自動呼叫             實作                   使 strong/weak ref ...
RefBase        IInterface                           IBinder      remote          BpRefBase                  meta interface...
IInterface::asBinder()             功能                   傳回連結兩個 interface 用的 binder             實作                   呼叫...
BnInterface::onAsBinder()             功能                   傳回連結兩個 interface 用的 binder             實作                  ...
BpInterface::onAsBinder()             功能                   傳回連結兩個 interface 用的 binder             實作                  ...
BpInterface                  BnInterface                                                   onAsBinder()                   ...
Drive for better vision
Upcoming SlideShare
Loading in...5
×

06 i interface_bp_refbase

576

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
576
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • 1. 所有 interface 相關的 class ,都由大寫 I 開頭, IInterface 是這些 class 的祖先 2. 繼承 interface 的稱為 meta interface ,是所有 service 的祖先,要創造新的 service 之前,要先創造 meta interface 3. 真正的 service 會提供 Bn 及 Bp 兩種介面,分別繼承 Bn-interface 及 Bp-interface ,兩者都繼承 meta interface
  • 這裡是 meta interface 的列表,所有的 meta interface 都會對應到 Bn/Bp-interface 例如 ICamera 有 BnCamera 及 BpCamera 例如 ICameraClient 有 BnCameraClient 及 BpCameraClient
  • 根據上面定義的函式,每個 BpRefBase 都有一個 remote IBinder 依此類推, BpInterface 也有一個 remote BnInterface 因此 BpRefBase 存在的原因,就是要定義出一條通道,這條通道上有近端和遠端,近端有 Bp 介面,遠端有 Bn 介面
  • 06 i interface_bp_refbase

    1. 1. Drive for better visionIInterface, BpRefBaseFebruary, 2012 Himax Media Solutions 承景科技股份有限公司
    2. 2. Class Hierarchy RefBase IInterface IBinder BpRefBase meta interface IServiceManager BBinder BpBinder BnInterface BpInterface Bn-interface Bp-interface BnServiceManager BpServiceManagerHimax Media Solutions Proprietary & Confidential 2
    3. 3. List of meta interfaces  IHolder  IMemoryHeap  IAudioFlinger  IMemory  IAudioFlingerClient  IMountService  IAudioPolicyService BnCamera  IMountServiceListener  IAudioRecord BpCamera  IMountShutdownObserver  IAudioTrack  IObbActionListener  ICamera BnCameraClient  IOMX  ICameraClient BpCameraClient  IOMXObserver  ICameraRecordingProxy  IPermissionController  ICameraRecordingProxyListener  IPowerManager  ICameraService  ISensorEventConnection  IDrmManagerService  ISensorServer  IDrmServiceListener  IServiceManager  IEffect  IStreamSource  IEffectClient  IStreamListener  IGraphicBufferAlloc  ISurface  IMediaMetadataRetriever  ISurfaceComposer  IMediaPlayer  ISurfaceComposerClient  IMediaPlayerClient  ISurfaceTexture  IMediaPlayerService  IMediaRecorder  IMediaRecorderClientHimax Media Solutions Proprietary & Confidential 3
    4. 4. class BpRefBase  功能  與 RefBase 相同,能夠作為 strong/weak pointer 參考的物件  可以額外儲存 remote IBinder 指標Himax Media Solutions Proprietary & Confidential 4
    5. 5. BpRefBase::BpRefBase(sp<IBinder> i)  功能  初始化 BpRefBase  實作  將 IBinder 物件設為 weak lifetime ,當 strong reference 為 0 時不會刪除物件  將 strong/weak ref 加 1 ,相當於 strong pointer 的效果 IBinder BpRefBase weakref_impl mRefs mRemote mStrong +1 mRefs mWeak +1 mBase mFlags +weakHimax Media Solutions Proprietary & Confidential 5
    6. 6. BpRefBase::onFirstRef()  功能  當第一個 strong pointer 參考時,會觸發此函式  實作  設定 "remote acquired" 的狀態 sp<BpRefBase> IBinder BpRefBase weakref_impl mRefs mRemote mStrong mRefs mWeak mState mBase mFlagsHimax Media Solutions Proprietary & Confidential 6
    7. 7. BpRefBase::remote()  功能  傳回所參考的 IBinder  實作  return mRemote IBinder BpRefBase weakref_impl mRefs mRemote mStrong mRefs mWeak mState mBase mFlagsHimax Media Solutions Proprietary & Confidential 7
    8. 8. BpRefBase::onIncStrongAttempted()  功能  不確定參考的目標是否還存在,呼叫 attemptIncStrong() 時 會觸發此函式  如果使 mStrong 加 1 成功,則傳回 true ;如果物件已經不存在 ,則傳回 false BpRefBase mRemote mRefs weakref_impl mStrong mWeak +1 ? IBinder mRefs mState mBase mFlagsHimax Media Solutions Proprietary & Confidential 8
    9. 9. BpRefBase::onLastStrongRef()  功能  當最後一個 strong pointer 消失時,會觸發此函式  實作  使 remote 的 strong ref 也減少 1 sp<BpRefBase> IBinder BpRefBase weakref_impl mRefs mRemote mStrong -1 mRefs mWeak mState mBase mFlagsHimax Media Solutions Proprietary & Confidential 9
    10. 10. BpRefBase::~BpRefBase()  功能  刪除物件時自動呼叫  實作  使 strong/weak ref 都減 1 ,相當於少了一個 strong pointer  如果有設定 "remote acquired" 屬性,表示 strong ref 已經 減少過了,就只需要減少 weak ref IBinder BpRefBase weakref_impl mRefs mRemote mStrong -1 mRefs mWeak -1 mState mBase mFlagsHimax Media Solutions Proprietary & Confidential 10
    11. 11. RefBase IInterface IBinder remote BpRefBase meta interface IServiceManager BBinder BpBinder BnInterface remote BpInterface Bn-interface Bp-interface BnServiceManager remote BpServiceManagerHimax Media Solutions Proprietary & Confidential 11
    12. 12. IInterface::asBinder()  功能  傳回連結兩個 interface 用的 binder  實作  呼叫 onAsBinder() , onAsBinder() 由繼承的 class 實作Himax Media Solutions Proprietary & Confidential 12
    13. 13. BnInterface::onAsBinder()  功能  傳回連結兩個 interface 用的 binder  實作  return this  因為 BnInterface 是繼承 IBinder/BBinder 而來,所以本身就有 IBinder 的屬性Himax Media Solutions Proprietary & Confidential 13
    14. 14. BpInterface::onAsBinder()  功能  傳回連結兩個 interface 用的 binder  實作  return remote()  將遠端的 interface 當作 binder 傳回Himax Media Solutions Proprietary & Confidential 14
    15. 15. BpInterface BnInterface onAsBinder() IBinder onAsBinder() BpServiceManager BnServiceManager onAsBinder() IBinder onAsBinder()Himax Media Solutions Proprietary & Confidential 15
    16. 16. Drive for better vision

    ×