Android Binder清除呼叫者身份 [英] Android Binder clearing caller identity

查看:200
本文介绍了Android Binder清除呼叫者身份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我阅读了 Android 源代码,发现执行某些 Binder IPC时总是调用一对方法呼叫。我阅读了评论,但不清楚其根本原因。该对方法如下:

Recently I read Android source codes and find that a pair of methods are always called when doing some Binder 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.

Binder.restoreCallingIdentity(origId);

有人知道该对方法的功能是什么吗?

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

推荐答案

我认为我的回答比官方API中的描述要好: a href = http://developer.android.com/reference/android/os/Binder.html rel = nofollow> http://developer.android.com/reference/android/os/Binder.html

I don't think I can answer better than the description in the official APIs: http://developer.android.com/reference/android/os/Binder.html

公共静态最终长整型clearCallingIdentity()


重置当前线程上传入IPC的身份。如果在处理传入呼叫时,您将要在进程本地的其他对象的接口上进行调用,并且需要对进入它们的调用进行权限检查(因此它们将检查您自己的权限),则这很有用本地进程,而不是最初称为您的进程)。

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).

这篇关于Android Binder清除呼叫者身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆