1928e054931d357326613c78e62f4d850b7c442ffJeff Brown/*
2928e054931d357326613c78e62f4d850b7c442ffJeff Brown * Copyright (C) 2011 The Android Open Source Project
3928e054931d357326613c78e62f4d850b7c442ffJeff Brown *
4928e054931d357326613c78e62f4d850b7c442ffJeff Brown * Licensed under the Apache License, Version 2.0 (the "License");
5928e054931d357326613c78e62f4d850b7c442ffJeff Brown * you may not use this file except in compliance with the License.
6928e054931d357326613c78e62f4d850b7c442ffJeff Brown * You may obtain a copy of the License at
7928e054931d357326613c78e62f4d850b7c442ffJeff Brown *
8928e054931d357326613c78e62f4d850b7c442ffJeff Brown *      http://www.apache.org/licenses/LICENSE-2.0
9928e054931d357326613c78e62f4d850b7c442ffJeff Brown *
10928e054931d357326613c78e62f4d850b7c442ffJeff Brown * Unless required by applicable law or agreed to in writing, software
11928e054931d357326613c78e62f4d850b7c442ffJeff Brown * distributed under the License is distributed on an "AS IS" BASIS,
12928e054931d357326613c78e62f4d850b7c442ffJeff Brown * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13928e054931d357326613c78e62f4d850b7c442ffJeff Brown * See the License for the specific language governing permissions and
14928e054931d357326613c78e62f4d850b7c442ffJeff Brown * limitations under the License.
15928e054931d357326613c78e62f4d850b7c442ffJeff Brown */
16928e054931d357326613c78e62f4d850b7c442ffJeff Brown
174532e6158474a263d9d26c2b42240bcf7ce9b172Jeff Brownpackage com.android.server.input;
18928e054931d357326613c78e62f4d850b7c442ffJeff Brown
19928e054931d357326613c78e62f4d850b7c442ffJeff Brown/**
20928e054931d357326613c78e62f4d850b7c442ffJeff Brown * Functions as a handle for an application that can receive input.
21928e054931d357326613c78e62f4d850b7c442ffJeff Brown * Enables the native input dispatcher to refer indirectly to the window manager's
22928e054931d357326613c78e62f4d850b7c442ffJeff Brown * application window token.
23928e054931d357326613c78e62f4d850b7c442ffJeff Brown * @hide
24928e054931d357326613c78e62f4d850b7c442ffJeff Brown */
25928e054931d357326613c78e62f4d850b7c442ffJeff Brownpublic final class InputApplicationHandle {
26928e054931d357326613c78e62f4d850b7c442ffJeff Brown    // Pointer to the native input application handle.
27928e054931d357326613c78e62f4d850b7c442ffJeff Brown    // This field is lazily initialized via JNI.
28928e054931d357326613c78e62f4d850b7c442ffJeff Brown    @SuppressWarnings("unused")
29928e054931d357326613c78e62f4d850b7c442ffJeff Brown    private int ptr;
30928e054931d357326613c78e62f4d850b7c442ffJeff Brown
31928e054931d357326613c78e62f4d850b7c442ffJeff Brown    // The window manager's application window token.
324532e6158474a263d9d26c2b42240bcf7ce9b172Jeff Brown    public final Object appWindowToken;
33928e054931d357326613c78e62f4d850b7c442ffJeff Brown
349302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown    // Application name.
359302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown    public String name;
369302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown
379302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown    // Dispatching timeout.
389302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown    public long dispatchingTimeoutNanos;
399302c8796fc4dcda08d4bd1e11733848fd4fafafJeff Brown
40928e054931d357326613c78e62f4d850b7c442ffJeff Brown    private native void nativeDispose();
41928e054931d357326613c78e62f4d850b7c442ffJeff Brown
424532e6158474a263d9d26c2b42240bcf7ce9b172Jeff Brown    public InputApplicationHandle(Object appWindowToken) {
43928e054931d357326613c78e62f4d850b7c442ffJeff Brown        this.appWindowToken = appWindowToken;
44928e054931d357326613c78e62f4d850b7c442ffJeff Brown    }
45928e054931d357326613c78e62f4d850b7c442ffJeff Brown
46928e054931d357326613c78e62f4d850b7c442ffJeff Brown    @Override
47928e054931d357326613c78e62f4d850b7c442ffJeff Brown    protected void finalize() throws Throwable {
48cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown        try {
49cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown            nativeDispose();
50cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown        } finally {
51cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown            super.finalize();
52cc4f7db698f88b633a286d8ab1105b28a474cd09Jeff Brown        }
53928e054931d357326613c78e62f4d850b7c442ffJeff Brown    }
54928e054931d357326613c78e62f4d850b7c442ffJeff Brown}
55