1 /**
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 package com.android.systemui.shared.system;
17 
18 import android.hardware.input.InputManagerGlobal;
19 import android.os.Looper;
20 import android.view.Choreographer;
21 import android.view.InputMonitor;
22 
23 import com.android.systemui.shared.system.InputChannelCompat.InputEventListener;
24 import com.android.systemui.shared.system.InputChannelCompat.InputEventReceiver;
25 
26 /**
27  * @see android.view.InputMonitor
28  */
29 public class InputMonitorCompat {
30     private final InputMonitor mInputMonitor;
31 
32     /**
33      * Monitor input on the specified display for gestures.
34      */
InputMonitorCompat(String name, int displayId)35     public InputMonitorCompat(String name, int displayId) {
36         mInputMonitor = InputManagerGlobal.getInstance()
37                 .monitorGestureInput(name, displayId);
38     }
39 
40     /**
41      * @see InputMonitor#pilferPointers()
42      */
pilferPointers()43     public void pilferPointers() {
44         mInputMonitor.pilferPointers();
45     }
46 
47     /**
48      * @see InputMonitor#dispose()
49      */
dispose()50     public void dispose() {
51         mInputMonitor.dispose();
52     }
53 
54     /**
55      * @see InputMonitor#getInputChannel()
56      */
getInputReceiver(Looper looper, Choreographer choreographer, InputEventListener listener)57     public InputEventReceiver getInputReceiver(Looper looper, Choreographer choreographer,
58             InputEventListener listener) {
59         return new InputEventReceiver(mInputMonitor.getInputChannel(), looper, choreographer,
60                 listener);
61     }
62 }
63