blob: d5f9cf3ad4d59dc25149f48db2fb2224a0e62fa3 [file] [log] [blame]
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.server.am;
import android.app.ActivityOptions;
import android.content.pm.ActivityInfo;
import android.graphics.Rect;
import com.android.server.am.LaunchingBoundsController.LaunchingBoundsPositioner;
/**
* An implementation of {@link LaunchingBoundsPositioner}, which applies the launch bounds specified
* inside {@link ActivityOptions#getLaunchBounds()}.
*/
public class LaunchingActivityPositioner implements LaunchingBoundsPositioner {
private final ActivityStackSupervisor mSupervisor;
LaunchingActivityPositioner(ActivityStackSupervisor activityStackSupervisor) {
mSupervisor = activityStackSupervisor;
}
@Override
public int onCalculateBounds(TaskRecord task, ActivityInfo.WindowLayout layout,
ActivityRecord activity, ActivityRecord source,
ActivityOptions options, Rect current, Rect result) {
// We only care about figuring out bounds for activities.
if (activity == null) {
return RESULT_SKIP;
}
// Activity must be resizeable in the specified task.
if (!(mSupervisor.canUseActivityOptionsLaunchBounds(options)
&& (activity.isResizeable() || (task != null && task.isResizeable())))) {
return RESULT_SKIP;
}
final Rect bounds = TaskRecord.validateBounds(options.getLaunchBounds());
// Bounds weren't valid.
if (bounds == null) {
return RESULT_SKIP;
}
result.set(bounds);
// When this is the most explicit position specification so we should not allow further
// modification of the position.
return RESULT_DONE;
}
}