Search in sources :

Example 1 with UiAutomation

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

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 2 with UiAutomation

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

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 3 with UiAutomation

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

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 4 with UiAutomation

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

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 5 with UiAutomation

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

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)

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