diff --git a/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorService.java b/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorService.java index 547cdc8..1ccfe36 100644 --- a/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorService.java +++ b/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorService.java @@ -937,4 +937,10 @@ public interface AutomatorService { */ @JsonRpcErrors({@JsonRpcError(exception=NotImplementedException.class, code=ERROR_CODE_BASE)}) String toast(String switchStatus) throws NotImplementedException; + + /** + * Method used to clear hierarachy in case of an update not occurring + */ + @JsonRpcErrors({@JsonRpcError(exception=UiAutomator2Exception.class, code=ERROR_CODE_BASE)}) + void clearHierarchyCache(); } 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 3d446d2..6ac97b4 100644 --- a/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorServiceImpl.java +++ b/app/src/androidTest/java/com/github/uiautomator/stub/AutomatorServiceImpl.java @@ -1641,4 +1641,14 @@ public String toast(String switchStatus) throws NotImplementedException { } return null; } + + @Override + public void clearHierarchyCache() { + try { + ReflectionUtils.clearAccessibilityCache(); + }catch (Exception e) { + e.printStackTrace(); + throw new UiAutomator2Exception(e); + } + } }