1 /*
2  * Copyright (C) 2017 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.inputmethodservice.cts.common;
18 
19 import android.inputmethodservice.cts.common.test.TestInfo;
20 
21 /**
22  * Constants of device event.
23  */
24 public final class DeviceEventConstants {
25 
26     // This is constants holding class, can't instantiate.
DeviceEventConstants()27     private DeviceEventConstants() {}
28 
29     /** Intent action in order to record IME events. */
30     public static final String ACTION_DEVICE_EVENT =
31             "android.inputmethodservice.cts.action.DEVICE_EVENT";
32 
33     /**
34      * Intent receiver's package, class, and component name.
35      */
36     public static final String RECEIVER_PACKAGE = "android.inputmethodservice.cts.provider";
37     public static final String RECEIVER_CLASS =
38             "android.inputmethodservice.cts.receiver.EventReceiver";
39     public static final String RECEIVER_COMPONENT = ComponentNameUtils.buildComponentName(
40             RECEIVER_PACKAGE, RECEIVER_CLASS);
41 
42     /**
43      * Intent extra key for who sends a device event.
44      * Values are Input Method class name, for example {@link Ime1Constants#CLASS}, or device test
45      * method name, for example {@link TestInfo#getTestName()}).
46      *
47      * @see android.content.Intent#putExtra(String,String)
48      * @see android.content.Intent#getStringExtra(String)
49      */
50     public static final String EXTRA_EVENT_SENDER = "event_sender";
51 
52     /**
53      * Intent extra key for what type a device event is. Values are {@link DeviceEventType#name()}.
54      *
55      * @see android.content.Intent#putExtra(String,String)
56      * @see android.content.Intent#getStringExtra(String)
57      */
58     public static final String EXTRA_EVENT_TYPE = "event_type";
59 
60     /**
61      * Intent extra key for at what time a device event happens. Value is taken from
62      * {@code android.os.SystemClock.uptimeMillis()}.
63      *
64      * @see android.content.Intent#putExtra(String,long)
65      * @see android.content.Intent#getLongExtra(String,long)
66      */
67     public static final String EXTRA_EVENT_TIME = "event_time";
68 
69     /**
70      * Types of device event, a value of {@link #EXTRA_EVENT_TYPE}.
71      */
72     public enum DeviceEventType {
73         /**
74          * {@link android.inputmethodservice.InputMethodService#onCreate()} callback.
75          */
76         ON_CREATE,
77 
78         /**
79          * {@link android.inputmethodservice.InputMethodService#onBindInput()} callback.
80          */
81         ON_BIND_INPUT,
82 
83         /**
84          * {@link android.inputmethodservice.InputMethodService#onStartInput(
85          * android.view.inputmethod.EditorInfo, boolean)}
86          * callback.
87          */
88         ON_START_INPUT,
89 
90         /**
91          * {@link android.inputmethodservice.InputMethodService#onStartInputView(
92          * android.view.inputmethod.EditorInfo, boolean)}
93          */
94         ON_START_INPUT_VIEW,
95 
96         /**
97          * {@link android.inputmethodservice.InputMethodService#onUnbindInput()} callback.
98          */
99         ON_UNBIND_INPUT,
100 
101         /**
102          * {@link android.inputmethodservice.InputMethodService#onFinishInputView(boolean)}
103          * callback.
104          */
105         ON_FINISH_INPUT_VIEW,
106 
107         /**
108          * {@link android.inputmethodservice.InputMethodService#onFinishInput()}
109          * callback.
110          */
111         ON_FINISH_INPUT,
112 
113         /**
114          * {@link android.inputmethodservice.InputMethodService#onDestroy()} callback.
115          */
116         ON_DESTROY,
117 
118         /** Test start and end event types. */
119         TEST_START,
120         TEST_END,
121     }
122 }
123