ITokenManager.hal revision 7100c1da8dfb629b2ab56b5c7a4dcd27ed6e0c9b
1/*
2 * Copyright (C) 2016 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.hidl.token@1.0;
18
19/**
20 * This facilitates converting hidl interfaces into something that
21 * are more easily transferrable to other processes.
22 */
23interface ITokenManager {
24
25    /**
26     * Register an interface. The server must only keep a weak reference
27     * to the token. The lifetime of the token is thus linked to the
28     * lifetime of the stored interface.
29     *
30     * @param store Interface which can later be fetched with the returned token.
31     * @return token Opaque value which may be used as inputs to other functions.
32     */
33    createToken(interface store) generates (uint64_t token);
34
35    /**
36     * Explicitly unregister an interface. If the server still holds a weak reference
37     * to an interface, but that interface interface is deleted and the reference
38     * cannot be promoted, then success must be false.
39     *
40     * @param token Token recieved from createToken
41     * @return success Whether or not an interface was successfully unregistered.
42     */
43    unregister(uint64_t token) generates (bool success);
44
45    /**
46     * Fetches an interface from a provided token. This must also unregister the
47     * token.
48     *
49     * @param token Token recieved from createToken
50     * @return store Interface registered with createToken and the corresponding
51     *               token or nullptr.
52     */
53    get(uint64_t token) generates (interface store);
54};
55