Search in sources :

Example 1 with AccessibilityEventFilter

use of android.app.UiAutomation.AccessibilityEventFilter in project android_frameworks_base by ResurrectionRemix.

the class UiDevice method waitForWindowUpdate.

/**
     * Waits for a window content update event to occur.
     *
     * If a package name for the window is specified, but the current window
     * does not have the same package name, the function returns immediately.
     *
     * @param packageName the specified window package name (can be <code>null</code>).
     *        If <code>null</code>, a window update from any front-end window will end the wait
     * @param timeout the timeout for the wait
     *
     * @return true if a window update occurred, false if timeout has elapsed or if the current
     *         window does not have the specified package name
     * @since API Level 16
     */
public boolean waitForWindowUpdate(final String packageName, long timeout) {
    Tracer.trace(packageName, timeout);
    if (packageName != null) {
        if (!packageName.equals(getCurrentPackageName())) {
            return false;
        }
    }
    Runnable emptyRunnable = new Runnable() {

        @Override
        public void run() {
        }
    };
    AccessibilityEventFilter checkWindowUpdate = new AccessibilityEventFilter() {

        @Override
        public boolean accept(AccessibilityEvent t) {
            if (t.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
                return packageName == null || packageName.equals(t.getPackageName());
            }
            return false;
        }
    };
    try {
        getAutomatorBridge().executeCommandAndWaitForAccessibilityEvent(emptyRunnable, checkWindowUpdate, timeout);
    } catch (TimeoutException e) {
        return false;
    } catch (Exception e) {
        Log.e(LOG_TAG, "waitForWindowUpdate: general exception from bridge", e);
        return false;
    }
    return true;
}
Also used : AccessibilityEventFilter(android.app.UiAutomation.AccessibilityEventFilter) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) TimeoutException(java.util.concurrent.TimeoutException) RemoteException(android.os.RemoteException) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with AccessibilityEventFilter

use of android.app.UiAutomation.AccessibilityEventFilter in project android_frameworks_base by crdroidandroid.

the class UiDevice method waitForWindowUpdate.

/**
     * Waits for a window content update event to occur.
     *
     * If a package name for the window is specified, but the current window
     * does not have the same package name, the function returns immediately.
     *
     * @param packageName the specified window package name (can be <code>null</code>).
     *        If <code>null</code>, a window update from any front-end window will end the wait
     * @param timeout the timeout for the wait
     *
     * @return true if a window update occurred, false if timeout has elapsed or if the current
     *         window does not have the specified package name
     * @since API Level 16
     */
public boolean waitForWindowUpdate(final String packageName, long timeout) {
    Tracer.trace(packageName, timeout);
    if (packageName != null) {
        if (!packageName.equals(getCurrentPackageName())) {
            return false;
        }
    }
    Runnable emptyRunnable = new Runnable() {

        @Override
        public void run() {
        }
    };
    AccessibilityEventFilter checkWindowUpdate = new AccessibilityEventFilter() {

        @Override
        public boolean accept(AccessibilityEvent t) {
            if (t.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
                return packageName == null || packageName.equals(t.getPackageName());
            }
            return false;
        }
    };
    try {
        getAutomatorBridge().executeCommandAndWaitForAccessibilityEvent(emptyRunnable, checkWindowUpdate, timeout);
    } catch (TimeoutException e) {
        return false;
    } catch (Exception e) {
        Log.e(LOG_TAG, "waitForWindowUpdate: general exception from bridge", e);
        return false;
    }
    return true;
}
Also used : AccessibilityEventFilter(android.app.UiAutomation.AccessibilityEventFilter) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) TimeoutException(java.util.concurrent.TimeoutException) RemoteException(android.os.RemoteException) TimeoutException(java.util.concurrent.TimeoutException)

Example 3 with AccessibilityEventFilter

use of android.app.UiAutomation.AccessibilityEventFilter in project platform_frameworks_base by android.

the class UiDevice method waitForWindowUpdate.

/**
     * Waits for a window content update event to occur.
     *
     * If a package name for the window is specified, but the current window
     * does not have the same package name, the function returns immediately.
     *
     * @param packageName the specified window package name (can be <code>null</code>).
     *        If <code>null</code>, a window update from any front-end window will end the wait
     * @param timeout the timeout for the wait
     *
     * @return true if a window update occurred, false if timeout has elapsed or if the current
     *         window does not have the specified package name
     * @since API Level 16
     */
public boolean waitForWindowUpdate(final String packageName, long timeout) {
    Tracer.trace(packageName, timeout);
    if (packageName != null) {
        if (!packageName.equals(getCurrentPackageName())) {
            return false;
        }
    }
    Runnable emptyRunnable = new Runnable() {

        @Override
        public void run() {
        }
    };
    AccessibilityEventFilter checkWindowUpdate = new AccessibilityEventFilter() {

        @Override
        public boolean accept(AccessibilityEvent t) {
            if (t.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
                return packageName == null || packageName.equals(t.getPackageName());
            }
            return false;
        }
    };
    try {
        getAutomatorBridge().executeCommandAndWaitForAccessibilityEvent(emptyRunnable, checkWindowUpdate, timeout);
    } catch (TimeoutException e) {
        return false;
    } catch (Exception e) {
        Log.e(LOG_TAG, "waitForWindowUpdate: general exception from bridge", e);
        return false;
    }
    return true;
}
Also used : AccessibilityEventFilter(android.app.UiAutomation.AccessibilityEventFilter) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) TimeoutException(java.util.concurrent.TimeoutException) RemoteException(android.os.RemoteException) TimeoutException(java.util.concurrent.TimeoutException)

Example 4 with AccessibilityEventFilter

use of android.app.UiAutomation.AccessibilityEventFilter in project android_frameworks_base by DirtyUnicorns.

the class UiDevice method waitForWindowUpdate.

/**
     * Waits for a window content update event to occur.
     *
     * If a package name for the window is specified, but the current window
     * does not have the same package name, the function returns immediately.
     *
     * @param packageName the specified window package name (can be <code>null</code>).
     *        If <code>null</code>, a window update from any front-end window will end the wait
     * @param timeout the timeout for the wait
     *
     * @return true if a window update occurred, false if timeout has elapsed or if the current
     *         window does not have the specified package name
     * @since API Level 16
     */
public boolean waitForWindowUpdate(final String packageName, long timeout) {
    Tracer.trace(packageName, timeout);
    if (packageName != null) {
        if (!packageName.equals(getCurrentPackageName())) {
            return false;
        }
    }
    Runnable emptyRunnable = new Runnable() {

        @Override
        public void run() {
        }
    };
    AccessibilityEventFilter checkWindowUpdate = new AccessibilityEventFilter() {

        @Override
        public boolean accept(AccessibilityEvent t) {
            if (t.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
                return packageName == null || packageName.equals(t.getPackageName());
            }
            return false;
        }
    };
    try {
        getAutomatorBridge().executeCommandAndWaitForAccessibilityEvent(emptyRunnable, checkWindowUpdate, timeout);
    } catch (TimeoutException e) {
        return false;
    } catch (Exception e) {
        Log.e(LOG_TAG, "waitForWindowUpdate: general exception from bridge", e);
        return false;
    }
    return true;
}
Also used : AccessibilityEventFilter(android.app.UiAutomation.AccessibilityEventFilter) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) TimeoutException(java.util.concurrent.TimeoutException) RemoteException(android.os.RemoteException) TimeoutException(java.util.concurrent.TimeoutException)

Example 5 with AccessibilityEventFilter

use of android.app.UiAutomation.AccessibilityEventFilter in project android_frameworks_base by AOSPA.

the class UiDevice method waitForWindowUpdate.

/**
     * Waits for a window content update event to occur.
     *
     * If a package name for the window is specified, but the current window
     * does not have the same package name, the function returns immediately.
     *
     * @param packageName the specified window package name (can be <code>null</code>).
     *        If <code>null</code>, a window update from any front-end window will end the wait
     * @param timeout the timeout for the wait
     *
     * @return true if a window update occurred, false if timeout has elapsed or if the current
     *         window does not have the specified package name
     * @since API Level 16
     */
public boolean waitForWindowUpdate(final String packageName, long timeout) {
    Tracer.trace(packageName, timeout);
    if (packageName != null) {
        if (!packageName.equals(getCurrentPackageName())) {
            return false;
        }
    }
    Runnable emptyRunnable = new Runnable() {

        @Override
        public void run() {
        }
    };
    AccessibilityEventFilter checkWindowUpdate = new AccessibilityEventFilter() {

        @Override
        public boolean accept(AccessibilityEvent t) {
            if (t.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
                return packageName == null || packageName.equals(t.getPackageName());
            }
            return false;
        }
    };
    try {
        getAutomatorBridge().executeCommandAndWaitForAccessibilityEvent(emptyRunnable, checkWindowUpdate, timeout);
    } catch (TimeoutException e) {
        return false;
    } catch (Exception e) {
        Log.e(LOG_TAG, "waitForWindowUpdate: general exception from bridge", e);
        return false;
    }
    return true;
}
Also used : AccessibilityEventFilter(android.app.UiAutomation.AccessibilityEventFilter) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) TimeoutException(java.util.concurrent.TimeoutException) RemoteException(android.os.RemoteException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

AccessibilityEventFilter (android.app.UiAutomation.AccessibilityEventFilter)5 RemoteException (android.os.RemoteException)5 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)5 TimeoutException (java.util.concurrent.TimeoutException)5