Throw IllegalArgumentException for takeScreenshot()
Throw IllegalArgumentException for non default display since it’s unsupported Bug: 150865445 Test: a11y CTS & unit tests Change-Id: Iac0602e444d23b28ea05d29dd4605c7a821b641a
This commit is contained in:
@@ -48,6 +48,7 @@ import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Display;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.SurfaceControl;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerImpl;
|
||||
@@ -1937,8 +1938,8 @@ public abstract class AccessibilityService extends Service {
|
||||
* to declare the capability to take screenshot by setting the
|
||||
* {@link android.R.styleable#AccessibilityService_canTakeScreenshot}
|
||||
* property in its meta-data. For details refer to {@link #SERVICE_META_DATA}.
|
||||
* Besides, This API is only supported for default display now
|
||||
* {@link Display#DEFAULT_DISPLAY}.
|
||||
* This API only will support {@link Display#DEFAULT_DISPLAY} until {@link SurfaceControl}
|
||||
* supports non-default displays.
|
||||
* </p>
|
||||
*
|
||||
* @param displayId The logic display id, must be {@link Display#DEFAULT_DISPLAY} for
|
||||
@@ -1948,11 +1949,17 @@ public abstract class AccessibilityService extends Service {
|
||||
*
|
||||
* @return {@code true} if the taking screenshot accepted, {@code false} if too little time
|
||||
* has elapsed since the last screenshot, invalid display or internal errors.
|
||||
* @throws IllegalArgumentException if displayId is not {@link Display#DEFAULT_DISPLAY}.
|
||||
*/
|
||||
public boolean takeScreenshot(int displayId, @NonNull @CallbackExecutor Executor executor,
|
||||
@NonNull Consumer<ScreenshotResult> callback) {
|
||||
Preconditions.checkNotNull(executor, "executor cannot be null");
|
||||
Preconditions.checkNotNull(callback, "callback cannot be null");
|
||||
|
||||
if (displayId != Display.DEFAULT_DISPLAY) {
|
||||
throw new IllegalArgumentException("DisplayId isn't the default display");
|
||||
}
|
||||
|
||||
final IAccessibilityServiceConnection connection =
|
||||
AccessibilityInteractionClient.getInstance().getConnection(
|
||||
mConnectionId);
|
||||
|
||||
Reference in New Issue
Block a user