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

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

Merge "Add ScreenCapture system API" into main

parents 7a23442b 74b49fc0
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -56,7 +56,8 @@ usage: %s [-ahp] [-d display-id] [FILENAME]
   -d: specify the display ID to capture%s
       see "dumpsys SurfaceFlinger --display-id" for valid display IDs.
   -p: outputs in png format.
   --hint-for-seamless If set will use the hintForSeamless path in SF
   --preserve-display-colors: Set to true to preserves the native display colorspace. Useful
       for mixed HDR + SDR content, using identical processing as the display's

If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.
@@ -77,15 +78,15 @@ If FILENAME is not given, the results will be printed to stdout.
namespace LongOpts {
enum {
    Reserved = 255,
    HintForSeamless,
    PreservedDisplayColors,
};
}

static const struct option LONG_OPTIONS[] = {{"png", no_argument, nullptr, 'p'},
                                             {"jpeg", no_argument, nullptr, 'j'},
                                             {"help", no_argument, nullptr, 'h'},
                                             {"hint-for-seamless", no_argument, nullptr,
                                              LongOpts::HintForSeamless},
                                             {"preserve-display-colors", no_argument, nullptr,
                                              LongOpts::PreservedDisplayColors},
                                             {0, 0, 0, 0}};

static int32_t flinger2bitmapFormat(aidl::android::hardware::graphics::common::PixelFormat f) {
@@ -330,8 +331,8 @@ int main(int argc, char** argv) {
                }
                usage(pname, displayIdOpt);
                return 1;
            case LongOpts::HintForSeamless:
                captureArgs.hintForSeamlessTransition = true;
            case LongOpts::PreservedDisplayColors:
                captureArgs.preserveDisplayColors = true;
                break;
        }
    }
+17 −0
Original line number Diff line number Diff line
@@ -125,6 +125,23 @@ public abstract class DisplayManagerInternal {
     */
    public abstract ScreenCaptureInternal.ScreenshotHardwareBuffer systemScreenshot(int displayId);

    /**
     * Captures a screenshot of the specified display for internal system use.
     *
     * <p>This method allows for more granular control over the screenshot process
     * compared to {@link #systemScreenshot(int)}.
     *
     * @param displayId The display id to take the screenshot of.
     * @param argsBuilder A {@link ScreenCaptureInternal.DisplayCaptureArgs.Builder}
     *                    to specify screenshot parameters.
     * @param callback A {@link ScreenCaptureInternal.ScreenCaptureListener} to receive
     *                 the screenshot result or an error.
     */
    public abstract void systemScreenshot(
            int displayId,
            ScreenCaptureInternal.DisplayCaptureArgs.Builder argsBuilder,
            ScreenCaptureInternal.ScreenCaptureListener callback);

    /**
     * General screenshot functionality that excludes secure layers and applies appropriate rotation
     * that the device is currently in.
+8 −0
Original line number Diff line number Diff line
@@ -72,11 +72,13 @@ import android.view.displayhash.VerifiedDisplayHash;
import android.window.AddToSurfaceSyncGroupResult;
import android.window.ConfigurationChangeSetting;
import android.window.IGlobalDragListener;
import android.window.IScreenCaptureCallback;
import android.window.IScreenRecordingCallback;
import android.window.ISurfaceSyncGroupCompletedListener;
import android.window.ITaskFpsCallback;
import android.window.ITrustedPresentationListener;
import android.window.InputTransferToken;
import android.window.ScreenCapture;
import android.window.ScreenCaptureInternal;
import android.window.TrustedPresentationThresholds;
import android.window.WindowContextInfo;
@@ -1118,6 +1120,12 @@ interface IWindowManager
    oneway void captureDisplay(int displayId, in @nullable ScreenCaptureInternal.CaptureArgs captureArgs,
            in ScreenCaptureInternal.ScreenCaptureListener listener);

    /**
     * Implements the ScreenCapture system API.
     */
    oneway void screenCapture(in ScreenCapture.ScreenCaptureParams params,
                              in IScreenCaptureCallback callback);

    /**
     * Returns {@code true} if the key will be handled globally and not forwarded to all apps.
     *
+11 −0
Original line number Diff line number Diff line
package android.window;

import android.window.ScreenCapture;

/**
 * {@hide}
 */
interface IScreenCaptureCallback {
    oneway void onSuccess(in ScreenCapture.ScreenCaptureResult result);
    oneway void onFailure(int errorCode);
}
+5 −0
Original line number Diff line number Diff line
package android.window;

parcelable ScreenCapture.ScreenCaptureParams;

parcelable ScreenCapture.ScreenCaptureResult;
Loading