1 /*
2  * Copyright (C) 2023 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.wm.shell.common.pip
18 
19 import android.util.Size
20 import java.io.PrintWriter
21 
22 interface SizeSpecSource {
23     /** Returns max size allowed for the PIP window  */
getMaxSizenull24     fun getMaxSize(aspectRatio: Float): Size
25 
26     /** Returns default size for the PIP window  */
27     fun getDefaultSize(aspectRatio: Float): Size
28 
29     /** Returns min size allowed for the PIP window  */
30     fun getMinSize(aspectRatio: Float): Size
31 
32     /** Returns the adjusted size based on current size and target aspect ratio  */
33     fun getSizeForAspectRatio(size: Size, aspectRatio: Float): Size
34 
35     /** Overrides the minimum pip size requested by the app */
36     fun setOverrideMinSize(overrideMinSize: Size?)
37 
38     /** Returns the minimum pip size requested by the app */
39     fun getOverrideMinSize(): Size?
40 
41     /** Returns the minimum edge size of the override minimum size, or 0 if not set.  */
42     fun getOverrideMinEdgeSize(): Int {
43         val overrideMinSize = getOverrideMinSize() ?: return 0
44         return Math.min(overrideMinSize.width, overrideMinSize.height)
45     }
46 
onConfigurationChangednull47     fun onConfigurationChanged() {}
48 
49     /** Dumps the internal state of the size spec */
dumpnull50     fun dump(pw: PrintWriter, prefix: String) {}
51 }