• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.view;
18 
19 import android.annotation.IntDef;
20 
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 
24 /**
25  * Constants for interfacing with WindowManagerService and WindowManagerPolicyInternal.
26  * @hide
27  */
28 public interface WindowManagerPolicyConstants {
29     // Policy flags.  These flags are also defined in frameworks/base/include/ui/Input.h.
30     int FLAG_WAKE = 0x00000001;
31     int FLAG_VIRTUAL = 0x00000002;
32 
33     int FLAG_INJECTED = 0x01000000;
34     int FLAG_TRUSTED = 0x02000000;
35     int FLAG_FILTERED = 0x04000000;
36     int FLAG_DISABLE_KEY_REPEAT = 0x08000000;
37 
38     int FLAG_INTERACTIVE = 0x20000000;
39     int FLAG_PASS_TO_USER = 0x40000000;
40 
41     // Flags for IActivityManager.keyguardGoingAway()
42     int KEYGUARD_GOING_AWAY_FLAG_TO_SHADE = 1 << 0;
43     int KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS = 1 << 1;
44     int KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER = 1 << 2;
45 
46     // Flags used for indicating whether the internal and/or external input devices
47     // of some type are available.
48     int PRESENCE_INTERNAL = 1 << 0;
49     int PRESENCE_EXTERNAL = 1 << 1;
50 
51     // Navigation bar position values
52     int NAV_BAR_INVALID = -1;
53     int NAV_BAR_LEFT = 1 << 0;
54     int NAV_BAR_RIGHT = 1 << 1;
55     int NAV_BAR_BOTTOM = 1 << 2;
56 
57     // Navigation bar interaction modes
58     int NAV_BAR_MODE_3BUTTON = 0;
59     int NAV_BAR_MODE_2BUTTON = 1;
60     int NAV_BAR_MODE_GESTURAL = 2;
61 
62     // Associated overlays for each nav bar mode
63     String NAV_BAR_MODE_3BUTTON_OVERLAY = "com.android.internal.systemui.navbar.threebutton";
64     String NAV_BAR_MODE_2BUTTON_OVERLAY = "com.android.internal.systemui.navbar.twobutton";
65     String NAV_BAR_MODE_GESTURAL_OVERLAY = "com.android.internal.systemui.navbar.gestural";
66 
67     /**
68      * Broadcast sent when a user activity is detected.
69      */
70     String ACTION_USER_ACTIVITY_NOTIFICATION =
71             "android.intent.action.USER_ACTIVITY_NOTIFICATION";
72 
73     /**
74      * Sticky broadcast of the current HDMI plugged state.
75      */
76     String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
77 
78     /**
79      * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if
80      * plugged in to HDMI, false if not.
81      */
82     String EXTRA_HDMI_PLUGGED_STATE = "state";
83 
84     /**
85      * Set to {@code true} when intent was invoked from pressing the home key.
86      * @hide
87      */
88     String EXTRA_FROM_HOME_KEY = "android.intent.extra.FROM_HOME_KEY";
89 
90     // TODO: move this to a more appropriate place.
91     interface PointerEventListener {
92         /**
93          * 1. onPointerEvent will be called on the service.UiThread.
94          * 2. motionEvent will be recycled after onPointerEvent returns so if it is needed later a
95          * copy() must be made and the copy must be recycled.
96          **/
onPointerEvent(MotionEvent motionEvent)97         void onPointerEvent(MotionEvent motionEvent);
98     }
99 
100     /** Screen turned off because of a device admin */
101     int OFF_BECAUSE_OF_ADMIN = 1;
102     /** Screen turned off because of power button */
103     int OFF_BECAUSE_OF_USER = 2;
104     /** Screen turned off because of timeout */
105     int OFF_BECAUSE_OF_TIMEOUT = 3;
106 
107     @IntDef(prefix = { "ON_BECAUSE_OF_" }, value = {
108             ON_BECAUSE_OF_USER,
109             ON_BECAUSE_OF_APPLICATION,
110             ON_BECAUSE_OF_UNKNOWN,
111     })
112     @Retention(RetentionPolicy.SOURCE)
113     public @interface OnReason{}
114 
115     /** Convert the on reason to a human readable format */
onReasonToString(@nReason int why)116     static String onReasonToString(@OnReason int why) {
117         switch (why) {
118             case ON_BECAUSE_OF_USER:
119                 return "ON_BECAUSE_OF_USER";
120             case ON_BECAUSE_OF_APPLICATION:
121                 return "ON_BECAUSE_OF_APPLICATION";
122             case ON_BECAUSE_OF_UNKNOWN:
123                 return "ON_BECAUSE_OF_UNKNOWN";
124             default:
125                 return Integer.toString(why);
126         }
127     }
128 
129     /** Screen turned on because of a user-initiated action. */
130     int ON_BECAUSE_OF_USER = 1;
131     /** Screen turned on because of an application request or event */
132     int ON_BECAUSE_OF_APPLICATION = 2;
133     /** Screen turned on for an unknown reason */
134     int ON_BECAUSE_OF_UNKNOWN = 3;
135 
136     int APPLICATION_LAYER = 2;
137     int APPLICATION_MEDIA_SUBLAYER = -2;
138     int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1;
139     int APPLICATION_PANEL_SUBLAYER = 1;
140     int APPLICATION_SUB_PANEL_SUBLAYER = 2;
141     int APPLICATION_ABOVE_SUB_PANEL_SUBLAYER = 3;
142 
143     /**
144      * Convert the off reason to a human readable format.
145      */
offReasonToString(int why)146     static String offReasonToString(int why) {
147         switch (why) {
148             case OFF_BECAUSE_OF_ADMIN:
149                 return "OFF_BECAUSE_OF_ADMIN";
150             case OFF_BECAUSE_OF_USER:
151                 return "OFF_BECAUSE_OF_USER";
152             case OFF_BECAUSE_OF_TIMEOUT:
153                 return "OFF_BECAUSE_OF_TIMEOUT";
154             default:
155                 return Integer.toString(why);
156         }
157     }
158 }
159