Throw IllegalArgumentException for takeScreenshot() am: 0ad1f82733 am: 124787817a

Change-Id: I79e968d9450b61afee69e5cf864cd89c9e20a561
This commit is contained in:
Automerger Merge Worker
2020-03-12 04:45:59 +00:00

View File

@@ -48,6 +48,7 @@ import android.util.Slog;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.Display; import android.view.Display;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.SurfaceControl;
import android.view.SurfaceView; import android.view.SurfaceView;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.WindowManagerImpl; import android.view.WindowManagerImpl;
@@ -1937,8 +1938,8 @@ public abstract class AccessibilityService extends Service {
* to declare the capability to take screenshot by setting the * to declare the capability to take screenshot by setting the
* {@link android.R.styleable#AccessibilityService_canTakeScreenshot} * {@link android.R.styleable#AccessibilityService_canTakeScreenshot}
* property in its meta-data. For details refer to {@link #SERVICE_META_DATA}. * property in its meta-data. For details refer to {@link #SERVICE_META_DATA}.
* Besides, This API is only supported for default display now * This API only will support {@link Display#DEFAULT_DISPLAY} until {@link SurfaceControl}
* {@link Display#DEFAULT_DISPLAY}. * supports non-default displays.
* </p> * </p>
* *
* @param displayId The logic display id, must be {@link Display#DEFAULT_DISPLAY} for * @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 * @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. * 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, public boolean takeScreenshot(int displayId, @NonNull @CallbackExecutor Executor executor,
@NonNull Consumer<ScreenshotResult> callback) { @NonNull Consumer<ScreenshotResult> callback) {
Preconditions.checkNotNull(executor, "executor cannot be null"); Preconditions.checkNotNull(executor, "executor cannot be null");
Preconditions.checkNotNull(callback, "callback 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 = final IAccessibilityServiceConnection connection =
AccessibilityInteractionClient.getInstance().getConnection( AccessibilityInteractionClient.getInstance().getConnection(
mConnectionId); mConnectionId);