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.SystemApi; 20 import android.app.ActivityOptions; 21 import android.car.builtin.annotation.PlatformVersion; 22 import android.content.pm.ActivityInfo; 23 import android.view.WindowLayout; 24 25 import com.android.annotation.AddedIn; 26 27 /** 28 * Wrapper of the parameters of {@code LaunchParamsController.LaunchParamsModifier.onCalculate()} 29 * @hide 30 */ 31 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 32 public final class CalculateParams { 33 private TaskWrapper mTask; 34 private WindowLayoutWrapper mLayout; 35 private ActivityRecordWrapper mActivity; 36 private ActivityRecordWrapper mSource; 37 private ActivityOptionsWrapper mOptions; 38 private RequestWrapper mRequest; 39 private int mPhase; 40 private LaunchParamsWrapper mCurrentParams; 41 private LaunchParamsWrapper mOutParams; 42 private boolean mSupportsMultiDisplay; 43 CalculateParams()44 private CalculateParams() {} 45 46 /** @hide */ 47 @AddedIn(PlatformVersion.TIRAMISU_0) create(Task task, ActivityInfo.WindowLayout layout, ActivityRecord actvity, ActivityRecord source, ActivityOptions options, ActivityStarter.Request request, int phase, LaunchParamsController.LaunchParams currentParams, LaunchParamsController.LaunchParams outParms, boolean supportsMultiDisplay)48 public static CalculateParams create(Task task, ActivityInfo.WindowLayout layout, 49 ActivityRecord actvity, ActivityRecord source, 50 ActivityOptions options, ActivityStarter.Request request, int phase, 51 LaunchParamsController.LaunchParams currentParams, 52 LaunchParamsController.LaunchParams outParms, 53 boolean supportsMultiDisplay) { 54 CalculateParams params = new CalculateParams(); 55 params.mTask = TaskWrapper.create(task); 56 params.mLayout = WindowLayoutWrapper.create(layout); 57 params.mActivity = ActivityRecordWrapper.create(actvity); 58 params.mSource = ActivityRecordWrapper.create(source); 59 params.mOptions = ActivityOptionsWrapper.create(options); 60 params.mRequest = RequestWrapper.create(request); 61 params.mPhase = phase; 62 params.mCurrentParams = LaunchParamsWrapper.create(currentParams); 63 params.mOutParams = LaunchParamsWrapper.create(outParms); 64 params.mSupportsMultiDisplay = supportsMultiDisplay; 65 return params; 66 } 67 68 /** 69 * Gets the {@link TaskWrapper} currently being positioned. 70 */ 71 @AddedIn(PlatformVersion.TIRAMISU_0) getTask()72 public TaskWrapper getTask() { 73 return mTask; 74 } 75 76 /** 77 * Gets the specified {@link WindowLayoutWrapper}. 78 */ 79 @AddedIn(PlatformVersion.TIRAMISU_0) getWindowLayout()80 public WindowLayoutWrapper getWindowLayout() { 81 return mLayout; 82 } 83 84 /** 85 * Gets the {@link ActivityRecordWrapper} currently being positioned. 86 */ 87 @AddedIn(PlatformVersion.TIRAMISU_0) getActivity()88 public ActivityRecordWrapper getActivity() { 89 return mActivity; 90 } 91 92 /** 93 * Gets the {@link ActivityRecordWrapper} from which activity was started from. 94 */ 95 @AddedIn(PlatformVersion.TIRAMISU_0) getSource()96 public ActivityRecordWrapper getSource() { 97 return mSource; 98 } 99 100 /** 101 * Gets the {@link ActivityOptionsWrapper} specified for the activity. 102 */ 103 @AddedIn(PlatformVersion.TIRAMISU_0) getOptions()104 public ActivityOptionsWrapper getOptions() { 105 return mOptions; 106 } 107 108 /** 109 * Gets the optional {@link RequestWrapper} from the activity starter. 110 */ 111 @AddedIn(PlatformVersion.TIRAMISU_0) getRequest()112 public RequestWrapper getRequest() { 113 return mRequest; 114 } 115 116 /** 117 * Gets the {@link LaunchParamsController.LaunchParamsModifier.Phase} that the resolution should 118 * finish. 119 */ 120 @AddedIn(PlatformVersion.TIRAMISU_0) getPhase()121 public int getPhase() { 122 return mPhase; 123 } 124 125 /** 126 * Gets the current {@link LaunchParamsWrapper}. 127 */ 128 @AddedIn(PlatformVersion.TIRAMISU_0) getCurrentParams()129 public LaunchParamsWrapper getCurrentParams() { 130 return mCurrentParams; 131 } 132 133 /** 134 * Gets the resulting {@link LaunchParamsWrapper}. 135 */ 136 @AddedIn(PlatformVersion.TIRAMISU_0) getOutParams()137 public LaunchParamsWrapper getOutParams() { 138 return mOutParams; 139 } 140 141 /** 142 * Returns whether the current system supports the multiple display. 143 */ 144 @AddedIn(PlatformVersion.TIRAMISU_0) supportsMultiDisplay()145 public boolean supportsMultiDisplay() { 146 return mSupportsMultiDisplay; 147 } 148 } 149