/** * Check for leaked objects that were {@code obtain}ed but never * {@code recycle}d. * * @param printUnrecycledWindowsToSystemErr - if true, stack traces of calls * to {@code obtain} that lack matching calls to {@code recycle} are * dumped to System.err. * @return {@code true} if there are unrecycled windows */ public static boolean areThereUnrecycledWindows(boolean printUnrecycledWindowsToSystemErr) { if (printUnrecycledWindowsToSystemErr) { for (final StrictEqualityWindowWrapper wrapper : obtainedInstances.keySet()) { final ShadowAccessibilityWindowInfo shadow = Shadow.extract(wrapper.mInfo); System.err.println(String.format( "Leaked type = %d, id = %d. Stack trace:", shadow.getType(), shadow.getId())); for (final StackTraceElement stackTraceElement : obtainedInstances.get(wrapper)) { System.err.println(stackTraceElement.toString()); } } } return (obtainedInstances.size() != 0); }
@Override @Implementation @SuppressWarnings("ReferenceEquality") public boolean equals(Object object) { if (!(object instanceof AccessibilityWindowInfo)) { return false; } final AccessibilityWindowInfo window = (AccessibilityWindowInfo) object; final ShadowAccessibilityWindowInfo otherShadow = Shadow.extract(window); boolean areEqual = (type == otherShadow.getType()); areEqual &= (parent == otherShadow.getParent()); areEqual &= (rootNode == otherShadow.getRoot()); areEqual &= (layer == otherShadow.getLayer()); areEqual &= (id == otherShadow.getId()); areEqual &= (title == otherShadow.getTitle()); areEqual &= (isAccessibilityFocused == otherShadow.isAccessibilityFocused()); areEqual &= (isActive == otherShadow.isActive()); areEqual &= (isFocused == otherShadow.isFocused()); Rect anotherBounds = new Rect(); otherShadow.getBoundsInScreen(anotherBounds); areEqual &= (boundsInScreen.equals(anotherBounds)); return areEqual; }
/** * Check for leaked objects that were {@code obtain}ed but never * {@code recycle}d. * * @param printUnrecycledWindowsToSystemErr - if true, stack traces of calls * to {@code obtain} that lack matching calls to {@code recycle} are * dumped to System.err. * @return {@code true} if there are unrecycled windows */ public static boolean areThereUnrecycledWindows(boolean printUnrecycledWindowsToSystemErr) { if (printUnrecycledWindowsToSystemErr) { for (final StrictEqualityWindowWrapper wrapper : obtainedInstances.keySet()) { final ShadowAccessibilityWindowInfo shadow = Shadow.extract(wrapper.mInfo); System.err.println(String.format( "Leaked type = %d, id = %d. Stack trace:", shadow.getType(), shadow.getId())); for (final StackTraceElement stackTraceElement : obtainedInstances.get(wrapper)) { System.err.println(stackTraceElement.toString()); } } } return (obtainedInstances.size() != 0); }
/** * Check for leaked objects that were {@code obtain}ed but never * {@code recycle}d. * * @param printUnrecycledWindowsToSystemErr - if true, stack traces of calls * to {@code obtain} that lack matching calls to {@code recycle} are * dumped to System.err. * @return {@code true} if there are unrecycled windows */ public static boolean areThereUnrecycledWindows(boolean printUnrecycledWindowsToSystemErr) { if (printUnrecycledWindowsToSystemErr) { for (final StrictEqualityWindowWrapper wrapper : obtainedInstances.keySet()) { final ShadowAccessibilityWindowInfo shadow = Shadow.extract(wrapper.mInfo); System.err.println(String.format( "Leaked type = %d, id = %d. Stack trace:", shadow.getType(), shadow.getId())); for (final StackTraceElement stackTraceElement : obtainedInstances.get(wrapper)) { System.err.println(stackTraceElement.toString()); } } } return (obtainedInstances.size() != 0); }
/** * Check for leaked objects that were {@code obtain}ed but never * {@code recycle}d. * * @param printUnrecycledWindowsToSystemErr - if true, stack traces of calls * to {@code obtain} that lack matching calls to {@code recycle} are * dumped to System.err. * @return {@code true} if there are unrecycled windows */ public static boolean areThereUnrecycledWindows(boolean printUnrecycledWindowsToSystemErr) { if (printUnrecycledWindowsToSystemErr) { for (final StrictEqualityWindowWrapper wrapper : obtainedInstances.keySet()) { final ShadowAccessibilityWindowInfo shadow = ((ShadowAccessibilityWindowInfo) ShadowExtractor.extract(wrapper.mInfo)); System.err.println(String.format( "Leaked type = %d, id = %d. Stack trace:", shadow.getType(), shadow.getId())); for (final StackTraceElement stackTraceElement : obtainedInstances.get(wrapper)) { System.err.println(stackTraceElement.toString()); } } } return (obtainedInstances.size() != 0); }
/** * Check for leaked objects that were {@code obtain}ed but never * {@code recycle}d. * * @param printUnrecycledWindowsToSystemErr - if true, stack traces of calls * to {@code obtain} that lack matching calls to {@code recycle} are * dumped to System.err. * @return {@code true} if there are unrecycled windows */ public static boolean areThereUnrecycledWindows(boolean printUnrecycledWindowsToSystemErr) { if (printUnrecycledWindowsToSystemErr) { for (final StrictEqualityWindowWrapper wrapper : obtainedInstances.keySet()) { final ShadowAccessibilityWindowInfo shadow = ((ShadowAccessibilityWindowInfo) ShadowExtractor.extract(wrapper.mInfo)); System.err.println(String.format( "Leaked type = %d, id = %d. Stack trace:", shadow.getType(), shadow.getId())); for (final StackTraceElement stackTraceElement : obtainedInstances.get(wrapper)) { System.err.println(stackTraceElement.toString()); } } } return (obtainedInstances.size() != 0); }
@Override @Implementation public boolean equals(Object object) { if (!(object instanceof AccessibilityWindowInfo)) { return false; } final AccessibilityWindowInfo window = (AccessibilityWindowInfo) object; final ShadowAccessibilityWindowInfo otherShadow = (ShadowAccessibilityWindowInfo) ShadowExtractor.extract(window); boolean areEqual = (type == otherShadow.getType()); areEqual &= (parent == otherShadow.getParent()); areEqual &= (rootNode == otherShadow.getRoot()); areEqual &= (layer == otherShadow.getLayer()); areEqual &= (id == otherShadow.getId()); areEqual &= (isAccessibilityFocused == otherShadow.isAccessibilityFocused()); areEqual &= (isActive == otherShadow.isActive()); areEqual &= (isFocused == otherShadow.isFocused()); Rect anotherBounds = new Rect(); otherShadow.getBoundsInScreen(anotherBounds); areEqual &= (boundsInScreen.equals(anotherBounds)); return areEqual; }
@Override @Implementation public boolean equals(Object object) { if (!(object instanceof AccessibilityWindowInfo)) { return false; } final AccessibilityWindowInfo window = (AccessibilityWindowInfo) object; final ShadowAccessibilityWindowInfo otherShadow = Shadow.extract(window); boolean areEqual = (type == otherShadow.getType()); areEqual &= (parent == otherShadow.getParent()); areEqual &= (rootNode == otherShadow.getRoot()); areEqual &= (layer == otherShadow.getLayer()); areEqual &= (id == otherShadow.getId()); areEqual &= (isAccessibilityFocused == otherShadow.isAccessibilityFocused()); areEqual &= (isActive == otherShadow.isActive()); areEqual &= (isFocused == otherShadow.isFocused()); Rect anotherBounds = new Rect(); otherShadow.getBoundsInScreen(anotherBounds); areEqual &= (boundsInScreen.equals(anotherBounds)); return areEqual; }
@Override @Implementation public boolean equals(Object object) { if (!(object instanceof AccessibilityWindowInfo)) { return false; } final AccessibilityWindowInfo window = (AccessibilityWindowInfo) object; final ShadowAccessibilityWindowInfo otherShadow = (ShadowAccessibilityWindowInfo) ShadowExtractor.extract(window); boolean areEqual = (type == otherShadow.getType()); areEqual &= (parent == otherShadow.getParent()); areEqual &= (rootNode == otherShadow.getRoot()); areEqual &= (layer == otherShadow.getLayer()); areEqual &= (id == otherShadow.getId()); areEqual &= (isAccessibilityFocused == otherShadow.isAccessibilityFocused()); areEqual &= (isActive == otherShadow.isActive()); areEqual &= (isFocused == otherShadow.isFocused()); Rect anotherBounds = new Rect(); otherShadow.getBoundsInScreen(anotherBounds); areEqual &= (boundsInScreen.equals(anotherBounds)); return areEqual; }
@Override @Implementation @SuppressWarnings("ReferenceEquality") public boolean equals(Object object) { if (!(object instanceof AccessibilityWindowInfo)) { return false; } final AccessibilityWindowInfo window = (AccessibilityWindowInfo) object; final ShadowAccessibilityWindowInfo otherShadow = Shadow.extract(window); boolean areEqual = (type == otherShadow.getType()); areEqual &= (parent == otherShadow.getParent()); areEqual &= (rootNode == otherShadow.getRoot()); areEqual &= (layer == otherShadow.getLayer()); areEqual &= (id == otherShadow.getId()); areEqual &= (title == otherShadow.getTitle()); areEqual &= (isAccessibilityFocused == otherShadow.isAccessibilityFocused()); areEqual &= (isActive == otherShadow.isActive()); areEqual &= (isFocused == otherShadow.isFocused()); Rect anotherBounds = new Rect(); otherShadow.getBoundsInScreen(anotherBounds); areEqual &= (boundsInScreen.equals(anotherBounds)); return areEqual; }