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() 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(android.view.inputmethod.EditorInfo,boolean) onStartInput(EditorInfo,boolean}
85          * callback.
86          */
87         ON_START_INPUT,
88 
89         /**
90          * {@link android.inputmethodservice.InputMethodService#onStartInputView(android.view.inputmethod.EditorInfo, boolean) onStartInputView(EditorInfo,boolean}
91          */
92         ON_START_INPUT_VIEW,
93 
94         /**
95          * {@link android.inputmethodservice.InputMethodService#onUnbindInput()} callback.
96          */
97         ON_UNBIND_INPUT,
98 
99         /**
100          * {@link android.inputmethodservice.InputMethodService#onFinishInputView(boolean) onFinishInputView(boolean)}
101          * callback.
102          */
103         ON_FINISH_INPUT_VIEW,
104 
105         /**
106          * {@link android.inputmethodservice.InputMethodService#onFinishInput() onFinishInput()}
107          * callback.
108          */
109         ON_FINISH_INPUT,
110 
111         /**
112          * {@link android.inputmethodservice.InputMethodService#onDestroy() onDestroy()} callback.
113          */
114         ON_DESTROY,
115 
116         /** Test start and end event types. */
117         TEST_START,
118         TEST_END,
119     }
120 }
121