1 /*
2 ** Copyright 2006, 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 com.android.internal.app.IAssistScreenshotReceiver;
20 import com.android.internal.view.IInputContext;
21 import com.android.internal.view.IInputMethodClient;
22 
23 import android.content.res.CompatibilityInfo;
24 import android.content.res.Configuration;
25 import android.graphics.Bitmap;
26 import android.graphics.Point;
27 import android.graphics.Rect;
28 import android.os.Bundle;
29 import android.os.IRemoteCallback;
30 import android.view.IApplicationToken;
31 import android.view.IOnKeyguardExitResult;
32 import android.view.IRotationWatcher;
33 import android.view.IWindowSession;
34 import android.view.IWindowSessionCallback;
35 import android.view.KeyEvent;
36 import android.view.InputEvent;
37 import android.view.MagnificationSpec;
38 import android.view.MotionEvent;
39 import android.view.InputChannel;
40 import android.view.InputDevice;
41 import android.view.IInputFilter;
42 import android.view.WindowContentFrameStats;
43 
44 /**
45  * System private interface to the window manager.
46  *
47  * {@hide}
48  */
49 interface IWindowManager
50 {
51     /**
52      * ===== NOTICE =====
53      * The first three methods must remain the first three methods. Scripts
54      * and tools rely on their transaction number to work properly.
55      */
56     // This is used for debugging
startViewServer(int port)57     boolean startViewServer(int port);   // Transaction #1
stopViewServer()58     boolean stopViewServer();            // Transaction #2
isViewServerRunning()59     boolean isViewServerRunning();       // Transaction #3
60 
openSession(in IWindowSessionCallback callback, in IInputMethodClient client, in IInputContext inputContext)61     IWindowSession openSession(in IWindowSessionCallback callback, in IInputMethodClient client,
62             in IInputContext inputContext);
inputMethodClientHasFocus(IInputMethodClient client)63     boolean inputMethodClientHasFocus(IInputMethodClient client);
64 
getInitialDisplaySize(int displayId, out Point size)65     void getInitialDisplaySize(int displayId, out Point size);
getBaseDisplaySize(int displayId, out Point size)66     void getBaseDisplaySize(int displayId, out Point size);
setForcedDisplaySize(int displayId, int width, int height)67     void setForcedDisplaySize(int displayId, int width, int height);
clearForcedDisplaySize(int displayId)68     void clearForcedDisplaySize(int displayId);
getInitialDisplayDensity(int displayId)69     int getInitialDisplayDensity(int displayId);
getBaseDisplayDensity(int displayId)70     int getBaseDisplayDensity(int displayId);
setForcedDisplayDensity(int displayId, int density)71     void setForcedDisplayDensity(int displayId, int density);
clearForcedDisplayDensity(int displayId)72     void clearForcedDisplayDensity(int displayId);
setForcedDisplayScalingMode(int displayId, int mode)73     void setForcedDisplayScalingMode(int displayId, int mode); // 0 = auto, 1 = disable
74 
setOverscan(int displayId, int left, int top, int right, int bottom)75     void setOverscan(int displayId, int left, int top, int right, int bottom);
76 
77     // These can only be called when holding the MANAGE_APP_TOKENS permission.
pauseKeyDispatching(IBinder token)78     void pauseKeyDispatching(IBinder token);
resumeKeyDispatching(IBinder token)79     void resumeKeyDispatching(IBinder token);
setEventDispatching(boolean enabled)80     void setEventDispatching(boolean enabled);
addWindowToken(IBinder token, int type)81     void addWindowToken(IBinder token, int type);
removeWindowToken(IBinder token)82     void removeWindowToken(IBinder token);
addAppToken(int addPos, IApplicationToken token, int groupId, int stackId, int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId, int configChanges, boolean voiceInteraction, boolean launchTaskBehind)83     void addAppToken(int addPos, IApplicationToken token, int groupId, int stackId,
84             int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId,
85             int configChanges, boolean voiceInteraction, boolean launchTaskBehind);
setAppTask(IBinder token, int taskId)86     void setAppTask(IBinder token, int taskId);
setAppOrientation(IApplicationToken token, int requestedOrientation)87     void setAppOrientation(IApplicationToken token, int requestedOrientation);
getAppOrientation(IApplicationToken token)88     int getAppOrientation(IApplicationToken token);
setFocusedApp(IBinder token, boolean moveFocusNow)89     void setFocusedApp(IBinder token, boolean moveFocusNow);
prepareAppTransition(int transit, boolean alwaysKeepCurrent)90     void prepareAppTransition(int transit, boolean alwaysKeepCurrent);
getPendingAppTransition()91     int getPendingAppTransition();
overridePendingAppTransition(String packageName, int enterAnim, int exitAnim, IRemoteCallback startedCallback)92     void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim,
93             IRemoteCallback startedCallback);
overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth, int startHeight)94     void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
95             int startHeight);
overridePendingAppTransitionClipReveal(int startX, int startY, int startWidth, int startHeight)96     void overridePendingAppTransitionClipReveal(int startX, int startY,
97             int startWidth, int startHeight);
overridePendingAppTransitionThumb(in Bitmap srcThumb, int startX, int startY, IRemoteCallback startedCallback, boolean scaleUp)98     void overridePendingAppTransitionThumb(in Bitmap srcThumb, int startX, int startY,
99             IRemoteCallback startedCallback, boolean scaleUp);
overridePendingAppTransitionAspectScaledThumb(in Bitmap srcThumb, int startX, int startY, int targetWidth, int targetHeight, IRemoteCallback startedCallback, boolean scaleUp)100     void overridePendingAppTransitionAspectScaledThumb(in Bitmap srcThumb, int startX,
101             int startY, int targetWidth, int targetHeight, IRemoteCallback startedCallback,
102             boolean scaleUp);
overridePendingAppTransitionInPlace(String packageName, int anim)103     void overridePendingAppTransitionInPlace(String packageName, int anim);
executeAppTransition()104     void executeAppTransition();
setAppStartingWindow(IBinder token, String pkg, int theme, in CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, IBinder transferFrom, boolean createIfNeeded)105     void setAppStartingWindow(IBinder token, String pkg, int theme,
106             in CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes,
107             int icon, int logo, int windowFlags, IBinder transferFrom, boolean createIfNeeded);
setAppWillBeHidden(IBinder token)108     void setAppWillBeHidden(IBinder token);
setAppVisibility(IBinder token, boolean visible)109     void setAppVisibility(IBinder token, boolean visible);
startAppFreezingScreen(IBinder token, int configChanges)110     void startAppFreezingScreen(IBinder token, int configChanges);
stopAppFreezingScreen(IBinder token, boolean force)111     void stopAppFreezingScreen(IBinder token, boolean force);
removeAppToken(IBinder token)112     void removeAppToken(IBinder token);
113 
114     // Re-evaluate the current orientation from the caller's state.
115     // If there is a change, the new Configuration is returned and the
116     // caller must call setNewConfiguration() sometime later.
updateOrientationFromAppTokens(in Configuration currentConfig, IBinder freezeThisOneIfNeeded)117     Configuration updateOrientationFromAppTokens(in Configuration currentConfig,
118             IBinder freezeThisOneIfNeeded);
setNewConfiguration(in Configuration config)119     void setNewConfiguration(in Configuration config);
120 
startFreezingScreen(int exitAnim, int enterAnim)121     void startFreezingScreen(int exitAnim, int enterAnim);
stopFreezingScreen()122     void stopFreezingScreen();
123 
124     // these require DISABLE_KEYGUARD permission
disableKeyguard(IBinder token, String tag)125     void disableKeyguard(IBinder token, String tag);
reenableKeyguard(IBinder token)126     void reenableKeyguard(IBinder token);
exitKeyguardSecurely(IOnKeyguardExitResult callback)127     void exitKeyguardSecurely(IOnKeyguardExitResult callback);
isKeyguardLocked()128     boolean isKeyguardLocked();
isKeyguardSecure()129     boolean isKeyguardSecure();
inKeyguardRestrictedInputMode()130     boolean inKeyguardRestrictedInputMode();
dismissKeyguard()131     void dismissKeyguard();
keyguardGoingAway(boolean disableWindowAnimations, boolean keyguardGoingToNotificationShade)132     void keyguardGoingAway(boolean disableWindowAnimations,
133             boolean keyguardGoingToNotificationShade);
134 
closeSystemDialogs(String reason)135     void closeSystemDialogs(String reason);
136 
137     // These can only be called with the SET_ANIMATON_SCALE permission.
getAnimationScale(int which)138     float getAnimationScale(int which);
getAnimationScales()139     float[] getAnimationScales();
setAnimationScale(int which, float scale)140     void setAnimationScale(int which, float scale);
setAnimationScales(in float[] scales)141     void setAnimationScales(in float[] scales);
142 
getCurrentAnimatorScale()143     float getCurrentAnimatorScale();
144 
145     // For testing
setInTouchMode(boolean showFocus)146     void setInTouchMode(boolean showFocus);
147 
148     // For StrictMode flashing a red border on violations from the UI
149     // thread.  The uid/pid is implicit from the Binder call, and the Window
150     // Manager uses that to determine whether or not the red border should
151     // actually be shown.  (it will be ignored that pid doesn't have windows
152     // on screen)
showStrictModeViolation(boolean on)153     void showStrictModeViolation(boolean on);
154 
155     // Proxy to set the system property for whether the flashing
156     // should be enabled.  The 'enabled' value is null or blank for
157     // the system default (differs per build variant) or any valid
158     // boolean string as parsed by SystemProperties.getBoolean().
setStrictModeVisualIndicatorPreference(String enabled)159     void setStrictModeVisualIndicatorPreference(String enabled);
160 
161     /**
162      * Set whether screen capture is disabled for all windows of a specific user
163      */
setScreenCaptureDisabled(int userId, boolean disabled)164     void setScreenCaptureDisabled(int userId, boolean disabled);
165 
166     // These can only be called with the SET_ORIENTATION permission.
167     /**
168      * Update the current screen rotation based on the current state of
169      * the world.
170      * @param alwaysSendConfiguration Flag to force a new configuration to
171      * be evaluated.  This can be used when there are other parameters in
172      * configuration that are changing.
173      * @param forceRelayout If true, the window manager will always do a relayout
174      * of its windows even if the rotation hasn't changed.
175      */
updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout)176     void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout);
177 
178     /**
179      * Retrieve the current screen orientation, constants as per
180      * {@link android.view.Surface}.
181      */
getRotation()182     int getRotation();
183 
184     /**
185      * Watch the rotation of the screen.  Returns the current rotation,
186      * calls back when it changes.
187      */
watchRotation(IRotationWatcher watcher)188     int watchRotation(IRotationWatcher watcher);
189 
190     /**
191      * Remove a rotation watcher set using watchRotation.
192      * @hide
193      */
removeRotationWatcher(IRotationWatcher watcher)194     void removeRotationWatcher(IRotationWatcher watcher);
195 
196     /**
197      * Determine the preferred edge of the screen to pin the compact options menu against.
198      * @return a Gravity value for the options menu panel
199      * @hide
200      */
getPreferredOptionsPanelGravity()201     int getPreferredOptionsPanelGravity();
202 
203     /**
204      * Lock the device orientation to the specified rotation, or to the
205      * current rotation if -1.  Sensor input will be ignored until
206      * thawRotation() is called.
207      * @hide
208      */
freezeRotation(int rotation)209     void freezeRotation(int rotation);
210 
211     /**
212      * Release the orientation lock imposed by freezeRotation().
213      * @hide
214      */
thawRotation()215     void thawRotation();
216 
217     /**
218      * Gets whether the rotation is frozen.
219      *
220      * @return Whether the rotation is frozen.
221      */
isRotationFrozen()222     boolean isRotationFrozen();
223 
224     /**
225      * Used only for assist -- request a screenshot of the current application.
226      */
requestAssistScreenshot(IAssistScreenshotReceiver receiver)227     boolean requestAssistScreenshot(IAssistScreenshotReceiver receiver);
228 
229     /**
230      * Create a screenshot of the applications currently displayed.
231      */
screenshotApplications(IBinder appToken, int displayId, int maxWidth, int maxHeight)232     Bitmap screenshotApplications(IBinder appToken, int displayId, int maxWidth, int maxHeight);
233 
234     /**
235      * Called by the status bar to notify Views of changes to System UI visiblity.
236      */
statusBarVisibilityChanged(int visibility)237     oneway void statusBarVisibilityChanged(int visibility);
238 
239     /**
240      * Device has a software navigation bar (separate from the status bar).
241      */
hasNavigationBar()242     boolean hasNavigationBar();
243 
244     /**
245      * Lock the device immediately with the specified options (can be null).
246      */
lockNow(in Bundle options)247     void lockNow(in Bundle options);
248 
249     /**
250      * Device is in safe mode.
251      */
isSafeModeEnabled()252     boolean isSafeModeEnabled();
253 
254     /**
255      * Enables the screen if all conditions are met.
256      */
enableScreenIfNeeded()257     void enableScreenIfNeeded();
258 
259     /**
260      * Clears the frame statistics for a given window.
261      *
262      * @param token The window token.
263      * @return Whether the frame statistics were cleared.
264      */
clearWindowContentFrameStats(IBinder token)265     boolean clearWindowContentFrameStats(IBinder token);
266 
267     /**
268      * Gets the content frame statistics for a given window.
269      *
270      * @param token The window token.
271      * @return The frame statistics or null if the window does not exist.
272      */
getWindowContentFrameStats(IBinder token)273     WindowContentFrameStats getWindowContentFrameStats(IBinder token);
274 }
275