InputDispatcher: Dropped event because input dispatch is disabled

只谈情不闲聊 提交于 2019-12-04 14:07:13

问题


I am developing ui automation platform for android.

For some reason sometimes (very rare) click events can be dropped

When it happen I see in log

I/InputDispatcher( 2707): Dropped event because input dispatch is disabled.

Please advise what can be done to enable input dispatch.

Thank you in advance


回答1:


There are certain conditions in which Input Dispatcher will drop the input events:

  1. DROP_REASON_BLOCKED : If current application is not responding and user is tapping on device, input event will be dropped
  2. DROP_REASON_STALE: Dropped event because it is stale
  3. DROP_REASON_APP_SWITCH: Dropped event because of pending overdue app switch
  4. DROP_REASON_DISABLED: Dropped event because input dispatch is disabled

etc.

In your case, its executing case 4. Means something going fishy or your first input is not executed yet. So Input Dispatcher is disabled.

Check [method dropInboundEventLocked of middleware class InputDispatcher.cpp




回答2:


It happened only when screen was off. Click event was turning screen on, but it event was quicker than turning screen on.

Now, I am checking if screen is off and turning it on

//Acquire wake lock in case screen is off
if (PermissionsUtil.checkSelfPermission(getContext(), Manifest.permission.WAKE_LOCK))
{
    PowerManager pm = (PowerManager)getContext().getSystemService(Context.POWER_SERVICE);
    if (pm.isScreenOn() == false)
    {
        wakeLock = pm.newWakeLock((PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), TAG);
        // 
        wakeLock.acquire();
        Log.d(TAG,"Acquiring wake lock");
     }
}

//Do my stuff

//Release wake lock in case it was acquire
if (wakeLock != null && wakeLock.isHeld())
{
    wakeLock.release();
    wakeLock = null;
    Log.d(TAG,"Releasing wake lock");
}


来源:https://stackoverflow.com/questions/11774771/inputdispatcher-dropped-event-because-input-dispatch-is-disabled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!