How Does Android Binder Work in Intra-Process Calls?

533 views
Skip to first unread message

Eddie Ho (何德威)

unread,
Nov 23, 2011, 4:23:02 AM11/23/11
to android-...@googlegroups.com

 

 

Hi all,

 

In the old android-platform mailing list, I saw Dianne Hackborn said Binder works as a local method call in intra-process case.

 

http://www.mailinglistarchive.com/html/android-...@googlegroups.com/2010-01/msg00305.html

 

        Because Android source code is big, I cannot quickly find the point determining if a Binder call needs go into Binder driver or just works as a local method call.

 

I know it is handled in Binder library, and I already spent a lot of time trace source code.

 

Could anyone help tell me where is the point?

 

Thank you very much. I will very appreciate your help.

 

 

Best Regards,
Eddie Ho
何德威

MediaTek Inc.
Tel: +886-3-5670766 ext. 20491
Email: eddi...@mediatek.com

 

************* Email Confidentiality Notice ********************
The information contained in this e-mail message (including any 
attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be 
conveyed only to the designated recipient(s). Any use, dissemination, 
distribution, printing, retaining or copying of this e-mail (including its 
attachments) by unintended recipient(s) is strictly prohibited and may 
be unlawful. If you are not an intended recipient of this e-mail, or believe 
that you have received this e-mail in error, please notify the sender 
immediately (by replying to this e-mail), delete any and all copies of 
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!

Alexander Petrov

unread,
Nov 23, 2011, 12:10:50 PM11/23/11
to android-...@googlegroups.com
frameworks/base/libs/binder
by source code in android 2.3.4 it uses symbolic device /dev/binder for ipc between applications

2011/11/23 Eddie Ho (何德威) <eddi...@mediatek.com>
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

磊 张

unread,
Nov 23, 2011, 8:54:06 PM11/23/11
to android-...@googlegroups.com
I think you gotta read the source code of Ibinder in android and android interface definition language(aidl)

IPC (inter process communication)

Borqs Ltd.
Lei




Date: Wed, 23 Nov 2011 20:10:50 +0300
Subject: Re: How Does Android Binder Work in Intra-Process Calls?
From: alex...@gmail.com
To: android-...@googlegroups.com

frameworks/base/libs/binder
by source code in android 2.3.4 it uses symbolic device /dev/binder for ipc between applications

2011/11/23 Eddie Ho (锟轿碉拷锟斤拷) <eddi...@mediatek.com>

 

 

Hi all,

 

In the old android-platform mailing list, I saw Dianne Hackborn said Binder works as a local method call in intra-process case.

 

http://www.mailinglistarchive.com/html/android-...@googlegroups.com/2010-01/msg00305.html

 

        Because Android source code is big, I cannot quickly find the point determining if a Binder call needs go into Binder driver or just works as a local method call.

 

I know it is handled in Binder library, and I already spent a lot of time trace source code.

 

Could anyone help tell me where is the point?

 

Thank you very much. I will very appreciate your help.

 

 

Best Regards,
Eddie Ho
锟轿碉拷锟斤拷

Eddie Ho (何德威)

unread,
Nov 24, 2011, 4:36:48 AM11/24/11
to android-...@googlegroups.com

 

 

Hi all,

 

After tracing code, I found getService() will return different Binder in inter-process and intra process cases.

 

Through this difference, intra-process communication does not involve Binder Driver.

 

Only inter-process communication involves Binder Driver.

 

Thanks. : )

 

 

From: android-...@googlegroups.com [mailto:android-...@googlegroups.com] On Behalf Of ?
Sent: Thursday, November 24, 2011 9:54 AM
To: android-...@googlegroups.com
Subject: RE: How Does Android Binder Work in Intra-Process Calls?

 

I think you gotta read the source code of Ibinder in android and android interface definition language(aidl)

IPC (inter process communication)

Borqs Ltd.
Lei



Date: Wed, 23 Nov 2011 20:10:50 +0300
Subject: Re: How Does Android Binder Work in Intra-Process Calls?
From: alex...@gmail.com
To: android-...@googlegroups.com

frameworks/base/libs/binder

by source code in android 2.3.4 it uses symbolic device /dev/binder for ipc between applications

2011/11/23 Eddie Ho (何德威) <eddi...@mediatek.com>

 

 

Hi all,

 

In the old android-platform mailing list, I saw Dianne Hackborn said Binder works as a local method call in intra-process case.

 

http://www.mailinglistarchive.com/html/android-...@googlegroups.com/2010-01/msg00305.html

 

        Because Android source code is big, I cannot quickly find the point determining if a Binder call needs go into Binder driver or just works as a local method call.

 

I know it is handled in Binder library, and I already spent a lot of time trace source code.

 

Could anyone help tell me where is the point?

 

Thank you very much. I will very appreciate your help.

 

 

Best Regards,
Eddie Ho
何德威

Eddie Ho (何德威)

unread,
Nov 24, 2011, 9:55:47 PM11/24/11
to android-...@googlegroups.com

 

 

Hi all,

 

        I don't know if my understanding is correct or not. Any feedback is welcome. : )

 

The following is my study about Binder “intra-process” call:

 

1.          In frameworks/base/libs/binder/IServiceManager.cpp:

 

getService() will return the result of checkService().

 

checkService() will call readStrongBinder().

 

2.          In frameworks/base/libs/binder/Parcel.cpp:

 

readStrongBinder() will call unflatten_binder().

 

==> if flat->type is BINDER_TYPE_BINDER, return a local pointer, and then the rest communication does not involve Binder Driver.

 

*out = static_cast<IBinder*>(flat->cookie);

 

==> if flat->type is BINDER_TYPE_HANDLE, return a proxy, and then the rest communication will involve Binder Driver.

 

*out = proc->getStrongProxyForHandle(flat->handle);

 

3.          Actually, the flat variable is originally generated from Binder Driver, kernel/drivers/staging/android/binder.c:

 

The following code shows that if the sender and receiver are in the same process, fp->type will be BINDER_TYPE_BINDER,

 

which leads to the result unflatten_binder() return a local pointer, and then the rest communication never involve Binder Driver.

 

                        if (ref->node->proc == target_proc) {                            <= the case sender and receiver are in the same process.

                                if (fp->type == BINDER_TYPE_HANDLE)

                                        fp->type = BINDER_TYPE_BINDER;                 <= In this case, change the Binder type to BINDER_TYPE_BINDER

                                else

                                        fp->type = BINDER_TYPE_WEAK_BINDER;

                                fp->binder = ref->node->ptr;

                                fp->cookie = ref->node->cookie;

                                binder_inc_node(ref->node, fp->type == BINDER_TYPE_BINDER, 0, NULL);

                                binder_debug(BINDER_DEBUG_TRANSACTION,

                                             "        ref %d desc %d -> node %d u%p\n",

                                             ref->debug_id, ref->desc, ref->node->debug_id,

                                             ref->node->ptr);

                        } else {                                                                             <=the case sender and receiver are not in the same process

 

The conclusion is:

 

Not every Binder communication involves Binder Driver, and at the stage of getService(), it is determined.

 

Thank you very much. : )

 

 

From: Eddie Ho (何德威)
Sent: Thursday, November 24, 2011 5:37 PM
To: android-...@googlegroups.com
Subject: RE: How Does Android Binder Work in Intra-Process Calls?

 

 

 

Hi all,

 

After tracing code, I found getService() will return different Binder in inter-process and intra process cases.

 

Through this difference, intra-process communication does not involve Binder Driver.

 

Only inter-process communication involves Binder Driver.

 

Thanks. : )

 

 

?


Sent: Thursday, November 24, 2011 9:54 AM
To: android-...@googlegroups.com

Subject: RE: How Does Android Binder Work in Intra-Process Calls?

I think you gotta read the source code of Ibinder in android and android interface definition language(aidl)

IPC (inter process communication)

Borqs Ltd.
Lei


Date: Wed, 23 Nov 2011 20:10:50 +0300
Subject: Re: How Does Android Binder Work in Intra-Process Calls?
From: alex...@gmail.com
To: android-...@googlegroups.com

frameworks/base/libs/binder

by source code in android 2.3.4 it uses symbolic device /dev/binder for ipc between applications

2011/11/23 Eddie Ho (何德威) <eddi...@mediatek.com>

 

 

Hi all,

 

In the old android-platform mailing list, I saw Dianne Hackborn said Binder works as a local method call in intra-process case.

 

http://www.mailinglistarchive.com/html/android-...@googlegroups.com/2010-01/msg00305.html

 

        Because Android source code is big, I cannot quickly find the point determining if a Binder call needs go into Binder driver or just works as a local method call.

 

I know it is handled in Binder library, and I already spent a lot of time trace source code.

 

Could anyone help tell me where is the point?

 

Thank you very much. I will very appreciate your help.

 

 

Best Regards,
Eddie Ho
何德威

磊 张

unread,
Nov 27, 2011, 8:55:43 PM11/27/11
to android-...@googlegroups.com
Hi eddie.

what I meant was that when you are tracing the source code , there are something more you can get.

in the IBinder source code, refer to the java doc , the annotation of the certain class . and then you will hava more
to figure out.


Lei




From: eddi...@mediatek.com
To: android-...@googlegroups.com
Date: Fri, 25 Nov 2011 10:55:47 +0800

Subject: RE: How Does Android Binder Work in Intra-Process Calls?

 

 

Hi all,

 

        I don't know if my understanding is correct or not. Any feedback is welcome. : )

 

The following is my study about Binder 锟斤拷intra-process锟斤拷 call:

2011/11/23 Eddie Ho (锟轿碉拷锟斤拷) <eddi...@mediatek.com>

 

 

Hi all,

 

In the old android-platform mailing list, I saw Dianne Hackborn said Binder works as a local method call in intra-process case.

 

http://www.mailinglistarchive.com/html/android-...@googlegroups.com/2010-01/msg00305.html

 

        Because Android source code is big, I cannot quickly find the point determining if a Binder call needs go into Binder driver or just works as a local method call.

 

I know it is handled in Binder library, and I already spent a lot of time trace source code.

 

Could anyone help tell me where is the point?

 

Thank you very much. I will very appreciate your help.

 

 

Best Regards,
Eddie Ho
锟轿碉拷锟斤拷

Reply all
Reply to author
Forward
0 new messages