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

Commit 3f9abb82 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move ScreenCapture to ScreenCaptureInternal" into main

parents 50c52f4f 7fd0a39e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.view.accessibility.IAccessibilityInteractionConnectionCallback;
import android.view.accessibility.AccessibilityWindowInfo;
import java.util.List;
import android.window.ScreenCapture;
import android.window.ScreenCaptureInternal;

/**
 * Interface given to an AccessibilitySerivce to talk to the AccessibilityManagerService.
@@ -167,7 +167,7 @@ interface IAccessibilityServiceConnection {

    @RequiresNoPermission
    void takeScreenshotOfWindow(int accessibilityWindowId, int interactionId,
        in ScreenCapture.ScreenCaptureListener listener,
        in ScreenCaptureInternal.ScreenCaptureListener listener,
        IAccessibilityInteractionConnectionCallback callback);

    @RequiresNoPermission
+2 −2
Original line number Diff line number Diff line
@@ -24,8 +24,8 @@ import android.view.SurfaceControl;
import android.view.WindowContentFrameStats;
import android.view.WindowAnimationFrameStats;
import android.os.ParcelFileDescriptor;
import android.window.ScreenCapture.ScreenCaptureListener;
import android.window.ScreenCapture.LayerCaptureArgs;
import android.window.ScreenCaptureInternal.ScreenCaptureListener;
import android.window.ScreenCaptureInternal.LayerCaptureArgs;

import java.util.List;

+10 −9
Original line number Diff line number Diff line
@@ -73,8 +73,8 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityWindowInfo;
import android.view.accessibility.IAccessibilityInteractionConnection;
import android.view.inputmethod.EditorInfo;
import android.window.ScreenCapture;
import android.window.ScreenCapture.ScreenshotHardwareBuffer;
import android.window.ScreenCaptureInternal;
import android.window.ScreenCaptureInternal.ScreenshotHardwareBuffer;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
@@ -1290,8 +1290,8 @@ public final class UiAutomation {
        display.getRealSize(displaySize);

        // Take the screenshot
        ScreenCapture.SynchronousScreenCaptureListener syncScreenCapture =
                ScreenCapture.createSyncCaptureListener();
        ScreenCaptureInternal.SynchronousScreenCaptureListener syncScreenCapture =
                ScreenCaptureInternal.createSyncCaptureListener();
        try {
            if (!mUiAutomationConnection.takeScreenshot(
                    new Rect(0, 0, displaySize.x, displaySize.y), syncScreenCapture, mDisplayId)) {
@@ -1350,8 +1350,8 @@ public final class UiAutomation {
        display.getRealSize(displaySize);

        // Take the screenshot
        ScreenCapture.SynchronousScreenCaptureListener syncScreenCapture =
                ScreenCapture.createSyncCaptureListener();
        ScreenCaptureInternal.SynchronousScreenCaptureListener syncScreenCapture =
                ScreenCaptureInternal.createSyncCaptureListener();
        try {
            if (!mUiAutomationConnection.takeScreenshot(
                    new Rect(0, 0, displaySize.x, displaySize.y), syncScreenCapture, displayId)) {
@@ -1419,8 +1419,8 @@ public final class UiAutomation {
        // Apply a sync transaction to ensure SurfaceFlinger is flushed before capturing a
        // screenshot.
        new SurfaceControl.Transaction().apply(true);
        ScreenCapture.SynchronousScreenCaptureListener syncScreenCapture =
                ScreenCapture.createSyncCaptureListener();
        ScreenCaptureInternal.SynchronousScreenCaptureListener syncScreenCapture =
                ScreenCaptureInternal.createSyncCaptureListener();
        try {
            if (!mUiAutomationConnection.takeSurfaceControlScreenshot(sc, syncScreenCapture)) {
                Log.e(LOG_TAG, "Failed to take screenshot for window=" + window);
@@ -1430,7 +1430,8 @@ public final class UiAutomation {
            Log.e(LOG_TAG, "Error while taking screenshot!", re);
            return null;
        }
        ScreenCapture.ScreenshotHardwareBuffer captureBuffer = syncScreenCapture.getBuffer();
        ScreenCaptureInternal.ScreenshotHardwareBuffer captureBuffer =
                syncScreenCapture.getBuffer();
        if (captureBuffer == null) {
            Log.e(LOG_TAG, "Failed to take screenshot for window=" + window);
            return null;
+12 −11
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ import android.view.WindowAnimationFrameStats;
import android.view.WindowContentFrameStats;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.IAccessibilityManager;
import android.window.ScreenCapture;
import android.window.ScreenCapture.CaptureArgs;
import android.window.ScreenCaptureInternal;
import android.window.ScreenCaptureInternal.CaptureArgs;

import libcore.io.IoUtils;

@@ -226,8 +226,8 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
    }

    @Override
    public boolean takeScreenshot(Rect crop, ScreenCapture.ScreenCaptureListener listener,
            int displayId) {
    public boolean takeScreenshot(
            Rect crop, ScreenCaptureInternal.ScreenCaptureListener listener, int displayId) {
        synchronized (mLock) {
            throwIfCalledByNotTrustedUidLocked();
            throwIfShutdownLocked();
@@ -251,8 +251,9 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {

    @Nullable
    @Override
    public boolean takeSurfaceControlScreenshot(@NonNull SurfaceControl surfaceControl,
            ScreenCapture.ScreenCaptureListener listener) {
    public boolean takeSurfaceControlScreenshot(
            @NonNull SurfaceControl surfaceControl,
            ScreenCaptureInternal.ScreenCaptureListener listener) {
        synchronized (mLock) {
            throwIfCalledByNotTrustedUidLocked();
            throwIfShutdownLocked();
@@ -261,11 +262,11 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {

        final long identity = Binder.clearCallingIdentity();
        try {
            ScreenCapture.LayerCaptureArgs args =
                    new ScreenCapture.LayerCaptureArgs.Builder(surfaceControl)
            ScreenCaptureInternal.LayerCaptureArgs args =
                    new ScreenCaptureInternal.LayerCaptureArgs.Builder(surfaceControl)
                            .setChildrenOnly(false)
                            .build();
            int status = ScreenCapture.captureLayers(args, listener);
            int status = ScreenCaptureInternal.captureLayers(args, listener);

            if (status != 0) {
                return false;
+8 −8
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import android.view.SurfaceControl;
import android.view.SurfaceControl.RefreshRateRange;
import android.view.SurfaceControl.Transaction;
import android.window.DisplayWindowPolicyController;
import android.window.ScreenCapture;
import android.window.ScreenCaptureInternal;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -116,23 +116,23 @@ public abstract class DisplayManagerInternal {
    public abstract void unregisterDisplayGroupListener(DisplayGroupListener listener);

    /**
     * Screenshot for internal system-only use such as rotation, etc.  This method includes
     * secure layers and the result should never be exposed to non-system applications.
     * This method does not apply any rotation and provides the output in natural orientation.
     * Screenshot for internal system-only use such as rotation, etc. This method includes secure
     * layers and the result should never be exposed to non-system applications. This method does
     * not apply any rotation and provides the output in natural orientation.
     *
     * @param displayId The display id to take the screenshot of.
     * @return The buffer or null if we have failed.
     */
    public abstract ScreenCapture.ScreenshotHardwareBuffer systemScreenshot(int displayId);
    public abstract ScreenCaptureInternal.ScreenshotHardwareBuffer systemScreenshot(int displayId);

    /**
     * General screenshot functionality that excludes secure layers and applies appropriate
     * rotation that the device is currently in.
     * General screenshot functionality that excludes secure layers and applies appropriate rotation
     * that the device is currently in.
     *
     * @param displayId The display id to take the screenshot of.
     * @return The buffer or null if we have failed.
     */
    public abstract ScreenCapture.ScreenshotHardwareBuffer userScreenshot(int displayId);
    public abstract ScreenCaptureInternal.ScreenshotHardwareBuffer userScreenshot(int displayId);

    /**
     * Returns information about the specified logical display.
Loading