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