Search in sources :

Example 46 with AccessibilityEvent

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;
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent) Implementation(org.robolectric.annotation.Implementation)

Example 47 with AccessibilityEvent

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;
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent) Implementation(org.robolectric.annotation.Implementation)

Example 48 with AccessibilityEvent

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;
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 49 with AccessibilityEvent

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;
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 50 with AccessibilityEvent

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();
        }
    }
}
Also used : AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Aggregations

AccessibilityEvent (android.view.accessibility.AccessibilityEvent)241 AccessibilityManager (android.view.accessibility.AccessibilityManager)49 LargeTest (android.test.suitebuilder.annotation.LargeTest)40 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)20 ViewParent (android.view.ViewParent)13 TimeoutException (java.util.concurrent.TimeoutException)11 MediumTest (android.test.suitebuilder.annotation.MediumTest)10 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)10 Notification (android.app.Notification)7 ITransientNotification (android.app.ITransientNotification)6 Context (android.content.Context)6 RemoteException (android.os.RemoteException)6 StatusBarNotification (android.service.notification.StatusBarNotification)6 AccessibilityRecordCompat (android.support.v4.view.accessibility.AccessibilityRecordCompat)6 ViewGroup (android.view.ViewGroup)6 Test (org.junit.Test)6 SuppressLint (android.annotation.SuppressLint)5 AccessibilityEventFilter (android.app.UiAutomation.AccessibilityEventFilter)5 OnAccessibilityEventListener (android.app.UiAutomation.OnAccessibilityEventListener)5 UiAutomationShellWrapper (com.android.uiautomator.core.UiAutomationShellWrapper)5