Michael Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 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 | |
| 17 | package android.view; |
| 18 | |
| 19 | import android.annotation.NonNull; |
| 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| 22 | import android.os.RemoteException; |
| 23 | |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 24 | import com.android.internal.util.DataClass; |
| 25 | |
Michael Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 26 | /** |
Michael Wright | ad3a6bf | 2019-04-04 14:17:09 +0100 | [diff] [blame] | 27 | * 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 Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 34 | * @hide |
| 35 | */ |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 36 | @DataClass(genToString = true) |
Michael Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 37 | public final class InputMonitor implements Parcelable { |
| 38 | private static final String TAG = "InputMonitor"; |
| 39 | |
| 40 | private static final boolean DEBUG = false; |
| 41 | |
Michael Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 42 | @NonNull |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 43 | private final InputChannel mInputChannel; |
Michael Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 44 | @NonNull |
| 45 | private final IInputMonitorHost mHost; |
| 46 | |
Michael Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 47 | |
| 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 Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 72 | mInputChannel.dispose(); |
Michael Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 73 | try { |
| 74 | mHost.dispose(); |
| 75 | } catch (RemoteException e) { |
| 76 | e.rethrowFromSystemServer(); |
| 77 | } |
| 78 | } |
| 79 | |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 80 | |
| 81 | |
Siarhei Vishniakou | 7480ae2 | 2019-10-15 15:18:55 -0700 | [diff] [blame] | 82 | // Code below generated by codegen v1.0.7. |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 83 | // |
| 84 | // DO NOT MODIFY! |
Siarhei Vishniakou | 7480ae2 | 2019-10-15 15:18:55 -0700 | [diff] [blame] | 85 | // CHECKSTYLE:OFF Generated code |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 86 | // |
| 87 | // To regenerate run: |
| 88 | // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/InputMonitor.java |
Siarhei Vishniakou | 7480ae2 | 2019-10-15 15:18:55 -0700 | [diff] [blame] | 89 | |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 90 | |
| 91 | @DataClass.Generated.Member |
| 92 | public InputMonitor( |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 93 | @NonNull InputChannel inputChannel, |
| 94 | @NonNull IInputMonitorHost host) { |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 95 | 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 Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 106 | public @NonNull InputChannel getInputChannel() { |
| 107 | return mInputChannel; |
| 108 | } |
| 109 | |
| 110 | @DataClass.Generated.Member |
| 111 | public @NonNull IInputMonitorHost getHost() { |
| 112 | return mHost; |
Michael Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | @Override |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 116 | @DataClass.Generated.Member |
Michael Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 117 | public String toString() { |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 118 | // You can override field toString logic by defining methods like: |
| 119 | // String fieldNameToString() { ... } |
| 120 | |
| 121 | return "InputMonitor { " + |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 122 | "inputChannel = " + mInputChannel + ", " + |
| 123 | "host = " + mHost + |
| 124 | " }"; |
Michael Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 125 | } |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 126 | |
| 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 Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 133 | dest.writeTypedObject(mInputChannel, flags); |
| 134 | dest.writeStrongInterface(mHost); |
| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | @DataClass.Generated.Member |
| 139 | public int describeContents() { return 0; } |
| 140 | |
Siarhei Vishniakou | 7480ae2 | 2019-10-15 15:18:55 -0700 | [diff] [blame] | 141 | /** @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 Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 161 | @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 Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 170 | public InputMonitor createFromParcel(Parcel in) { |
Siarhei Vishniakou | 7480ae2 | 2019-10-15 15:18:55 -0700 | [diff] [blame] | 171 | return new InputMonitor(in); |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 172 | } |
| 173 | }; |
| 174 | |
| 175 | @DataClass.Generated( |
Siarhei Vishniakou | 7480ae2 | 2019-10-15 15:18:55 -0700 | [diff] [blame] | 176 | time = 1571177265149L, |
| 177 | codegenVersion = "1.0.7", |
Siarhei Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 178 | sourceFile = "frameworks/base/core/java/android/view/InputMonitor.java", |
Siarhei Vishniakou | 7480ae2 | 2019-10-15 15:18:55 -0700 | [diff] [blame] | 179 | 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 Vishniakou | 29aea7f | 2019-09-30 20:26:59 +0100 | [diff] [blame] | 180 | @Deprecated |
| 181 | private void __metadata() {} |
| 182 | |
Michael Wright | c799523 | 2019-02-14 12:33:46 +0000 | [diff] [blame] | 183 | } |