Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac337e7a authored by Jacky Kao's avatar Jacky Kao Committed by Android (Google) Code Review
Browse files

Merge "Throw IllegalArgumentException for takeScreenshot()" into rvc-dev

parents 888edd6f 0ad1f827
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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);