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.pip; 18 19 import android.graphics.Rect; 20 21 import com.android.wm.shell.common.annotations.ExternalThread; 22 23 import java.util.function.Consumer; 24 25 /** 26 * Interface to engage picture in picture feature. 27 */ 28 @ExternalThread 29 public interface Pip { 30 /** 31 * Expand PIP, it's possible that specific request to activate the window via Alt-tab. 32 */ expandPip()33 default void expandPip() { 34 } 35 36 /** 37 * Called when SysUI state changed. 38 * 39 * @param isSysUiStateValid Is SysUI state valid or not. 40 * @param flag Current SysUI state. 41 */ onSystemUiStateChanged(boolean isSysUiStateValid, int flag)42 default void onSystemUiStateChanged(boolean isSysUiStateValid, int flag) { 43 } 44 45 /** 46 * Set the callback when {@link PipTaskOrganizer#isInPip()} state is changed. 47 * 48 * @param callback The callback accepts the result of {@link PipTaskOrganizer#isInPip()} 49 * when it's changed. 50 */ setOnIsInPipStateChangedListener(Consumer<Boolean> callback)51 default void setOnIsInPipStateChangedListener(Consumer<Boolean> callback) {} 52 53 /** 54 * Called when showing Pip menu. 55 */ showPictureInPictureMenu()56 default void showPictureInPictureMenu() {} 57 58 /** 59 * Called by NavigationBar and TaskbarDelegate in order to listen in for PiP bounds change. This 60 * is mostly used for times where the PiP bounds could conflict with SystemUI elements, such as 61 * a stashed PiP and the Back-from-Edge gesture. 62 */ addPipExclusionBoundsChangeListener(Consumer<Rect> listener)63 default void addPipExclusionBoundsChangeListener(Consumer<Rect> listener) { } 64 65 /** 66 * Remove a callback added previously. This is used when NavigationBar is removed from the 67 * view hierarchy or destroyed. 68 */ removePipExclusionBoundsChangeListener(Consumer<Rect> listener)69 default void removePipExclusionBoundsChangeListener(Consumer<Rect> listener) { } 70 } 71