Android Q上broadcast 的新特性:广播延时方案

Android Q上broadcast 的新特性:广播延时方案

在AMS中有仨个广播队列mFgBroadcastQueue,mBgBroadcastQueue,mBgBroadcastQueue,用来分别管理仨类优先级别不同的广播,广播的分类是基于flag:FLAG_RECEIVER_FOREGROUND,FLAG_RECEIVER_OFFLOAD mFgBroadcastQueue,mBgBroadcastQueue,mBgBroadcastQueue,都是BroadcastQueue的对象,在BroadcastQueue.java中有几个比较关键的函数和成员变量

/**

* Lists of all active broadcasts that are to be executed immediately

* (without waiting for another broadcast to finish). Currently this only

* contains broadcasts to registered receivers, to avoid spinning up

* a bunch of processes to execute IntentReceiver components. Background-

* and foreground-priority broadcasts are queued separately.

*/

final ArrayList mParallelBroadcasts = new ArrayList<>();

/**

* Tracking of the ordered broadcast queue, including deferral policy and alarm

* prioritization.

*/

final BroadcastDispatcher mDispatcher;

public void enqueueParallelBroadcastLocked(BroadcastRecord r) {

mParallelBroadcasts.add(r);

enqueueBroadcastHelper(r);

}

public v

📌 相关推荐