FileDocCategorySizeDatePackage
UiAutomationShellWrapper.javaAPI DocAndroid 5.1 API4390Thu Mar 12 22:22:08 GMT 2015com.android.uiautomator.core

UiAutomationShellWrapper

public class UiAutomationShellWrapper extends Object
hide

Fields Summary
private static final String
HANDLER_THREAD_NAME
private final android.os.HandlerThread
mHandlerThread
private android.app.UiAutomation
mUiAutomation
Constructors Summary
Methods Summary
public voidconnect()


       
        if (mHandlerThread.isAlive()) {
            throw new IllegalStateException("Already connected!");
        }
        mHandlerThread.start();
        mUiAutomation = new UiAutomation(mHandlerThread.getLooper(),
                new UiAutomationConnection());
        mUiAutomation.connect();
    
public voiddisconnect()

        if (!mHandlerThread.isAlive()) {
            throw new IllegalStateException("Already disconnected!");
        }
        mUiAutomation.disconnect();
        mHandlerThread.quit();
    
public android.app.UiAutomationgetUiAutomation()

        return mUiAutomation;
    
public voidsetCompressedLayoutHierarchy(boolean compressed)

        AccessibilityServiceInfo info = mUiAutomation.getServiceInfo();
        if (compressed)
            info.flags &= ~AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
        else
            info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
        mUiAutomation.setServiceInfo(info);
    
public voidsetRunAsMonkey(boolean isSet)
Enable or disable monkey test mode. Setting test as "monkey" indicates to some applications that a test framework is running as a "monkey" type. Such applications may choose not to perform actions that do submits so to avoid allowing monkey tests from doing harm or performing annoying actions such as dialing 911 or posting messages to public forums, etc.

param
isSet True to set as monkey test. False to set as regular functional test (default).
see
{@link ActivityManager#isUserAMonkey()}

        IActivityManager am = ActivityManagerNative.getDefault();
        if (am == null) {
            throw new RuntimeException("Can't manage monkey status; is the system running?");
        }
        try {
            if (isSet) {
                am.setActivityController(new DummyActivityController());
            } else {
                am.setActivityController(null);
            }
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }