1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.screenshot.policy 18 19 import com.android.systemui.screenshot.data.model.DisplayContentModel 20 21 /** Contains logic to determine when and how an adjust to screenshot behavior applies. */ interfacenull22fun interface CapturePolicy { 23 /** 24 * Test the policy against the current display task state. If the policy applies, Returns a 25 * [PolicyResult.Matched] containing [CaptureParameters] used to alter the request. 26 */ 27 suspend fun check(content: DisplayContentModel): PolicyResult 28 29 /** The result of a screen capture policy check. */ 30 sealed interface PolicyResult { 31 /** The policy rules matched the given display content and will be applied. */ 32 data class Matched( 33 /** The name of the policy rule which matched. */ 34 val policy: String, 35 /** Why the policy matched. */ 36 val reason: String, 37 /** Details on how to modify the screen capture request. */ 38 val parameters: CaptureParameters, 39 ) : PolicyResult 40 41 /** The policy rules do not match the given display content and do not apply. */ 42 data class NotMatched( 43 /** The name of the policy rule which matched. */ 44 val policy: String, 45 /** Why the policy did not match. */ 46 val reason: String 47 ) : PolicyResult 48 } 49 } 50