InputDispatcher: Dropped event because input dispatch is disabled

前端 未结 2 885
南旧
南旧 2021-02-11 01:50

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



        
2条回答
  •  囚心锁ツ
    2021-02-11 02:35

    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");
    }
    

提交回复
热议问题