Crystal Jake Crystal Jake - 1 year ago 103
Android Question

Android Binder clearing caller identity

Recently I read

source codes and find that a pair of methods are always called when doing some
IPC call. I read the comment, but I can't clearly know the root reason. The pair of method is as follow:

final long origId = Binder.clearCallingIdentity();

//other local method.


Does anyone know what's the function of that pair of method? It seems to relate to permission.

Answer Source

I don't think I can answer better than the description in the official APIs:

public static final long clearCallingIdentity ()

Reset the identity of the incoming IPC on the current thread. This can be useful if, while handling an incoming call, you will be calling on interfaces of other objects that may be local to your process and need to do permission checks on the calls coming into them (so they will check the permission of your own local process, and not whatever process originally called you).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download