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