Search in sources :

Example 6 with UiAutomation

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

the class UiAutomationShellWrapper method connect.

public void connect() {
    if (mHandlerThread.isAlive()) {
        throw new IllegalStateException("Already connected!");
    }
    mHandlerThread.start();
    mUiAutomation = new UiAutomation(mHandlerThread.getLooper(), new UiAutomationConnection());
    mUiAutomation.connect();
}
Also used : UiAutomationConnection(android.app.UiAutomationConnection) UiAutomation(android.app.UiAutomation)

Example 7 with UiAutomation

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

the class UiAutomationShellWrapper method connect.

public void connect() {
    if (mHandlerThread.isAlive()) {
        throw new IllegalStateException("Already connected!");
    }
    mHandlerThread.start();
    mUiAutomation = new UiAutomation(mHandlerThread.getLooper(), new UiAutomationConnection());
    mUiAutomation.connect();
}
Also used : UiAutomationConnection(android.app.UiAutomationConnection) UiAutomation(android.app.UiAutomation)

Example 8 with UiAutomation

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

the class DumpCommand method run.

@Override
public void run(String[] args) {
    File dumpFile = DEFAULT_DUMP_FILE;
    boolean verboseMode = true;
    for (String arg : args) {
        if (arg.equals("--compressed"))
            verboseMode = false;
        else if (!arg.startsWith("-")) {
            dumpFile = new File(arg);
        }
    }
    UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
    automationWrapper.connect();
    if (verboseMode) {
        // default
        automationWrapper.setCompressedLayoutHierarchy(false);
    } else {
        automationWrapper.setCompressedLayoutHierarchy(true);
    }
    // do a wait for idle in case the app is busy.
    try {
        UiAutomation uiAutomation = automationWrapper.getUiAutomation();
        uiAutomation.waitForIdle(1000, 1000 * 10);
        AccessibilityNodeInfo info = uiAutomation.getRootInActiveWindow();
        if (info == null) {
            System.err.println("ERROR: null root node returned by UiTestAutomationBridge.");
            return;
        }
        Display display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
        int rotation = display.getRotation();
        Point size = new Point();
        display.getSize(size);
        AccessibilityNodeInfoDumper.dumpWindowToFile(info, dumpFile, rotation, size.x, size.y);
    } catch (TimeoutException re) {
        System.err.println("ERROR: could not get idle state.");
        return;
    } finally {
        automationWrapper.disconnect();
    }
    System.out.println(String.format("UI hierchary dumped to: %s", dumpFile.getAbsolutePath()));
}
Also used : UiAutomation(android.app.UiAutomation) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Point(android.graphics.Point) File(java.io.File) Point(android.graphics.Point) UiAutomationShellWrapper(com.android.uiautomator.core.UiAutomationShellWrapper) Display(android.view.Display) TimeoutException(java.util.concurrent.TimeoutException)

Example 9 with UiAutomation

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

the class DumpCommand method run.

@Override
public void run(String[] args) {
    File dumpFile = DEFAULT_DUMP_FILE;
    boolean verboseMode = true;
    for (String arg : args) {
        if (arg.equals("--compressed"))
            verboseMode = false;
        else if (!arg.startsWith("-")) {
            dumpFile = new File(arg);
        }
    }
    UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
    automationWrapper.connect();
    if (verboseMode) {
        // default
        automationWrapper.setCompressedLayoutHierarchy(false);
    } else {
        automationWrapper.setCompressedLayoutHierarchy(true);
    }
    // do a wait for idle in case the app is busy.
    try {
        UiAutomation uiAutomation = automationWrapper.getUiAutomation();
        uiAutomation.waitForIdle(1000, 1000 * 10);
        AccessibilityNodeInfo info = uiAutomation.getRootInActiveWindow();
        if (info == null) {
            System.err.println("ERROR: null root node returned by UiTestAutomationBridge.");
            return;
        }
        Display display = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY);
        int rotation = display.getRotation();
        Point size = new Point();
        display.getSize(size);
        AccessibilityNodeInfoDumper.dumpWindowToFile(info, dumpFile, rotation, size.x, size.y);
    } catch (TimeoutException re) {
        System.err.println("ERROR: could not get idle state.");
        return;
    } finally {
        automationWrapper.disconnect();
    }
    System.out.println(String.format("UI hierchary dumped to: %s", dumpFile.getAbsolutePath()));
}
Also used : UiAutomation(android.app.UiAutomation) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) Point(android.graphics.Point) File(java.io.File) Point(android.graphics.Point) UiAutomationShellWrapper(com.android.uiautomator.core.UiAutomationShellWrapper) Display(android.view.Display) TimeoutException(java.util.concurrent.TimeoutException)

Example 10 with UiAutomation

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

the class UiAutomationShellWrapper method connect.

public void connect() {
    if (mHandlerThread.isAlive()) {
        throw new IllegalStateException("Already connected!");
    }
    mHandlerThread.start();
    mUiAutomation = new UiAutomation(mHandlerThread.getLooper(), new UiAutomationConnection());
    mUiAutomation.connect();
}
Also used : UiAutomationConnection(android.app.UiAutomationConnection) UiAutomation(android.app.UiAutomation)

Aggregations

UiAutomation (android.app.UiAutomation)10 UiAutomationConnection (android.app.UiAutomationConnection)5 Point (android.graphics.Point)5 Display (android.view.Display)5 AccessibilityNodeInfo (android.view.accessibility.AccessibilityNodeInfo)5 UiAutomationShellWrapper (com.android.uiautomator.core.UiAutomationShellWrapper)5 File (java.io.File)5 TimeoutException (java.util.concurrent.TimeoutException)5