1 /* 2 * Copyright (C) 2020 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.wm.shell.splitscreen; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.graphics.Rect; 22 23 import com.android.wm.shell.common.annotations.ExternalThread; 24 import com.android.wm.shell.common.split.SplitScreenConstants.SplitPosition; 25 26 import java.util.concurrent.Executor; 27 28 /** 29 * Interface to engage split-screen feature. 30 * TODO: Figure out which of these are actually needed outside of the Shell 31 */ 32 @ExternalThread 33 public interface SplitScreen { 34 /** 35 * Stage type isn't specified normally meaning to use what ever the default is. 36 * E.g. exit split-screen and launch the app in fullscreen. 37 */ 38 int STAGE_TYPE_UNDEFINED = -1; 39 /** 40 * The main stage type. 41 * @see MainStage 42 */ 43 int STAGE_TYPE_MAIN = 0; 44 45 /** 46 * The side stage type. 47 * @see SideStage 48 */ 49 int STAGE_TYPE_SIDE = 1; 50 51 @IntDef(prefix = { "STAGE_TYPE_" }, value = { 52 STAGE_TYPE_UNDEFINED, 53 STAGE_TYPE_MAIN, 54 STAGE_TYPE_SIDE 55 }) 56 @interface StageType {} 57 58 /** Callback interface for listening to changes in a split-screen stage. */ 59 interface SplitScreenListener { onStagePositionChanged(@tageType int stage, @SplitPosition int position)60 default void onStagePositionChanged(@StageType int stage, @SplitPosition int position) {} onTaskStageChanged(int taskId, @StageType int stage, boolean visible)61 default void onTaskStageChanged(int taskId, @StageType int stage, boolean visible) {} onSplitBoundsChanged(Rect rootBounds, Rect mainBounds, Rect sideBounds)62 default void onSplitBoundsChanged(Rect rootBounds, Rect mainBounds, Rect sideBounds) {} onSplitVisibilityChanged(boolean visible)63 default void onSplitVisibilityChanged(boolean visible) {} 64 } 65 66 /** Registers listener that gets split screen callback. */ registerSplitScreenListener(@onNull SplitScreenListener listener, @NonNull Executor executor)67 void registerSplitScreenListener(@NonNull SplitScreenListener listener, 68 @NonNull Executor executor); 69 70 /** Unregisters listener that gets split screen callback. */ unregisterSplitScreenListener(@onNull SplitScreenListener listener)71 void unregisterSplitScreenListener(@NonNull SplitScreenListener listener); 72 73 /** Called when device waking up finished. */ onFinishedWakingUp()74 void onFinishedWakingUp(); 75 76 /** Called when requested to go to fullscreen from the current active split app. */ goToFullscreenFromSplit()77 void goToFullscreenFromSplit(); 78 79 /** Get a string representation of a stage type */ stageTypeToString(@tageType int stage)80 static String stageTypeToString(@StageType int stage) { 81 switch (stage) { 82 case STAGE_TYPE_UNDEFINED: return "UNDEFINED"; 83 case STAGE_TYPE_MAIN: return "MAIN"; 84 case STAGE_TYPE_SIDE: return "SIDE"; 85 default: return "UNKNOWN(" + stage + ")"; 86 } 87 } 88 } 89