@Implementation public static AccessibilityEvent obtain(int eventType) { // We explicitly avoid allocating the AccessibilityEvent from the actual pool by using // the private constructor. Not doing so affects test suites which use both shadow and // non-shadow objects. final AccessibilityEvent obtainedInstance = ReflectionHelpers.callConstructor(AccessibilityEvent.class); final ShadowAccessibilityEvent shadowObtained = ((ShadowAccessibilityEvent) ShadowExtractor.extract(obtainedInstance)); sAllocationCount++; StrictEqualityEventWrapper wrapper = new StrictEqualityEventWrapper(obtainedInstance); obtainedInstances.put(wrapper, Thread.currentThread().getStackTrace()); orderedInstances.put(sAllocationCount, wrapper); shadowObtained.eventType = eventType; return obtainedInstance; }
/** @return A shallow copy. */ private AccessibilityEvent getClone() { // We explicitly avoid allocating the AccessibilityEvent from the actual pool by using // the private constructor. Not doing so affects test suites which use both shadow and // non-shadow objects. final AccessibilityEvent newEvent = ReflectionHelpers.callConstructor(AccessibilityEvent.class); final ShadowAccessibilityEvent newShadow = (ShadowAccessibilityEvent) ShadowExtractor.extract(newEvent); newShadow.eventType = eventType; newShadow.contentDescription = contentDescription; newShadow.packageName = packageName; newShadow.className = className; newShadow.enabled = enabled; newShadow.setParcelableData(getParcelableData()); return newEvent; }