1 /*
2  * Copyright (C) 2011 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.Point;
20 import com.android.internal.app.IAssistScreenshotReceiver;
21 import com.android.internal.view.IInputContext;
22 import com.android.internal.view.IInputMethodClient;
23 
24 import android.content.res.CompatibilityInfo;
25 import android.content.res.Configuration;
26 import android.graphics.Bitmap;
27 import android.os.Bundle;
28 import android.os.IBinder;
29 import android.os.IRemoteCallback;
30 import android.os.RemoteException;
31 import android.util.DisplayMetrics;
32 
33 import java.lang.Override;
34 
35 /**
36  * Basic implementation of {@link IWindowManager} so that {@link Display} (and
37  * {@link Display_Delegate}) can return a valid instance.
38  */
39 public class IWindowManagerImpl implements IWindowManager {
40 
41     private final Configuration mConfig;
42     private final DisplayMetrics mMetrics;
43     private final int mRotation;
44     private final boolean mHasNavigationBar;
45 
IWindowManagerImpl(Configuration config, DisplayMetrics metrics, int rotation, boolean hasNavigationBar)46     public IWindowManagerImpl(Configuration config, DisplayMetrics metrics, int rotation,
47             boolean hasNavigationBar) {
48         mConfig = config;
49         mMetrics = metrics;
50         mRotation = rotation;
51         mHasNavigationBar = hasNavigationBar;
52     }
53 
54     // custom API.
55 
getMetrics()56     public DisplayMetrics getMetrics() {
57         return mMetrics;
58     }
59 
60     // ---- implementation of IWindowManager that we care about ----
61 
62     @Override
getRotation()63     public int getRotation() throws RemoteException {
64         return mRotation;
65     }
66 
67     @Override
hasNavigationBar()68     public boolean hasNavigationBar() {
69         return mHasNavigationBar;
70     }
71 
72     // ---- unused implementation of IWindowManager ----
73 
74     @Override
addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, int arg4, boolean arg5, boolean arg6, int arg7, int arg8, boolean arg9, boolean arg10)75     public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, int arg4,
76             boolean arg5, boolean arg6, int arg7, int arg8, boolean arg9, boolean arg10)
77             throws RemoteException {
78         // TODO Auto-generated method stub
79 
80     }
81 
82     @Override
addWindowToken(IBinder arg0, int arg1)83     public void addWindowToken(IBinder arg0, int arg1) throws RemoteException {
84         // TODO Auto-generated method stub
85 
86     }
87 
88     @Override
clearForcedDisplaySize(int displayId)89     public void clearForcedDisplaySize(int displayId) throws RemoteException {
90         // TODO Auto-generated method stub
91     }
92 
93     @Override
clearForcedDisplayDensity(int displayId)94     public void clearForcedDisplayDensity(int displayId) throws RemoteException {
95         // TODO Auto-generated method stub
96     }
97 
98     @Override
setOverscan(int displayId, int left, int top, int right, int bottom)99     public void setOverscan(int displayId, int left, int top, int right, int bottom)
100             throws RemoteException {
101         // TODO Auto-generated method stub
102     }
103 
104     @Override
closeSystemDialogs(String arg0)105     public void closeSystemDialogs(String arg0) throws RemoteException {
106         // TODO Auto-generated method stub
107 
108     }
109 
110     @Override
startFreezingScreen(int exitAnim, int enterAnim)111     public void startFreezingScreen(int exitAnim, int enterAnim) {
112         // TODO Auto-generated method stub
113     }
114 
115     @Override
stopFreezingScreen()116     public void stopFreezingScreen() {
117         // TODO Auto-generated method stub
118     }
119 
120     @Override
disableKeyguard(IBinder arg0, String arg1)121     public void disableKeyguard(IBinder arg0, String arg1) throws RemoteException {
122         // TODO Auto-generated method stub
123 
124     }
125 
126     @Override
executeAppTransition()127     public void executeAppTransition() throws RemoteException {
128         // TODO Auto-generated method stub
129 
130     }
131 
132     @Override
exitKeyguardSecurely(IOnKeyguardExitResult arg0)133     public void exitKeyguardSecurely(IOnKeyguardExitResult arg0) throws RemoteException {
134         // TODO Auto-generated method stub
135 
136     }
137 
138     @Override
freezeRotation(int arg0)139     public void freezeRotation(int arg0) throws RemoteException {
140         // TODO Auto-generated method stub
141 
142     }
143 
144     @Override
getAnimationScale(int arg0)145     public float getAnimationScale(int arg0) throws RemoteException {
146         // TODO Auto-generated method stub
147         return 0;
148     }
149 
150     @Override
getAnimationScales()151     public float[] getAnimationScales() throws RemoteException {
152         // TODO Auto-generated method stub
153         return null;
154     }
155 
156     @Override
getAppOrientation(IApplicationToken arg0)157     public int getAppOrientation(IApplicationToken arg0) throws RemoteException {
158         // TODO Auto-generated method stub
159         return 0;
160     }
161 
162     @Override
getPendingAppTransition()163     public int getPendingAppTransition() throws RemoteException {
164         // TODO Auto-generated method stub
165         return 0;
166     }
167 
168     @Override
inKeyguardRestrictedInputMode()169     public boolean inKeyguardRestrictedInputMode() throws RemoteException {
170         // TODO Auto-generated method stub
171         return false;
172     }
173 
174     @Override
inputMethodClientHasFocus(IInputMethodClient arg0)175     public boolean inputMethodClientHasFocus(IInputMethodClient arg0) throws RemoteException {
176         // TODO Auto-generated method stub
177         return false;
178     }
179 
180     @Override
isKeyguardLocked()181     public boolean isKeyguardLocked() throws RemoteException {
182         // TODO Auto-generated method stub
183         return false;
184     }
185 
186     @Override
isKeyguardSecure()187     public boolean isKeyguardSecure() throws RemoteException {
188         // TODO Auto-generated method stub
189         return false;
190     }
191 
192     @Override
isViewServerRunning()193     public boolean isViewServerRunning() throws RemoteException {
194         // TODO Auto-generated method stub
195         return false;
196     }
197 
198     @Override
openSession(IWindowSessionCallback argn1, IInputMethodClient arg0, IInputContext arg1)199     public IWindowSession openSession(IWindowSessionCallback argn1, IInputMethodClient arg0,
200             IInputContext arg1) throws RemoteException {
201         // TODO Auto-generated method stub
202         return null;
203     }
204 
205     @Override
overridePendingAppTransition(String arg0, int arg1, int arg2, IRemoteCallback startedCallback)206     public void overridePendingAppTransition(String arg0, int arg1, int arg2,
207             IRemoteCallback startedCallback) throws RemoteException {
208         // TODO Auto-generated method stub
209 
210     }
211 
212     @Override
overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth, int startHeight)213     public void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
214             int startHeight) throws RemoteException {
215         // TODO Auto-generated method stub
216     }
217 
218     @Override
overridePendingAppTransitionClipReveal(int startX, int startY, int startWidth, int startHeight)219     public void overridePendingAppTransitionClipReveal(int startX, int startY,
220             int startWidth, int startHeight) throws RemoteException {
221         // TODO Auto-generated method stub
222     }
223 
224     @Override
overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY, IRemoteCallback startedCallback, boolean scaleUp)225     public void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY,
226             IRemoteCallback startedCallback, boolean scaleUp) throws RemoteException {
227         // TODO Auto-generated method stub
228     }
229 
230     @Override
overridePendingAppTransitionAspectScaledThumb(Bitmap srcThumb, int startX, int startY, int targetWidth, int targetHeight, IRemoteCallback startedCallback, boolean scaleUp)231     public void overridePendingAppTransitionAspectScaledThumb(Bitmap srcThumb, int startX,
232             int startY, int targetWidth, int targetHeight, IRemoteCallback startedCallback,
233             boolean scaleUp) {
234         // TODO Auto-generated method stub
235     }
236 
237     @Override
overridePendingAppTransitionInPlace(String packageName, int anim)238     public void overridePendingAppTransitionInPlace(String packageName, int anim) {
239         // TODO Auto-generated method stub
240     }
241 
242     @Override
pauseKeyDispatching(IBinder arg0)243     public void pauseKeyDispatching(IBinder arg0) throws RemoteException {
244         // TODO Auto-generated method stub
245 
246     }
247 
248     @Override
prepareAppTransition(int arg0, boolean arg1)249     public void prepareAppTransition(int arg0, boolean arg1) throws RemoteException {
250         // TODO Auto-generated method stub
251 
252     }
253 
254     @Override
reenableKeyguard(IBinder arg0)255     public void reenableKeyguard(IBinder arg0) throws RemoteException {
256         // TODO Auto-generated method stub
257 
258     }
259 
260     @Override
removeAppToken(IBinder arg0)261     public void removeAppToken(IBinder arg0) throws RemoteException {
262         // TODO Auto-generated method stub
263 
264     }
265 
266     @Override
removeWindowToken(IBinder arg0)267     public void removeWindowToken(IBinder arg0) throws RemoteException {
268         // TODO Auto-generated method stub
269 
270     }
271 
272     @Override
resumeKeyDispatching(IBinder arg0)273     public void resumeKeyDispatching(IBinder arg0) throws RemoteException {
274         // TODO Auto-generated method stub
275 
276     }
277 
278     @Override
requestAssistScreenshot(IAssistScreenshotReceiver receiver)279     public boolean requestAssistScreenshot(IAssistScreenshotReceiver receiver)
280             throws RemoteException {
281         // TODO Auto-generated method stub
282         return false;
283     }
284 
285     @Override
screenshotApplications(IBinder appToken, int displayId, int maxWidth, int maxHeight)286     public Bitmap screenshotApplications(IBinder appToken, int displayId, int maxWidth,
287             int maxHeight) throws RemoteException {
288         // TODO Auto-generated method stub
289         return null;
290     }
291 
292     @Override
setAnimationScale(int arg0, float arg1)293     public void setAnimationScale(int arg0, float arg1) throws RemoteException {
294         // TODO Auto-generated method stub
295 
296     }
297 
298     @Override
setAnimationScales(float[] arg0)299     public void setAnimationScales(float[] arg0) throws RemoteException {
300         // TODO Auto-generated method stub
301 
302     }
303 
304     @Override
getCurrentAnimatorScale()305     public float getCurrentAnimatorScale() throws RemoteException {
306         return 0;
307     }
308 
309     @Override
setAppTask(IBinder arg0, int arg1)310     public void setAppTask(IBinder arg0, int arg1) throws RemoteException {
311         // TODO Auto-generated method stub
312 
313     }
314 
315     @Override
setAppOrientation(IApplicationToken arg0, int arg1)316     public void setAppOrientation(IApplicationToken arg0, int arg1) throws RemoteException {
317         // TODO Auto-generated method stub
318     }
319 
320     @Override
setAppStartingWindow(IBinder arg0, String arg1, int arg2, CompatibilityInfo arg3, CharSequence arg4, int arg5, int arg6, int arg7, int arg8, IBinder arg9, boolean arg10)321     public void setAppStartingWindow(IBinder arg0, String arg1, int arg2, CompatibilityInfo arg3,
322             CharSequence arg4, int arg5, int arg6, int arg7, int arg8, IBinder arg9, boolean arg10)
323             throws RemoteException {
324         // TODO Auto-generated method stub
325     }
326 
327     @Override
setAppVisibility(IBinder arg0, boolean arg1)328     public void setAppVisibility(IBinder arg0, boolean arg1) throws RemoteException {
329         // TODO Auto-generated method stub
330 
331     }
332 
333     @Override
setAppWillBeHidden(IBinder arg0)334     public void setAppWillBeHidden(IBinder arg0) throws RemoteException {
335         // TODO Auto-generated method stub
336     }
337 
338     @Override
setEventDispatching(boolean arg0)339     public void setEventDispatching(boolean arg0) throws RemoteException {
340         // TODO Auto-generated method stub
341     }
342 
343     @Override
setFocusedApp(IBinder arg0, boolean arg1)344     public void setFocusedApp(IBinder arg0, boolean arg1) throws RemoteException {
345         // TODO Auto-generated method stub
346     }
347 
348     @Override
getInitialDisplaySize(int displayId, Point size)349     public void getInitialDisplaySize(int displayId, Point size) {
350         // TODO Auto-generated method stub
351     }
352 
353     @Override
getBaseDisplaySize(int displayId, Point size)354     public void getBaseDisplaySize(int displayId, Point size) {
355         // TODO Auto-generated method stub
356     }
357 
358     @Override
setForcedDisplaySize(int displayId, int arg0, int arg1)359     public void setForcedDisplaySize(int displayId, int arg0, int arg1) throws RemoteException {
360         // TODO Auto-generated method stub
361     }
362 
363     @Override
getInitialDisplayDensity(int displayId)364     public int getInitialDisplayDensity(int displayId) {
365         return -1;
366     }
367 
368     @Override
getBaseDisplayDensity(int displayId)369     public int getBaseDisplayDensity(int displayId) {
370         return -1;
371     }
372 
373     @Override
setForcedDisplayDensity(int displayId, int density)374     public void setForcedDisplayDensity(int displayId, int density) throws RemoteException {
375         // TODO Auto-generated method stub
376     }
377 
378     @Override
setForcedDisplayScalingMode(int displayId, int mode)379     public void setForcedDisplayScalingMode(int displayId, int mode) {
380     }
381 
382     @Override
setInTouchMode(boolean arg0)383     public void setInTouchMode(boolean arg0) throws RemoteException {
384         // TODO Auto-generated method stub
385     }
386 
387     @Override
setNewConfiguration(Configuration arg0)388     public void setNewConfiguration(Configuration arg0) throws RemoteException {
389         // TODO Auto-generated method stub
390     }
391 
392     @Override
setScreenCaptureDisabled(int userId, boolean disabled)393     public void setScreenCaptureDisabled(int userId, boolean disabled) {
394         // TODO Auto-generated method stub
395     }
396 
397     @Override
updateRotation(boolean arg0, boolean arg1)398     public void updateRotation(boolean arg0, boolean arg1) throws RemoteException {
399         // TODO Auto-generated method stub
400     }
401 
402     @Override
setStrictModeVisualIndicatorPreference(String arg0)403     public void setStrictModeVisualIndicatorPreference(String arg0) throws RemoteException {
404         // TODO Auto-generated method stub
405     }
406 
407     @Override
showStrictModeViolation(boolean arg0)408     public void showStrictModeViolation(boolean arg0) throws RemoteException {
409         // TODO Auto-generated method stub
410     }
411 
412     @Override
startAppFreezingScreen(IBinder arg0, int arg1)413     public void startAppFreezingScreen(IBinder arg0, int arg1) throws RemoteException {
414         // TODO Auto-generated method stub
415     }
416 
417     @Override
startViewServer(int arg0)418     public boolean startViewServer(int arg0) throws RemoteException {
419         // TODO Auto-generated method stub
420         return false;
421     }
422 
423     @Override
statusBarVisibilityChanged(int arg0)424     public void statusBarVisibilityChanged(int arg0) throws RemoteException {
425         // TODO Auto-generated method stub
426     }
427 
428     @Override
stopAppFreezingScreen(IBinder arg0, boolean arg1)429     public void stopAppFreezingScreen(IBinder arg0, boolean arg1) throws RemoteException {
430         // TODO Auto-generated method stub
431     }
432 
433     @Override
stopViewServer()434     public boolean stopViewServer() throws RemoteException {
435         // TODO Auto-generated method stub
436         return false;
437     }
438 
439     @Override
thawRotation()440     public void thawRotation() throws RemoteException {
441         // TODO Auto-generated method stub
442     }
443 
444     @Override
updateOrientationFromAppTokens(Configuration arg0, IBinder arg1)445     public Configuration updateOrientationFromAppTokens(Configuration arg0, IBinder arg1)
446             throws RemoteException {
447         // TODO Auto-generated method stub
448         return null;
449     }
450 
451     @Override
watchRotation(IRotationWatcher arg0)452     public int watchRotation(IRotationWatcher arg0) throws RemoteException {
453         // TODO Auto-generated method stub
454         return 0;
455     }
456 
457     @Override
removeRotationWatcher(IRotationWatcher arg0)458     public void removeRotationWatcher(IRotationWatcher arg0) throws RemoteException {
459     }
460 
461     @Override
asBinder()462     public IBinder asBinder() {
463         // TODO Auto-generated method stub
464         return null;
465     }
466 
467     @Override
getPreferredOptionsPanelGravity()468     public int getPreferredOptionsPanelGravity() throws RemoteException {
469         return Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
470     }
471 
472     @Override
dismissKeyguard()473     public void dismissKeyguard() {
474     }
475 
476     @Override
keyguardGoingAway(boolean disableWindowAnimations, boolean keyguardGoingToNotificationShade)477     public void keyguardGoingAway(boolean disableWindowAnimations,
478             boolean keyguardGoingToNotificationShade) throws RemoteException {
479     }
480 
481     @Override
lockNow(Bundle options)482     public void lockNow(Bundle options) {
483         // TODO Auto-generated method stub
484     }
485 
486     @Override
isSafeModeEnabled()487     public boolean isSafeModeEnabled() {
488         return false;
489     }
490 
491     @Override
isRotationFrozen()492     public boolean isRotationFrozen() throws RemoteException {
493         // TODO Auto-generated method stub
494         return false;
495     }
496 
497     @Override
enableScreenIfNeeded()498     public void enableScreenIfNeeded() throws RemoteException {
499         // TODO Auto-generated method stub
500     }
501 
502     @Override
clearWindowContentFrameStats(IBinder token)503     public boolean clearWindowContentFrameStats(IBinder token) throws RemoteException {
504         // TODO Auto-generated method stub
505         return false;
506     }
507 
508     @Override
getWindowContentFrameStats(IBinder token)509     public WindowContentFrameStats getWindowContentFrameStats(IBinder token)
510             throws RemoteException {
511         // TODO Auto-generated method stub
512         return null;
513     }
514 }
515