• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 import com.android.wm.shell.common.annotations.ExternalThread;
22 import com.android.wm.shell.common.split.SplitLayout.SplitPosition;
23 
24 /**
25  * Interface to engage split-screen feature.
26  * TODO: Figure out which of these are actually needed outside of the Shell
27  */
28 @ExternalThread
29 public interface SplitScreen {
30     /**
31      * Stage type isn't specified normally meaning to use what ever the default is.
32      * E.g. exit split-screen and launch the app in fullscreen.
33      */
34     int STAGE_TYPE_UNDEFINED = -1;
35     /**
36      * The main stage type.
37      * @see MainStage
38      */
39     int STAGE_TYPE_MAIN = 0;
40 
41     /**
42      * The side stage type.
43      * @see SideStage
44      */
45     int STAGE_TYPE_SIDE = 1;
46 
47     @IntDef(prefix = { "STAGE_TYPE_" }, value = {
48             STAGE_TYPE_UNDEFINED,
49             STAGE_TYPE_MAIN,
50             STAGE_TYPE_SIDE
51     })
52     @interface StageType {}
53 
54     /** Callback interface for listening to changes in a split-screen stage. */
55     interface SplitScreenListener {
onStagePositionChanged(@tageType int stage, @SplitPosition int position)56         void onStagePositionChanged(@StageType int stage, @SplitPosition int position);
onTaskStageChanged(int taskId, @StageType int stage, boolean visible)57         void onTaskStageChanged(int taskId, @StageType int stage, boolean visible);
58     }
59 
60     /**
61      * Returns a binder that can be passed to an external process to manipulate SplitScreen.
62      */
createExternalInterface()63     default ISplitScreen createExternalInterface() {
64         return null;
65     }
66 
67     /** Get a string representation of a stage type */
stageTypeToString(@tageType int stage)68     static String stageTypeToString(@StageType int stage) {
69         switch (stage) {
70             case STAGE_TYPE_UNDEFINED: return "UNDEFINED";
71             case STAGE_TYPE_MAIN: return "MAIN";
72             case STAGE_TYPE_SIDE: return "SIDE";
73             default: return "UNKNOWN(" + stage + ")";
74         }
75     }
76 }
77