Create drm 1.1 HAL
New methods are for querying HDCP, security levels and
number of sessions
bug:64001680
bug:33657579
Change-Id: Idb3d66a805ac530221536058614e0df8460e627b
diff --git a/drm/1.1/Android.bp b/drm/1.1/Android.bp
new file mode 100644
index 0000000..c895af6
--- /dev/null
+++ b/drm/1.1/Android.bp
@@ -0,0 +1,25 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+ name: "android.hardware.drm@1.1",
+ root: "android.hardware",
+ vndk: {
+ enabled: true,
+ },
+ srcs: [
+ "types.hal",
+ "ICryptoFactory.hal",
+ "IDrmFactory.hal",
+ "IDrmPlugin.hal",
+ ],
+ interfaces: [
+ "android.hardware.drm@1.0",
+ "android.hidl.base@1.0",
+ ],
+ types: [
+ "HdcpLevel",
+ "SecurityLevel",
+ ],
+ gen_java: false,
+}
+
diff --git a/drm/1.1/ICryptoFactory.hal b/drm/1.1/ICryptoFactory.hal
new file mode 100644
index 0000000..a1a7480
--- /dev/null
+++ b/drm/1.1/ICryptoFactory.hal
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 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@1.1;
+
+import @1.0::ICryptoFactory;
+import @1.0::ICryptoPlugin;
+
+/**
+ * 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.
+ *
+ * The 1.1 factory must always create 1.1 ICryptoPlugin interfaces, which are
+ * returned via the 1.0 createPlugin method.
+ *
+ * To use 1.1 features the caller must cast the returned interface to a
+ * 1.1 HAL, using V1_1::ICryptoPlugin::castFrom().
+ */
+interface ICryptoFactory extends @1.0::ICryptoFactory {
+};
diff --git a/drm/1.1/IDrmFactory.hal b/drm/1.1/IDrmFactory.hal
new file mode 100644
index 0000000..b6d6bfb
--- /dev/null
+++ b/drm/1.1/IDrmFactory.hal
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 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@1.1;
+
+import @1.0::IDrmFactory;
+import @1.0::IDrmPlugin;
+
+/**
+ * IDrmFactory is the main entry point for interacting with a vendor's
+ * drm HAL to create drm plugin instances. A drm plugin instance
+ * creates drm sessions which are used to obtain keys for a crypto
+ * session so it can decrypt protected video content.
+ *
+ * The 1.1 factory must always create 1.1 IDrmPlugin interfaces, which are
+ * returned via the 1.0 createPlugin method.
+ *
+ * To use 1.1 features the caller must cast the returned interface to a
+ * 1.1 HAL, using V1_1::IDrmPlugin::castFrom().
+ */
+
+interface IDrmFactory extends @1.0::IDrmFactory {
+};
diff --git a/drm/1.1/IDrmPlugin.hal b/drm/1.1/IDrmPlugin.hal
new file mode 100644
index 0000000..0660a43
--- /dev/null
+++ b/drm/1.1/IDrmPlugin.hal
@@ -0,0 +1,109 @@
+/**
+ * Copyright (C) 2017 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@1.1;
+
+import @1.0::IDrmPlugin;
+import @1.0::IDrmPluginListener;
+import @1.0::Status;
+import @1.1::HdcpLevel;
+import @1.1::SecurityLevel;
+
+/**
+ * IDrmPlugin is used to interact with a specific drm plugin that was created by
+ * IDrm::createPlugin. A drm plugin provides methods for obtaining drm keys that
+ * may be used by a codec to decrypt protected video content.
+ */
+interface IDrmPlugin extends @1.0::IDrmPlugin {
+ /**
+ * Return the currently negotiated and max supported HDCP levels.
+ *
+ * The current level is based on the display(s) the device is connected to.
+ * If multiple HDCP-capable displays are simultaneously connected to
+ * separate interfaces, this method returns the lowest negotiated HDCP level
+ * of all interfaces.
+ *
+ * The maximum HDCP level is the highest level that can potentially be
+ * negotiated. It is a constant for any device, i.e. it does not depend on
+ * downstream receiving devices that could be connected. For example, if
+ * the device has HDCP 1.x keys and is capable of negotiating HDCP 1.x, but
+ * does not have HDCP 2.x keys, then the maximum HDCP capability would be
+ * reported as 1.x. If multiple HDCP-capable interfaces are present, it
+ * indicates the highest of the maximum HDCP levels of all interfaces.
+ *
+ * This method should only be used for informational purposes, not for
+ * enforcing compliance with HDCP requirements. Trusted enforcement of HDCP
+ * policies must be handled by the DRM system.
+ *
+ * @return status the status of the call. The status must be OK or
+ * ERROR_DRM_INVALID_STATE if the HAL is in a state where the HDCP
+ * level cannot be queried.
+ * @return connectedLevel the lowest HDCP level for any connected
+ * displays
+ * @return maxLevel the highest HDCP level that can be supported
+ * by the device
+ */
+ getHdcpLevels() generates (Status status, HdcpLevel connectedLevel,
+ HdcpLevel maxLevel);
+
+ /**
+ * Return the current number of open sessions and the maximum number of
+ * sessions that may be opened simultaneosly among all DRM instances for the
+ * active DRM scheme.
+ *
+ * @return status the status of the call. The status must be OK or
+ * ERROR_DRM_INVALID_STATE if the HAL is in a state where number of
+ * sessions cannot be queried.
+ * @return currentSessions the number of currently opened sessions
+ * @return maxSessions the maximum number of sessions that the device
+ * can support
+ */
+ getNumberOfSessions() generates (Status status, uint32_t currentSessions,
+ uint32_t maxSessions);
+
+ /**
+ * Return the current security level of a session. A session has an initial
+ * security level determined by the robustness of the DRM system's
+ * implementation on the device.
+ *
+ * @param sessionId the session id the call applies to
+ * @return status the status of the call. The status must be OK or one of
+ * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the
+ * session is not opened, BAD_VALUE if the sessionId is invalid or
+ * ERROR_DRM_INVALID_STATE if the HAL is in a state where the
+ * security level cannot be queried.
+ * @return level the current security level for the session
+ */
+ getSecurityLevel(vec<uint8_t> sessionId) generates(Status status,
+ SecurityLevel level);
+
+ /**
+ * Set the security level of a session. This can be useful if specific
+ * attributes of a lower security level are needed by an application, such
+ * as image manipulation or compositing which requires non-secure decoded
+ * frames. Reducing the security level may limit decryption to lower content
+ * resolutions, depending on the license policy.
+ *
+ * @param sessionId the session id the call applies to
+ * @param level the requested security level
+ * @return status the status of the call. The status must be OK or one of
+ * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the session
+ * is not opened, BAD_VALUE if the sessionId or security level is
+ * invalid or ERROR_DRM_INVALID_STATE if the HAL is in a state where
+ * the security level cannot be set.
+ */
+ setSecurityLevel(vec<uint8_t> sessionId, SecurityLevel level)
+ generates(Status status);
+};
diff --git a/drm/1.1/types.hal b/drm/1.1/types.hal
new file mode 100644
index 0000000..9447524
--- /dev/null
+++ b/drm/1.1/types.hal
@@ -0,0 +1,95 @@
+/**
+ * Copyright (C) 2017 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@1.1;
+
+/**
+ * HDCP specifications are defined by Digital Content Protection LLC (DCP).
+ * "HDCP Specification Rev. 2.2 Interface Independent Adaptation"
+ * "HDCP 2.2 on HDMI Specification"
+ */
+enum HdcpLevel : uint32_t {
+ /**
+ * Unable to determine the HDCP level
+ */
+ HDCP_UNKNOWN,
+
+ /**
+ * No HDCP, output is unprotected
+ */
+ HDCP_NONE,
+
+ /**
+ * HDCP version 1.0
+ */
+ HDCP_V1,
+
+ /**
+ * HDCP version 2.0 Type 1.
+ */
+ HDCP_V2,
+
+ /**
+ * HDCP version 2.1 Type 1.
+ */
+ HDCP_V2_1,
+
+ /**
+ * HDCP version 2.2 Type 1.
+ */
+ HDCP_V2_2,
+
+ /**
+ * No digital output, implicitly secure
+ */
+ HDCP_NO_OUTPUT
+};
+
+enum SecurityLevel : uint32_t {
+ /**
+ * Unable to determine the security level
+ */
+ UNKNOWN,
+
+ /**
+ * Software-based whitebox crypto
+ */
+ SW_SECURE_CRYPTO,
+
+ /**
+ * Software-based whitebox crypto and an obfuscated decoder
+ */
+ SW_SECURE_DECODE,
+
+ /**
+ * DRM key management and crypto operations are performed within a
+ * hardware backed trusted execution environment
+ */
+ HW_SECURE_CRYPTO,
+
+ /**
+ * DRM key management, crypto operations and decoding of content
+ * are performed within a hardware backed trusted execution environment
+ */
+ HW_SECURE_DECODE,
+
+ /**
+ * DRM key management, crypto operations, decoding of content and all
+ * handling of the media (compressed and uncompressed) is handled within
+ * a hardware backed trusted execution environment.
+ */
+ HW_SECURE_ALL,
+};