blob: 8c6b0078c17c3a33731ed2d38f9d55ed3035a456 [file] [log] [blame]
Wale Ogunwaleb699ce02016-07-18 12:05:30 -07001/*
2 * Copyright (C) 2016 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
17package com.android.server.wm;
18
19import com.android.internal.policy.IShortcutService;
20
21import android.content.Context;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070022import android.content.res.CompatibilityInfo;
23import android.content.res.Configuration;
24import android.graphics.Rect;
25import android.os.Bundle;
26import android.os.IBinder;
27import android.os.RemoteException;
Wale Ogunwaleadde52e2016-07-16 13:11:55 -070028import android.util.Log;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070029import android.view.Display;
30import android.view.IWindowManager;
31import android.view.KeyEvent;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070032import android.view.View;
33import android.view.WindowManager;
34import android.view.WindowManagerPolicy;
35import android.view.animation.Animation;
36
37import java.io.PrintWriter;
38
Wale Ogunwaleadde52e2016-07-16 13:11:55 -070039import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
40import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
41import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;
42import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL;
43import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
44import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;
45import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY;
46import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
47import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
48import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS;
49import static android.view.WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY;
50import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
51import static android.view.WindowManager.LayoutParams.TYPE_DRAG;
52import static android.view.WindowManager.LayoutParams.TYPE_DREAM;
53import static android.view.WindowManager.LayoutParams.TYPE_INPUT_CONSUMER;
54import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
55import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
56import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
57import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM;
58import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY;
59import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
60import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
61import static android.view.WindowManager.LayoutParams.TYPE_PHONE;
62import static android.view.WindowManager.LayoutParams.TYPE_POINTER;
63import static android.view.WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
64import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION;
65import static android.view.WindowManager.LayoutParams.TYPE_QS_DIALOG;
66import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT;
67import static android.view.WindowManager.LayoutParams.TYPE_SEARCH_BAR;
68import static android.view.WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY;
69import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
70import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL;
71import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL;
72import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
73import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
74import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
75import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
76import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
77import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION;
78import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION_STARTING;
79import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
80import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
81
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070082public class TestWindowManagerPolicy implements WindowManagerPolicy {
Wale Ogunwaleadde52e2016-07-16 13:11:55 -070083 private static final String TAG = "TestWindowManagerPolicy";
Wale Ogunwaleb699ce02016-07-18 12:05:30 -070084
85 @Override
86 public void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)
87 throws RemoteException {
88
89 }
90
91 @Override
92 public void init(Context context, IWindowManager windowManager,
93 WindowManagerFuncs windowManagerFuncs) {
94
95 }
96
97 @Override
98 public boolean isDefaultOrientationForced() {
99 return false;
100 }
101
102 @Override
Guang Zhu91355d52016-08-05 18:09:21 -0700103 public boolean canShowDismissingWindowWhileLockedLw() {
104 return false;
105 }
106
107 @Override
Wale Ogunwaleb699ce02016-07-18 12:05:30 -0700108 public void setInitialDisplaySize(Display display, int width, int height, int density) {
109
110 }
111
112 @Override
113 public void setDisplayOverscan(Display display, int left, int top, int right, int bottom) {
114
115 }
116
117 @Override
118 public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp) {
119 return 0;
120 }
121
122 @Override
123 public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs) {
124 return false;
125 }
126
127 @Override
128 public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) {
129
130 }
131
132 @Override
133 public void adjustConfigurationLw(Configuration config, int keyboardPresence,
134 int navigationPresence) {
135
136 }
137
138 @Override
139 public int windowTypeToLayerLw(int type) {
Wale Ogunwaleadde52e2016-07-16 13:11:55 -0700140 // TODO: figure-out a good way to keep this in-sync with PhoneWindowManager...sigh!
141 if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) {
142 return 2;
143 }
144 switch (type) {
145 case TYPE_PRIVATE_PRESENTATION:
146 return 2;
147 case TYPE_WALLPAPER:
148 // wallpaper is at the bottom, though the window manager may move it.
149 return 2;
150 case TYPE_DOCK_DIVIDER:
151 return 2;
152 case TYPE_QS_DIALOG:
153 return 2;
154 case TYPE_PHONE:
155 return 3;
156 case TYPE_SEARCH_BAR:
157 case TYPE_VOICE_INTERACTION_STARTING:
158 return 4;
159 case TYPE_VOICE_INTERACTION:
160 // voice interaction layer is almost immediately above apps.
161 return 5;
162 case TYPE_INPUT_CONSUMER:
163 return 6;
164 case TYPE_SYSTEM_DIALOG:
165 return 7;
166 case TYPE_TOAST:
167 // toasts and the plugged-in battery thing
168 return 8;
169 case TYPE_PRIORITY_PHONE:
170 // SIM errors and unlock. Not sure if this really should be in a high layer.
171 return 9;
172 case TYPE_DREAM:
173 // used for Dreams (screensavers with TYPE_DREAM windows)
174 return 10;
175 case TYPE_SYSTEM_ALERT:
176 // like the ANR / app crashed dialogs
177 return 11;
178 case TYPE_INPUT_METHOD:
179 // on-screen keyboards and other such input method user interfaces go here.
180 return 12;
181 case TYPE_INPUT_METHOD_DIALOG:
182 // on-screen keyboards and other such input method user interfaces go here.
183 return 13;
184 case TYPE_KEYGUARD_SCRIM:
185 // the safety window that shows behind keyguard while keyguard is starting
186 return 14;
187 case TYPE_STATUS_BAR_SUB_PANEL:
188 return 15;
189 case TYPE_STATUS_BAR:
190 return 16;
191 case TYPE_STATUS_BAR_PANEL:
192 return 17;
193 case TYPE_KEYGUARD_DIALOG:
194 return 18;
195 case TYPE_VOLUME_OVERLAY:
196 // the on-screen volume indicator and controller shown when the user
197 // changes the device volume
198 return 19;
199 case TYPE_SYSTEM_OVERLAY:
200 // the on-screen volume indicator and controller shown when the user
201 // changes the device volume
202 return 20;
203 case TYPE_NAVIGATION_BAR:
204 // the navigation bar, if available, shows atop most things
205 return 21;
206 case TYPE_NAVIGATION_BAR_PANEL:
207 // some panels (e.g. search) need to show on top of the navigation bar
208 return 22;
209 case TYPE_SCREENSHOT:
210 // screenshot selection layer shouldn't go above system error, but it should cover
211 // navigation bars at the very least.
212 return 23;
213 case TYPE_SYSTEM_ERROR:
214 // system-level error dialogs
215 return 24;
216 case TYPE_MAGNIFICATION_OVERLAY:
217 // used to highlight the magnified portion of a display
218 return 25;
219 case TYPE_DISPLAY_OVERLAY:
220 // used to simulate secondary display devices
221 return 26;
222 case TYPE_DRAG:
223 // the drag layer: input for drag-and-drop is associated with this window,
224 // which sits above all other focusable windows
225 return 27;
226 case TYPE_ACCESSIBILITY_OVERLAY:
227 // overlay put by accessibility services to intercept user interaction
228 return 28;
229 case TYPE_SECURE_SYSTEM_OVERLAY:
230 return 29;
231 case TYPE_BOOT_PROGRESS:
232 return 30;
233 case TYPE_POINTER:
234 // the (mouse) pointer layer
235 return 31;
236 }
237 Log.e(TAG, "Unknown window type: " + type);
238 return 2;
Wale Ogunwaleb699ce02016-07-18 12:05:30 -0700239 }
240
241 @Override
242 public int subWindowTypeToLayerLw(int type) {
Wale Ogunwaleadde52e2016-07-16 13:11:55 -0700243 // TODO: figure-out a good way to keep this in-sync with PhoneWindowManager...
244 switch (type) {
245 case TYPE_APPLICATION_PANEL:
246 case TYPE_APPLICATION_ATTACHED_DIALOG:
247 return 1;
248 case TYPE_APPLICATION_MEDIA:
249 return -2;
250 case TYPE_APPLICATION_MEDIA_OVERLAY:
251 return -1;
252 case TYPE_APPLICATION_SUB_PANEL:
253 return 2;
254 case TYPE_APPLICATION_ABOVE_SUB_PANEL:
255 return 3;
256 }
257 Log.e(TAG, "Unknown sub-window type: " + type);
Wale Ogunwaleb699ce02016-07-18 12:05:30 -0700258 return 0;
259 }
260
261 @Override
262 public int getMaxWallpaperLayer() {
263 return 0;
264 }
265
266 @Override
267 public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode) {
268 return 0;
269 }
270
271 @Override
272 public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation, int uiMode) {
273 return 0;
274 }
275
276 @Override
277 public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode) {
278 return 0;
279 }
280
281 @Override
282 public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation, int uiMode) {
283 return 0;
284 }
285
286 @Override
287 public boolean isForceHiding(WindowManager.LayoutParams attrs) {
288 return false;
289 }
290
291 @Override
292 public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs) {
293 return false;
294 }
295
296 @Override
297 public boolean canBeForceHidden(WindowState win,
298 WindowManager.LayoutParams attrs) {
299 return false;
300 }
301
302 @Override
303 public WindowState getWinShowWhenLockedLw() {
304 return null;
305 }
306
307 @Override
308 public View addStartingWindow(IBinder appToken, String packageName, int theme,
309 CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon,
310 int logo, int windowFlags, Configuration overrideConfig) {
311 return null;
312 }
313
314 @Override
315 public void removeStartingWindow(IBinder appToken, View window) {
316
317 }
318
319 @Override
320 public int prepareAddWindowLw(WindowState win,
321 WindowManager.LayoutParams attrs) {
322 return 0;
323 }
324
325 @Override
326 public void removeWindowLw(WindowState win) {
327
328 }
329
330 @Override
331 public int selectAnimationLw(WindowState win, int transit) {
332 return 0;
333 }
334
335 @Override
336 public void selectRotationAnimationLw(int[] anim) {
337
338 }
339
340 @Override
341 public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId,
342 boolean forceDefault) {
343 return false;
344 }
345
346 @Override
347 public Animation createForceHideEnterAnimation(boolean onWallpaper,
348 boolean goingToNotificationShade) {
349 return null;
350 }
351
352 @Override
353 public Animation createForceHideWallpaperExitAnimation(boolean goingToNotificationShade) {
354 return null;
355 }
356
357 @Override
358 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
359 return 0;
360 }
361
362 @Override
363 public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags) {
364 return 0;
365 }
366
367 @Override
368 public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event,
369 int policyFlags) {
370 return 0;
371 }
372
373 @Override
374 public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event,
375 int policyFlags) {
376 return null;
377 }
378
379 @Override
380 public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
381 int displayRotation, int uiMode) {
382
383 }
384
385 @Override
386 public int getSystemDecorLayerLw() {
387 return 0;
388 }
389
390 @Override
391 public void getContentRectLw(Rect r) {
392
393 }
394
395 @Override
396 public void layoutWindowLw(WindowState win,
397 WindowState attached) {
398
399 }
400
401 @Override
402 public boolean getInsetHintLw(WindowManager.LayoutParams attrs, Rect taskBounds,
403 int displayRotation, int displayWidth, int displayHeight, Rect outContentInsets,
404 Rect outStableInsets, Rect outOutsets) {
405 return false;
406 }
407
408 @Override
409 public void finishLayoutLw() {
410
411 }
412
413 @Override
414 public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight) {
415
416 }
417
418 @Override
419 public void applyPostLayoutPolicyLw(WindowState win,
420 WindowManager.LayoutParams attrs, WindowState attached) {
421
422 }
423
424 @Override
425 public int finishPostLayoutPolicyLw() {
426 return 0;
427 }
428
429 @Override
430 public boolean allowAppAnimationsLw() {
431 return false;
432 }
433
434 @Override
435 public int focusChangedLw(WindowState lastFocus,
436 WindowState newFocus) {
437 return 0;
438 }
439
440 @Override
441 public void startedWakingUp() {
442
443 }
444
445 @Override
446 public void finishedWakingUp() {
447
448 }
449
450 @Override
451 public void startedGoingToSleep(int why) {
452
453 }
454
455 @Override
456 public void finishedGoingToSleep(int why) {
457
458 }
459
460 @Override
461 public void screenTurningOn(ScreenOnListener screenOnListener) {
462
463 }
464
465 @Override
466 public void screenTurnedOn() {
467
468 }
469
470 @Override
471 public void screenTurnedOff() {
472
473 }
474
475 @Override
476 public boolean isScreenOn() {
477 return false;
478 }
479
480 @Override
481 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
482
483 }
484
485 @Override
486 public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) {
487
488 }
489
490 @Override
491 public void enableKeyguard(boolean enabled) {
492
493 }
494
495 @Override
496 public void exitKeyguardSecurely(OnKeyguardExitResult callback) {
497
498 }
499
500 @Override
501 public boolean isKeyguardLocked() {
502 return false;
503 }
504
505 @Override
506 public boolean isKeyguardSecure(int userId) {
507 return false;
508 }
509
510 @Override
511 public boolean isKeyguardShowingOrOccluded() {
512 return false;
513 }
514
515 @Override
516 public boolean isKeyguardShowingAndNotOccluded() {
517 return false;
518 }
519
520 @Override
521 public boolean inKeyguardRestrictedKeyInputMode() {
522 return false;
523 }
524
525 @Override
526 public void dismissKeyguardLw() {
527
528 }
529
530 @Override
531 public void notifyActivityDrawnForKeyguardLw() {
532
533 }
534
535 @Override
536 public boolean isKeyguardDrawnLw() {
537 return false;
538 }
539
540 @Override
541 public int rotationForOrientationLw(int orientation,
542 int lastRotation) {
543 return 0;
544 }
545
546 @Override
547 public boolean rotationHasCompatibleMetricsLw(int orientation,
548 int rotation) {
549 return false;
550 }
551
552 @Override
553 public void setRotationLw(int rotation) {
554
555 }
556
557 @Override
558 public void setSafeMode(boolean safeMode) {
559
560 }
561
562 @Override
563 public void systemReady() {
564
565 }
566
567 @Override
568 public void systemBooted() {
569
570 }
571
572 @Override
573 public void showBootMessage(CharSequence msg, boolean always) {
574
575 }
576
577 @Override
578 public void hideBootMessages() {
579
580 }
581
582 @Override
583 public void userActivity() {
584
585 }
586
587 @Override
588 public void enableScreenAfterBoot() {
589
590 }
591
592 @Override
593 public void setCurrentOrientationLw(int newOrientation) {
594
595 }
596
597 @Override
598 public boolean performHapticFeedbackLw(WindowState win, int effectId,
599 boolean always) {
600 return false;
601 }
602
603 @Override
604 public void keepScreenOnStartedLw() {
605
606 }
607
608 @Override
609 public void keepScreenOnStoppedLw() {
610
611 }
612
613 @Override
614 public int getUserRotationMode() {
615 return 0;
616 }
617
618 @Override
619 public void setUserRotationMode(int mode,
620 int rotation) {
621
622 }
623
624 @Override
625 public int adjustSystemUiVisibilityLw(int visibility) {
626 return 0;
627 }
628
629 @Override
630 public boolean hasNavigationBar() {
631 return false;
632 }
633
634 @Override
635 public void lockNow(Bundle options) {
636
637 }
638
639 @Override
640 public void setLastInputMethodWindowLw(WindowState ime,
641 WindowState target) {
642
643 }
644
645 @Override
646 public void showRecentApps(boolean fromHome) {
647
648 }
649
650 @Override
651 public void showGlobalActions() {
652
653 }
654
655 @Override
656 public int getInputMethodWindowVisibleHeightLw() {
657 return 0;
658 }
659
660 @Override
661 public void setCurrentUserLw(int newUserId) {
662
663 }
664
665 @Override
Evan Rosky18396452016-07-27 15:19:37 -0700666 public void setSwitchingUser(boolean switching) {
667
668 }
669
670 @Override
Wale Ogunwaleb699ce02016-07-18 12:05:30 -0700671 public void dump(String prefix, PrintWriter writer, String[] args) {
672
673 }
674
675 @Override
676 public boolean canMagnifyWindow(int windowType) {
677 return false;
678 }
679
680 @Override
681 public boolean isTopLevelWindow(int windowType) {
682 return false;
683 }
684
685 @Override
686 public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) {
687
688 }
689
690 @Override
691 public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight,
692 Rect outInsets) {
693
694 }
695
696 @Override
697 public boolean isNavBarForcedShownLw(WindowState win) {
698 return false;
699 }
700
701 @Override
702 public void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight,
703 Rect outInsets) {
704
705 }
706
707 @Override
708 public boolean isDockSideAllowed(int dockSide) {
709 return false;
710 }
711
712 @Override
713 public void onConfigurationChanged() {
714
715 }
716
717 @Override
718 public boolean shouldRotateSeamlessly(int oldRotation, int newRotation) {
719 return false;
720 }
721}