blob: 311a0f11efb0228c014fefef3c75cff6230de6df [file] [log] [blame]
Garfield Tane84e6f92019-08-29 17:28:41 -07001/*
2 * Copyright (C) 2019 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#ifndef _UI_INPUT_INPUTDISPATCHER_INJECTIONSTATE_H
18#define _UI_INPUT_INPUTDISPATCHER_INJECTIONSTATE_H
19
20#include "InputDispatcherInterface.h"
21
22#include <stdint.h>
23
24namespace android::inputdispatcher {
25
26/*
27 * Constants used to determine the input event injection synchronization mode.
28 */
29enum {
30 /* Injection is asynchronous and is assumed always to be successful. */
31 INPUT_EVENT_INJECTION_SYNC_NONE = 0,
32
33 /* Waits for previous events to be dispatched so that the input dispatcher can determine
34 * whether input event injection willbe permitted based on the current input focus.
35 * Does not wait for the input event to finish processing. */
36 INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_RESULT = 1,
37
38 /* Waits for the input event to be completely processed. */
39 INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_FINISHED = 2,
40};
41
42struct InjectionState {
43 mutable int32_t refCount;
44
45 int32_t injectorPid;
46 int32_t injectorUid;
47 int32_t injectionResult; // initially INPUT_EVENT_INJECTION_PENDING
48 bool injectionIsAsync; // set to true if injection is not waiting for the result
49 int32_t pendingForegroundDispatches; // the number of foreground dispatches in progress
50
51 InjectionState(int32_t injectorPid, int32_t injectorUid);
52 void release();
53
54private:
55 ~InjectionState();
56};
57
58} // namespace android::inputdispatcher
59
60#endif // _UI_INPUT_INPUTDISPATCHER_INJECTIONSTATE_H