1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744
|
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.view;
import static android.Manifest.permission;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS;
import static android.view.WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
import static android.view.WindowManager.LayoutParams.TYPE_DRAG;
import static android.view.WindowManager.LayoutParams.TYPE_DREAM;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_CONSUMER;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_PHONE;
import static android.view.WindowManager.LayoutParams.TYPE_POINTER;
import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION;
import static android.view.WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION;
import static android.view.WindowManager.LayoutParams.TYPE_QS_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT;
import static android.view.WindowManager.LayoutParams.TYPE_SEARCH_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION;
import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static android.view.WindowManager.LayoutParams.isSystemAlertWindowType;
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.ActivityManager.StackId;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.util.Slog;
import android.view.animation.Animation;
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.policy.IShortcutService;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* This interface supplies all UI-specific behavior of the window manager. An
* instance of it is created by the window manager when it starts up, and allows
* customization of window layering, special window types, key dispatching, and
* layout.
*
* <p>Because this provides deep interaction with the system window manager,
* specific methods on this interface can be called from a variety of contexts
* with various restrictions on what they can do. These are encoded through
* a suffixes at the end of a method encoding the thread the method is called
* from and any locks that are held when it is being called; if no suffix
* is attached to a method, then it is not called with any locks and may be
* called from the main window manager thread or another thread calling into
* the window manager.
*
* <p>The current suffixes are:
*
* <dl>
* <dt> Ti <dd> Called from the input thread. This is the thread that
* collects pending input events and dispatches them to the appropriate window.
* It may block waiting for events to be processed, so that the input stream is
* properly serialized.
* <dt> Tq <dd> Called from the low-level input queue thread. This is the
* thread that reads events out of the raw input devices and places them
* into the global input queue that is read by the <var>Ti</var> thread.
* This thread should not block for a long period of time on anything but the
* key driver.
* <dt> Lw <dd> Called with the main window manager lock held. Because the
* window manager is a very low-level system service, there are few other
* system services you can call with this lock held. It is explicitly okay to
* make calls into the package manager and power manager; it is explicitly not
* okay to make calls into the activity manager or most other services. Note that
* {@link android.content.Context#checkPermission(String, int, int)} and
* variations require calling into the activity manager.
* <dt> Li <dd> Called with the input thread lock held. This lock can be
* acquired by the window manager while it holds the window lock, so this is
* even more restrictive than <var>Lw</var>.
* </dl>
*
* @hide
*/
public interface WindowManagerPolicy {
// Policy flags. These flags are also defined in frameworks/base/include/ui/Input.h.
public final static int FLAG_WAKE = 0x00000001;
public final static int FLAG_VIRTUAL = 0x00000002;
public final static int FLAG_INJECTED = 0x01000000;
public final static int FLAG_TRUSTED = 0x02000000;
public final static int FLAG_FILTERED = 0x04000000;
public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000;
public final static int FLAG_INTERACTIVE = 0x20000000;
public final static int FLAG_PASS_TO_USER = 0x40000000;
// Flags for IActivityManager.keyguardGoingAway()
public final static int KEYGUARD_GOING_AWAY_FLAG_TO_SHADE = 1 << 0;
public final static int KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS = 1 << 1;
public final static int KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER = 1 << 2;
// Flags used for indicating whether the internal and/or external input devices
// of some type are available.
public final static int PRESENCE_INTERNAL = 1 << 0;
public final static int PRESENCE_EXTERNAL = 1 << 1;
// Navigation bar position values
int NAV_BAR_LEFT = 1 << 0;
int NAV_BAR_RIGHT = 1 << 1;
int NAV_BAR_BOTTOM = 1 << 2;
public final static boolean WATCH_POINTER = false;
/**
* Sticky broadcast of the current HDMI plugged state.
*/
public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
/**
* Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if
* plugged in to HDMI, false if not.
*/
public final static String EXTRA_HDMI_PLUGGED_STATE = "state";
/**
* Set to {@code true} when intent was invoked from pressing the home key.
* @hide
*/
@SystemApi
public static final String EXTRA_FROM_HOME_KEY = "android.intent.extra.FROM_HOME_KEY";
/**
* Pass this event to the user / app. To be returned from
* {@link #interceptKeyBeforeQueueing}.
*/
public final static int ACTION_PASS_TO_USER = 0x00000001;
/**
* Register shortcuts for window manager to dispatch.
* Shortcut code is packed as (metaState << Integer.SIZE) | keyCode
* @hide
*/
void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)
throws RemoteException;
/**
* Called when the Keyguard occluded state changed.
* @param occluded Whether Keyguard is currently occluded or not.
*/
void onKeyguardOccludedChangedLw(boolean occluded);
/**
* Interface to the Window Manager state associated with a particular
* window. You can hold on to an instance of this interface from the call
* to prepareAddWindow() until removeWindow().
*/
public interface WindowState {
/**
* Return the uid of the app that owns this window.
*/
int getOwningUid();
/**
* Return the package name of the app that owns this window.
*/
String getOwningPackage();
/**
* Perform standard frame computation. The result can be obtained with
* getFrame() if so desired. Must be called with the window manager
* lock held.
*
* @param parentFrame The frame of the parent container this window
* is in, used for computing its basic position.
* @param displayFrame The frame of the overall display in which this
* window can appear, used for constraining the overall dimensions
* of the window.
* @param overlayFrame The frame within the display that is inside
* of the overlay region.
* @param contentFrame The frame within the display in which we would
* like active content to appear. This will cause windows behind to
* be resized to match the given content frame.
* @param visibleFrame The frame within the display that the window
* is actually visible, used for computing its visible insets to be
* given to windows behind.
* This can be used as a hint for scrolling (avoiding resizing)
* the window to make certain that parts of its content
* are visible.
* @param decorFrame The decor frame specified by policy specific to this window,
* to use for proper cropping during animation.
* @param stableFrame The frame around which stable system decoration is positioned.
* @param outsetFrame The frame that includes areas that aren't part of the surface but we
* want to treat them as such.
*/
public void computeFrameLw(Rect parentFrame, Rect displayFrame,
Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame,
Rect stableFrame, Rect outsetFrame);
/**
* Retrieve the current frame of the window that has been assigned by
* the window manager. Must be called with the window manager lock held.
*
* @return Rect The rectangle holding the window frame.
*/
public Rect getFrameLw();
/**
* Retrieve the current position of the window that is actually shown.
* Must be called with the window manager lock held.
*
* @return Point The point holding the shown window position.
*/
public Point getShownPositionLw();
/**
* Retrieve the frame of the display that this window was last
* laid out in. Must be called with the
* window manager lock held.
*
* @return Rect The rectangle holding the display frame.
*/
public Rect getDisplayFrameLw();
/**
* Retrieve the frame of the area inside the overscan region of the
* display that this window was last laid out in. Must be called with the
* window manager lock held.
*
* @return Rect The rectangle holding the display overscan frame.
*/
public Rect getOverscanFrameLw();
/**
* Retrieve the frame of the content area that this window was last
* laid out in. This is the area in which the content of the window
* should be placed. It will be smaller than the display frame to
* account for screen decorations such as a status bar or soft
* keyboard. Must be called with the
* window manager lock held.
*
* @return Rect The rectangle holding the content frame.
*/
public Rect getContentFrameLw();
/**
* Retrieve the frame of the visible area that this window was last
* laid out in. This is the area of the screen in which the window
* will actually be fully visible. It will be smaller than the
* content frame to account for transient UI elements blocking it
* such as an input method's candidates UI. Must be called with the
* window manager lock held.
*
* @return Rect The rectangle holding the visible frame.
*/
public Rect getVisibleFrameLw();
/**
* Returns true if this window is waiting to receive its given
* internal insets from the client app, and so should not impact the
* layout of other windows.
*/
public boolean getGivenInsetsPendingLw();
/**
* Retrieve the insets given by this window's client for the content
* area of windows behind it. Must be called with the
* window manager lock held.
*
* @return Rect The left, top, right, and bottom insets, relative
* to the window's frame, of the actual contents.
*/
public Rect getGivenContentInsetsLw();
/**
* Retrieve the insets given by this window's client for the visible
* area of windows behind it. Must be called with the
* window manager lock held.
*
* @return Rect The left, top, right, and bottom insets, relative
* to the window's frame, of the actual visible area.
*/
public Rect getGivenVisibleInsetsLw();
/**
* Retrieve the current LayoutParams of the window.
*
* @return WindowManager.LayoutParams The window's internal LayoutParams
* instance.
*/
public WindowManager.LayoutParams getAttrs();
/**
* Return whether this window needs the menu key shown. Must be called
* with window lock held, because it may need to traverse down through
* window list to determine the result.
* @param bottom The bottom-most window to consider when determining this.
*/
public boolean getNeedsMenuLw(WindowState bottom);
/**
* Retrieve the current system UI visibility flags associated with
* this window.
*/
public int getSystemUiVisibility();
/**
* Get the layer at which this window's surface will be Z-ordered.
*/
public int getSurfaceLayer();
/**
* Retrieve the type of the top-level window.
*
* @return the base type of the parent window if attached or its own type otherwise
*/
public int getBaseType();
/**
* Return the token for the application (actually activity) that owns
* this window. May return null for system windows.
*
* @return An IApplicationToken identifying the owning activity.
*/
public IApplicationToken getAppToken();
/**
* Return true if this window is participating in voice interaction.
*/
public boolean isVoiceInteraction();
/**
* Return true if, at any point, the application token associated with
* this window has actually displayed any windows. This is most useful
* with the "starting up" window to determine if any windows were
* displayed when it is closed.
*
* @return Returns true if one or more windows have been displayed,
* else false.
*/
public boolean hasAppShownWindows();
/**
* Is this window visible? It is not visible if there is no
* surface, or we are in the process of running an exit animation
* that will remove the surface.
*/
boolean isVisibleLw();
/**
* Is this window currently visible to the user on-screen? It is
* displayed either if it is visible or it is currently running an
* animation before no longer being visible. Must be called with the
* window manager lock held.
*/
boolean isDisplayedLw();
/**
* Return true if this window (or a window it is attached to, but not
* considering its app token) is currently animating.
*/
boolean isAnimatingLw();
/**
* @return Whether the window can affect SystemUI flags, meaning that SystemUI (system bars,
* for example) will be affected by the flags specified in this window. This is the
* case when the surface is on screen but not exiting.
*/
boolean canAffectSystemUiFlags();
/**
* Is this window considered to be gone for purposes of layout?
*/
boolean isGoneForLayoutLw();
/**
* Returns true if the window has a surface that it has drawn a
* complete UI in to. Note that this is different from {@link #hasDrawnLw()}
* in that it also returns true if the window is READY_TO_SHOW, but was not yet
* promoted to HAS_DRAWN.
*/
boolean isDrawnLw();
/**
* Returns true if this window has been shown on screen at some time in
* the past. Must be called with the window manager lock held.
*/
public boolean hasDrawnLw();
/**
* Can be called by the policy to force a window to be hidden,
* regardless of whether the client or window manager would like
* it shown. Must be called with the window manager lock held.
* Returns true if {@link #showLw} was last called for the window.
*/
public boolean hideLw(boolean doAnimation);
/**
* Can be called to undo the effect of {@link #hideLw}, allowing a
* window to be shown as long as the window manager and client would
* also like it to be shown. Must be called with the window manager
* lock held.
* Returns true if {@link #hideLw} was last called for the window.
*/
public boolean showLw(boolean doAnimation);
/**
* Check whether the process hosting this window is currently alive.
*/
public boolean isAlive();
/**
* Check if window is on {@link Display#DEFAULT_DISPLAY}.
* @return true if window is on default display.
*/
public boolean isDefaultDisplay();
/**
* Check whether the window is currently dimming.
*/
public boolean isDimming();
/**
* @return the stack id this windows belongs to, or {@link StackId#INVALID_STACK_ID} if
* not attached to any stack.
*/
int getStackId();
/**
* Returns true if the window is current in multi-windowing mode. i.e. it shares the
* screen with other application windows.
*/
public boolean isInMultiWindowMode();
public int getRotationAnimationHint();
public boolean isInputMethodWindow();
public int getDisplayId();
/**
* Returns true if the window owner can add internal system windows.
* That is, they have {@link permission#INTERNAL_SYSTEM_WINDOW}.
*/
default boolean canAddInternalSystemWindow() {
return false;
}
/**
* Returns true if the window owner has the permission to acquire a sleep token when it's
* visible. That is, they have the permission {@link permission#DEVICE_POWER}.
*/
boolean canAcquireSleepToken();
}
/**
* Representation of a input consumer that the policy has added to the
* window manager to consume input events going to windows below it.
*/
public interface InputConsumer {
/**
* Remove the input consumer from the window manager.
*/
void dismiss();
}
/**
* Holds the contents of a starting window. {@link #addSplashScreen} needs to wrap the
* contents of the starting window into an class implementing this interface, which then will be
* held by WM and released with {@link #remove} when no longer needed.
*/
interface StartingSurface {
/**
* Removes the starting window surface. Do not hold the window manager lock when calling
* this method!
*/
void remove();
}
/**
* Interface for calling back in to the window manager that is private
* between it and the policy.
*/
public interface WindowManagerFuncs {
public static final int LID_ABSENT = -1;
public static final int LID_CLOSED = 0;
public static final int LID_OPEN = 1;
public static final int CAMERA_LENS_COVER_ABSENT = -1;
public static final int CAMERA_LENS_UNCOVERED = 0;
public static final int CAMERA_LENS_COVERED = 1;
/**
* Ask the window manager to re-evaluate the system UI flags.
*/
public void reevaluateStatusBarVisibility();
/**
* Add a input consumer which will consume all input events going to any window below it.
*/
public InputConsumer createInputConsumer(Looper looper, String name,
InputEventReceiver.Factory inputEventReceiverFactory);
/**
* Returns a code that describes the current state of the lid switch.
*/
public int getLidState();
/**
* Lock the device now.
*/
public void lockDeviceNow();
/**
* Returns a code that descripbes whether the camera lens is covered or not.
*/
public int getCameraLensCoverState();
/**
* Switch the input method, to be precise, input method subtype.
*
* @param forwardDirection {@code true} to rotate in a forward direction.
*/
public void switchInputMethod(boolean forwardDirection);
public void shutdown(boolean confirm);
public void reboot(boolean confirm);
public void rebootSafeMode(boolean confirm);
/**
* Return the window manager lock needed to correctly call "Lw" methods.
*/
public Object getWindowManagerLock();
/** Register a system listener for touch events */
void registerPointerEventListener(PointerEventListener listener);
/** Unregister a system listener for touch events */
void unregisterPointerEventListener(PointerEventListener listener);
/**
* @return The content insets of the docked divider window.
*/
int getDockedDividerInsetsLw();
/**
* Retrieves the {@param outBounds} from the stack with id {@param stackId}.
*/
void getStackBounds(int stackId, Rect outBounds);
/**
* Notifies window manager that {@link #isShowingDreamLw} has changed.
*/
void notifyShowingDreamChanged();
/**
* @return The currently active input method window.
*/
WindowState getInputMethodWindowLw();
/**
* Notifies window manager that {@link #isKeyguardTrustedLw} has changed.
*/
void notifyKeyguardTrustedChanged();
/**
* Notifies the window manager that screen is being turned off.
*
* @param listener callback to call when display can be turned off
*/
void screenTurningOff(ScreenOffListener listener);
}
public interface PointerEventListener {
/**
* 1. onPointerEvent will be called on the service.UiThread.
* 2. motionEvent will be recycled after onPointerEvent returns so if it is needed later a
* copy() must be made and the copy must be recycled.
**/
void onPointerEvent(MotionEvent motionEvent);
/**
* @see #onPointerEvent(MotionEvent)
**/
default void onPointerEvent(MotionEvent motionEvent, int displayId) {
if (displayId == DEFAULT_DISPLAY) {
onPointerEvent(motionEvent);
}
}
}
/** Window has been added to the screen. */
public static final int TRANSIT_ENTER = 1;
/** Window has been removed from the screen. */
public static final int TRANSIT_EXIT = 2;
/** Window has been made visible. */
public static final int TRANSIT_SHOW = 3;
/** Window has been made invisible.
* TODO: Consider removal as this is unused. */
public static final int TRANSIT_HIDE = 4;
/** The "application starting" preview window is no longer needed, and will
* animate away to show the real window. */
public static final int TRANSIT_PREVIEW_DONE = 5;
// NOTE: screen off reasons are in order of significance, with more
// important ones lower than less important ones.
/** Screen turned off because of a device admin */
public final int OFF_BECAUSE_OF_ADMIN = 1;
/** Screen turned off because of power button */
public final int OFF_BECAUSE_OF_USER = 2;
/** Screen turned off because of timeout */
public final int OFF_BECAUSE_OF_TIMEOUT = 3;
/** @hide */
@IntDef({USER_ROTATION_FREE, USER_ROTATION_LOCKED})
@Retention(RetentionPolicy.SOURCE)
public @interface UserRotationMode {}
/** When not otherwise specified by the activity's screenOrientation, rotation should be
* determined by the system (that is, using sensors). */
public final int USER_ROTATION_FREE = 0;
/** When not otherwise specified by the activity's screenOrientation, rotation is set by
* the user. */
public final int USER_ROTATION_LOCKED = 1;
/**
* Perform initialization of the policy.
*
* @param context The system context we are running in.
*/
public void init(Context context, IWindowManager windowManager,
WindowManagerFuncs windowManagerFuncs);
/**
* @return true if com.android.internal.R.bool#config_forceDefaultOrientation is true.
*/
public boolean isDefaultOrientationForced();
/**
* Called by window manager once it has the initial, default native
* display dimensions.
*/
public void setInitialDisplaySize(Display display, int width, int height, int density);
/**
* Called by window manager to set the overscan region that should be used for the
* given display.
*/
public void setDisplayOverscan(Display display, int left, int top, int right, int bottom);
/**
* Check permissions when adding a window.
*
* @param attrs The window's LayoutParams.
* @param outAppOp First element will be filled with the app op corresponding to
* this window, or OP_NONE.
*
* @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
* else an error code, usually
* {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
*/
public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp);
/**
* Check permissions when adding a window.
*
* @param attrs The window's LayoutParams.
*
* @return True if the window may only be shown to the current user, false if the window can
* be shown on all users' windows.
*/
public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs);
/**
* Sanitize the layout parameters coming from a client. Allows the policy
* to do things like ensure that windows of a specific type can't take
* input focus.
*
* @param attrs The window layout parameters to be modified. These values
* are modified in-place.
*/
public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
/**
* After the window manager has computed the current configuration based
* on its knowledge of the display and input devices, it gives the policy
* a chance to adjust the information contained in it. If you want to
* leave it as-is, simply do nothing.
*
* <p>This method may be called by any thread in the window manager, but
* no internal locks in the window manager will be held.
*
* @param config The Configuration being computed, for you to change as
* desired.
* @param keyboardPresence Flags that indicate whether internal or external
* keyboards are present.
* @param navigationPresence Flags that indicate whether internal or external
* navigation devices are present.
*/
public void adjustConfigurationLw(Configuration config, int keyboardPresence,
int navigationPresence);
/**
* Returns the layer assignment for the window state. Allows you to control how different
* kinds of windows are ordered on-screen.
*
* @param win The window state
* @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
*/
default int getWindowLayerLw(WindowState win) {
return getWindowLayerFromTypeLw(win.getBaseType(), win.canAddInternalSystemWindow());
}
/**
* Returns the layer assignment for the window type. Allows you to control how different
* kinds of windows are ordered on-screen.
*
* @param type The type of window being assigned.
* @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
*/
default int getWindowLayerFromTypeLw(int type) {
if (isSystemAlertWindowType(type)) {
throw new IllegalArgumentException("Use getWindowLayerFromTypeLw() or"
+ " getWindowLayerLw() for alert window types");
}
return getWindowLayerFromTypeLw(type, false /* canAddInternalSystemWindow */);
}
/**
* Returns the layer assignment for the window type. Allows you to control how different
* kinds of windows are ordered on-screen.
*
* @param type The type of window being assigned.
* @param canAddInternalSystemWindow If the owner window associated with the type we are
* evaluating can add internal system windows. I.e they have
* {@link permission#INTERNAL_SYSTEM_WINDOW}. If true, alert window
* types {@link android.view.WindowManager.LayoutParams#isSystemAlertWindowType(int)}
* can be assigned layers greater than the layer for
* {@link android.view.WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY} Else, their
* layers would be lesser.
* @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
*/
default int getWindowLayerFromTypeLw(int type, boolean canAddInternalSystemWindow) {
if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) {
return APPLICATION_LAYER;
}
switch (type) {
case TYPE_WALLPAPER:
// wallpaper is at the bottom, though the window manager may move it.
return 1;
case TYPE_PRESENTATION:
case TYPE_PRIVATE_PRESENTATION:
return APPLICATION_LAYER;
case TYPE_DOCK_DIVIDER:
return APPLICATION_LAYER;
case TYPE_QS_DIALOG:
return APPLICATION_LAYER;
case TYPE_PHONE:
return 3;
case TYPE_SEARCH_BAR:
case TYPE_VOICE_INTERACTION_STARTING:
return 4;
case TYPE_VOICE_INTERACTION:
// voice interaction layer is almost immediately above apps.
return 5;
case TYPE_INPUT_CONSUMER:
return 6;
case TYPE_SYSTEM_DIALOG:
return 7;
case TYPE_TOAST:
// toasts and the plugged-in battery thing
return 8;
case TYPE_PRIORITY_PHONE:
// SIM errors and unlock. Not sure if this really should be in a high layer.
return 9;
case TYPE_SYSTEM_ALERT:
// like the ANR / app crashed dialogs
return canAddInternalSystemWindow ? 11 : 10;
case TYPE_APPLICATION_OVERLAY:
return 12;
case TYPE_DREAM:
// used for Dreams (screensavers with TYPE_DREAM windows)
return 13;
case TYPE_INPUT_METHOD:
// on-screen keyboards and other such input method user interfaces go here.
return 14;
case TYPE_INPUT_METHOD_DIALOG:
// on-screen keyboards and other such input method user interfaces go here.
return 15;
case TYPE_STATUS_BAR_SUB_PANEL:
return 17;
case TYPE_STATUS_BAR:
return 18;
case TYPE_STATUS_BAR_PANEL:
return 19;
case TYPE_KEYGUARD_DIALOG:
return 20;
case TYPE_VOLUME_OVERLAY:
// the on-screen volume indicator and controller shown when the user
// changes the device volume
return 21;
case TYPE_SYSTEM_OVERLAY:
// the on-screen volume indicator and controller shown when the user
// changes the device volume
return canAddInternalSystemWindow ? 22 : 11;
case TYPE_NAVIGATION_BAR:
// the navigation bar, if available, shows atop most things
return 23;
case TYPE_NAVIGATION_BAR_PANEL:
// some panels (e.g. search) need to show on top of the navigation bar
return 24;
case TYPE_SCREENSHOT:
// screenshot selection layer shouldn't go above system error, but it should cover
// navigation bars at the very least.
return 25;
case TYPE_SYSTEM_ERROR:
// system-level error dialogs
return canAddInternalSystemWindow ? 26 : 10;
case TYPE_MAGNIFICATION_OVERLAY:
// used to highlight the magnified portion of a display
return 27;
case TYPE_DISPLAY_OVERLAY:
// used to simulate secondary display devices
return 28;
case TYPE_DRAG:
// the drag layer: input for drag-and-drop is associated with this window,
// which sits above all other focusable windows
return 29;
case TYPE_ACCESSIBILITY_OVERLAY:
// overlay put by accessibility services to intercept user interaction
return 30;
case TYPE_SECURE_SYSTEM_OVERLAY:
return 31;
case TYPE_BOOT_PROGRESS:
return 32;
case TYPE_POINTER:
// the (mouse) pointer layer
return 33;
default:
Slog.e("WindowManager", "Unknown window type: " + type);
return APPLICATION_LAYER;
}
}
int APPLICATION_LAYER = 2;
int APPLICATION_MEDIA_SUBLAYER = -2;
int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1;
int APPLICATION_PANEL_SUBLAYER = 1;
int APPLICATION_SUB_PANEL_SUBLAYER = 2;
int APPLICATION_ABOVE_SUB_PANEL_SUBLAYER = 3;
/**
* Return how to Z-order sub-windows in relation to the window they are attached to.
* Return positive to have them ordered in front, negative for behind.
*
* @param type The sub-window type code.
*
* @return int Layer in relation to the attached window, where positive is
* above and negative is below.
*/
default int getSubWindowLayerFromTypeLw(int type) {
switch (type) {
case TYPE_APPLICATION_PANEL:
case TYPE_APPLICATION_ATTACHED_DIALOG:
return APPLICATION_PANEL_SUBLAYER;
case TYPE_APPLICATION_MEDIA:
return APPLICATION_MEDIA_SUBLAYER;
case TYPE_APPLICATION_MEDIA_OVERLAY:
return APPLICATION_MEDIA_OVERLAY_SUBLAYER;
case TYPE_APPLICATION_SUB_PANEL:
return APPLICATION_SUB_PANEL_SUBLAYER;
case TYPE_APPLICATION_ABOVE_SUB_PANEL:
return APPLICATION_ABOVE_SUB_PANEL_SUBLAYER;
}
Slog.e("WindowManager", "Unknown sub-window type: " + type);
return 0;
}
/**
* Get the highest layer (actually one more than) that the wallpaper is
* allowed to be in.
*/
public int getMaxWallpaperLayer();
/**
* Return the display width available after excluding any screen
* decorations that could never be removed in Honeycomb. That is, system bar or
* button bar.
*/
public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation,
int uiMode, int displayId);
/**
* Return the display height available after excluding any screen
* decorations that could never be removed in Honeycomb. That is, system bar or
* button bar.
*/
public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation,
int uiMode, int displayId);
/**
* Return the available screen width that we should report for the
* configuration. This must be no larger than
* {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than
* that to account for more transient decoration like a status bar.
*/
public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation,
int uiMode, int displayId);
/**
* Return the available screen height that we should report for the
* configuration. This must be no larger than
* {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than
* that to account for more transient decoration like a status bar.
*/
public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation,
int uiMode, int displayId);
/**
* Return whether the given window can become the Keyguard window. Typically returns true for
* the StatusBar.
*/
public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs);
/**
* @return whether {@param win} can be hidden by Keyguard
*/
public boolean canBeHiddenByKeyguardLw(WindowState win);
/**
* Called when the system would like to show a UI to indicate that an
* application is starting. You can use this to add a
* APPLICATION_STARTING_TYPE window with the given appToken to the window
* manager (using the normal window manager APIs) that will be shown until
* the application displays its own window. This is called without the
* window manager locked so that you can call back into it.
*
* @param appToken Token of the application being started.
* @param packageName The name of the application package being started.
* @param theme Resource defining the application's overall visual theme.
* @param nonLocalizedLabel The default title label of the application if
* no data is found in the resource.
* @param labelRes The resource ID the application would like to use as its name.
* @param icon The resource ID the application would like to use as its icon.
* @param windowFlags Window layout flags.
* @param overrideConfig override configuration to consider when generating
* context to for resources.
* @param displayId Id of the display to show the splash screen at.
*
* @return The starting surface.
*
*/
public StartingSurface addSplashScreen(IBinder appToken, String packageName, int theme,
CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon,
int logo, int windowFlags, Configuration overrideConfig, int displayId);
/**
* Prepare for a window being added to the window manager. You can throw an
* exception here to prevent the window being added, or do whatever setup
* you need to keep track of the window.
*
* @param win The window being added.
* @param attrs The window's LayoutParams.
*
* @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an
* error code to abort the add.
*/
public int prepareAddWindowLw(WindowState win,
WindowManager.LayoutParams attrs);
/**
* Called when a window is being removed from a window manager. Must not
* throw an exception -- clean up as much as possible.
*
* @param win The window being removed.
*/
public void removeWindowLw(WindowState win);
/**
* Control the animation to run when a window's state changes. Return a
* non-0 number to force the animation to a specific resource ID, or 0
* to use the default animation.
*
* @param win The window that is changing.
* @param transit What is happening to the window: {@link #TRANSIT_ENTER},
* {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
* {@link #TRANSIT_HIDE}.
*
* @return Resource ID of the actual animation to use, or 0 for none.
*/
public int selectAnimationLw(WindowState win, int transit);
/**
* Determine the animation to run for a rotation transition based on the
* top fullscreen windows {@link WindowManager.LayoutParams#rotationAnimation}
* and whether it is currently fullscreen and frontmost.
*
* @param anim The exiting animation resource id is stored in anim[0], the
* entering animation resource id is stored in anim[1].
*/
public void selectRotationAnimationLw(int anim[]);
/**
* Validate whether the current top fullscreen has specified the same
* {@link WindowManager.LayoutParams#rotationAnimation} value as that
* being passed in from the previous top fullscreen window.
*
* @param exitAnimId exiting resource id from the previous window.
* @param enterAnimId entering resource id from the previous window.
* @param forceDefault For rotation animations only, if true ignore the
* animation values and just return false.
* @return true if the previous values are still valid, false if they
* should be replaced with the default.
*/
public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId,
boolean forceDefault);
/**
* Create and return an animation to re-display a window that was force hidden by Keyguard.
*/
public Animation createHiddenByKeyguardExit(boolean onWallpaper,
boolean goingToNotificationShade);
/**
* Create and return an animation to let the wallpaper disappear after being shown behind
* Keyguard.
*/
public Animation createKeyguardWallpaperExit(boolean goingToNotificationShade);
/**
* Called from the input reader thread before a key is enqueued.
*
* <p>There are some actions that need to be handled here because they
* affect the power state of the device, for example, the power keys.
* Generally, it's best to keep as little as possible in the queue thread
* because it's the most fragile.
* @param event The key event.
* @param policyFlags The policy flags associated with the key.
*
* @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
*/
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags);
/**
* Called from the input reader thread before a motion is enqueued when the device is in a
* non-interactive state.
*
* <p>There are some actions that need to be handled here because they
* affect the power state of the device, for example, waking on motions.
* Generally, it's best to keep as little as possible in the queue thread
* because it's the most fragile.
* @param policyFlags The policy flags associated with the motion.
*
* @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
*/
public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags);
/**
* Called from the input dispatcher thread before a key is dispatched to a window.
*
* <p>Allows you to define
* behavior for keys that can not be overridden by applications.
* This method is called from the input thread, with no locks held.
*
* @param win The window that currently has focus. This is where the key
* event will normally go.
* @param event The key event.
* @param policyFlags The policy flags associated with the key.
* @return 0 if the key should be dispatched immediately, -1 if the key should
* not be dispatched ever, or a positive value indicating the number of
* milliseconds by which the key dispatch should be delayed before trying
* again.
*/
public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags);
/**
* Called from the input dispatcher thread when an application did not handle
* a key that was dispatched to it.
*
* <p>Allows you to define default global behavior for keys that were not handled
* by applications. This method is called from the input thread, with no locks held.
*
* @param win The window that currently has focus. This is where the key
* event will normally go.
* @param event The key event.
* @param policyFlags The policy flags associated with the key.
* @return Returns an alternate key event to redispatch as a fallback, or null to give up.
* The caller is responsible for recycling the key event.
*/
public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags);
/**
* Called when layout of the windows is about to start.
*
* @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}.
* @param displayWidth The current full width of the screen.
* @param displayHeight The current full height of the screen.
* @param displayRotation The current rotation being applied to the base window.
* @param uiMode The current uiMode in configuration.
*/
public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
int displayRotation, int uiMode);
/**
* Returns the bottom-most layer of the system decor, above which no policy decor should
* be applied.
*/
public int getSystemDecorLayerLw();
/**
* Return the rectangle of the screen that is available for applications to run in.
* This will be called immediately after {@link #beginLayoutLw}.
*
* @param r The rectangle to be filled with the boundaries available to applications.
*/
public void getContentRectLw(Rect r);
/**
* Called for each window attached to the window manager as layout is
* proceeding. The implementation of this function must take care of
* setting the window's frame, either here or in finishLayout().
*
* @param win The window being positioned.
* @param attached For sub-windows, the window it is attached to; this
* window will already have had layoutWindow() called on it
* so you can use its Rect. Otherwise null.
*/
public void layoutWindowLw(WindowState win, WindowState attached);
/**
* Return the insets for the areas covered by system windows. These values
* are computed on the most recent layout, so they are not guaranteed to
* be correct.
*
* @param attrs The LayoutParams of the window.
* @param taskBounds The bounds of the task this window is on or {@code null} if no task is
* associated with the window.
* @param displayRotation Rotation of the display.
* @param displayWidth The width of the display.
* @param displayHeight The height of the display.
* @param outContentInsets The areas covered by system windows, expressed as positive insets.
* @param outStableInsets The areas covered by stable system windows irrespective of their
* current visibility. Expressed as positive insets.
* @param outOutsets The areas that are not real display, but we would like to treat as such.
* @return Whether to always consume the navigation bar.
* See {@link #isNavBarForcedShownLw(WindowState)}.
*/
public boolean getInsetHintLw(WindowManager.LayoutParams attrs, Rect taskBounds,
int displayRotation, int displayWidth, int displayHeight, Rect outContentInsets,
Rect outStableInsets, Rect outOutsets);
/**
* Called when layout of the windows is finished. After this function has
* returned, all windows given to layoutWindow() <em>must</em> have had a
* frame assigned.
*/
public void finishLayoutLw();
/** Layout state may have changed (so another layout will be performed) */
static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
/** Configuration state may have changed */
static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
/** Wallpaper may need to move */
static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
/** Need to recompute animations */
static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
/**
* Called following layout of all windows before each window has policy applied.
*
* @param displayWidth The current full width of the screen.
* @param displayHeight The current full height of the screen.
*/
public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight);
/**
* Called following layout of all window to apply policy to each window.
*
* @param win The window being positioned.
* @param attrs The LayoutParams of the window.
* @param attached For sub-windows, the window it is attached to. Otherwise null.
*/
public void applyPostLayoutPolicyLw(WindowState win,
WindowManager.LayoutParams attrs, WindowState attached, WindowState imeTarget);
/**
* Called following layout of all windows and after policy has been applied
* to each window. If in this function you do
* something that may have modified the animation state of another window,
* be sure to return non-zero in order to perform another pass through layout.
*
* @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
* {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
* or {@link #FINISH_LAYOUT_REDO_ANIM}.
*/
public int finishPostLayoutPolicyLw();
/**
* Return true if it is okay to perform animations for an app transition
* that is about to occur. You may return false for this if, for example,
* the lock screen is currently displayed so the switch should happen
* immediately.
*/
public boolean allowAppAnimationsLw();
/**
* A new window has been focused.
*/
public int focusChangedLw(WindowState lastFocus, WindowState newFocus);
/**
* Called when the device has started waking up.
*/
public void startedWakingUp();
/**
* Called when the device has finished waking up.
*/
public void finishedWakingUp();
/**
* Called when the device has started going to sleep.
*
* @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
* or {@link #OFF_BECAUSE_OF_TIMEOUT}.
*/
public void startedGoingToSleep(int why);
/**
* Called when the device has finished going to sleep.
*
* @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
* or {@link #OFF_BECAUSE_OF_TIMEOUT}.
*/
public void finishedGoingToSleep(int why);
/**
* Called when the device is about to turn on the screen to show content.
* When waking up, this method will be called once after the call to wakingUp().
* When dozing, the method will be called sometime after the call to goingToSleep() and
* may be called repeatedly in the case where the screen is pulsing on and off.
*
* Must call back on the listener to tell it when the higher-level system
* is ready for the screen to go on (i.e. the lock screen is shown).
*/
public void screenTurningOn(ScreenOnListener screenOnListener);
/**
* Called when the device has actually turned on the screen, i.e. the display power state has
* been set to ON and the screen is unblocked.
*/
public void screenTurnedOn();
/**
* Called when the display would like to be turned off. This gives policy a chance to do some
* things before the display power state is actually changed to off.
*
* @param screenOffListener Must be called to tell that the display power state can actually be
* changed now after policy has done its work.
*/
public void screenTurningOff(ScreenOffListener screenOffListener);
/**
* Called when the device has turned the screen off.
*/
public void screenTurnedOff();
public interface ScreenOnListener {
void onScreenOn();
}
/**
* See {@link #screenTurnedOff}
*/
public interface ScreenOffListener {
void onScreenOff();
}
/**
* Return whether the default display is on and not blocked by a black surface.
*/
public boolean isScreenOn();
/**
* @return whether the device is currently allowed to animate.
*
* Note: this can be true even if it is not appropriate to animate for reasons that are outside
* of the policy's authority.
*/
boolean okToAnimate();
/**
* Tell the policy that the lid switch has changed state.
* @param whenNanos The time when the change occurred in uptime nanoseconds.
* @param lidOpen True if the lid is now open.
*/
public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
/**
* Tell the policy that the camera lens has been covered or uncovered.
* @param whenNanos The time when the change occurred in uptime nanoseconds.
* @param lensCovered True if the lens is covered.
*/
public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered);
/**
* Tell the policy if anyone is requesting that keyguard not come on.
*
* @param enabled Whether keyguard can be on or not. does not actually
* turn it on, unless it was previously disabled with this function.
*
* @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
* @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
*/
@SuppressWarnings("javadoc")
public void enableKeyguard(boolean enabled);
/**
* Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely}
*/
interface OnKeyguardExitResult {
void onKeyguardExitResult(boolean success);
}
/**
* Tell the policy if anyone is requesting the keyguard to exit securely
* (this would be called after the keyguard was disabled)
* @param callback Callback to send the result back.
* @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
*/
@SuppressWarnings("javadoc")
void exitKeyguardSecurely(OnKeyguardExitResult callback);
/**
* isKeyguardLocked
*
* Return whether the keyguard is currently locked.
*
* @return true if in keyguard is locked.
*/
public boolean isKeyguardLocked();
/**
* isKeyguardSecure
*
* Return whether the keyguard requires a password to unlock.
* @param userId
*
* @return true if in keyguard is secure.
*/
public boolean isKeyguardSecure(int userId);
/**
* Return whether the keyguard is currently occluded.
*
* @return true if in keyguard is occluded, false otherwise
*/
public boolean isKeyguardOccluded();
/**
* @return true if in keyguard is on and not occluded.
*/
public boolean isKeyguardShowingAndNotOccluded();
/**
* @return whether Keyguard is in trusted state and can be dismissed without credentials
*/
public boolean isKeyguardTrustedLw();
/**
* inKeyguardRestrictedKeyInputMode
*
* if keyguard screen is showing or in restricted key input mode (i.e. in
* keyguard password emergency screen). When in such mode, certain keys,
* such as the Home key and the right soft keys, don't work.
*
* @return true if in keyguard restricted input mode.
*/
public boolean inKeyguardRestrictedKeyInputMode();
/**
* Ask the policy to dismiss the keyguard, if it is currently shown.
*
* @param callback Callback to be informed about the result.
*/
public void dismissKeyguardLw(@Nullable IKeyguardDismissCallback callback);
/**
* Ask the policy whether the Keyguard has drawn. If the Keyguard is disabled, this method
* returns true as soon as we know that Keyguard is disabled.
*
* @return true if the keyguard has drawn.
*/
public boolean isKeyguardDrawnLw();
public boolean isShowingDreamLw();
/**
* Given an orientation constant, returns the appropriate surface rotation,
* taking into account sensors, docking mode, rotation lock, and other factors.
*
* @param orientation An orientation constant, such as
* {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
* @param lastRotation The most recently used rotation.
* @return The surface rotation to use.
*/
public int rotationForOrientationLw(@ActivityInfo.ScreenOrientation int orientation,
int lastRotation);
/**
* Given an orientation constant and a rotation, returns true if the rotation
* has compatible metrics to the requested orientation. For example, if
* the application requested landscape and got seascape, then the rotation
* has compatible metrics; if the application requested portrait and got landscape,
* then the rotation has incompatible metrics; if the application did not specify
* a preference, then anything goes.
*
* @param orientation An orientation constant, such as
* {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
* @param rotation The rotation to check.
* @return True if the rotation is compatible with the requested orientation.
*/
public boolean rotationHasCompatibleMetricsLw(@ActivityInfo.ScreenOrientation int orientation,
int rotation);
/**
* Called by the window manager when the rotation changes.
*
* @param rotation The new rotation.
*/
public void setRotationLw(int rotation);
/**
* Called when the system is mostly done booting to set whether
* the system should go into safe mode.
*/
public void setSafeMode(boolean safeMode);
/**
* Called when the system is mostly done booting.
*/
public void systemReady();
/**
* Called when the system is done booting to the point where the
* user can start interacting with it.
*/
public void systemBooted();
/**
* Show boot time message to the user.
*/
public void showBootMessage(final CharSequence msg, final boolean always);
/**
* Hide the UI for showing boot messages, never to be displayed again.
*/
public void hideBootMessages();
/**
* Called when userActivity is signalled in the power manager.
* This is safe to call from any thread, with any window manager locks held or not.
*/
public void userActivity();
/**
* Called when we have finished booting and can now display the home
* screen to the user. This will happen after systemReady(), and at
* this point the display is active.
*/
public void enableScreenAfterBoot();
public void setCurrentOrientationLw(@ActivityInfo.ScreenOrientation int newOrientation);
/**
* Call from application to perform haptic feedback on its window.
*/
public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
/**
* Called when we have started keeping the screen on because a window
* requesting this has become visible.
*/
public void keepScreenOnStartedLw();
/**
* Called when we have stopped keeping the screen on because the last window
* requesting this is no longer visible.
*/
public void keepScreenOnStoppedLw();
/**
* Gets the current user rotation mode.
*
* @return The rotation mode.
*
* @see WindowManagerPolicy#USER_ROTATION_LOCKED
* @see WindowManagerPolicy#USER_ROTATION_FREE
*/
@UserRotationMode
public int getUserRotationMode();
/**
* Inform the policy that the user has chosen a preferred orientation ("rotation lock").
*
* @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
* {@link WindowManagerPolicy#USER_ROTATION_FREE}.
* @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
* {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
*/
public void setUserRotationMode(@UserRotationMode int mode, @Surface.Rotation int rotation);
/**
* Called when a new system UI visibility is being reported, allowing
* the policy to adjust what is actually reported.
* @param visibility The raw visibility reported by the status bar.
* @return The new desired visibility.
*/
public int adjustSystemUiVisibilityLw(int visibility);
/**
* Called by System UI to notify of changes to the visibility of Recents.
*/
public void setRecentsVisibilityLw(boolean visible);
/**
* Called by System UI to notify of changes to the visibility of PIP.
*/
void setPipVisibilityLw(boolean visible);
/**
* Specifies whether there is an on-screen navigation bar separate from the status bar.
*/
public boolean hasNavigationBar();
/**
* Lock the device now.
*/
public void lockNow(Bundle options);
/**
* Set the last used input method window state. This state is used to make IME transition
* smooth.
* @hide
*/
public void setLastInputMethodWindowLw(WindowState ime, WindowState target);
/**
* An internal callback (from InputMethodManagerService) to notify a state change regarding
* whether the back key should dismiss the software keyboard (IME) or not.
*
* @param newValue {@code true} if the software keyboard is shown and the back key is expected
* to dismiss the software keyboard.
* @hide
*/
default void setDismissImeOnBackKeyPressed(boolean newValue) {
// Default implementation does nothing.
}
/**
* Show the recents task list app.
* @hide
*/
public void showRecentApps(boolean fromHome);
/**
* Show the global actions dialog.
* @hide
*/
public void showGlobalActions();
/**
* @return The current height of the input method window.
*/
public int getInputMethodWindowVisibleHeightLw();
/**
* Called when the current user changes. Guaranteed to be called before the broadcast
* of the new user id is made to all listeners.
*
* @param newUserId The id of the incoming user.
*/
public void setCurrentUserLw(int newUserId);
/**
* For a given user-switch operation, this will be called once with switching=true before the
* user-switch and once with switching=false afterwards (or if the user-switch was cancelled).
* This gives the policy a chance to alter its behavior for the duration of a user-switch.
*
* @param switching true if a user-switch is in progress
*/
void setSwitchingUser(boolean switching);
/**
* Print the WindowManagerPolicy's state into the given stream.
*
* @param prefix Text to print at the front of each line.
* @param writer The PrintWriter to which you should dump your state. This will be
* closed for you after you return.
* @param args additional arguments to the dump request.
*/
public void dump(String prefix, PrintWriter writer, String[] args);
/**
* Returns whether a given window type can be magnified.
*
* @param windowType The window type.
* @return True if the window can be magnified.
*/
public boolean canMagnifyWindow(int windowType);
/**
* Returns whether a given window type is considered a top level one.
* A top level window does not have a container, i.e. attached window,
* or if it has a container it is laid out as a top-level window, not
* as a child of its container.
*
* @param windowType The window type.
* @return True if the window is a top level one.
*/
public boolean isTopLevelWindow(int windowType);
/**
* Notifies the keyguard to start fading out.
*
* @param startTime the start time of the animation in uptime milliseconds
* @param fadeoutDuration the duration of the exit animation, in milliseconds
*/
public void startKeyguardExitAnimation(long startTime, long fadeoutDuration);
/**
* Calculates the stable insets without running a layout.
*
* @param displayRotation the current display rotation
* @param displayWidth the current display width
* @param displayHeight the current display height
* @param outInsets the insets to return
*/
public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight,
Rect outInsets);
/**
* @return true if the navigation bar is forced to stay visible
*/
public boolean isNavBarForcedShownLw(WindowState win);
/**
* @return The side of the screen where navigation bar is positioned.
* @see #NAV_BAR_LEFT
* @see #NAV_BAR_RIGHT
* @see #NAV_BAR_BOTTOM
*/
int getNavBarPosition();
/**
* Calculates the insets for the areas that could never be removed in Honeycomb, i.e. system
* bar or button bar. See {@link #getNonDecorDisplayWidth}.
*
* @param displayRotation the current display rotation
* @param displayWidth the current display width
* @param displayHeight the current display height
* @param outInsets the insets to return
*/
public void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight,
Rect outInsets);
/**
* @return True if a specified {@param dockSide} is allowed on the current device, or false
* otherwise. It is guaranteed that at least one dock side for a particular orientation
* is allowed, so for example, if DOCKED_RIGHT is not allowed, DOCKED_LEFT is allowed.
*/
public boolean isDockSideAllowed(int dockSide);
/**
* Called when the configuration has changed, and it's safe to load new values from resources.
*/
public void onConfigurationChanged();
public boolean shouldRotateSeamlessly(int oldRotation, int newRotation);
/**
* Called when System UI has been started.
*/
void onSystemUiStarted();
/**
* Checks whether the policy is ready for dismissing the boot animation and completing the boot.
*
* @return true if ready; false otherwise.
*/
boolean canDismissBootAnimation();
}
|