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

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

Merge changes I97306f07,Iace58c81,Icf73251f,I4ea124fb,I83fb90d7 into main

* changes:
  Adds ProfileTypeRepository
  Adds SystemUiProxy / SystemUiProxyClient
  Adds ScreenshotPolicyModule
  Separate RequestProcessor from interface
  Cleanup MULTI_DISPLAY_SCREENSHOT flag
parents 1cc982e9 17b05e6b
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -394,10 +394,6 @@ object Flags {
    // TODO(b/251205791): Tracking Bug
    @JvmField val SCREENSHOT_APP_CLIPS = releasedFlag("screenshot_app_clips")

    /** TODO(b/295143676): Tracking bug. When enable, captures a screenshot for each display. */
    @JvmField
    val MULTI_DISPLAY_SCREENSHOT = releasedFlag("multi_display_screenshot")

    // 1400 - columbus
    // TODO(b/254512756): Tracking Bug
    val QUICK_TAP_IN_PCC = releasedFlag("quick_tap_in_pcc")
+1 −40
Original line number Diff line number Diff line
@@ -18,32 +18,11 @@ package com.android.systemui.screenshot

import android.util.Log
import android.view.WindowManager.TAKE_SCREENSHOT_PROVIDED_IMAGE
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.app.tracing.coroutines.launch
import kotlinx.coroutines.CoroutineScope
import java.util.function.Consumer
import javax.inject.Inject

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

/** Implementation of [ScreenshotRequestProcessor] */
@SysUISingleton
class RequestProcessor
@Inject
constructor(
class RequestProcessor(
    private val capture: ImageCapture,
    private val policy: ScreenshotPolicy,
    /** For the Java Async version, to invoke the callback. */
    @Application private val mainScope: CoroutineScope
) : ScreenshotRequestProcessor {

    override suspend fun process(screenshot: ScreenshotData): ScreenshotData {
@@ -78,24 +57,6 @@ constructor(

        return result
    }

    /**
     * Note: This is for compatibility with existing Java. Prefer the suspending function when
     * calling from a Coroutine context.
     *
     * @param screenshot the screenshot to process
     * @param callback the callback to provide the processed screenshot, invoked from the main
     *                 thread
     */
    fun processAsync(screenshot: ScreenshotData, callback: Consumer<ScreenshotData>) {
        mainScope.launch({ "$TAG#processAsync" }) {
            val result = process(screenshot)
            callback.accept(result)
        }
    }
}

private const val TAG = "RequestProcessor"

/** Exception thrown by [RequestProcessor] if something goes wrong. */
class RequestProcessorException(message: String) : IllegalStateException(message)
+2 −2
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ internal constructor(

    /** Factory for [ScreenshotNotificationsController]. */
    @AssistedFactory
    interface Factory {
        fun create(displayId: Int = Display.DEFAULT_DISPLAY): ScreenshotNotificationsController
    fun interface Factory {
        fun create(displayId: Int): ScreenshotNotificationsController
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.withContext

/** Provides state from the main SystemUI process on behalf of the Screenshot process. */
internal class ScreenshotProxyService
class ScreenshotProxyService
@Inject
constructor(
    private val mExpansionMgr: ShadeExpansionStateManager,
+30 −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

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

/** Exception thrown by [RequestProcessor] if something goes wrong. */
class RequestProcessorException(message: String) : IllegalStateException(message)
Loading