1 /* 2 * Copyright (C) 2014 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 android.view; 18 19 import android.graphics.Rect; 20 import android.graphics.Region; 21 import android.hardware.display.DisplayManagerInternal; 22 import android.os.IBinder; 23 import android.view.animation.Animation; 24 25 import java.util.List; 26 27 /** 28 * Window manager local system service interface. 29 * 30 * @hide Only for use within the system server. 31 */ 32 public abstract class WindowManagerInternal { 33 34 /** 35 * Interface to receive a callback when the windows reported for 36 * accessibility changed. 37 */ 38 public interface WindowsForAccessibilityCallback { 39 40 /** 41 * Called when the windows for accessibility changed. 42 * 43 * @param windows The windows for accessibility. 44 */ onWindowsForAccessibilityChanged(List<WindowInfo> windows)45 public void onWindowsForAccessibilityChanged(List<WindowInfo> windows); 46 } 47 48 /** 49 * Callbacks for contextual changes that affect the screen magnification 50 * feature. 51 */ 52 public interface MagnificationCallbacks { 53 54 /** 55 * Called when the bounds of the screen content that is magnified changed. 56 * Note that not the entire screen is magnified. 57 * 58 * @param bounds The bounds. 59 */ onMagnifedBoundsChanged(Region bounds)60 public void onMagnifedBoundsChanged(Region bounds); 61 62 /** 63 * Called when an application requests a rectangle on the screen to allow 64 * the client to apply the appropriate pan and scale. 65 * 66 * @param left The rectangle left. 67 * @param top The rectangle top. 68 * @param right The rectangle right. 69 * @param bottom The rectangle bottom. 70 */ onRectangleOnScreenRequested(int left, int top, int right, int bottom)71 public void onRectangleOnScreenRequested(int left, int top, int right, int bottom); 72 73 /** 74 * Notifies that the rotation changed. 75 * 76 * @param rotation The current rotation. 77 */ onRotationChanged(int rotation)78 public void onRotationChanged(int rotation); 79 80 /** 81 * Notifies that the context of the user changed. For example, an application 82 * was started. 83 */ onUserContextChanged()84 public void onUserContextChanged(); 85 } 86 87 /** 88 * Abstract class to be notified about {@link com.android.server.wm.AppTransition} events. Held 89 * as an abstract class so a listener only needs to implement the methods of its interest. 90 */ 91 public static abstract class AppTransitionListener { 92 93 /** 94 * Called when an app transition is being setup and about to be executed. 95 */ onAppTransitionPendingLocked()96 public void onAppTransitionPendingLocked() {} 97 98 /** 99 * Called when a pending app transition gets cancelled. 100 */ onAppTransitionCancelledLocked()101 public void onAppTransitionCancelledLocked() {} 102 103 /** 104 * Called when an app transition gets started 105 * 106 * @param openToken the token for the opening app 107 * @param closeToken the token for the closing app 108 * @param openAnimation the animation for the opening app 109 * @param closeAnimation the animation for the closing app 110 */ onAppTransitionStartingLocked(IBinder openToken, IBinder closeToken, Animation openAnimation, Animation closeAnimation)111 public void onAppTransitionStartingLocked(IBinder openToken, IBinder closeToken, 112 Animation openAnimation, Animation closeAnimation) {} 113 114 /** 115 * Called when an app transition is finished running. 116 * 117 * @param token the token for app whose transition has finished 118 */ onAppTransitionFinishedLocked(IBinder token)119 public void onAppTransitionFinishedLocked(IBinder token) {} 120 } 121 122 /** 123 * Request that the window manager call 124 * {@link DisplayManagerInternal#performTraversalInTransactionFromWindowManager} 125 * within a surface transaction at a later time. 126 */ requestTraversalFromDisplayManager()127 public abstract void requestTraversalFromDisplayManager(); 128 129 /** 130 * Set by the accessibility layer to observe changes in the magnified region, 131 * rotation, and other window transformations related to display magnification 132 * as the window manager is responsible for doing the actual magnification 133 * and has access to the raw window data while the accessibility layer serves 134 * as a controller. 135 * 136 * @param callbacks The callbacks to invoke. 137 */ setMagnificationCallbacks(MagnificationCallbacks callbacks)138 public abstract void setMagnificationCallbacks(MagnificationCallbacks callbacks); 139 140 /** 141 * Set by the accessibility layer to specify the magnification and panning to 142 * be applied to all windows that should be magnified. 143 * 144 * @param spec The MagnficationSpec to set. 145 * 146 * @see #setMagnificationCallbacks(MagnificationCallbacks) 147 */ setMagnificationSpec(MagnificationSpec spec)148 public abstract void setMagnificationSpec(MagnificationSpec spec); 149 150 /** 151 * Gets the magnification and translation applied to a window given its token. 152 * Not all windows are magnified and the window manager policy determines which 153 * windows are magnified. The returned result also takes into account the compat 154 * scale if necessary. 155 * 156 * @param windowToken The window's token. 157 * 158 * @return The magnification spec for the window. 159 * 160 * @see #setMagnificationCallbacks(MagnificationCallbacks) 161 */ getCompatibleMagnificationSpecForWindow( IBinder windowToken)162 public abstract MagnificationSpec getCompatibleMagnificationSpecForWindow( 163 IBinder windowToken); 164 165 /** 166 * Sets a callback for observing which windows are touchable for the purposes 167 * of accessibility. 168 * 169 * @param callback The callback. 170 */ setWindowsForAccessibilityCallback( WindowsForAccessibilityCallback callback)171 public abstract void setWindowsForAccessibilityCallback( 172 WindowsForAccessibilityCallback callback); 173 174 /** 175 * Sets a filter for manipulating the input event stream. 176 * 177 * @param filter The filter implementation. 178 */ setInputFilter(IInputFilter filter)179 public abstract void setInputFilter(IInputFilter filter); 180 181 /** 182 * Gets the token of the window that has input focus. 183 * 184 * @return The token. 185 */ getFocusedWindowToken()186 public abstract IBinder getFocusedWindowToken(); 187 188 /** 189 * @return Whether the keyguard is engaged. 190 */ isKeyguardLocked()191 public abstract boolean isKeyguardLocked(); 192 193 /** 194 * Gets the frame of a window given its token. 195 * 196 * @param token The token. 197 * @param outBounds The frame to populate. 198 */ getWindowFrame(IBinder token, Rect outBounds)199 public abstract void getWindowFrame(IBinder token, Rect outBounds); 200 201 /** 202 * Opens the global actions dialog. 203 */ showGlobalActions()204 public abstract void showGlobalActions(); 205 206 /** 207 * Invalidate all visible windows. Then report back on the callback once all windows have 208 * redrawn. 209 */ waitForAllWindowsDrawn(Runnable callback, long timeout)210 public abstract void waitForAllWindowsDrawn(Runnable callback, long timeout); 211 212 /** 213 * Adds a window token for a given window type. 214 * 215 * @param token The token to add. 216 * @param type The window type. 217 */ addWindowToken(android.os.IBinder token, int type)218 public abstract void addWindowToken(android.os.IBinder token, int type); 219 220 /** 221 * Removes a window token. 222 * 223 * @param token The toke to remove. 224 * @param removeWindows Whether to also remove the windows associated with the token. 225 */ removeWindowToken(android.os.IBinder token, boolean removeWindows)226 public abstract void removeWindowToken(android.os.IBinder token, boolean removeWindows); 227 228 /** 229 * Registers a listener to be notified about app transition events. 230 * 231 * @param listener The listener to register. 232 */ registerAppTransitionListener(AppTransitionListener listener)233 public abstract void registerAppTransitionListener(AppTransitionListener listener); 234 } 235