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 IActivityTaskManager.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     int KEYGUARD_GOING_AWAY_FLAG_SUBTLE_WINDOW_ANIMATIONS = 1 << 3;
46 
47     // Flags used for indicating whether the internal and/or external input devices
48     // of some type are available.
49     int PRESENCE_INTERNAL = 1 << 0;
50     int PRESENCE_EXTERNAL = 1 << 1;
51 
52     // Navigation bar position values
53     int NAV_BAR_INVALID = -1;
54     int NAV_BAR_LEFT = 1 << 0;
55     int NAV_BAR_RIGHT = 1 << 1;
56     int NAV_BAR_BOTTOM = 1 << 2;
57 
58     // Navigation bar interaction modes
59     int NAV_BAR_MODE_3BUTTON = 0;
60     int NAV_BAR_MODE_2BUTTON = 1;
61     int NAV_BAR_MODE_GESTURAL = 2;
62 
63     // Associated overlays for each nav bar mode
64     String NAV_BAR_MODE_3BUTTON_OVERLAY = "com.android.internal.systemui.navbar.threebutton";
65     String NAV_BAR_MODE_2BUTTON_OVERLAY = "com.android.internal.systemui.navbar.twobutton";
66     String NAV_BAR_MODE_GESTURAL_OVERLAY = "com.android.internal.systemui.navbar.gestural";
67 
68     /**
69      * Sticky broadcast of the current HDMI plugged state.
70      */
71     String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
72 
73     /**
74      * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if
75      * plugged in to HDMI, false if not.
76      */
77     String EXTRA_HDMI_PLUGGED_STATE = "state";
78 
79     /**
80      * Set to {@code true} when intent was invoked from pressing the home key.
81      * @hide
82      */
83     String EXTRA_FROM_HOME_KEY = "android.intent.extra.FROM_HOME_KEY";
84 
85     // TODO: move this to a more appropriate place.
86     interface PointerEventListener {
87         /**
88          * 1. onPointerEvent will be called on the service.UiThread.
89          * 2. motionEvent will be recycled after onPointerEvent returns so if it is needed later a
90          * copy() must be made and the copy must be recycled.
91          **/
onPointerEvent(MotionEvent motionEvent)92         void onPointerEvent(MotionEvent motionEvent);
93     }
94 
95     /** Screen turned off because of a device admin */
96     int OFF_BECAUSE_OF_ADMIN = 1;
97     /** Screen turned off because of power button */
98     int OFF_BECAUSE_OF_USER = 2;
99     /** Screen turned off because of timeout */
100     int OFF_BECAUSE_OF_TIMEOUT = 3;
101 
102     @IntDef(prefix = { "ON_BECAUSE_OF_" }, value = {
103             ON_BECAUSE_OF_USER,
104             ON_BECAUSE_OF_APPLICATION,
105             ON_BECAUSE_OF_UNKNOWN,
106     })
107     @Retention(RetentionPolicy.SOURCE)
108     public @interface OnReason{}
109 
110     /** Convert the on reason to a human readable format */
onReasonToString(@nReason int why)111     static String onReasonToString(@OnReason int why) {
112         switch (why) {
113             case ON_BECAUSE_OF_USER:
114                 return "ON_BECAUSE_OF_USER";
115             case ON_BECAUSE_OF_APPLICATION:
116                 return "ON_BECAUSE_OF_APPLICATION";
117             case ON_BECAUSE_OF_UNKNOWN:
118                 return "ON_BECAUSE_OF_UNKNOWN";
119             default:
120                 return Integer.toString(why);
121         }
122     }
123 
124     /** Screen turned on because of a user-initiated action. */
125     int ON_BECAUSE_OF_USER = 1;
126     /** Screen turned on because of an application request or event */
127     int ON_BECAUSE_OF_APPLICATION = 2;
128     /** Screen turned on for an unknown reason */
129     int ON_BECAUSE_OF_UNKNOWN = 3;
130 
131     int APPLICATION_LAYER = 2;
132     int APPLICATION_MEDIA_SUBLAYER = -2;
133     int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1;
134     int APPLICATION_PANEL_SUBLAYER = 1;
135     int APPLICATION_SUB_PANEL_SUBLAYER = 2;
136     int APPLICATION_ABOVE_SUB_PANEL_SUBLAYER = 3;
137 
138     /**
139      * Convert the off reason to a human readable format.
140      */
offReasonToString(int why)141     static String offReasonToString(int why) {
142         switch (why) {
143             case OFF_BECAUSE_OF_ADMIN:
144                 return "OFF_BECAUSE_OF_ADMIN";
145             case OFF_BECAUSE_OF_USER:
146                 return "OFF_BECAUSE_OF_USER";
147             case OFF_BECAUSE_OF_TIMEOUT:
148                 return "OFF_BECAUSE_OF_TIMEOUT";
149             default:
150                 return Integer.toString(why);
151         }
152     }
153 }
154