ViewRootImpl和WMS交互顺序


1.获取IWindowManager代理

IWindowManager 就是一个接口,拿到代理,也就是通常的binder转接口

WindowManagerGlobal 

sWindowManagerService = IWindowManager.Stub.asInterface(
                        ServiceManager.getService("window"));



2 openSession

客户端是直接调用上面那个接口的方法。

实现是WMS里面有一个Session返回

 @Override
    public IWindowSession openSession(IWindowSessionCallback callback, IInputMethodClient client,
            IInputContext inputContext) {
        if (client == null) throw new IllegalArgumentException("null client");
        if (inputContext == null) throw new IllegalArgumentException("null inputContext");
        Session session = new Session(this, callback, client, inputContext);
        return session;
    }


final class Session extends IWindowSession.Stub


又来一个接口IWindowSession


实现类找一下IWindowSession.Stub子类就是Session




3.1  ViewRootImpl.setView

客户端获取的Session代理addView实现,客户端只能到这里

---

看看binder服务端Session中addToDisplay

 @Override
    public int addToDisplay(IWindow window, int seq, WindowManager.LayoutParams attrs,
            int viewVisibility, int displayId, Rect outContentInsets,
            InputChannel outInputChannel) {
        return mService.addWindow(this, window, seq, attrs, viewVisibility, displayId,
                outContentInsets, outInputChannel);
    }


mService指的是WMS

WMS addVWindow

public int addWindow(Session session, IWindow client, int seq,
            WindowManager.LayoutParams attrs, int viewVisibility, int displayId,
            Rect outContentInsets, InputChannel outInputChannel) {
        int[] appOp = new int[1];
        int res = mPolicy.checkAddPermission(attrs, appOp);
        if (res != WindowManagerGlobal.ADD_OKAY) {
            return res;
        }


        boolean reportNewConfig = false;
        WindowState attachedWindow = null;
        WindowState win = null;
        long origId;
        final int type = attrs.type;


        synchronized(mWindowMap) {、

...


梳理一下setContentView是Activity方法,其实是调用Window的方法,然后调用

ViewRootImpl方法,它是先拿到WMS代理获取Session然后调用Session方法。


binder另一头是Session调用WMS方法。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值