Android 5.0之DisplayThread

从Android5.0开始,引入了DisplayThread类来处理与显示相关的低延迟操作。此类专为WindowManager、DisplayManager及InputManager设计,用于执行实时的快速显示任务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在Android 5.0中,新增了一个DisplayThread类,源码位置在frameworks/base/services/core/java/com/android/server/DisplayThread.java. 


这个类的注释是这么写的,

 * Shared singleton foreground thread for the system.  This is a thread for
 * operations that affect what's on the display, which needs to have a minimum
 * of latency.  This thread should pretty much only be used by the WindowManager,
 * DisplayManager, and InputManager to perform quick operations in real time.

也就是说,从Android 5.0开始,所有跟系统前景相关的操作都集中到这个线程类中。这个类用来处理需要低时延的显示相关的操作。这个线程只能由WindowManager,DisplayManager和InputManager用来实时显示相关的快速操作。


于是WindowManagerService运行的线程再次发生了变化。在Android 4.1的时代,WmS拥有一个自己的主线程WMThread。4.1之后到4.4,SystemServer提供了一个wmHandlerThread来替代它。到了5.0之后,WmS改成运行在DisplayThread的Handler中。

    public static WindowManagerService main(final Context context,
            final InputManagerService im,
            final boolean haveInputMethods, final boolean showBootMsgs,
            final boolean onlyCore) {
        final WindowManagerService[] holder = new WindowManagerService[1];
        DisplayThread.getHandler().runWithScissors(new Runnable() {
            @Override
            public void run() {
                holder[0] = new WindowManagerService(context, im,
                        haveInputMethods, showBootMsgs, onlyCore);
            }
        }, 0);
        return holder[0];
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jtag特工

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值