blob: 5815e980975698e467f5f92247b9dcebfe3ee286 [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,
37 ActivityRecord activity, ActivityOptions options, Rect current, Rect result) {
38 // We only care about figuring out bounds for activities.
39 if (activity == null) {
40 return RESULT_SKIP;
41 }
42
43 // Activity must be resizeable in the specified task.
44 if (!(mSupervisor.canUseActivityOptionsLaunchBounds(options)
45 && (activity.isResizeable() || (task != null && task.isResizeable())))) {
46 return RESULT_SKIP;
47 }
48
49 final Rect bounds = TaskRecord.validateBounds(options.getLaunchBounds());
50
51 // Bounds weren't valid.
52 if (bounds == null) {
53 return RESULT_SKIP;
54 }
55
56 result.set(bounds);
57
58 // When this is the most explicit position specification so we should not allow further
59 // modification of the position.
60 return RESULT_DONE;
61 }
62}