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 Classes Modifier and Type Class Description static classShadowAccessibilityService.GestureDispatchRepresents a gesture that has been dispatched through the accessibility service. -
Constructor Summary
Constructors Constructor Description ShadowAccessibilityService() -
Method Summary
Modifier and Type Method Description protected booleandispatchGesture(GestureDescription gesture, AccessibilityService.GestureResultCallback callback, Handler handler)List<ShadowAccessibilityService.GestureDispatch>getGesturesDispatched()Returns a list of gestures that have been dispatched.List<Integer>getGlobalActionsPerformed()protected List<AccessibilityNodeInfo.AccessibilityAction>getSystemActions()protected List<AccessibilityWindowInfo>getWindows()Returns a representation of interactive windows shown on the device's default display.protected SparseArray<List<AccessibilityWindowInfo>>getWindowsOnAllDisplays()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.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.protected voidtakeScreenshot(int displayId, Executor executor, AccessibilityService.TakeScreenshotCallback callback)voidunsetTakeScreenshotErrorCode()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, 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 final List<AccessibilityNodeInfo.AccessibilityAction> getSystemActions() -
setSystemActions
-
getWindows
Returns a representation of interactive windows shown on the device's default display. Mirrors the values provided to#setWindows(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) -
setTakeScreenshotErrorCode
public void setTakeScreenshotErrorCode(int errorCode)SetsAccessibilityService.takeScreenshot(int, Executor, TakeScreenshotCallback)to start returning the givenerrorCode.- See Also:
to unset the error condition.
-
unsetTakeScreenshotErrorCode
public void unsetTakeScreenshotErrorCode()SetsAccessibilityService.takeScreenshot(int, Executor, TakeScreenshotCallback)to start returning successful results again.- See Also:
to set an error condition instead.
-
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 callingAccessibilityService.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. Iffalse,AccessibilityService.dispatchGesture(android.accessibilityservice.GestureDescription, android.accessibilityservice.AccessibilityService.GestureResultCallback, android.os.Handler)will returnfalse.
-