Binder系统调用关系详解【DOC精选】.doc

  1. 1、本文档共17页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Binder系统调用关系详解【DOC精选】

Binder系统调用关系详解 这篇文档主要讲述Binder系统的调用关系,为大家讲解Binder系统是如何通过IPC在本地产生远端服务的代理类。由于Binder系统贯穿整个Android系统框架,所以在讲解时,有些系统框架上的知识点,我还不是非常明白,就略过了。我将把注意力集中在代理类的产生以及如何将代理类传给APP的这些关键点上,为大家讲解。IPC过程中最重要的就是:当Activity调用bindService()时,系统框架是如何在本地产生remote Service的proxy。 下面将通过code为大家详细解析这整个过程。请各位关注一下我在code中用黑色字体写出的注释,以及用红色标明的变量。   调用至ActivityManagerService.java中bindService(),代码如下: public int bindService(IApplicationThread caller, IBinder token, Intent service, String resolvedType, IServiceConnection connection, int flags) { // Refuse possible leaked file descriptors if (service != null service.hasFileDescriptors() == true) { throw new IllegalArgumentException(File descriptors passed in Intent); } synchronized(this) { if (DEBUG_SERVICE) Slog.v(TAG, bindService: + service + type= + resolvedType + conn= + connection.asBinder() + flags=0x + Integer.toHexString(flags)); final ProcessRecord callerApp = getRecordForAppLocked(caller); //当前运行App的进程记录信息 if (callerApp == null) {  //正常情况下当前App的进程记录不可能为空,这一段忽略 throw new SecurityException( Unable to find app for caller + caller + (pid= + Binder.getCallingPid() + ) when binding service + service); } ActivityRecord activity = null;  //代表Activity堆栈内的一条记录,继承自IApplicationToken.Stub if (token != null) { int aindex = mMainStack.indexOfTokenLocked(token); if (aindex 0) { Slog.w(TAG, Binding with unknown activity: + token); return 0; } activity = (ActivityRecord)mMainStack.mHistory.get(aindex);  //从Activity堆栈中取出记录 } int clientLabel = 0; PendingIntent clientIntent = null; if (callerA.uid == Process.SYSTEM_UID) {

文档评论(0)

taotao0b + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档