drm hal aidl API cleanup

* Merge IDrmFactory / ICryptoFactory
* Simplify isContentTypeSupported / isCryptoSchemeSupported
* Remove requiresSecureDecoderDefault
* DecryptArgs
* DestinationBuffer union
* byte[16] Uuid
* KeyStatusType underscores
* setSharedBufferBase generic buffer type

Bug: 214410088
Test: VtsAidlHalDrmTargetTest
Change-Id: Ic30100af9bdb95aff9d140e093edb083c1b49592
This commit is contained in:
Robert Shih
2022-02-07 16:43:42 -08:00
parent 55a87cc169
commit fe6d6b122c
22 changed files with 180 additions and 228 deletions

View File

@@ -221,10 +221,6 @@
<hal format="aidl" optional="true">
<name>android.hardware.drm</name>
<version>1</version>
<interface>
<name>ICryptoFactory</name>
<regex-instance>.*</regex-instance>
</interface>
<interface>
<name>IDrmFactory</name>
<regex-instance>.*</regex-instance>

View File

@@ -1,39 +0,0 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.drm;
@Backing(type="int") @VintfStability
enum BufferType {
SHARED_MEMORY = 0,
NATIVE_HANDLE = 1,
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 The Android Open Source Project
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,9 @@
package android.hardware.drm;
@VintfStability
parcelable DecryptResult {
int bytesWritten;
String detailedError;
parcelable CryptoSchemes {
List<android.hardware.drm.Uuid> uuids;
android.hardware.drm.SecurityLevel minLevel;
android.hardware.drm.SecurityLevel maxLevel;
List<String> mimeTypes;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 The Android Open Source Project
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,14 @@
package android.hardware.drm;
@VintfStability
interface ICryptoFactory {
@nullable android.hardware.drm.ICryptoPlugin createPlugin(in android.hardware.drm.Uuid uuid, in byte[] initData);
boolean isCryptoSchemeSupported(in android.hardware.drm.Uuid uuid);
parcelable DecryptArgs {
boolean secure;
byte[] keyId;
byte[] iv;
android.hardware.drm.Mode mode;
android.hardware.drm.Pattern pattern;
android.hardware.drm.SubSample[] subSamples;
android.hardware.drm.SharedBuffer source;
long offset;
android.hardware.drm.DestinationBuffer destination;
}

View File

@@ -33,8 +33,7 @@
package android.hardware.drm;
@VintfStability
parcelable DestinationBuffer {
android.hardware.drm.BufferType type;
union DestinationBuffer {
android.hardware.drm.SharedBuffer nonsecureMemory;
android.hardware.common.NativeHandle secureMemory;
}

View File

@@ -34,10 +34,10 @@
package android.hardware.drm;
@VintfStability
interface ICryptoPlugin {
android.hardware.drm.DecryptResult decrypt(in boolean secure, in byte[] keyId, in byte[] iv, in android.hardware.drm.Mode mode, in android.hardware.drm.Pattern pattern, in android.hardware.drm.SubSample[] subSamples, in android.hardware.drm.SharedBuffer source, in long offset, in android.hardware.drm.DestinationBuffer destination);
int decrypt(in android.hardware.drm.DecryptArgs args);
List<android.hardware.drm.LogMessage> getLogMessages();
void notifyResolution(in int width, in int height);
boolean requiresSecureDecoderComponent(in String mime);
void setMediaDrmSession(in byte[] sessionId);
void setSharedBufferBase(in android.hardware.common.Ashmem base, in int bufferId);
void setSharedBufferBase(in android.hardware.drm.SharedBuffer base);
}

View File

@@ -34,8 +34,7 @@
package android.hardware.drm;
@VintfStability
interface IDrmFactory {
@nullable android.hardware.drm.IDrmPlugin createPlugin(in android.hardware.drm.Uuid uuid, in String appPackageName);
List<android.hardware.drm.Uuid> getSupportedCryptoSchemes();
boolean isContentTypeSupported(in String mimeType);
boolean isCryptoSchemeSupported(in android.hardware.drm.Uuid uuid, in String mimeType, in android.hardware.drm.SecurityLevel securityLevel);
@nullable android.hardware.drm.IDrmPlugin createDrmPlugin(in android.hardware.drm.Uuid uuid, in String appPackageName);
@nullable android.hardware.drm.ICryptoPlugin createCryptoPlugin(in android.hardware.drm.Uuid uuid, in byte[] initData);
android.hardware.drm.CryptoSchemes getSupportedCryptoSchemes();
}

View File

@@ -63,7 +63,6 @@ interface IDrmPlugin {
void removeOfflineLicense(in android.hardware.drm.KeySetId keySetId);
void removeSecureStop(in android.hardware.drm.SecureStopId secureStopId);
boolean requiresSecureDecoder(in String mime, in android.hardware.drm.SecurityLevel level);
boolean requiresSecureDecoderDefault(in String mime);
void restoreKeys(in byte[] sessionId, in android.hardware.drm.KeySetId keySetId);
void setCipherAlgorithm(in byte[] sessionId, in String algorithm);
void setListener(in android.hardware.drm.IDrmPluginListener listener);

View File

@@ -36,8 +36,8 @@ package android.hardware.drm;
enum KeyStatusType {
USABLE = 0,
EXPIRED = 1,
OUTPUTNOTALLOWED = 2,
STATUSPENDING = 3,
INTERNALERROR = 4,
USABLEINFUTURE = 5,
OUTPUT_NOT_ALLOWED = 2,
STATUS_PENDING = 3,
INTERNAL_ERROR = 4,
USABLE_IN_FUTURE = 5,
}

View File

@@ -37,4 +37,5 @@ parcelable SharedBuffer {
int bufferId;
long offset;
long size;
android.hardware.common.NativeHandle handle;
}

View File

@@ -34,5 +34,5 @@
package android.hardware.drm;
@VintfStability
parcelable Uuid {
byte[] uuid;
byte[16] uuid;
}

View File

@@ -1,24 +0,0 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.drm;
@VintfStability
@Backing(type="int")
enum BufferType {
SHARED_MEMORY = 0,
NATIVE_HANDLE = 1,
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 The Android Open Source Project
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,18 +16,30 @@
package android.hardware.drm;
/**
* The DecryptResult parcelable contains the result of
* ICryptoPlugin decrypt method.
*/
import android.hardware.drm.SecurityLevel;
import android.hardware.drm.Uuid;
@VintfStability
parcelable DecryptResult {
/** The number of decrypted bytes. */
int bytesWritten;
parcelable CryptoSchemes {
/**
* Vendor-specific error message if provided by the vendor's
* crypto HAL.
* Supported crypto schemes
*/
String detailedError;
List<Uuid> uuids;
/**
* Minimum supported security level (inclusive)
*/
SecurityLevel minLevel;
/**
* Maximum supported security level (inclusive)
*/
SecurityLevel maxLevel;
/**
* Supported mime types
*/
List<String> mimeTypes;
}

View File

@@ -0,0 +1,87 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.drm;
import android.hardware.drm.DestinationBuffer;
import android.hardware.drm.KeyStatusType;
import android.hardware.drm.Mode;
import android.hardware.drm.Pattern;
import android.hardware.drm.SharedBuffer;
import android.hardware.drm.SubSample;
/**
* Arguments to ICryptoPlugin decrypt
*/
@VintfStability
parcelable DecryptArgs {
/**
* A flag to indicate if a secure decoder is being used.
*
* This enables the plugin to configure buffer modes to work consistently
* with a secure decoder.
*/
boolean secure;
/**
* The keyId for the key that is used to do the decryption.
*
* The keyId refers to a key in the associated MediaDrm instance.
*/
byte[] keyId;
/**
* The initialization vector
*/
byte[] iv;
/**
* Crypto mode
*/
Mode mode;
/**
* Crypto pattern
*/
Pattern pattern;
/**
* A vector of subsamples indicating the number of clear and encrypted
* bytes to process.
*
* This allows the decrypt call to operate on a range of subsamples in a
* single call
*/
SubSample[] subSamples;
/**
* Input buffer for the decryption
*/
SharedBuffer source;
/**
* The offset of the first byte of encrypted data from the base of the
* source buffer
*/
long offset;
/**
* Output buffer for the decryption
*/
DestinationBuffer destination;
}

View File

@@ -17,29 +17,24 @@
package android.hardware.drm;
import android.hardware.common.NativeHandle;
import android.hardware.drm.BufferType;
import android.hardware.drm.SharedBuffer;
/**
* A decrypt destination buffer can be either normal user-space shared
* memory for the non-secure decrypt case, or it can be a secure buffer
* which is referenced by a native-handle. The native handle is allocated
* by the vendor's buffer allocator.
* which is referenced by a native-handle.
*
* The native handle is allocated by the vendor's buffer allocator.
*/
@VintfStability
parcelable DestinationBuffer {
union DestinationBuffer {
/**
* The type of the buffer
*/
BufferType type;
/**
* If type == SHARED_MEMORY, the decrypted data must be written
* to user-space non-secure shared memory.
* decrypted data written to user-space non-secure shared memory.
*/
SharedBuffer nonsecureMemory;
/**
* If type == NATIVE_HANDLE, the decrypted data must be written
* to secure memory referenced by the vendor's buffer allocator.
* decrypted data written to secure memory referenced by the vendor's
* buffer allocator.
*/
NativeHandle secureMemory;
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.drm;
import android.hardware.drm.Uuid;
/**
* ICryptoFactory is the main entry point for interacting with a vendor's
* crypto HAL to create crypto plugins.
* Crypto plugins create crypto sessions which are used by a codec to decrypt
* protected video content.
*/
@VintfStability
interface ICryptoFactory {
/**
* Create a crypto plugin for the specified uuid and scheme-specific
* initialization data.
*
* @param uuid uniquely identifies the drm scheme. See
* http://dashif.org/identifiers/protection for uuid assignments
*
* @param initData scheme-specific init data.
*
* @return A crypto plugin instance if successful, or null if not created.
*/
@nullable android.hardware.drm.ICryptoPlugin createPlugin(
in Uuid uuid, in byte[] initData);
/**
* Determine if a crypto scheme is supported by this HAL.
*
* @param uuid identifies the crypto scheme in question
* @return must be true only if the scheme is supported
*/
boolean isCryptoSchemeSupported(in Uuid uuid);
}

View File

@@ -17,7 +17,7 @@
package android.hardware.drm;
import android.hardware.common.Ashmem;
import android.hardware.drm.DecryptResult;
import android.hardware.drm.DecryptArgs;
import android.hardware.drm.DestinationBuffer;
import android.hardware.drm.LogMessage;
import android.hardware.drm.Mode;
@@ -38,23 +38,7 @@ interface ICryptoPlugin {
* Decrypt an array of subsamples from the source memory buffer to the
* destination memory buffer.
*
* @param secure a flag to indicate if a secure decoder is being used.
* This enables the plugin to configure buffer modes to work
* consistently with a secure decoder.
* @param the keyId for the key that is used to do the decryption. The
* keyId refers to a key in the associated MediaDrm instance.
* @param iv the initialization vector to use
* @param mode the crypto mode to use
* @param pattern the crypto pattern to use
* @param subSamples a vector of subsamples indicating the number
* of clear and encrypted bytes to process. This allows the decrypt
* call to operate on a range of subsamples in a single call
* @param source the input buffer for the decryption
* @param offset the offset of the first byte of encrypted data from
* the base of the source buffer
* @param destination the output buffer for the decryption
*
* @return DecryptResult parcelable
* @return number of decrypted bytes
* Implicit error codes:
* + ERROR_DRM_CANNOT_HANDLE in other failure cases
* + ERROR_DRM_DECRYPT if the decrypt operation fails
@@ -74,9 +58,7 @@ interface ICryptoPlugin {
* + ERROR_DRM_SESSION_NOT_OPENED if the decrypt session is not
* opened
*/
DecryptResult decrypt(in boolean secure, in byte[] keyId, in byte[] iv, in Mode mode,
in Pattern pattern, in SubSample[] subSamples, in SharedBuffer source, in long offset,
in DestinationBuffer destination);
int decrypt(in DecryptArgs args);
/**
* Get OEMCrypto or plugin error messages.
@@ -129,10 +111,8 @@ interface ICryptoPlugin {
* There can be multiple shared buffers per crypto plugin. The buffers
* are distinguished by the bufferId.
*
* @param base the base of the memory buffer identified by
* bufferId
* @param bufferId identifies the specific shared buffer for which
* the base is being set.
* @param base the base of the memory buffer abstracted by
* SharedBuffer parcelable (bufferId, size, handle)
*/
void setSharedBufferBase(in Ashmem base, in int bufferId);
void setSharedBufferBase(in SharedBuffer base);
}

View File

@@ -16,6 +16,7 @@
package android.hardware.drm;
import android.hardware.drm.CryptoSchemes;
import android.hardware.drm.SecurityLevel;
import android.hardware.drm.Uuid;
@@ -40,9 +41,23 @@ interface IDrmFactory {
* Implicit error codes:
* + ERROR_DRM_CANNOT_HANDLE if the plugin cannot be created.
*/
@nullable android.hardware.drm.IDrmPlugin createPlugin(
@nullable android.hardware.drm.IDrmPlugin createDrmPlugin(
in Uuid uuid, in String appPackageName);
/**
* Create a crypto plugin for the specified uuid and scheme-specific
* initialization data.
*
* @param uuid uniquely identifies the drm scheme. See
* http://dashif.org/identifiers/protection for uuid assignments
*
* @param initData scheme-specific init data.
*
* @return A crypto plugin instance if successful, or null if not created.
*/
@nullable android.hardware.drm.ICryptoPlugin createCryptoPlugin(
in Uuid uuid, in byte[] initData);
/**
* Return vector of uuids identifying crypto schemes supported by
* this HAL.
@@ -50,27 +65,6 @@ interface IDrmFactory {
* @return List of uuids for which isCryptoSchemeSupported is true;
* each uuid can be used as input to createPlugin.
*/
List<Uuid> getSupportedCryptoSchemes();
CryptoSchemes getSupportedCryptoSchemes();
/**
* Determine if the HAL factory is able to construct plugins that
* support a given media container format specified by mimeType
*
* @param mimeType identifies the mime type in question
*
* @return must be true only if the scheme is supported
*/
boolean isContentTypeSupported(in String mimeType);
/**
* Determine if a specific security level is supported by the device.
*
* @param uuid identifies the crypto scheme in question
* @param mimeType identifies the mime type in question
* @param securityLevel specifies the security level required
*
* @return must be true only if the scheme is supported
*/
boolean isCryptoSchemeSupported(
in Uuid uuid, in String mimeType, in SecurityLevel securityLevel);
}

View File

@@ -576,17 +576,6 @@ interface IDrmPlugin {
*/
boolean requiresSecureDecoder(in String mime, in SecurityLevel level);
/**
* Check if the specified mime-type requires a secure decoder component
* at the highest security level supported on the device.
*
* @param mime The content mime-type
*
* @return must be true if and only if a secure decoder is required
* for the specified mime-type
*/
boolean requiresSecureDecoderDefault(in String mime);
/**
* Restore persisted offline keys into a new session
*

View File

@@ -32,20 +32,20 @@ enum KeyStatusType {
* The key is not currently usable to decrypt media data because its output
* requirements cannot currently be met.
*/
OUTPUTNOTALLOWED,
OUTPUT_NOT_ALLOWED,
/**
* The status of the key is not yet known and is being determined.
*/
STATUSPENDING,
STATUS_PENDING,
/**
* The key is not currently usable to decrypt media data because of an
* internal error in processing unrelated to input parameters.
*/
INTERNALERROR,
INTERNAL_ERROR,
/**
* The key is not yet usable to decrypt media because the start
* time is in the future. The key must become usable when
* its start time is reached.
*/
USABLEINFUTURE,
USABLE_IN_FUTURE,
}

View File

@@ -16,6 +16,8 @@
package android.hardware.drm;
import android.hardware.common.NativeHandle;
/**
* SharedBuffer describes a decrypt buffer which is defined by a bufferId, an
* offset and a size. The offset is relative to the shared memory base for the
@@ -36,4 +38,8 @@ parcelable SharedBuffer {
* The size of the shared buffer in bytes
*/
long size;
/**
* Handle to shared memory
*/
NativeHandle handle;
}

View File

@@ -18,5 +18,5 @@ package android.hardware.drm;
@VintfStability
parcelable Uuid {
byte[] uuid;
byte[16] uuid;
}