use of android.view.accessibility.AccessibilityEvent in project robolectric by robolectric.
the class ShadowAccessibilityEvent method obtain.
@Implementation
public static AccessibilityEvent obtain(AccessibilityEvent event) {
ShadowAccessibilityEvent shadowEvent = ((ShadowAccessibilityEvent) ShadowExtractor.extract(event));
AccessibilityEvent obtainedInstance = shadowEvent.getClone();
sAllocationCount++;
StrictEqualityEventWrapper wrapper = new StrictEqualityEventWrapper(obtainedInstance);
obtainedInstances.put(wrapper, Thread.currentThread().getStackTrace());
orderedInstances.put(sAllocationCount, wrapper);
return obtainedInstance;
}
use of android.view.accessibility.AccessibilityEvent in project robolectric by robolectric.
the class ShadowAccessibilityEvent method obtain.
@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;
}
use of android.view.accessibility.AccessibilityEvent in project robolectric by robolectric.
the class ShadowAccessibilityEvent method getClone.
/**
* @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;
}
use of android.view.accessibility.AccessibilityEvent in project platform_frameworks_base by android.
the class ExpandableNotificationRow method onRequestSendAccessibilityEventInternal.
@Override
public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) {
if (super.onRequestSendAccessibilityEventInternal(child, event)) {
// Add a record for the entire layout since its content is somehow small.
// The event comes from a leaf view that is interacted with.
AccessibilityEvent record = AccessibilityEvent.obtain();
onInitializeAccessibilityEvent(record);
dispatchPopulateAccessibilityEvent(record);
event.appendRecord(record);
return true;
}
return false;
}
use of android.view.accessibility.AccessibilityEvent in project platform_frameworks_base by android.
the class VolumeDialog method dismissH.
protected void dismissH(int reason) {
if (mMotion.isAnimating()) {
return;
}
mHandler.removeMessages(H.DISMISS);
mHandler.removeMessages(H.SHOW);
if (!mShowing)
return;
mShowing = false;
mMotion.startDismiss(new Runnable() {
@Override
public void run() {
updateExpandedH(false, /* expanding */
true);
}
});
if (mAccessibilityMgr.isEnabled()) {
AccessibilityEvent event = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
event.setPackageName(mContext.getPackageName());
event.setClassName(CustomDialog.class.getSuperclass().getName());
event.getText().add(mContext.getString(R.string.volume_dialog_accessibility_dismissed_message));
mAccessibilityMgr.sendAccessibilityEvent(event);
}
Events.writeEvent(mContext, Events.EVENT_DISMISS_DIALOG, reason);
mController.notifyVisible(false);
synchronized (mSafetyWarningLock) {
if (mSafetyWarning != null) {
if (D.BUG)
Log.d(TAG, "SafetyWarning dismissed");
mSafetyWarning.dismiss();
}
}
}
Aggregations