1*4d7e907cSAndroid Build Coastguard Worker/** 2*4d7e907cSAndroid Build Coastguard Worker * Copyright (C) 2018 The Android Open Source Project 3*4d7e907cSAndroid Build Coastguard Worker * 4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*4d7e907cSAndroid Build Coastguard Worker * 8*4d7e907cSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*4d7e907cSAndroid Build Coastguard Worker * 10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License. 15*4d7e907cSAndroid Build Coastguard Worker */ 16*4d7e907cSAndroid Build Coastguard Workerpackage [email protected]; 17*4d7e907cSAndroid Build Coastguard Worker 18*4d7e907cSAndroid Build Coastguard Workerimport @1.0::KeyedVector; 19*4d7e907cSAndroid Build Coastguard Workerimport @1.0::KeyType; 20*4d7e907cSAndroid Build Coastguard Workerimport @1.0::SessionId; 21*4d7e907cSAndroid Build Coastguard Workerimport @1.0::Status; 22*4d7e907cSAndroid Build Coastguard Workerimport @1.1::IDrmPlugin; 23*4d7e907cSAndroid Build Coastguard Workerimport @1.1::KeyRequestType; 24*4d7e907cSAndroid Build Coastguard Workerimport @1.2::IDrmPluginListener; 25*4d7e907cSAndroid Build Coastguard Worker 26*4d7e907cSAndroid Build Coastguard Worker/** 27*4d7e907cSAndroid Build Coastguard Worker * IDrmPlugin is used to interact with a specific drm plugin that was 28*4d7e907cSAndroid Build Coastguard Worker * created by IDrm::createPlugin. A drm plugin provides methods for 29*4d7e907cSAndroid Build Coastguard Worker * obtaining drm keys to be used by a codec to decrypt protected video 30*4d7e907cSAndroid Build Coastguard Worker * content. 31*4d7e907cSAndroid Build Coastguard Worker */ 32*4d7e907cSAndroid Build Coastguard Workerinterface IDrmPlugin extends @1.1::IDrmPlugin { 33*4d7e907cSAndroid Build Coastguard Worker 34*4d7e907cSAndroid Build Coastguard Worker /** 35*4d7e907cSAndroid Build Coastguard Worker * The keys in an offline license allow protected content to be 36*4d7e907cSAndroid Build Coastguard Worker * played even if the device is not connected to a network. 37*4d7e907cSAndroid Build Coastguard Worker * Offline licenses are stored on the device after a key 38*4d7e907cSAndroid Build Coastguard Worker * request/response exchange when the key request KeyType is 39*4d7e907cSAndroid Build Coastguard Worker * OFFLINE. Normally each app is responsible for keeping track of 40*4d7e907cSAndroid Build Coastguard Worker * the KeySetIds it has created. In some situations however, it 41*4d7e907cSAndroid Build Coastguard Worker * will be necessary to request the list of stored offline license 42*4d7e907cSAndroid Build Coastguard Worker * KeySetIds. If an app loses the KeySetId for any stored licenses 43*4d7e907cSAndroid Build Coastguard Worker * that it created, for example, it must be able to recover the 44*4d7e907cSAndroid Build Coastguard Worker * stored KeySetIds so those licenses will be removed when they 45*4d7e907cSAndroid Build Coastguard Worker * expire or when the app is uninstalled. 46*4d7e907cSAndroid Build Coastguard Worker * <p> 47*4d7e907cSAndroid Build Coastguard Worker * This method returns a list of the KeySetIds for all offline 48*4d7e907cSAndroid Build Coastguard Worker * licenses. The offline license KeySetId allows an app to query 49*4d7e907cSAndroid Build Coastguard Worker * the status of an offline license or remove it. 50*4d7e907cSAndroid Build Coastguard Worker * 51*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. Must be OK or 52*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the HAL is in a state where the 53*4d7e907cSAndroid Build Coastguard Worker * KeySetIds can't be returned. 54*4d7e907cSAndroid Build Coastguard Worker * @return a list of offline license keySetIds. If there are no offline 55*4d7e907cSAndroid Build Coastguard Worker * licenses, the list must be empty and OK must be returned as the 56*4d7e907cSAndroid Build Coastguard Worker * status. 57*4d7e907cSAndroid Build Coastguard Worker */ 58*4d7e907cSAndroid Build Coastguard Worker getOfflineLicenseKeySetIds() generates (@1.0::Status status, 59*4d7e907cSAndroid Build Coastguard Worker vec<KeySetId> keySetIds); 60*4d7e907cSAndroid Build Coastguard Worker 61*4d7e907cSAndroid Build Coastguard Worker /** 62*4d7e907cSAndroid Build Coastguard Worker * Normally offline licenses are released using a key 63*4d7e907cSAndroid Build Coastguard Worker * request/response exchange using getKeyRequest where the KeyType 64*4d7e907cSAndroid Build Coastguard Worker * is RELEASE, followed by provideKeyResponse. This allows the 65*4d7e907cSAndroid Build Coastguard Worker * server to cryptographically confirm that the license has been 66*4d7e907cSAndroid Build Coastguard Worker * removed and then adjust the count of offline licenses allocated 67*4d7e907cSAndroid Build Coastguard Worker * to the device. 68*4d7e907cSAndroid Build Coastguard Worker * <p> 69*4d7e907cSAndroid Build Coastguard Worker * In some exceptional situations it will be necessary to directly 70*4d7e907cSAndroid Build Coastguard Worker * remove offline licenses without notifying the server, which is 71*4d7e907cSAndroid Build Coastguard Worker * performed by this method. 72*4d7e907cSAndroid Build Coastguard Worker * 73*4d7e907cSAndroid Build Coastguard Worker * @param keySetId the id of the offline license to remove 74*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. Must be one of OK on 75*4d7e907cSAndroid Build Coastguard Worker * success, BAD_VALUE if the license is not found or 76*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the HAL is in a state where the 77*4d7e907cSAndroid Build Coastguard Worker * KeySetIds can't be removed. 78*4d7e907cSAndroid Build Coastguard Worker */ 79*4d7e907cSAndroid Build Coastguard Worker removeOfflineLicense(KeySetId keySetId) generates (@1.0::Status status); 80*4d7e907cSAndroid Build Coastguard Worker 81*4d7e907cSAndroid Build Coastguard Worker /** 82*4d7e907cSAndroid Build Coastguard Worker * Request the state of an offline license. An offline license must 83*4d7e907cSAndroid Build Coastguard Worker * be usable or inactive. The keys in a usable offline license are 84*4d7e907cSAndroid Build Coastguard Worker * available for decryption. When the offline license state is 85*4d7e907cSAndroid Build Coastguard Worker * inactive, the keys have been marked for release using 86*4d7e907cSAndroid Build Coastguard Worker * getKeyRequest with KeyType RELEASE but the key response has not 87*4d7e907cSAndroid Build Coastguard Worker * been received. The keys in an inactive offline license are not 88*4d7e907cSAndroid Build Coastguard Worker * usable for decryption. 89*4d7e907cSAndroid Build Coastguard Worker * 90*4d7e907cSAndroid Build Coastguard Worker * @param keySetId the id of the offline license 91*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. Must be one of OK on 92*4d7e907cSAndroid Build Coastguard Worker * success, BAD_VALUE if the license is not found or 93*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the HAL is in a state where the 94*4d7e907cSAndroid Build Coastguard Worker * offline license state can't be queried. 95*4d7e907cSAndroid Build Coastguard Worker * @return the offline license state, one of USABLE or INACTIVE. 96*4d7e907cSAndroid Build Coastguard Worker * If the return status is not OK then state must be set to 97*4d7e907cSAndroid Build Coastguard Worker * UNKNOWN. 98*4d7e907cSAndroid Build Coastguard Worker */ 99*4d7e907cSAndroid Build Coastguard Worker getOfflineLicenseState(KeySetId keySetId) generates ( 100*4d7e907cSAndroid Build Coastguard Worker @1.0::Status status, OfflineLicenseState state); 101*4d7e907cSAndroid Build Coastguard Worker 102*4d7e907cSAndroid Build Coastguard Worker /** 103*4d7e907cSAndroid Build Coastguard Worker * A key request/response exchange occurs between the app and a License 104*4d7e907cSAndroid Build Coastguard Worker * Server to obtain the keys required to decrypt the content. 105*4d7e907cSAndroid Build Coastguard Worker * getKeyRequest_1_2() is used to obtain an opaque key request blob that is 106*4d7e907cSAndroid Build Coastguard Worker * delivered to the license server. 107*4d7e907cSAndroid Build Coastguard Worker * 108*4d7e907cSAndroid Build Coastguard Worker * getKeyRequest_1_2() only differs from getKeyRequest_1_1() in that 109*4d7e907cSAndroid Build Coastguard Worker * additional status codes must be returned. 110*4d7e907cSAndroid Build Coastguard Worker * 111*4d7e907cSAndroid Build Coastguard Worker * @param scope either a sessionId or a keySetId, depending on the 112*4d7e907cSAndroid Build Coastguard Worker * specified keyType. When the keyType is OFFLINE or STREAMING, scope 113*4d7e907cSAndroid Build Coastguard Worker * must be set to the sessionId the keys will be provided to. When the 114*4d7e907cSAndroid Build Coastguard Worker * keyType is RELEASE, scope must be set to the keySetId of the keys 115*4d7e907cSAndroid Build Coastguard Worker * being released. 116*4d7e907cSAndroid Build Coastguard Worker * @param initData container-specific data, its meaning is interpreted 117*4d7e907cSAndroid Build Coastguard Worker * based on the mime type provided in the mimeType parameter. It could 118*4d7e907cSAndroid Build Coastguard Worker * contain, for example, the content ID, key ID or other data obtained 119*4d7e907cSAndroid Build Coastguard Worker * from the content metadata that is required to generate the key 120*4d7e907cSAndroid Build Coastguard Worker * request. initData must be empty when keyType is RELEASE. 121*4d7e907cSAndroid Build Coastguard Worker * @param mimeType identifies the mime type of the content 122*4d7e907cSAndroid Build Coastguard Worker * @param keyType specifies if the keys are to be used for streaming, 123*4d7e907cSAndroid Build Coastguard Worker * offline or a release 124*4d7e907cSAndroid Build Coastguard Worker * @param optionalParameters included in the key request message to 125*4d7e907cSAndroid Build Coastguard Worker * allow a client application to provide additional message parameters 126*4d7e907cSAndroid Build Coastguard Worker * to the server. 127*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or one of 128*4d7e907cSAndroid Build Coastguard Worker * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session is 129*4d7e907cSAndroid Build Coastguard Worker * not opened, ERROR_DRM_NOT_PROVISIONED if the device requires 130*4d7e907cSAndroid Build Coastguard Worker * provisioning before it is able to generate a key request, 131*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_RESOURCE_CONTENTION if client applications using the hal 132*4d7e907cSAndroid Build Coastguard Worker * are temporarily exceeding the available crypto resources such that a 133*4d7e907cSAndroid Build Coastguard Worker * retry of the operation is likely to succeed, ERROR_DRM_CANNOT_HANDLE 134*4d7e907cSAndroid Build Coastguard Worker * if getKeyRequest is not supported at the time of the call, BAD_VALUE 135*4d7e907cSAndroid Build Coastguard Worker * if any parameters are invalid or ERROR_DRM_INVALID_STATE if the HAL 136*4d7e907cSAndroid Build Coastguard Worker * is in a state where a key request cannot be generated. 137*4d7e907cSAndroid Build Coastguard Worker * @return request if successful, the opaque key request blob is returned 138*4d7e907cSAndroid Build Coastguard Worker * @return requestType indicates type information about the returned 139*4d7e907cSAndroid Build Coastguard Worker * request. The type must be one of INITIAL, RENEWAL, RELEASE, NONE or 140*4d7e907cSAndroid Build Coastguard Worker * UPDATE. An INITIAL request is the first key request for a 141*4d7e907cSAndroid Build Coastguard Worker * license. RENEWAL is a subsequent key request used to refresh the 142*4d7e907cSAndroid Build Coastguard Worker * keys in a license. RELEASE corresponds to a keyType of RELEASE, 143*4d7e907cSAndroid Build Coastguard Worker * which indicates keys are being released. NONE indicates that no 144*4d7e907cSAndroid Build Coastguard Worker * request is needed because the keys are already loaded. UPDATE 145*4d7e907cSAndroid Build Coastguard Worker * indicates that the keys need to be refetched after the initial 146*4d7e907cSAndroid Build Coastguard Worker * license request. 147*4d7e907cSAndroid Build Coastguard Worker * @return defaultUrl the URL that the request may be sent to, if 148*4d7e907cSAndroid Build Coastguard Worker * provided by the drm HAL. The app can choose to override this URL. 149*4d7e907cSAndroid Build Coastguard Worker */ 150*4d7e907cSAndroid Build Coastguard Worker getKeyRequest_1_2(vec<uint8_t> scope, vec<uint8_t> initData, 151*4d7e907cSAndroid Build Coastguard Worker string mimeType, KeyType keyType, KeyedVector optionalParameters) 152*4d7e907cSAndroid Build Coastguard Worker generates (Status status, vec<uint8_t> request, 153*4d7e907cSAndroid Build Coastguard Worker KeyRequestType requestType, string defaultUrl); 154*4d7e907cSAndroid Build Coastguard Worker 155*4d7e907cSAndroid Build Coastguard Worker /** 156*4d7e907cSAndroid Build Coastguard Worker * A provision request/response exchange occurs between the app and a 157*4d7e907cSAndroid Build Coastguard Worker * provisioning server to retrieve a device certificate. getProvisionRequest 158*4d7e907cSAndroid Build Coastguard Worker * is used to obtain an opaque provisioning request blob that is delivered 159*4d7e907cSAndroid Build Coastguard Worker * to the provisioning server. 160*4d7e907cSAndroid Build Coastguard Worker * 161*4d7e907cSAndroid Build Coastguard Worker * getProvisionRequest_1_2() only differs from getProvisionRequest_1_0() in 162*4d7e907cSAndroid Build Coastguard Worker * that additional status codes must be returned. 163*4d7e907cSAndroid Build Coastguard Worker * 164*4d7e907cSAndroid Build Coastguard Worker * @param certificateType the type of certificate requested, e.g. "X.509" 165*4d7e907cSAndroid Build Coastguard Worker * @param certificateAuthority identifies the certificate authority. A 166*4d7e907cSAndroid Build Coastguard Worker * certificate authority (CA) is an entity which issues digital 167*4d7e907cSAndroid Build Coastguard Worker * certificates for use by other parties. It is an example of a trusted 168*4d7e907cSAndroid Build Coastguard Worker * third party. 169*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or one of 170*4d7e907cSAndroid Build Coastguard Worker * the following errors: ERROR_DRM_RESOURCE_CONTENTION if client 171*4d7e907cSAndroid Build Coastguard Worker * applications using the hal are temporarily exceeding the available 172*4d7e907cSAndroid Build Coastguard Worker * crypto resources such that a retry of the operation is likely to 173*4d7e907cSAndroid Build Coastguard Worker * succeed, ERROR_DRM_CANNOT_HANDLE if the drm scheme does not require 174*4d7e907cSAndroid Build Coastguard Worker * provisioning or ERROR_DRM_INVALID_STATE if the HAL is in a state 175*4d7e907cSAndroid Build Coastguard Worker * where the provision request cannot be generated. 176*4d7e907cSAndroid Build Coastguard Worker * @return request if successful the opaque certificate request blob 177*4d7e907cSAndroid Build Coastguard Worker * is returned 178*4d7e907cSAndroid Build Coastguard Worker * @return defaultUrl URL that the provisioning request may be 179*4d7e907cSAndroid Build Coastguard Worker * sent to, if known by the HAL implementation. An app can choose to 180*4d7e907cSAndroid Build Coastguard Worker * override this URL. If the HAL implementation does not provide a 181*4d7e907cSAndroid Build Coastguard Worker * defaultUrl, the returned string must be empty. 182*4d7e907cSAndroid Build Coastguard Worker */ 183*4d7e907cSAndroid Build Coastguard Worker getProvisionRequest_1_2(string certificateType, string certificateAuthority) 184*4d7e907cSAndroid Build Coastguard Worker generates (Status status, vec<uint8_t> request, string defaultUrl); 185*4d7e907cSAndroid Build Coastguard Worker 186*4d7e907cSAndroid Build Coastguard Worker /** 187*4d7e907cSAndroid Build Coastguard Worker * Return the currently negotiated and max supported HDCP levels. 188*4d7e907cSAndroid Build Coastguard Worker * 189*4d7e907cSAndroid Build Coastguard Worker * This method only differs from @1.1 version by the addition of 190*4d7e907cSAndroid Build Coastguard Worker * support for HDCP 2.3. 191*4d7e907cSAndroid Build Coastguard Worker * 192*4d7e907cSAndroid Build Coastguard Worker * The current level is based on the display(s) the device is connected to. 193*4d7e907cSAndroid Build Coastguard Worker * If multiple HDCP-capable displays are simultaneously connected to 194*4d7e907cSAndroid Build Coastguard Worker * separate interfaces, this method returns the lowest negotiated HDCP level 195*4d7e907cSAndroid Build Coastguard Worker * of all interfaces. 196*4d7e907cSAndroid Build Coastguard Worker * 197*4d7e907cSAndroid Build Coastguard Worker * The maximum HDCP level is the highest level that can potentially be 198*4d7e907cSAndroid Build Coastguard Worker * negotiated. It is a constant for any device, i.e. it does not depend on 199*4d7e907cSAndroid Build Coastguard Worker * downstream receiving devices that could be connected. For example, if 200*4d7e907cSAndroid Build Coastguard Worker * the device has HDCP 1.x keys and is capable of negotiating HDCP 1.x, but 201*4d7e907cSAndroid Build Coastguard Worker * does not have HDCP 2.x keys, then the maximum HDCP capability would be 202*4d7e907cSAndroid Build Coastguard Worker * reported as 1.x. If multiple HDCP-capable interfaces are present, it 203*4d7e907cSAndroid Build Coastguard Worker * indicates the highest of the maximum HDCP levels of all interfaces. 204*4d7e907cSAndroid Build Coastguard Worker * 205*4d7e907cSAndroid Build Coastguard Worker * This method should only be used for informational purposes, not for 206*4d7e907cSAndroid Build Coastguard Worker * enforcing compliance with HDCP requirements. Trusted enforcement of HDCP 207*4d7e907cSAndroid Build Coastguard Worker * policies must be handled by the DRM system. 208*4d7e907cSAndroid Build Coastguard Worker * 209*4d7e907cSAndroid Build Coastguard Worker * @return status the status of the call. The status must be OK or 210*4d7e907cSAndroid Build Coastguard Worker * ERROR_DRM_INVALID_STATE if the HAL is in a state where the HDCP 211*4d7e907cSAndroid Build Coastguard Worker * level cannot be queried. 212*4d7e907cSAndroid Build Coastguard Worker * @return connectedLevel the lowest HDCP level for any connected 213*4d7e907cSAndroid Build Coastguard Worker * displays 214*4d7e907cSAndroid Build Coastguard Worker * @return maxLevel the highest HDCP level that can be supported 215*4d7e907cSAndroid Build Coastguard Worker * by the device 216*4d7e907cSAndroid Build Coastguard Worker */ 217*4d7e907cSAndroid Build Coastguard Worker getHdcpLevels_1_2() generates (Status status, HdcpLevel connectedLevel, 218*4d7e907cSAndroid Build Coastguard Worker HdcpLevel maxLevel); 219*4d7e907cSAndroid Build Coastguard Worker 220*4d7e907cSAndroid Build Coastguard Worker /** 221*4d7e907cSAndroid Build Coastguard Worker * Send a session lost state event to the listener. This event 222*4d7e907cSAndroid Build Coastguard Worker * indicates that a session's state has become invalid because the 223*4d7e907cSAndroid Build Coastguard Worker * device crypto hardware is incapable of retaining crypto session 224*4d7e907cSAndroid Build Coastguard Worker * state across suspend and resume cycles. 225*4d7e907cSAndroid Build Coastguard Worker * 226*4d7e907cSAndroid Build Coastguard Worker * @param sessionId identifies the session the event originated from 227*4d7e907cSAndroid Build Coastguard Worker */ 228*4d7e907cSAndroid Build Coastguard Worker sendSessionLostState(SessionId sessionId); 229*4d7e907cSAndroid Build Coastguard Worker 230*4d7e907cSAndroid Build Coastguard Worker /** 231*4d7e907cSAndroid Build Coastguard Worker * Send a keys change event to the listener. The keys change event 232*4d7e907cSAndroid Build Coastguard Worker * indicates the status of each key in the session. Keys can be 233*4d7e907cSAndroid Build Coastguard Worker * indicated as being usable, expired, outputnotallowed or statuspending. 234*4d7e907cSAndroid Build Coastguard Worker * 235*4d7e907cSAndroid Build Coastguard Worker * This method only differs from @1.0 version by the addition of new 236*4d7e907cSAndroid Build Coastguard Worker * KeyStatusType(s) in keyStatusList. 237*4d7e907cSAndroid Build Coastguard Worker * 238*4d7e907cSAndroid Build Coastguard Worker * @param sessionId identifies the session the event originated from 239*4d7e907cSAndroid Build Coastguard Worker * @param keyStatusList indicates the status for each key ID in the 240*4d7e907cSAndroid Build Coastguard Worker * session. 241*4d7e907cSAndroid Build Coastguard Worker * @param hasNewUsableKey indicates if the event includes at least one 242*4d7e907cSAndroid Build Coastguard Worker * key that has become usable. 243*4d7e907cSAndroid Build Coastguard Worker */ 244*4d7e907cSAndroid Build Coastguard Worker sendKeysChange_1_2(SessionId sessionId, vec<KeyStatus> keyStatusList, 245*4d7e907cSAndroid Build Coastguard Worker bool hasNewUsableKey); 246*4d7e907cSAndroid Build Coastguard Worker 247*4d7e907cSAndroid Build Coastguard Worker}; 248