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

Commit bf2033fc authored by Mark Renouf's avatar Mark Renouf Committed by Android (Google) Code Review
Browse files

Merge changes from topic "private_profile_screenshots" into main

* changes:
  Use existing screenshot if present when type is FULLSCREEN
  Adds PolicyRequestProcessor to support new policy checks
parents ac18d855 eba13714
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -395,10 +395,10 @@ public class ScreenshotController {
        Assert.isMainThread();

        mCurrentRequestCallback = requestCallback;
        if (screenshot.getType() == WindowManager.TAKE_SCREENSHOT_FULLSCREEN) {
        if (screenshot.getType() == WindowManager.TAKE_SCREENSHOT_FULLSCREEN
                && screenshot.getBitmap() == null) {
            Rect bounds = getFullScreenRect();
            screenshot.setBitmap(
                    mImageCapture.captureDisplay(mDisplayId, bounds));
            screenshot.setBitmap(mImageCapture.captureDisplay(mDisplayId, bounds));
            screenshot.setScreenBounds(bounds);
        }

+4 −3
Original line number Diff line number Diff line
@@ -17,13 +17,14 @@
package com.android.systemui.screenshot

/** Processes a screenshot request sent from [ScreenshotHelper]. */
interface ScreenshotRequestProcessor {
fun interface ScreenshotRequestProcessor {
    /**
     * Inspects the incoming ScreenshotData, potentially modifying it based upon policy.
     *
     * @param screenshot the screenshot to process
     * @param original the screenshot to process
     * @return a potentially modified screenshot data
     */
    suspend fun process(screenshot: ScreenshotData): ScreenshotData
    suspend fun process(original: ScreenshotData): ScreenshotData
}

/** Exception thrown by [RequestProcessor] if something goes wrong. */
+8 −8
Original line number Diff line number Diff line
@@ -92,14 +92,14 @@ constructor(
        // Let's wait before logging "screenshot requested", as we should log the processed
        // ScreenshotData.
        val screenshotData =
            try {
                screenshotRequestProcessor.process(rawScreenshotData)
            } catch (e: RequestProcessorException) {
                Log.e(TAG, "Failed to process screenshot request!", e)
            runCatching { screenshotRequestProcessor.process(rawScreenshotData) }
                .onFailure {
                    Log.e(TAG, "Failed to process screenshot request!", it)
                    logScreenshotRequested(rawScreenshotData)
                    onFailedScreenshotRequest(rawScreenshotData, callback)
                return
                }
                .getOrNull()
                ?: return

        logScreenshotRequested(screenshotData)
        Log.d(TAG, "Screenshot request: $screenshotData")
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.screenshot.data.model

import android.content.ComponentName
import android.graphics.Rect

/** A child task within a RootTaskInfo */
data class ChildTaskModel(
    /** The task identifier */
    val id: Int,
    /** The task name */
    val name: String,
    /** The location and size of the task */
    val bounds: Rect,
    /** The user which created the task. */
    val userId: Int,
) {
    val componentName: ComponentName?
        get() = ComponentName.unflattenFromString(name)
}
+1 −1
Original line number Diff line number Diff line
@@ -24,6 +24,6 @@ data class DisplayContentModel(
    val displayId: Int,
    /** Information about the current System UI state which can affect capture. */
    val systemUiState: SystemUiState,
    /** A list of root tasks on the display, ordered from bottom to top along the z-axis */
    /** A list of root tasks on the display, ordered from top to bottom along the z-axis */
    val rootTasks: List<RootTaskInfo>,
)
Loading