• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.server.wm;
18 
19 import android.annotation.Nullable;
20 import android.annotation.SystemApi;
21 import android.car.builtin.annotation.PlatformVersion;
22 import android.graphics.Rect;
23 
24 import com.android.annotation.AddedIn;
25 
26 /**
27  * Wrapper of {@link com.android.server.wm.LaunchParamsController.LaunchParams}.
28  * @hide
29  */
30 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
31 public final class LaunchParamsWrapper {
32     /** Returned when the modifier does not want to influence the bounds calculation */
33     @AddedIn(PlatformVersion.TIRAMISU_0)
34     public static int RESULT_SKIP = LaunchParamsController.LaunchParamsModifier.RESULT_SKIP;
35     /**
36      * Returned when the modifier has changed the bounds and would like its results to be the
37      * final bounds applied.
38      */
39     @AddedIn(PlatformVersion.TIRAMISU_0)
40     public static int RESULT_DONE = LaunchParamsController.LaunchParamsModifier.RESULT_DONE;
41     /**
42      * Returned when the modifier has changed the bounds but is okay with other modifiers
43      * influencing the bounds.
44      */
45     @AddedIn(PlatformVersion.TIRAMISU_0)
46     public static int RESULT_CONTINUE = LaunchParamsController.LaunchParamsModifier.RESULT_CONTINUE;
47 
48     private final LaunchParamsController.LaunchParams mLaunchParams;
49 
LaunchParamsWrapper(LaunchParamsController.LaunchParams launchParams)50     private LaunchParamsWrapper(LaunchParamsController.LaunchParams launchParams) {
51         mLaunchParams = launchParams;
52     }
53 
54     /** @hide */
55     @AddedIn(PlatformVersion.TIRAMISU_0)
create( @ullable LaunchParamsController.LaunchParams launchParams)56     public static LaunchParamsWrapper create(
57             @Nullable LaunchParamsController.LaunchParams launchParams) {
58         if (launchParams == null) return null;
59         return new LaunchParamsWrapper(launchParams);
60     }
61 
62     /**
63      * Gets the {@link TaskDisplayAreaWrapper} the {@link Task} would prefer to be on.
64      */
65     @AddedIn(PlatformVersion.TIRAMISU_0)
getPreferredTaskDisplayArea()66     public TaskDisplayAreaWrapper getPreferredTaskDisplayArea() {
67         return TaskDisplayAreaWrapper.create(mLaunchParams.mPreferredTaskDisplayArea);
68     }
69 
70     /**
71      * Sets the {@link TaskDisplayAreaWrapper} the {@link Task} would prefer to be on.
72      */
73     @AddedIn(PlatformVersion.TIRAMISU_0)
setPreferredTaskDisplayArea(TaskDisplayAreaWrapper tda)74     public void setPreferredTaskDisplayArea(TaskDisplayAreaWrapper tda) {
75         mLaunchParams.mPreferredTaskDisplayArea = tda.getTaskDisplayArea();
76     }
77 
78     /**
79      * Gets the windowing mode to be in.
80      */
81     @AddedIn(PlatformVersion.TIRAMISU_0)
getWindowingMode()82     public int getWindowingMode() {
83         return mLaunchParams.mWindowingMode;
84     }
85 
86     /**
87      * Sets the windowing mode to be in.
88      */
89     @AddedIn(PlatformVersion.TIRAMISU_0)
setWindowingMode(int windowingMode)90     public void setWindowingMode(int windowingMode) {
91         mLaunchParams.mWindowingMode = windowingMode;
92     }
93 
94     /**
95      *  Gets the bounds within the parent container.
96      */
97     @AddedIn(PlatformVersion.TIRAMISU_0)
getBounds()98     public Rect getBounds() {
99         return mLaunchParams.mBounds;
100     }
101 
102     /**
103      *  Sets the bounds within the parent container.
104      */
105     @AddedIn(PlatformVersion.TIRAMISU_0)
setBounds(Rect bounds)106     public void setBounds(Rect bounds) {
107         mLaunchParams.mBounds.set(bounds);
108     }
109 
110     @Override
111     @AddedIn(PlatformVersion.TIRAMISU_0)
toString()112     public String toString() {
113         return "LaunchParams{" +
114                 "mPreferredTaskDisplayArea=" + mLaunchParams.mPreferredTaskDisplayArea +
115                 ", mWindowingMode=" + mLaunchParams.mWindowingMode +
116                 ", mBounds=" + mLaunchParams.mBounds.toString() + '}';
117     }
118 }
119