diff --git a/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorServiceImpl.java b/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorServiceImpl.java index fb3f65a..d6bdc27 100644 --- a/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorServiceImpl.java +++ b/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorServiceImpl.java @@ -103,14 +103,18 @@ public DeviceInfo deviceInfo() { public void setAccessibilityPatterns(HashMap patterns) { String[] packageNames = patterns.keySet().toArray(new String[patterns.size()]); for (String name : packageNames) { - Log.d("Accessibility package names " + name); + Log.d("Accessibility package name " + name); } AccessibilityServiceInfo serviceInfo = uiAutomation.getServiceInfo(); serviceInfo.packageNames = packageNames; serviceInfo.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED; serviceInfo.notificationTimeout = 500; uiAutomation.setServiceInfo(serviceInfo); - uiAutomation.setOnAccessibilityEventListener(new EventListener(patterns)); + if (patterns.isEmpty()){ + uiAutomation.setOnAccessibilityEventListener(null); + } else { + uiAutomation.setOnAccessibilityEventListener(new EventListener(patterns)); + } } @Override