1 #ifndef HIDL_GENERATED_ANDROID_HARDWARE_DRM_V1_4_ICRYPTOPLUGIN_H
2 #define HIDL_GENERATED_ANDROID_HARDWARE_DRM_V1_4_ICRYPTOPLUGIN_H
3
4 #include <android/hardware/drm/1.2/ICryptoPlugin.h>
5 #include <android/hardware/drm/1.4/types.h>
6
7 #include <android/hidl/manager/1.0/IServiceNotification.h>
8
9 #include <hidl/HidlSupport.h>
10 #include <hidl/MQDescriptor.h>
11 #include <hidl/Status.h>
12 #include <utils/NativeHandle.h>
13 #include <utils/misc.h>
14
15 namespace android {
16 namespace hardware {
17 namespace drm {
18 namespace V1_4 {
19
20 /**
21 * ICryptoPlugin is the HAL for vendor-provided crypto plugins.
22 * It allows crypto sessions to be opened and operated on, to
23 * load crypto keys for a codec to decrypt protected video content.
24 */
25 struct ICryptoPlugin : public ::android::hardware::drm::V1_2::ICryptoPlugin {
26 /**
27 * Type tag for use in template logic that indicates this is a 'pure' class.
28 */
29 typedef ::android::hardware::details::i_tag _hidl_tag;
30
31 /**
32 * Fully qualified interface name: "[email protected]::ICryptoPlugin"
33 */
34 static const char* descriptor;
35
36 /**
37 * Returns whether this object's implementation is outside of the current process.
38 */
isRemoteICryptoPlugin39 virtual bool isRemote() const override { return false; }
40
41 /**
42 * Check if the specified mime-type requires a secure decoder
43 * component.
44 *
45 * @param mime The content mime-type
46 * @return secureRequired must be true only if a secure decoder is required
47 * for the specified mime-type
48 */
49 virtual ::android::hardware::Return<bool> requiresSecureDecoderComponent(const ::android::hardware::hidl_string& mime) override = 0;
50
51 /**
52 * Notify a plugin of the currently configured resolution
53 *
54 * @param width - the display resolutions's width
55 * @param height - the display resolution's height
56 */
57 virtual ::android::hardware::Return<void> notifyResolution(uint32_t width, uint32_t height) override = 0;
58
59 /**
60 * Associate a mediadrm session with this crypto session
61 *
62 * @param sessionId the MediaDrm session ID to associate with this crypto
63 * session
64 * @return status the status of the call, status must be
65 * ERROR_DRM_SESSION_NOT_OPENED if the session is not opened, or
66 * ERROR_DRM_CANNOT_HANDLE if the operation is not supported by the drm
67 * scheme.
68 */
69 virtual ::android::hardware::Return<::android::hardware::drm::V1_0::Status> setMediaDrmSession(const ::android::hardware::hidl_vec<uint8_t>& sessionId) override = 0;
70
71 /**
72 * Set a shared memory base for subsequent decrypt operations. The buffer
73 * base is a hidl_memory which maps shared memory in the HAL module.
74 * After the shared buffer base is established, the decrypt() method
75 * receives SharedBuffer instances which specify the buffer address range
76 * for decrypt source and destination addresses.
77 *
78 * There can be multiple shared buffers per crypto plugin. The buffers
79 * are distinguished by the bufferId.
80 *
81 * @param base the base IMemory of the memory buffer identified by
82 * bufferId
83 * @param bufferId identifies the specific shared buffer for which
84 * the base is being set.
85 */
86 virtual ::android::hardware::Return<void> setSharedBufferBase(const ::android::hardware::hidl_memory& base, uint32_t bufferId) override = 0;
87
88 /**
89 * Return callback for decrypt
90 */
91 using decrypt_cb = std::function<void(::android::hardware::drm::V1_0::Status status, uint32_t bytesWritten, const ::android::hardware::hidl_string& detailedError)>;
92 /**
93 * Decrypt an array of subsamples from the source memory buffer to the
94 * destination memory buffer.
95 *
96 * @param secure a flag to indicate if a secure decoder is being used. This
97 * enables the plugin to configure buffer modes to work consistently with
98 * a secure decoder.
99 * @param the keyId for the key that should be used to do the
100 * the decryption. The keyId refers to a key in the associated
101 * MediaDrm instance.
102 * @param iv the initialization vector to use
103 * @param mode the crypto mode to use
104 * @param pattern the crypto pattern to use
105 * @param subSamples a vector of subsamples indicating the number
106 * of clear and encrypted bytes to process. This allows the decrypt
107 * call to operate on a range of subsamples in a single call
108 * @param source the input buffer for the decryption
109 * @param offset the offset of the first byte of encrypted data from
110 * the base of the source buffer
111 * @param destination the output buffer for the decryption
112 * @return status the status of the call. The status must be OK or one of
113 * the following errors: ERROR_DRM_NO_LICENSE if no license keys have been
114 * loaded, ERROR_DRM_LICENSE_EXPIRED if the license keys have expired,
115 * ERROR_DRM_RESOURCE_BUSY if the resources required to perform the
116 * decryption are not available, ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION
117 * if required output protections are not active,
118 * ERROR_DRM_SESSION_NOT_OPENED if the decrypt session is not opened,
119 * ERROR_DRM_DECRYPT if the decrypt operation fails, and
120 * ERROR_DRM_CANNOT_HANDLE in other failure cases.
121 * @return bytesWritten the number of bytes output from the decryption
122 * @return detailedError if the error is a vendor-specific error, the
123 * vendor's crypto HAL may provide a detailed error string to help
124 * describe the error.
125 */
126 virtual ::android::hardware::Return<void> decrypt(bool secure, const ::android::hardware::hidl_array<uint8_t, 16>& keyId, const ::android::hardware::hidl_array<uint8_t, 16>& iv, ::android::hardware::drm::V1_0::Mode mode, const ::android::hardware::drm::V1_0::Pattern& pattern, const ::android::hardware::hidl_vec<::android::hardware::drm::V1_0::SubSample>& subSamples, const ::android::hardware::drm::V1_0::SharedBuffer& source, uint64_t offset, const ::android::hardware::drm::V1_0::DestinationBuffer& destination, decrypt_cb _hidl_cb) override = 0;
127
128 /**
129 * Return callback for decrypt_1_2
130 */
131 using decrypt_1_2_cb = std::function<void(::android::hardware::drm::V1_2::Status status, uint32_t bytesWritten, const ::android::hardware::hidl_string& detailedError)>;
132 /**
133 * Decrypt an array of subsamples from the source memory buffer to the
134 * destination memory buffer.
135 *
136 * decrypt_1_2() only differs from decrypt() in that additional status
137 * codes must be returned.
138 *
139 * @param secure a flag to indicate if a secure decoder is being used. This
140 * enables the plugin to configure buffer modes to work consistently with
141 * a secure decoder.
142 * @param the keyId for the key that is used to do the the decryption. The
143 * keyId refers to a key in the associated MediaDrm instance.
144 * @param iv the initialization vector to use
145 * @param mode the crypto mode to use
146 * @param pattern the crypto pattern to use
147 * @param subSamples a vector of subsamples indicating the number
148 * of clear and encrypted bytes to process. This allows the decrypt
149 * call to operate on a range of subsamples in a single call
150 * @param source the input buffer for the decryption
151 * @param offset the offset of the first byte of encrypted data from
152 * the base of the source buffer
153 * @param destination the output buffer for the decryption
154 * @return status the status of the call. The status must be OK or one
155 * of the following errors:
156 * ERROR_DRM_NO_LICENSE if no license keys have been loaded
157 * ERROR_DRM_LICENSE_EXPIRED if the license keys have expired
158 * ERROR_DRM_RESOURCE_BUSY if the resources required to perform
159 * the decryption are not available
160 * ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION if required output
161 * protections are not active
162 * ERROR_DRM_INSUFFICIENT_SECURITY if the security level of the
163 * device is not sufficient to meet the requirements in
164 * the license policy
165 * ERROR_DRM_FRAME_TOO_LARGE if the frame being decrypted into
166 * the secure output buffer exceeds the size of the buffer
167 * ERROR_DRM_SESSION_NOT_OPENED if the decrypt session is not
168 * opened
169 * ERROR_DRM_DECRYPT if the decrypt operation fails
170 * ERROR_DRM_INVALID_STATE if the device is in a state where it
171 * is not able to perform decryption
172 * ERROR_DRM_CANNOT_HANDLE in other failure cases.
173 *
174 * @return bytesWritten the number of bytes output from the decryption
175 * @return detailedError if the error is a vendor-specific error, the
176 * vendor's crypto HAL may provide a detailed error string to help
177 * describe the error.
178 */
179 virtual ::android::hardware::Return<void> decrypt_1_2(bool secure, const ::android::hardware::hidl_array<uint8_t, 16>& keyId, const ::android::hardware::hidl_array<uint8_t, 16>& iv, ::android::hardware::drm::V1_0::Mode mode, const ::android::hardware::drm::V1_0::Pattern& pattern, const ::android::hardware::hidl_vec<::android::hardware::drm::V1_0::SubSample>& subSamples, const ::android::hardware::drm::V1_0::SharedBuffer& source, uint64_t offset, const ::android::hardware::drm::V1_0::DestinationBuffer& destination, decrypt_1_2_cb _hidl_cb) override = 0;
180
181 /**
182 * Return callback for getLogMessages
183 */
184 using getLogMessages_cb = std::function<void(::android::hardware::drm::V1_4::Status status, const ::android::hardware::hidl_vec<::android::hardware::drm::V1_4::LogMessage>& logMessages)>;
185 /**
186 * @return logMessages latest plugin level log messages. Can be used
187 * by apps in diagnosis of errors.
188 * @return status the status of the call. The status must be:
189 * OK on success;
190 * GENERAL_OEM_ERROR on OEM-provided, low-level component failures;
191 * GENERAL_PLUGIN_ERROR on unexpected plugin-level errors.
192 */
193 virtual ::android::hardware::Return<void> getLogMessages(getLogMessages_cb _hidl_cb) = 0;
194
195 /**
196 * Return callback for interfaceChain
197 */
198 using interfaceChain_cb = std::function<void(const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& descriptors)>;
199 /*
200 * Provides run-time type information for this object.
201 * For example, for the following interface definition:
202 * package [email protected];
203 * interface IParent {};
204 * interface IChild extends IParent {};
205 * Calling interfaceChain on an IChild object must yield the following:
206 * ["[email protected]::IChild",
207 * "[email protected]::IParent"
208 * "[email protected]::IBase"]
209 *
210 * @return descriptors a vector of descriptors of the run-time type of the
211 * object.
212 */
213 virtual ::android::hardware::Return<void> interfaceChain(interfaceChain_cb _hidl_cb) override;
214
215 /*
216 * Emit diagnostic information to the given file.
217 *
218 * Optionally overriden.
219 *
220 * @param fd File descriptor to dump data to.
221 * Must only be used for the duration of this call.
222 * @param options Arguments for debugging.
223 * Must support empty for default debug information.
224 */
225 virtual ::android::hardware::Return<void> debug(const ::android::hardware::hidl_handle& fd, const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& options) override;
226
227 /**
228 * Return callback for interfaceDescriptor
229 */
230 using interfaceDescriptor_cb = std::function<void(const ::android::hardware::hidl_string& descriptor)>;
231 /*
232 * Provides run-time type information for this object.
233 * For example, for the following interface definition:
234 * package [email protected];
235 * interface IParent {};
236 * interface IChild extends IParent {};
237 * Calling interfaceDescriptor on an IChild object must yield
238 * "[email protected]::IChild"
239 *
240 * @return descriptor a descriptor of the run-time type of the
241 * object (the first element of the vector returned by
242 * interfaceChain())
243 */
244 virtual ::android::hardware::Return<void> interfaceDescriptor(interfaceDescriptor_cb _hidl_cb) override;
245
246 /**
247 * Return callback for getHashChain
248 */
249 using getHashChain_cb = std::function<void(const ::android::hardware::hidl_vec<::android::hardware::hidl_array<uint8_t, 32>>& hashchain)>;
250 /*
251 * Returns hashes of the source HAL files that define the interfaces of the
252 * runtime type information on the object.
253 * For example, for the following interface definition:
254 * package [email protected];
255 * interface IParent {};
256 * interface IChild extends IParent {};
257 * Calling interfaceChain on an IChild object must yield the following:
258 * [(hash of IChild.hal),
259 * (hash of IParent.hal)
260 * (hash of IBase.hal)].
261 *
262 * SHA-256 is used as the hashing algorithm. Each hash has 32 bytes
263 * according to SHA-256 standard.
264 *
265 * @return hashchain a vector of SHA-1 digests
266 */
267 virtual ::android::hardware::Return<void> getHashChain(getHashChain_cb _hidl_cb) override;
268
269 /*
270 * This method trigger the interface to enable/disable instrumentation based
271 * on system property hal.instrumentation.enable.
272 */
273 virtual ::android::hardware::Return<void> setHALInstrumentation() override;
274
275 /*
276 * Registers a death recipient, to be called when the process hosting this
277 * interface dies.
278 *
279 * @param recipient a hidl_death_recipient callback object
280 * @param cookie a cookie that must be returned with the callback
281 * @return success whether the death recipient was registered successfully.
282 */
283 virtual ::android::hardware::Return<bool> linkToDeath(const ::android::sp<::android::hardware::hidl_death_recipient>& recipient, uint64_t cookie) override;
284
285 /*
286 * Provides way to determine if interface is running without requesting
287 * any functionality.
288 */
289 virtual ::android::hardware::Return<void> ping() override;
290
291 /**
292 * Return callback for getDebugInfo
293 */
294 using getDebugInfo_cb = std::function<void(const ::android::hidl::base::V1_0::DebugInfo& info)>;
295 /*
296 * Get debug information on references on this interface.
297 * @return info debugging information. See comments of DebugInfo.
298 */
299 virtual ::android::hardware::Return<void> getDebugInfo(getDebugInfo_cb _hidl_cb) override;
300
301 /*
302 * This method notifies the interface that one or more system properties
303 * have changed. The default implementation calls
304 * (C++) report_sysprop_change() in libcutils or
305 * (Java) android.os.SystemProperties.reportSyspropChanged,
306 * which in turn calls a set of registered callbacks (eg to update trace
307 * tags).
308 */
309 virtual ::android::hardware::Return<void> notifySyspropsChanged() override;
310
311 /*
312 * Unregisters the registered death recipient. If this service was registered
313 * multiple times with the same exact death recipient, this unlinks the most
314 * recently registered one.
315 *
316 * @param recipient a previously registered hidl_death_recipient callback
317 * @return success whether the death recipient was unregistered successfully.
318 */
319 virtual ::android::hardware::Return<bool> unlinkToDeath(const ::android::sp<::android::hardware::hidl_death_recipient>& recipient) override;
320
321 // cast static functions
322 /**
323 * This performs a checked cast based on what the underlying implementation actually is.
324 */
325 static ::android::hardware::Return<::android::sp<::android::hardware::drm::V1_4::ICryptoPlugin>> castFrom(const ::android::sp<::android::hardware::drm::V1_4::ICryptoPlugin>& parent, bool emitError = false);
326 /**
327 * This performs a checked cast based on what the underlying implementation actually is.
328 */
329 static ::android::hardware::Return<::android::sp<::android::hardware::drm::V1_4::ICryptoPlugin>> castFrom(const ::android::sp<::android::hardware::drm::V1_2::ICryptoPlugin>& parent, bool emitError = false);
330 /**
331 * This performs a checked cast based on what the underlying implementation actually is.
332 */
333 static ::android::hardware::Return<::android::sp<::android::hardware::drm::V1_4::ICryptoPlugin>> castFrom(const ::android::sp<::android::hardware::drm::V1_0::ICryptoPlugin>& parent, bool emitError = false);
334 /**
335 * This performs a checked cast based on what the underlying implementation actually is.
336 */
337 static ::android::hardware::Return<::android::sp<::android::hardware::drm::V1_4::ICryptoPlugin>> castFrom(const ::android::sp<::android::hidl::base::V1_0::IBase>& parent, bool emitError = false);
338
339 // helper methods for interactions with the hwservicemanager
340 /**
341 * This gets the service of this type with the specified instance name. If the
342 * service is currently not available or not in the VINTF manifest on a Trebilized
343 * device, this will return nullptr. This is useful when you don't want to block
344 * during device boot. If getStub is true, this will try to return an unwrapped
345 * passthrough implementation in the same process. This is useful when getting an
346 * implementation from the same partition/compilation group.
347 *
348 * In general, prefer getService(std::string,bool)
349 */
350 static ::android::sp<ICryptoPlugin> tryGetService(const std::string &serviceName="default", bool getStub=false);
351 /**
352 * Deprecated. See tryGetService(std::string, bool)
353 */
354 static ::android::sp<ICryptoPlugin> tryGetService(const char serviceName[], bool getStub=false) { std::string str(serviceName ? serviceName : ""); return tryGetService(str, getStub); }
355 /**
356 * Deprecated. See tryGetService(std::string, bool)
357 */
358 static ::android::sp<ICryptoPlugin> tryGetService(const ::android::hardware::hidl_string& serviceName, bool getStub=false) { std::string str(serviceName.c_str()); return tryGetService(str, getStub); }
359 /**
360 * Calls tryGetService("default", bool). This is the recommended instance name for singleton services.
361 */
tryGetServiceICryptoPlugin362 static ::android::sp<ICryptoPlugin> tryGetService(bool getStub) { return tryGetService("default", getStub); }
363 /**
364 * This gets the service of this type with the specified instance name. If the
365 * service is not in the VINTF manifest on a Trebilized device, this will return
366 * nullptr. If the service is not available, this will wait for the service to
367 * become available. If the service is a lazy service, this will start the service
368 * and return when it becomes available. If getStub is true, this will try to
369 * return an unwrapped passthrough implementation in the same process. This is
370 * useful when getting an implementation from the same partition/compilation group.
371 */
372 static ::android::sp<ICryptoPlugin> getService(const std::string &serviceName="default", bool getStub=false);
373 /**
374 * Deprecated. See getService(std::string, bool)
375 */
376 static ::android::sp<ICryptoPlugin> getService(const char serviceName[], bool getStub=false) { std::string str(serviceName ? serviceName : ""); return getService(str, getStub); }
377 /**
378 * Deprecated. See getService(std::string, bool)
379 */
380 static ::android::sp<ICryptoPlugin> getService(const ::android::hardware::hidl_string& serviceName, bool getStub=false) { std::string str(serviceName.c_str()); return getService(str, getStub); }
381 /**
382 * Calls getService("default", bool). This is the recommended instance name for singleton services.
383 */
getServiceICryptoPlugin384 static ::android::sp<ICryptoPlugin> getService(bool getStub) { return getService("default", getStub); }
385 /**
386 * Registers a service with the service manager. For Trebilized devices, the service
387 * must also be in the VINTF manifest.
388 */
389 __attribute__ ((warn_unused_result))::android::status_t registerAsService(const std::string &serviceName="default");
390 /**
391 * Registers for notifications for when a service is registered.
392 */
393 static bool registerForNotifications(
394 const std::string &serviceName,
395 const ::android::sp<::android::hidl::manager::V1_0::IServiceNotification> ¬ification);
396 };
397
398 //
399 // type declarations for package
400 //
401
402 static inline std::string toString(const ::android::sp<::android::hardware::drm::V1_4::ICryptoPlugin>& o);
403
404 //
405 // type header definitions for package
406 //
407
toString(const::android::sp<::android::hardware::drm::V1_4::ICryptoPlugin> & o)408 static inline std::string toString(const ::android::sp<::android::hardware::drm::V1_4::ICryptoPlugin>& o) {
409 std::string os = "[class or subclass of ";
410 os += ::android::hardware::drm::V1_4::ICryptoPlugin::descriptor;
411 os += "]";
412 os += o->isRemote() ? "@remote" : "@local";
413 return os;
414 }
415
416
417 } // namespace V1_4
418 } // namespace drm
419 } // namespace hardware
420 } // namespace android
421
422 //
423 // global type declarations for package
424 //
425
426
427 #endif // HIDL_GENERATED_ANDROID_HARDWARE_DRM_V1_4_ICRYPTOPLUGIN_H
428