WMS通过?setInputWindowInfo将信息设置到SurfaceFlinger后是如何通知到Input的呢?如下图
12-26 14:09:36.912 2315 2315 D jinyanmeifocus: updateInputFlinger
12-26 14:09:36.920 2315 2650 D jinyanmeifocus: #00 pc 00000000001b1504 /system/bin/surfaceflinger (android::WindowInfosListenerInvoker::windowInfosChanged(android::gui::WindowInfosUpdate, std::__1::unordered_set<android::sp<android::gui::IWindowInfosReportedListener>, android::gui::SpHash<android::gui::IWindowInfosReportedListener>, std::__1::equal_to<android::sp<android::gui::IWindowInfosReportedListener> >, std::__1::allocator<android::sp<android::gui::IWindowInfosReportedListener> > >, bool)+116) (BuildId: 7b6306e54c32d48d9de95fd2f4f7363c)
12-26 14:09:36.920 2315 2650 D jinyanmeifocus: #01 pc 000000000023e048 /system/bin/surfaceflinger (std::__1::__function::__func<android::SurfaceFlinger::updateInputFlinger(android::VsyncId, android::TimePoint)::$_0, std::__1::allocator<android::SurfaceFlinger::updateInputFlinger(android::VsyncId, android::TimePoint)::$_0>, void ()>::operator()() (.__uniq.59679109406690186319419933358127648880.b7ab55bb571e826de581a294e3abdb85)+668) (BuildId: 7b6306e54c32d48d9de95fd2f4f7363c)
12-26 14:09:36.920 2315 2650 D jinyanmeifocus: #02 pc 00000000001510f8 /system/bin/surfaceflinger (void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, android::BackgroundExecutor::BackgroundExecutor()::$_0> >(void*) (.__uniq.40551338734768535425960610675403556019)+588) (BuildId: 7b6306e54c32d48d9de95fd2f4f7363c)
12-26 14:09:36.920 2315 2650 D jinyanmeifocus: #03 pc 00000000000cb6a8 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: a87908b48b368e6282bcc9f34bcfc28c)
12-26 14:09:36.920 2315 2650 D jinyanmeifocus: #04 pc 000000000006821c /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: a87908b48b368e6282bcc9f34bcfc28c)
12-26 14:09:36.940 2315 2315 D jinyanmeifocus: #00 pc 0000000000211cfc /system/bin/surfaceflinger (android::SurfaceFlinger::commit(android::TimePoint, android::VsyncId, android::TimePoint)+13448) (BuildId: 7b6306e54c32d48d9de95fd2f4f7363c)
12-26 14:09:36.940 2315 2315 D jinyanmeifocus: #01 pc 00000000001f1860 /system/bin/surfaceflinger (android::scheduler::Scheduler::onFrameSignal(android::ICompositor&, android::VsyncId, android::TimePoint)+60) (BuildId: 7b6306e54c32d48d9de95fd2f4f7363c)
12-26 14:09:36.940 2315 2315 D jinyanmeifocus: #02 pc 0000000000019044 /system/lib64/libutils.so (android::Looper::pollInner(int)+548) (BuildId: ab8535da6fc0d3526aee3d4b6edd4117)
12-26 14:09:36.941 2315 2315 D jinyanmeifocus: #03 pc 0000000000018dc0 /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+120) (BuildId: ab8535da6fc0d3526aee3d4b6edd4117)
12-26 14:09:36.941 2315 2315 D jinyanmeifocus: #04 pc 00000000001e3334 /system/bin/surfaceflinger (android::impl::MessageQueue::waitMessage()+84) (BuildId: 7b6306e54c32d48d9de95fd2f4f7363c)
12-26 14:09:36.941 2315 2315 D jinyanmeifocus: #05 pc 00000000001f181c /system/bin/surfaceflinger (android::scheduler::Scheduler::run()+28) (BuildId: 7b6306e54c32d48d9de95fd2f4f7363c)
12-26 14:09:36.941 2315 2315 D jinyanmeifocus: #06 pc 0000000000256b0c /system/bin/surfaceflinger (main+1792) (BuildId: 7b6306e54c32d48d9de95fd2f4f7363c)
12-26 14:09:36.941 2315 2315 D jinyanmeifocus: #07 pc 000000000005f610 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+104) (BuildId: a87908b48b368e6282bcc9f34bcfc28c)
这里遍历的listener实际上是DispatcherWindowListener
下面来看WindowInfosListenerReporter是如何添加到WindowInfosListenerInvoker中的
void WindowInfosListenerInvoker::addWindowInfosListener(sp<IWindowInfosListener> listener,
gui::WindowInfosListenerInfo* outInfo) {
int64_t listenerId = mNextListenerId++;
outInfo->listenerId = listenerId;
outInfo->windowInfosPublisher = sp<gui::IWindowInfosPublisher>::fromExisting(this);
ALOGJIN("addWindowInfosListener ");
android::CallStack stack(LOG_TAGJINYANMEI);
BackgroundExecutor::getInstance().sendCallbacks(
{[this, listener = std::move(listener), listenerId]() {
ATRACE_NAME("WindowInfosListenerInvoker::addWindowInfosListener");
sp<IBinder> asBinder = IInterface::asBinder(listener);
asBinder->linkToDeath(sp<DeathRecipient>::fromExisting(this));
mWindowInfosListeners.try_emplace(asBinder,
std::make_pair(listenerId, std::move(listener)));
}});
}
?//以SurfaceFlinger对端进程binder作为key 保存对应的listner