当前位置:网站首页>Input system learning ----- inputfilter

Input system learning ----- inputfilter

2022-06-22 02:06:00 aaajj

Android There is 2 individual InputFilter, What we usually find is text.InputFilter,

Here we are talking about input dependent view.InputFilter,

Input In the distribution process, it is necessary to determine whether or not InputFilter, If it's set up ,input The process will come to InputFilter in ,

see InputFilter The definition of , I inherited it binder Of stub object , It seems that it can be used as binder The service object transfers data in the process .

92 * @hide
93 */
94public abstract class InputFilter extends IInputFilter.Stub {
  

to glance at IInputFilter The definition of ,

frameworks/base/core/java/android/view/IInputFilter.aidl

17package android.view;
18
19import android.view.IInputFilterHost;
20import android.view.InputEvent;
21
22/**
23 * Interface for implementing an filter which observes and
24 * potentially transforms the input event stream in the system.
25 *
26 * @hide
27 */
28oneway interface IInputFilter {
29    void install(IInputFilterHost host);
30    void uninstall();
31    void filterInputEvent(in InputEvent event, int policyFlags);
32}

It can be seen that ,InputEvent,MotionEvent Objects can be serialized and passed through binder delivery .

InputFilter It defines handler For asynchronous processing , Compile the... Of the receiving system input event , Avoid systematic input The process is blocked , We can also call filterInputEvent Method to actively inject an event ,

149    final public void filterInputEvent(InputEvent event, int policyFlags) {
150        mH.obtainMessage(MSG_INPUT_EVENT, policyFlags, 0, event).sendToTarget();
151    }

handler The definition of

213    private final class H extends Handler {
214        public H(Looper looper) {
215            super(looper);
216        }
217
218        @Override
219        public void handleMessage(Message msg) {
220            switch (msg.what) {
221                case MSG_INSTALL:
222                    mHost = (IInputFilterHost) msg.obj;
223                    if (mInboundInputEventConsistencyVerifier != null) {
224                        mInboundInputEventConsistencyVerifier.reset();
225                    }
226                    if (mOutboundInputEventConsistencyVerifier != null) {
227                        mOutboundInputEventConsistencyVerifier.reset();
228                    }
229                    onInstalled();
230                    break;
231
232                case MSG_UNINSTALL:
233                    try {
234                        onUninstalled();
235                    } finally {
236                        mHost = null;
237                    }
238                    break;
239
240                case MSG_INPUT_EVENT: {
241                    final InputEvent event = (InputEvent)msg.obj;
242                    try {
243                        if (mInboundInputEventConsistencyVerifier != null) {
244                            mInboundInputEventConsistencyVerifier.onInputEvent(event, 0);
245                        }
246                        onInputEvent(event, msg.arg1);
247                    } finally {
248                        event.recycle();
249                    }
250                    break;
251                }
252            }
253        }
254    }
255}

Reference material

Android Auxiliary function --- Global gesture zoom - You know

原网站

版权声明
本文为[aaajj]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220146302240.html