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
Modifier and TypeClassDescriptionstatic final class
Represents a gesture that has been dispatched through the accessibility service. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
dispatchGesture
(GestureDescription gesture, AccessibilityService.GestureResultCallback callback, Handler handler) Returns a list of gestures that have been dispatched.protected 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 boolean
performGlobalAction
(int action) void
setCanDispatchGestures
(boolean canDispatchGestures) Sets whether the service is currently able to dispatch gestures.final void
setSystemActions
(List<AccessibilityNodeInfo.AccessibilityAction> systemActions) void
setTakeScreenshotErrorCode
(int errorCode) SetsAccessibilityService.takeScreenshot(int, Executor, TakeScreenshotCallback)
to start returning the givenerrorCode
.void
setWindows
(List<AccessibilityWindowInfo> windowList) Sets the list of interactive windows shown on the device's default display as reported bygetWindows()
void
setWindowsOnDisplay
(int displayId, List<AccessibilityWindowInfo> windowList) Sets the list of interactive windows shown on the device'sdisplayId
display.protected void
takeScreenshot
(int displayId, Executor executor, AccessibilityService.TakeScreenshotCallback callback) void
SetsAccessibilityService.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, startForeground, startForeground, stopForeground, stopForeground, stopSelf, stopSelf, stopSelfResult
Methods 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<AccessibilityWindowInfo>)
. 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 andnull
will 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) -
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'sdisplayId
display. If thewindowList
is null, we will remove the list with givendisplayId
display 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
.
-