Your SlideShare is downloading. ×
0
10 service manager
10 service manager
10 service manager
10 service manager
10 service manager
10 service manager
10 service manager
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

10 service manager

398

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
398
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Drive for better visionService ManagerFebruary, 2012 Himax Media Solutions 承景科技股份有限公司
  • 2. 概述  獨立的程式,有自己的 main()  frameworks/base/cmds/servicemanager  管理所有的 service ,所有新增、查詢、取得 service 都透過 這支程式Himax Media Solutions Proprietary & Confidential 2
  • 3. int main(int argc, char **argv)  功能  打開檔案 /dev/binder ,並進入無窮迴圈,處理收到的訊息  實作  用讀寫模式打開檔案 /dev/binder  將 address 0 開始,長度為 128KB 空間,對映到 /dev/binder 從 0 開始的空間  用 ioctl 送出命令 BINDER_SET_CONTEXT_MGR ,設為 context manager  呼叫 binder_loop(...) ,裡面是無窮迴圈Himax Media Solutions Proprietary & Confidential 3
  • 4. binder_loop(*bs, func) - 1  功能  接收訊息並作對應的處理  實作  write<BC_ENTER_LOOPER> 後進入 infinite loop  read 128 bytes ,根據第一個 byte 作出行動  BR_FAILED_REPLY, BR_DEAD_REPLY: 結束 service manager  BR_NOOP, BR_TRANSACTION_COMPLETE: 什麼都不作  BR_INCREFS, BR_ACQUIRE, BR_RELEASE, BR_DECREFS: 跳過 8 bytes 的 buffer ,什麼都不作  BR_DEAD_BINDER: 發出死亡通告  BR_REPLY: 跳過 40 bytes 的 buffer ,什麼都不作Himax Media Solutions Proprietary & Confidential 4
  • 5. binder_loop(*bs, func) - 2  實作  BR_TRANSACTION:  reply 結構指向 rdata ,下面使用 writeXXX() 的函式代表寫入資料  msg 結構指向 txn ,下面使用 readXXX() 的函式代表從中讀取資料  strict_policy = readInt32() // 從未使用,但還是要讀出來  s = readStr16(&len)  如果 s != "android.os.IServiceManager" ,則回傳錯誤訊息  switch(txn->code)  SVC_MGR_GET_SERVICE, SVC_MGR_CHECK_SERVICE:  先讀出一個 16-bit 字串 str  在 service info 陣列中,找名稱與 str 相同的 service  回應 HANDLE 物件 reply.insertObject(TYPE_HANDLE, ptr)  SVC_MGR_LIST_SERVICES:  先讀出 int n ,然後回應寫入第 n 個 service 的字串Himax Media Solutions Proprietary & Confidential 5
  • 6. binder_loop(*bs, func) - 3  實作  BR_TRANSACTION:  switch(txn->code)  SVC_MGR_ADD_SERVICE:  讀出 16-bit 字串 str 及 HANDLE 物件 ptr  檢查 txn->sender_euid 及字串 str 否合法: uid=0 、 uid=system 直接合法,其他情況要讀 allow[] 陣列  如果服務已存在,就終結舊的服務: write<BC_RELEASE, ptr> ,建立新的服務  如果服務不存在,新增服務到 svclist 的串列開頭  write<BC_ACQUIRE, ptr>  write<BC_REQUEST_DEATH_NOTIFICATION, ptr, death>  writeInt32(0)  write<BC_FREE_BUFFER, txn->data>  write<BC_REPLY, binder_io reply>Himax Media Solutions Proprietary & Confidential 6
  • 7. Drive for better vision

×