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.content.res.Configuration; 20 import android.graphics.Rect; 21 22 import com.android.wm.shell.common.annotations.ExternalThread; 23 24 import java.io.PrintWriter; 25 import java.util.function.Consumer; 26 27 /** 28 * Interface to engage picture in picture feature. 29 */ 30 @ExternalThread 31 public interface Pip { 32 33 /** 34 * Returns a binder that can be passed to an external process to manipulate PIP. 35 */ createExternalInterface()36 default IPip createExternalInterface() { 37 return null; 38 } 39 40 /** 41 * Expand PIP, it's possible that specific request to activate the window via Alt-tab. 42 */ expandPip()43 default void expandPip() { 44 } 45 46 /** 47 * Hides the PIP menu. 48 */ hidePipMenu(Runnable onStartCallback, Runnable onEndCallback)49 default void hidePipMenu(Runnable onStartCallback, Runnable onEndCallback) {} 50 51 /** 52 * Called when configuration is changed. 53 */ onConfigurationChanged(Configuration newConfig)54 default void onConfigurationChanged(Configuration newConfig) { 55 } 56 57 /** 58 * Called when display size or font size of settings changed 59 */ onDensityOrFontScaleChanged()60 default void onDensityOrFontScaleChanged() { 61 } 62 63 /** 64 * Called when overlay package change invoked. 65 */ onOverlayChanged()66 default void onOverlayChanged() { 67 } 68 69 /** 70 * Called when SysUI state changed. 71 * 72 * @param isSysUiStateValid Is SysUI state valid or not. 73 * @param flag Current SysUI state. 74 */ onSystemUiStateChanged(boolean isSysUiStateValid, int flag)75 default void onSystemUiStateChanged(boolean isSysUiStateValid, int flag) { 76 } 77 78 /** 79 * Registers the session listener for the current user. 80 */ registerSessionListenerForCurrentUser()81 default void registerSessionListenerForCurrentUser() { 82 } 83 84 /** 85 * Sets both shelf visibility and its height. 86 * 87 * @param visible visibility of shelf. 88 * @param height to specify the height for shelf. 89 */ setShelfHeight(boolean visible, int height)90 default void setShelfHeight(boolean visible, int height) { 91 } 92 93 /** 94 * Registers the pinned stack animation listener. 95 * 96 * @param callback The callback of pinned stack animation. 97 */ setPinnedStackAnimationListener(Consumer<Boolean> callback)98 default void setPinnedStackAnimationListener(Consumer<Boolean> callback) { 99 } 100 101 /** 102 * Set the pinned stack with {@link PipAnimationController.AnimationType} 103 * 104 * @param animationType The pre-defined {@link PipAnimationController.AnimationType} 105 */ setPinnedStackAnimationType(int animationType)106 default void setPinnedStackAnimationType(int animationType) { 107 } 108 109 /** 110 * Called when showing Pip menu. 111 */ showPictureInPictureMenu()112 default void showPictureInPictureMenu() {} 113 114 /** 115 * Called by NavigationBar in order to listen in for PiP bounds change. This is mostly used 116 * for times where the PiP bounds could conflict with SystemUI elements, such as a stashed 117 * PiP and the Back-from-Edge gesture. 118 */ setPipExclusionBoundsChangeListener(Consumer<Rect> listener)119 default void setPipExclusionBoundsChangeListener(Consumer<Rect> listener) { } 120 121 /** 122 * Dump the current state and information if need. 123 * 124 * @param pw The stream to dump information to. 125 */ dump(PrintWriter pw)126 default void dump(PrintWriter pw) { 127 } 128 } 129