Methods Summary |
---|
public void | clearWindowAnimationFrameStats()
synchronized (mLock) {
throwIfCalledByNotTrustedUidLocked();
throwIfShutdownLocked();
throwIfNotConnectedLocked();
}
final long identity = Binder.clearCallingIdentity();
try {
SurfaceControl.clearAnimationFrameStats();
} finally {
Binder.restoreCallingIdentity(identity);
}
|
public boolean | clearWindowContentFrameStats(int windowId)
synchronized (mLock) {
throwIfCalledByNotTrustedUidLocked();
throwIfShutdownLocked();
throwIfNotConnectedLocked();
}
final long identity = Binder.clearCallingIdentity();
try {
IBinder token = mAccessibilityManager.getWindowToken(windowId);
if (token == null) {
return false;
}
return mWindowManager.clearWindowContentFrameStats(token);
} finally {
Binder.restoreCallingIdentity(identity);
}
|
public void | connect(android.accessibilityservice.IAccessibilityServiceClient client)
if (client == null) {
throw new IllegalArgumentException("Client cannot be null!");
}
synchronized (mLock) {
throwIfShutdownLocked();
if (isConnectedLocked()) {
throw new IllegalStateException("Already connected.");
}
mOwningUid = Binder.getCallingUid();
registerUiTestAutomationServiceLocked(client);
storeRotationStateLocked();
}
|
public void | disconnect()
synchronized (mLock) {
throwIfCalledByNotTrustedUidLocked();
throwIfShutdownLocked();
if (!isConnectedLocked()) {
throw new IllegalStateException("Already disconnected.");
}
mOwningUid = -1;
unregisterUiTestAutomationServiceLocked();
restoreRotationStateLocked();
}
|
public void | executeShellCommand(java.lang.String command, android.os.ParcelFileDescriptor sink)
synchronized (mLock) {
throwIfCalledByNotTrustedUidLocked();
throwIfShutdownLocked();
throwIfNotConnectedLocked();
}
InputStream in = null;
OutputStream out = null;
try {
java.lang.Process process = Runtime.getRuntime().exec(command);
in = process.getInputStream();
out = new FileOutputStream(sink.getFileDescriptor());
final byte[] buffer = new byte[8192];
while (true) {
final int readByteCount = in.read(buffer);
if (readByteCount < 0) {
break;
}
out.write(buffer, 0, readByteCount);
}
} catch (IOException ioe) {
throw new RuntimeException("Error running shell command", ioe);
} finally {
IoUtils.closeQuietly(in);
IoUtils.closeQuietly(out);
IoUtils.closeQuietly(sink);
}
|
public android.view.WindowAnimationFrameStats | getWindowAnimationFrameStats()
synchronized (mLock) {
throwIfCalledByNotTrustedUidLocked();
throwIfShutdownLocked();
throwIfNotConnectedLocked();
}
final long identity = Binder.clearCallingIdentity();
try {
WindowAnimationFrameStats stats = new WindowAnimationFrameStats();
SurfaceControl.getAnimationFrameStats(stats);
return stats;
} finally {
Binder.restoreCallingIdentity(identity);
}
|
public android.view.WindowContentFrameStats | getWindowContentFrameStats(int windowId)
synchronized (mLock) {
throwIfCalledByNotTrustedUidLocked();
throwIfShutdownLocked();
throwIfNotConnectedLocked();
}
final long identity = Binder.clearCallingIdentity();
try {
IBinder token = mAccessibilityManager.getWindowToken(windowId);
if (token == null) {
return null;
}
return mWindowManager.getWindowContentFrameStats(token);
} finally {
Binder.restoreCallingIdentity(identity);
}
|
public boolean | injectInputEvent(android.view.InputEvent event, boolean sync)
synchronized (mLock) {
throwIfCalledByNotTrustedUidLocked();
throwIfShutdownLocked();
throwIfNotConnectedLocked();
}
final int mode = (sync) ? InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH
: InputManager.INJECT_INPUT_EVENT_MODE_ASYNC;
final long identity = Binder.clearCallingIdentity();
try {
return InputManager.getInstance().injectInputEvent(event, mode);
} finally {
Binder.restoreCallingIdentity(identity);
}
|
private boolean | isConnectedLocked()
return mClient != null;
|
private void | registerUiTestAutomationServiceLocked(android.accessibilityservice.IAccessibilityServiceClient client)
IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(
ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
| AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS;
info.setCapabilities(AccessibilityServiceInfo.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT
| AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION
| AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY
| AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS);
try {
// Calling out with a lock held is fine since if the system
// process is gone the client calling in will be killed.
manager.registerUiTestAutomationService(mToken, client, info);
mClient = client;
} catch (RemoteException re) {
throw new IllegalStateException("Error while registering UiTestAutomationService.", re);
}
|
private void | restoreRotationStateLocked()
try {
if (mInitialFrozenRotation != INITIAL_FROZEN_ROTATION_UNSPECIFIED) {
// Calling out with a lock held is fine since if the system
// process is gone the client calling in will be killed.
mWindowManager.freezeRotation(mInitialFrozenRotation);
} else {
// Calling out with a lock held is fine since if the system
// process is gone the client calling in will be killed.
mWindowManager.thawRotation();
}
} catch (RemoteException re) {
/* ignore */
}
|
public boolean | setRotation(int rotation)
synchronized (mLock) {
throwIfCalledByNotTrustedUidLocked();
throwIfShutdownLocked();
throwIfNotConnectedLocked();
}
final long identity = Binder.clearCallingIdentity();
try {
if (rotation == UiAutomation.ROTATION_UNFREEZE) {
mWindowManager.thawRotation();
} else {
mWindowManager.freezeRotation(rotation);
}
return true;
} catch (RemoteException re) {
/* ignore */
} finally {
Binder.restoreCallingIdentity(identity);
}
return false;
|
public void | shutdown()
synchronized (mLock) {
if (isConnectedLocked()) {
throwIfCalledByNotTrustedUidLocked();
}
throwIfShutdownLocked();
mIsShutdown = true;
if (isConnectedLocked()) {
disconnect();
}
}
|
private void | storeRotationStateLocked()
try {
if (mWindowManager.isRotationFrozen()) {
// Calling out with a lock held is fine since if the system
// process is gone the client calling in will be killed.
mInitialFrozenRotation = mWindowManager.getRotation();
}
} catch (RemoteException re) {
/* ignore */
}
|
public android.graphics.Bitmap | takeScreenshot(int width, int height)
synchronized (mLock) {
throwIfCalledByNotTrustedUidLocked();
throwIfShutdownLocked();
throwIfNotConnectedLocked();
}
final long identity = Binder.clearCallingIdentity();
try {
return SurfaceControl.screenshot(width, height);
} finally {
Binder.restoreCallingIdentity(identity);
}
|
private void | throwIfCalledByNotTrustedUidLocked()
final int callingUid = Binder.getCallingUid();
if (callingUid != mOwningUid && mOwningUid != Process.SYSTEM_UID
&& callingUid != 0 /*root*/) {
throw new SecurityException("Calling from not trusted UID!");
}
|
private void | throwIfNotConnectedLocked()
if (!isConnectedLocked()) {
throw new IllegalStateException("Not connected!");
}
|
private void | throwIfShutdownLocked()
if (mIsShutdown) {
throw new IllegalStateException("Connection shutdown!");
}
|
private void | unregisterUiTestAutomationServiceLocked()
IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(
ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
try {
// Calling out with a lock held is fine since if the system
// process is gone the client calling in will be killed.
manager.unregisterUiTestAutomationService(mClient);
mClient = null;
} catch (RemoteException re) {
throw new IllegalStateException("Error while unregistering UiTestAutomationService",
re);
}
|