SystemUI QSFactory插件解析

时间:2024-04-22 06:57:36

系统有默认的插件为 QSFactoryImpl,

QSTileHost 注册监听插件

pluginManager.addPluginListener(this, QSFactory.class, true);

在 QSTileHost 中把 默认插件和系统发现的插件都放入 mQsFactories,
然后有以下代码:

    public QSTile createTile(String tileSpec) {
        for (int i = 0; i < mQsFactories.size(); i++) {
            QSTile t = mQsFactories.get(i).createTile(tileSpec);
            if (t != null) {
                return t;
            }
        }
        return null;
    }
public QSTileView createTileView(QSTile tile, boolean collapsedView) {
    for (int i = 0; i < mQsFactories.size(); i++) {
        QSTileView view = mQsFactories.get(i).createTileView(tile, collapsedView);
        if (view != null) {
            return view;
        }
    }
    throw new RuntimeException("Default factory didn't create view for " + tile.getTileSpec());
}