Binder.clearCallingIdentity 和 Bi

2019-05-05  本文已影响0人  海在路上
进程A, 进程B, 进程B拥有a方法(),b方法()

A—①—> B.a() —②—> B.b();
① 需要提供给PID和UID判断权限。
② 不需要提供PID和UID判断权限。

public void a() {
    //clearCallingIdentity()方法会清除process A的UID和PID,重置为process B的UID和PID。
    final long origId = Binder.clearCallingIdentity(); 
    b();
    //此时仍然处在process A远程调用process B方法的过程中,此时需要restore  process A的UID和PID。
    Binder.restoreCallingIdentity(origId);
}

参考博客

上一篇 下一篇

猜你喜欢

热点阅读