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

Commit 5bcf61d1 authored by Mark Renouf's avatar Mark Renouf
Browse files

Adds PolicyRequestProcessor to support new policy checks

This request processor replaces the existing one. The interface
remains the same but adds a new set of dependencies and support
code (see previous commits).

The goal is to provide an easy path for future policy rules
and added capabilities. The first being a new check for special
handling of private profile content.

Bug: 327613051
Test: TODO
Flag: ACONFIG com.android.systemui.screenshot_private_profile DEVELOPMENT
Change-Id: I4f35a4551638f372331922153643e917fa46dee0
parent 9264b8c5
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -17,13 +17,14 @@
package com.android.systemui.screenshot
package com.android.systemui.screenshot


/** Processes a screenshot request sent from [ScreenshotHelper]. */
/** Processes a screenshot request sent from [ScreenshotHelper]. */
interface ScreenshotRequestProcessor {
fun interface ScreenshotRequestProcessor {
    /**
    /**
     * Inspects the incoming ScreenshotData, potentially modifying it based upon policy.
     * 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. */
/** Exception thrown by [RequestProcessor] if something goes wrong. */
+8 −8
Original line number Original line Diff line number Diff line
@@ -92,14 +92,14 @@ constructor(
        // Let's wait before logging "screenshot requested", as we should log the processed
        // Let's wait before logging "screenshot requested", as we should log the processed
        // ScreenshotData.
        // ScreenshotData.
        val screenshotData =
        val screenshotData =
            try {
            runCatching { screenshotRequestProcessor.process(rawScreenshotData) }
                screenshotRequestProcessor.process(rawScreenshotData)
                .onFailure {
            } catch (e: RequestProcessorException) {
                    Log.e(TAG, "Failed to process screenshot request!", it)
                Log.e(TAG, "Failed to process screenshot request!", e)
                    logScreenshotRequested(rawScreenshotData)
                    logScreenshotRequested(rawScreenshotData)
                    onFailedScreenshotRequest(rawScreenshotData, callback)
                    onFailedScreenshotRequest(rawScreenshotData, callback)
                return
                }
                }
                .getOrNull()
                ?: return


        logScreenshotRequested(screenshotData)
        logScreenshotRequested(screenshotData)
        Log.d(TAG, "Screenshot request: $screenshotData")
        Log.d(TAG, "Screenshot request: $screenshotData")
+35 −0
Original line number Original line 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 Original line Diff line number Diff line
@@ -24,6 +24,6 @@ data class DisplayContentModel(
    val displayId: Int,
    val displayId: Int,
    /** Information about the current System UI state which can affect capture. */
    /** Information about the current System UI state which can affect capture. */
    val systemUiState: SystemUiState,
    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>,
    val rootTasks: List<RootTaskInfo>,
)
)
+1 −1
Original line number Original line Diff line number Diff line
@@ -18,7 +18,7 @@ package com.android.systemui.screenshot.data.repository
import com.android.systemui.screenshot.data.model.DisplayContentModel
import com.android.systemui.screenshot.data.model.DisplayContentModel


/** Provides information about tasks related to a display. */
/** Provides information about tasks related to a display. */
interface DisplayContentRepository {
fun interface DisplayContentRepository {
    /** Provides information about the tasks and content presented on a given display. */
    /** Provides information about the tasks and content presented on a given display. */
    suspend fun getDisplayContent(displayId: Int): DisplayContentModel
    suspend fun getDisplayContent(displayId: Int): DisplayContentModel
}
}
Loading