1 /* 2 * Copyright (C) 2011 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.IBinder; 21 22 /** 23 * Functions as a handle for an application that can receive input. 24 * Enables the native input dispatcher to refer indirectly to the window manager's 25 * application window token. 26 * @hide 27 */ 28 public final class InputApplicationHandle { 29 // Pointer to the native input application handle. 30 // This field is lazily initialized via JNI. 31 @SuppressWarnings("unused") 32 private long ptr; 33 34 // Application name. 35 public final @NonNull String name; 36 37 // Dispatching timeout. 38 public final long dispatchingTimeoutMillis; 39 40 public final @NonNull IBinder token; 41 nativeDispose()42 private native void nativeDispose(); 43 InputApplicationHandle(@onNull IBinder token, @NonNull String name, long dispatchingTimeoutMillis)44 public InputApplicationHandle(@NonNull IBinder token, @NonNull String name, 45 long dispatchingTimeoutMillis) { 46 this.token = token; 47 this.name = name; 48 this.dispatchingTimeoutMillis = dispatchingTimeoutMillis; 49 } 50 InputApplicationHandle(InputApplicationHandle handle)51 public InputApplicationHandle(InputApplicationHandle handle) { 52 this.token = handle.token; 53 this.dispatchingTimeoutMillis = handle.dispatchingTimeoutMillis; 54 this.name = handle.name; 55 } 56 57 @Override finalize()58 protected void finalize() throws Throwable { 59 try { 60 nativeDispose(); 61 } finally { 62 super.finalize(); 63 } 64 } 65 } 66