Merge "Flatten SplitscreenPipMixedHandler into DefaultMixedHandler" into tm-qpr-dev

This commit is contained in:
Evan Rosky
2022-09-09 20:37:47 +00:00
committed by Android (Google) Code Review
3 changed files with 24 additions and 66 deletions

View File

@@ -82,7 +82,7 @@ import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.sysui.ShellCommandHandler;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.SplitscreenPipMixedHandler;
import com.android.wm.shell.transition.DefaultMixedHandler;
import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.unfold.ShellUnfoldProgressProvider;
import com.android.wm.shell.unfold.UnfoldAnimationController;
@@ -484,13 +484,13 @@ public abstract class WMShellModule {
@WMSingleton
@Provides
static SplitscreenPipMixedHandler provideSplitscreenPipMixedHandler(
static DefaultMixedHandler provideDefaultMixedHandler(
ShellInit shellInit,
Optional<SplitScreenController> splitScreenOptional,
Optional<PipTouchHandler> pipTouchHandlerOptional,
Transitions transitions) {
return new SplitscreenPipMixedHandler(shellInit, splitScreenOptional,
pipTouchHandlerOptional, transitions);
return new DefaultMixedHandler(shellInit, transitions, splitScreenOptional,
pipTouchHandlerOptional);
}
//
@@ -619,7 +619,7 @@ public abstract class WMShellModule {
@ShellCreateTriggerOverride
@Provides
static Object provideIndependentShellComponentsToCreate(
SplitscreenPipMixedHandler splitscreenPipMixedHandler,
DefaultMixedHandler defaultMixedHandler,
Optional<DesktopModeController> desktopModeController) {
return new Object();
}

View File

@@ -35,10 +35,14 @@ import android.window.WindowContainerTransaction;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.pip.PipTransitionController;
import com.android.wm.shell.pip.phone.PipTouchHandler;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.splitscreen.StageCoordinator;
import com.android.wm.shell.sysui.ShellInit;
import java.util.ArrayList;
import java.util.Optional;
/**
* A handler for dealing with transitions involving multiple other handlers. For example: an
@@ -47,8 +51,8 @@ import java.util.ArrayList;
public class DefaultMixedHandler implements Transitions.TransitionHandler {
private final Transitions mPlayer;
private final PipTransitionController mPipHandler;
private final StageCoordinator mSplitHandler;
private PipTransitionController mPipHandler;
private StageCoordinator mSplitHandler;
private static class MixedTransition {
static final int TYPE_ENTER_PIP_FROM_SPLIT = 1;
@@ -77,13 +81,22 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler {
mTransition = transition;
}
}
private final ArrayList<MixedTransition> mActiveTransitions = new ArrayList<>();
public DefaultMixedHandler(@NonNull Transitions player,
@NonNull PipTransitionController pipHandler, @NonNull StageCoordinator splitHandler) {
public DefaultMixedHandler(@NonNull ShellInit shellInit, @NonNull Transitions player,
Optional<SplitScreenController> splitScreenControllerOptional,
Optional<PipTouchHandler> pipTouchHandlerOptional) {
mPlayer = player;
mPipHandler = pipHandler;
mSplitHandler = splitHandler;
if (Transitions.ENABLE_SHELL_TRANSITIONS && pipTouchHandlerOptional.isPresent()
&& splitScreenControllerOptional.isPresent()) {
// Add after dependencies because it is higher priority
shellInit.addInitCallback(() -> {
mPipHandler = pipTouchHandlerOptional.get().getTransitionHandler();
mSplitHandler = splitScreenControllerOptional.get().getTransitionHandler();
mPlayer.addHandler(this);
}, this);
}
}
@Nullable

View File

@@ -1,55 +0,0 @@
/*
* Copyright (C) 2022 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.wm.shell.transition;
import com.android.wm.shell.pip.phone.PipTouchHandler;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.sysui.ShellInit;
import java.util.Optional;
/**
* Handles transitions between the Splitscreen and PIP components.
*/
public class SplitscreenPipMixedHandler {
private final Optional<SplitScreenController> mSplitScreenOptional;
private final Optional<PipTouchHandler> mPipTouchHandlerOptional;
private final Transitions mTransitions;
public SplitscreenPipMixedHandler(ShellInit shellInit,
Optional<SplitScreenController> splitScreenControllerOptional,
Optional<PipTouchHandler> pipTouchHandlerOptional,
Transitions transitions) {
mSplitScreenOptional = splitScreenControllerOptional;
mPipTouchHandlerOptional = pipTouchHandlerOptional;
mTransitions = transitions;
if (Transitions.ENABLE_SHELL_TRANSITIONS
&& mSplitScreenOptional.isPresent() && mPipTouchHandlerOptional.isPresent()) {
shellInit.addInitCallback(this::onInit, this);
}
}
private void onInit() {
// Special handling for initializing based on multiple components
final DefaultMixedHandler mixedHandler = new DefaultMixedHandler(mTransitions,
mPipTouchHandlerOptional.get().getTransitionHandler(),
mSplitScreenOptional.get().getTransitionHandler());
// Added at end so that it has highest priority.
mTransitions.addHandler(mixedHandler);
}
}