1/*
2 * Copyright (C) 2017, 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 * Copyright (c) 2015-2017, The Linux Foundation.
18 */
19/*
20 * Contributed by: Giesecke & Devrient GmbH.
21 */
22
23package android.se.omapi;
24
25import android.se.omapi.ISecureElementChannel;
26import android.se.omapi.ISecureElementReader;
27import android.se.omapi.ISecureElementListener;
28
29/** @hide */
30interface ISecureElementSession {
31
32    /**
33     * Returns the ATR of the connected card or null if the ATR is not available
34     */
35    byte[] getAtr();
36
37    /**
38     * Close the connection with the Secure Element. This will close any
39     * channels opened by this application with this Secure Element.
40     */
41    void close();
42
43    /**
44     * Close any channel opened on this session.
45     */
46    void closeChannels();
47
48
49    /**
50     * Tells if this session is closed.
51     *
52     * @return <code>true</code> if the session is closed, false otherwise.
53     */
54    boolean isClosed();
55
56    /**
57     * Opens a connection using the basic channel of the card in the
58     * specified reader and returns a channel handle. Selects the specified
59     * applet if aid != null.
60     * Logical channels cannot be opened with this connection.
61     * Use interface method openLogicalChannel() to open a logical channel.
62     */
63    ISecureElementChannel openBasicChannel(in byte[] aid, in byte p2,
64            ISecureElementListener listener);
65
66    /**
67     * Opens a connection using the next free logical channel of the card in the
68     * specified reader. Selects the specified applet.
69     * Selection of other applets with this connection is not supported.
70     */
71    ISecureElementChannel openLogicalChannel(in byte[] aid, in byte p2,
72            ISecureElementListener listener);
73}
74