blob: ad1f201ba3c1ce9e174d642af35083bc5224f5e8 [file] [log] [blame]
Michael Wrightc7995232019-02-14 12:33:46 +00001/*
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
17package android.view;
18
19import android.annotation.NonNull;
20import android.os.Parcel;
21import android.os.Parcelable;
22import android.os.RemoteException;
23
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +010024import com.android.internal.util.DataClass;
25
Michael Wrightc7995232019-02-14 12:33:46 +000026/**
Michael Wrightad3a6bf2019-04-04 14:17:09 +010027 * An {@code InputMonitor} allows privileged applications and components to monitor streams of
28 * {@link InputEvent}s without having to be the designated recipient for the event.
29 *
30 * For example, focus dispatched events would normally only go to the focused window on the
31 * targeted display, but an {@code InputMonitor} will also receive a copy of that event if they're
32 * registered to monitor that type of event on the targeted display.
33 *
Michael Wrightc7995232019-02-14 12:33:46 +000034 * @hide
35 */
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +010036@DataClass(genToString = true)
Michael Wrightc7995232019-02-14 12:33:46 +000037public final class InputMonitor implements Parcelable {
38 private static final String TAG = "InputMonitor";
39
40 private static final boolean DEBUG = false;
41
Michael Wrightc7995232019-02-14 12:33:46 +000042 @NonNull
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +010043 private final InputChannel mInputChannel;
Michael Wrightc7995232019-02-14 12:33:46 +000044 @NonNull
45 private final IInputMonitorHost mHost;
46
Michael Wrightc7995232019-02-14 12:33:46 +000047
48 /**
49 * Takes all of the current pointer events streams that are currently being sent to this
50 * monitor and generates appropriate cancellations for the windows that would normally get
51 * them.
52 *
53 * This method should be used with caution as unexpected pilfering can break fundamental user
54 * interactions.
55 */
56 public void pilferPointers() {
57 try {
58 mHost.pilferPointers();
59 } catch (RemoteException e) {
60 e.rethrowFromSystemServer();
61 }
62 }
63
64 /**
65 * Disposes the input monitor.
66 *
67 * Explicitly release all of the resources this monitor is holding on to (e.g. the
68 * InputChannel). Once this method is called, this monitor and any resources it's provided may
69 * no longer be used.
70 */
71 public void dispose() {
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +010072 mInputChannel.dispose();
Michael Wrightc7995232019-02-14 12:33:46 +000073 try {
74 mHost.dispose();
75 } catch (RemoteException e) {
76 e.rethrowFromSystemServer();
77 }
78 }
79
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +010080
81
Siarhei Vishniakou7480ae22019-10-15 15:18:55 -070082 // Code below generated by codegen v1.0.7.
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +010083 //
84 // DO NOT MODIFY!
Siarhei Vishniakou7480ae22019-10-15 15:18:55 -070085 // CHECKSTYLE:OFF Generated code
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +010086 //
87 // To regenerate run:
88 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/InputMonitor.java
Siarhei Vishniakou7480ae22019-10-15 15:18:55 -070089
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +010090
91 @DataClass.Generated.Member
92 public InputMonitor(
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +010093 @NonNull InputChannel inputChannel,
94 @NonNull IInputMonitorHost host) {
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +010095 this.mInputChannel = inputChannel;
96 com.android.internal.util.AnnotationValidations.validate(
97 NonNull.class, null, mInputChannel);
98 this.mHost = host;
99 com.android.internal.util.AnnotationValidations.validate(
100 NonNull.class, null, mHost);
101
102 // onConstructed(); // You can define this method to get a callback
103 }
104
105 @DataClass.Generated.Member
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +0100106 public @NonNull InputChannel getInputChannel() {
107 return mInputChannel;
108 }
109
110 @DataClass.Generated.Member
111 public @NonNull IInputMonitorHost getHost() {
112 return mHost;
Michael Wrightc7995232019-02-14 12:33:46 +0000113 }
114
115 @Override
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +0100116 @DataClass.Generated.Member
Michael Wrightc7995232019-02-14 12:33:46 +0000117 public String toString() {
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +0100118 // You can override field toString logic by defining methods like:
119 // String fieldNameToString() { ... }
120
121 return "InputMonitor { " +
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +0100122 "inputChannel = " + mInputChannel + ", " +
123 "host = " + mHost +
124 " }";
Michael Wrightc7995232019-02-14 12:33:46 +0000125 }
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +0100126
127 @Override
128 @DataClass.Generated.Member
129 public void writeToParcel(Parcel dest, int flags) {
130 // You can override field parcelling by defining methods like:
131 // void parcelFieldName(Parcel dest, int flags) { ... }
132
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +0100133 dest.writeTypedObject(mInputChannel, flags);
134 dest.writeStrongInterface(mHost);
135 }
136
137 @Override
138 @DataClass.Generated.Member
139 public int describeContents() { return 0; }
140
Siarhei Vishniakou7480ae22019-10-15 15:18:55 -0700141 /** @hide */
142 @SuppressWarnings({"unchecked", "RedundantCast"})
143 @DataClass.Generated.Member
144 /* package-private */ InputMonitor(Parcel in) {
145 // You can override field unparcelling by defining methods like:
146 // static FieldType unparcelFieldName(Parcel in) { ... }
147
148 InputChannel inputChannel = (InputChannel) in.readTypedObject(InputChannel.CREATOR);
149 IInputMonitorHost host = IInputMonitorHost.Stub.asInterface(in.readStrongBinder());
150
151 this.mInputChannel = inputChannel;
152 com.android.internal.util.AnnotationValidations.validate(
153 NonNull.class, null, mInputChannel);
154 this.mHost = host;
155 com.android.internal.util.AnnotationValidations.validate(
156 NonNull.class, null, mHost);
157
158 // onConstructed(); // You can define this method to get a callback
159 }
160
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +0100161 @DataClass.Generated.Member
162 public static final @NonNull Parcelable.Creator<InputMonitor> CREATOR
163 = new Parcelable.Creator<InputMonitor>() {
164 @Override
165 public InputMonitor[] newArray(int size) {
166 return new InputMonitor[size];
167 }
168
169 @Override
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +0100170 public InputMonitor createFromParcel(Parcel in) {
Siarhei Vishniakou7480ae22019-10-15 15:18:55 -0700171 return new InputMonitor(in);
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +0100172 }
173 };
174
175 @DataClass.Generated(
Siarhei Vishniakou7480ae22019-10-15 15:18:55 -0700176 time = 1571177265149L,
177 codegenVersion = "1.0.7",
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +0100178 sourceFile = "frameworks/base/core/java/android/view/InputMonitor.java",
Siarhei Vishniakou7480ae22019-10-15 15:18:55 -0700179 inputSignatures = "private static final java.lang.String TAG\nprivate static final boolean DEBUG\nprivate final @android.annotation.NonNull android.view.InputChannel mInputChannel\nprivate final @android.annotation.NonNull android.view.IInputMonitorHost mHost\npublic void pilferPointers()\npublic void dispose()\nclass InputMonitor extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true)")
Siarhei Vishniakou29aea7f2019-09-30 20:26:59 +0100180 @Deprecated
181 private void __metadata() {}
182
Michael Wrightc7995232019-02-14 12:33:46 +0000183}