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.os.IRemoteCallback;
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      * Request that the window manager call
89      * {@link DisplayManagerInternal#performTraversalInTransactionFromWindowManager}
90      * within a surface transaction at a later time.
91      */
requestTraversalFromDisplayManager()92     public abstract void requestTraversalFromDisplayManager();
93 
94     /**
95      * Set by the accessibility layer to observe changes in the magnified region,
96      * rotation, and other window transformations related to display magnification
97      * as the window manager is responsible for doing the actual magnification
98      * and has access to the raw window data while the accessibility layer serves
99      * as a controller.
100      *
101      * @param callbacks The callbacks to invoke.
102      */
setMagnificationCallbacks(MagnificationCallbacks callbacks)103     public abstract void setMagnificationCallbacks(MagnificationCallbacks callbacks);
104 
105     /**
106      * Set by the accessibility layer to specify the magnification and panning to
107      * be applied to all windows that should be magnified.
108      *
109      * @param spec The MagnficationSpec to set.
110      *
111      * @see #setMagnificationCallbacks(MagnificationCallbacks)
112      */
setMagnificationSpec(MagnificationSpec spec)113     public abstract void setMagnificationSpec(MagnificationSpec spec);
114 
115     /**
116      * Gets the magnification and translation applied to a window given its token.
117      * Not all windows are magnified and the window manager policy determines which
118      * windows are magnified. The returned result also takes into account the compat
119      * scale if necessary.
120      *
121      * @param windowToken The window's token.
122      *
123      * @return The magnification spec for the window.
124      *
125      * @see #setMagnificationCallbacks(MagnificationCallbacks)
126      */
getCompatibleMagnificationSpecForWindow( IBinder windowToken)127     public abstract MagnificationSpec getCompatibleMagnificationSpecForWindow(
128             IBinder windowToken);
129 
130     /**
131      * Sets a callback for observing which windows are touchable for the purposes
132      * of accessibility.
133      *
134      * @param callback The callback.
135      */
setWindowsForAccessibilityCallback( WindowsForAccessibilityCallback callback)136     public abstract void setWindowsForAccessibilityCallback(
137             WindowsForAccessibilityCallback callback);
138 
139     /**
140      * Sets a filter for manipulating the input event stream.
141      *
142      * @param filter The filter implementation.
143      */
setInputFilter(IInputFilter filter)144     public abstract void setInputFilter(IInputFilter filter);
145 
146     /**
147      * Gets the token of the window that has input focus.
148      *
149      * @return The token.
150      */
getFocusedWindowToken()151     public abstract IBinder getFocusedWindowToken();
152 
153     /**
154      * @return Whether the keyguard is engaged.
155      */
isKeyguardLocked()156     public abstract boolean isKeyguardLocked();
157 
158     /**
159      * Gets the frame of a window given its token.
160      *
161      * @param token The token.
162      * @param outBounds The frame to populate.
163      */
getWindowFrame(IBinder token, Rect outBounds)164     public abstract void getWindowFrame(IBinder token, Rect outBounds);
165 
166     /**
167      * Opens the global actions dialog.
168      */
showGlobalActions()169     public abstract void showGlobalActions();
170 
171     /**
172      * Invalidate all visible windows. Then report back on the callback once all windows have
173      * redrawn.
174      */
waitForAllWindowsDrawn(Runnable callback, long timeout)175     public abstract void waitForAllWindowsDrawn(Runnable callback, long timeout);
176 
177     /**
178      * Adds a window token for a given window type.
179      *
180      * @param token The token to add.
181      * @param type The window type.
182      */
addWindowToken(android.os.IBinder token, int type)183     public abstract void addWindowToken(android.os.IBinder token, int type);
184 
185     /**
186      * Removes a window token.
187      *
188      * @param token The toke to remove.
189      * @param removeWindows Whether to also remove the windows associated with the token.
190      */
removeWindowToken(android.os.IBinder token, boolean removeWindows)191     public abstract void removeWindowToken(android.os.IBinder token, boolean removeWindows);
192 }
193