Package org.robolectric.shadows
Class ShadowAccessibilityService
java.lang.Object
org.robolectric.shadows.ShadowContextWrapper
org.robolectric.shadows.ShadowService
org.robolectric.shadows.ShadowAccessibilityService
@Implements(android.accessibilityservice.AccessibilityService.class)
public class ShadowAccessibilityService
extends ShadowService
Shadow of AccessibilityService that tracks global actions and provides a mechanism to simulate
the window list.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents a gesture that has been dispatched through the accessibility service. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleandispatchGesture(GestureDescription gesture, AccessibilityService.GestureResultCallback callback, Handler handler) Returns a list of gestures that have been dispatched.protected AccessibilityNodeInfoprotected List<AccessibilityNodeInfo.AccessibilityAction> protected List<AccessibilityWindowInfo> Returns a representation of interactive windows shown on the device's default display.protected SparseArray<List<AccessibilityWindowInfo>> Returns a representation of interactive windows shown on the device's all displays.protected booleanperformGlobalAction(int action) voidsetCanDispatchGestures(boolean canDispatchGestures) Sets whether the service is currently able to dispatch gestures.voidsetRootInActiveWindow(AccessibilityNodeInfo rootInActiveWindow) final voidsetSystemActions(List<AccessibilityNodeInfo.AccessibilityAction> systemActions) voidsetTakeScreenshotErrorCode(int errorCode) SetsAccessibilityService.takeScreenshot(int, Executor, TakeScreenshotCallback)to start returning the givenerrorCode.voidsetWindows(List<AccessibilityWindowInfo> windowList) Sets the list of interactive windows shown on the device's default display as reported bygetWindows()voidsetWindowsOnDisplay(int displayId, List<AccessibilityWindowInfo> windowList) Sets the list of interactive windows shown on the device'sdisplayIddisplay.voidstartInput(EditorInfo editorInfo) protected voidtakeScreenshot(int displayId, Executor executor, AccessibilityService.TakeScreenshotCallback callback) voidSetsAccessibilityService.takeScreenshot(int, Executor, TakeScreenshotCallback)to start returning successful results again.Methods inherited from class org.robolectric.shadows.ShadowService
getForegroundServiceType, getLastForegroundNotification, getLastForegroundNotificationId, getNotificationShouldRemoved, getStopSelfId, getStopSelfResultId, isForegroundStopped, isLastForegroundNotificationAttached, isStoppedBySelf, onDestroy, setThrowInStartForeground, startForeground, startForeground, stopForeground, stopForeground, stopSelf, stopSelf, stopSelfResultMethods inherited from class org.robolectric.shadows.ShadowContextWrapper
clearBroadcastIntents, clearNextStartedActivities, clearStartedServices, denyPermissions, denyPermissions, getAllStartedServices, getBroadcastIntents, getBroadcastIntentsForUser, getBroadcastOptions, getNextStartedActivity, getNextStartedActivityForResult, getNextStartedService, getNextStoppedService, grantPermissions, grantPermissions, peekNextStartedActivity, peekNextStartedActivityForResult, peekNextStartedService, removeSystemService
-
Constructor Details
-
ShadowAccessibilityService
public ShadowAccessibilityService()
-
-
Method Details
-
performGlobalAction
-
getGlobalActionsPerformed
-
getSystemActions
@Implementation(minSdk=31) protected List<AccessibilityNodeInfo.AccessibilityAction> getSystemActions() -
setSystemActions
-
getWindows
Returns a representation of interactive windows shown on the device's default display. Mirrors the values provided tosetWindows(List). Returns an empty list if not set. -
getWindowsOnAllDisplays
@Implementation(minSdk=30) protected SparseArray<List<AccessibilityWindowInfo>> getWindowsOnAllDisplays()Returns a representation of interactive windows shown on the device's all displays. An empty list will be returned for default display andnullwill be return for other displays if they are not set bysetWindowsOnDisplay(int, List). -
dispatchGesture
@Implementation(minSdk=24) protected boolean dispatchGesture(GestureDescription gesture, AccessibilityService.GestureResultCallback callback, Handler handler) -
takeScreenshot
@Implementation(minSdk=30) protected void takeScreenshot(int displayId, Executor executor, AccessibilityService.TakeScreenshotCallback callback) -
getRootInActiveWindow
-
setRootInActiveWindow
-
setTakeScreenshotErrorCode
public void setTakeScreenshotErrorCode(int errorCode) SetsAccessibilityService.takeScreenshot(int, Executor, TakeScreenshotCallback)to start returning the givenerrorCode.- See Also:
-
unsetTakeScreenshotErrorCode
public void unsetTakeScreenshotErrorCode()SetsAccessibilityService.takeScreenshot(int, Executor, TakeScreenshotCallback)to start returning successful results again.- See Also:
-
setWindows
Sets the list of interactive windows shown on the device's default display as reported bygetWindows() -
setWindowsOnDisplay
Sets the list of interactive windows shown on the device'sdisplayIddisplay. If thewindowListis null, we will remove the list with givendisplayIddisplay as reported bygetWindowsOnAllDisplays(). -
getGesturesDispatched
Returns a list of gestures that have been dispatched.Gestures are dispatched by calling
AccessibilityService.dispatchGesture(android.accessibilityservice.GestureDescription, android.accessibilityservice.AccessibilityService.GestureResultCallback, android.os.Handler). -
setCanDispatchGestures
public void setCanDispatchGestures(boolean canDispatchGestures) Sets whether the service is currently able to dispatch gestures.If
false,AccessibilityService.dispatchGesture(android.accessibilityservice.GestureDescription, android.accessibilityservice.AccessibilityService.GestureResultCallback, android.os.Handler)will returnfalse. -
startInput
-