blob: 793884d08c08aa258b23d9b3b9bd6d61efa2d4e0 [file] [log] [blame]
Bryce Leedacefc42017-10-10 12:56:02 -07001/*
2 * Copyright (C) 2017 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
17package com.android.server.am;
18
19import android.app.ActivityOptions;
20import android.content.pm.ActivityInfo;
21import android.graphics.Rect;
22import com.android.server.am.LaunchingBoundsController.LaunchingBoundsPositioner;
23
24/**
25 * An implementation of {@link LaunchingBoundsPositioner}, which applies the launch bounds specified
26 * inside {@link ActivityOptions#getLaunchBounds()}.
27 */
28public class LaunchingActivityPositioner implements LaunchingBoundsPositioner {
29 private final ActivityStackSupervisor mSupervisor;
30
31 LaunchingActivityPositioner(ActivityStackSupervisor activityStackSupervisor) {
32 mSupervisor = activityStackSupervisor;
33 }
34
35 @Override
36 public int onCalculateBounds(TaskRecord task, ActivityInfo.WindowLayout layout,
Bryce Leee4ad7452017-10-26 08:44:04 -070037 ActivityRecord activity, ActivityRecord source,
38 ActivityOptions options, Rect current, Rect result) {
Bryce Leedacefc42017-10-10 12:56:02 -070039 // We only care about figuring out bounds for activities.
40 if (activity == null) {
41 return RESULT_SKIP;
42 }
43
44 // Activity must be resizeable in the specified task.
45 if (!(mSupervisor.canUseActivityOptionsLaunchBounds(options)
46 && (activity.isResizeable() || (task != null && task.isResizeable())))) {
47 return RESULT_SKIP;
48 }
49
Bryce Leef3c6a472017-11-14 14:53:06 -080050 final Rect bounds = options.getLaunchBounds();
Bryce Leedacefc42017-10-10 12:56:02 -070051
52 // Bounds weren't valid.
Bryce Leef3c6a472017-11-14 14:53:06 -080053 if (bounds == null || bounds.isEmpty()) {
Bryce Leedacefc42017-10-10 12:56:02 -070054 return RESULT_SKIP;
55 }
56
57 result.set(bounds);
58
59 // When this is the most explicit position specification so we should not allow further
60 // modification of the position.
61 return RESULT_DONE;
62 }
63}