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 */
16package android.hardware.cas@1.0;
17
18import android.hardware.cas@1.0::types;
19
20/**
21  * ICas is the API to control the cas system and is accessible from both
22 * Java and native level. It is used to manage sessions, provision/refresh
23 * the cas system, and process the EMM/ECM messages. It also allows bi-directional,
24 * scheme-specific communications between the client and the cas system.
25 */
26
27interface ICas {
28    /**
29     * Provide the CA private data from a CA_descriptor in the conditional
30     * access table to a CasPlugin.
31     *
32     * @param pvtData a byte array containing the private data, the format of
33     * which is scheme-specific and opaque to the framework.
34     * @return status the status of the call.
35     */
36    setPrivateData(vec<uint8_t> pvtData) generates (Status status);
37
38    /**
39     * Open a session to descramble one or more streams scrambled by the
40     * conditional access system.
41     *
42     * @return status the status of the call.
43     * @return sessionId the id of the newly opened session.
44     */
45    openSession() generates(Status status, HidlCasSessionId sessionId);
46
47    /**
48     * Close a session.
49     *
50     * @param sessionId the id of the session to be closed.
51     * @return status the status of the call.
52     */
53    closeSession(HidlCasSessionId sessionId) generates (Status status);
54
55    /**
56     * Provide the CA private data from a CA_descriptor in the program map
57     * table to a session.
58     *
59     * @param sessionId the id of the session which the private data applies to.
60     * @param pvtData a byte array containing the private data, the format of
61     * which is scheme-specific and opaque to the framework.
62     * @return status the status of the call.
63     */
64    setSessionPrivateData(HidlCasSessionId sessionId, vec<uint8_t> pvtData)
65        generates (Status status);
66
67    /**
68     * Process an ECM from the ECM stream for this session’s elementary stream.
69     *
70     * @param sessionId the id of the session which the ecm data applies to.
71     * @param ecm a byte array containing the ecm data.
72     * @return status the status of the call.
73     */
74    processEcm(HidlCasSessionId sessionId, vec<uint8_t> ecm)
75        generates (Status status);
76
77    /**
78     * Process an in-band EMM from the EMM stream.
79     *
80     * @param emm a byte array containing the emm data.
81     * @return status the status of the call.
82     */
83    processEmm(vec<uint8_t> emm) generates (Status status);
84
85    /**
86     * Send an scheme-specific event to the CasPlugin.
87     *
88     * @param event an integer denoting a scheme-specific event to be sent.
89     * @param arg a scheme-specific integer argument for the event.
90     * @param data a byte array containing scheme-specific data for the event.
91     * @return status the status of the call.
92     */
93    sendEvent(int32_t event, int32_t arg, vec<uint8_t> eventData)
94        generates (Status status);
95
96    /**
97     * Initiate a provisioning operation for a CA system.
98     *
99     * @param provisionString string containing information needed for the
100     * provisioning operation, the format of which is scheme and implementation
101     * specific.
102     * @return status the status of the call.
103     */
104    provision(string provisionString) generates (Status status);
105
106    /**
107     * Notify the CA system to refresh entitlement keys.
108     *
109     * @param refreshType the type of the refreshment.
110     * @param refreshData private data associated with the refreshment.
111     * @return status the status of the call.
112     */
113    refreshEntitlements(int32_t refreshType, vec<uint8_t> refreshData)
114        generates (Status status);
115
116    /**
117     * Release the descrambler instance.
118     *
119     * @return status the status of the call.
120     */
121    release() generates (Status status);
122};
123