diff options
| author | Robert Shih <robertshih@google.com> | 2019-04-18 00:06:54 -0700 |
|---|---|---|
| committer | Jeff Tinker <jtinker@google.com> | 2019-05-08 00:52:01 +0000 |
| commit | 31703179a53f4f36e9ae67b3b28fe936a2995c20 (patch) | |
| tree | 5648e6713a68f0317c44d644245f6f90f4e1bf0b /drm | |
| parent | 7af01ada853bfaeced663cf6b6fa1b987da26304 (diff) | |
| download | android_hardware_interfaces-31703179a53f4f36e9ae67b3b28fe936a2995c20.tar.gz android_hardware_interfaces-31703179a53f4f36e9ae67b3b28fe936a2995c20.tar.bz2 android_hardware_interfaces-31703179a53f4f36e9ae67b3b28fe936a2995c20.zip | |
Add status for license starting in the future
Bug:116738851
Test: vts-tradefed run commandAndExit -m VtsHalDrmV1_2Target
Change-Id: Id5017e3ffa1fcf5aaad1815b59a425ac63f2e53e
Diffstat (limited to 'drm')
| -rw-r--r-- | drm/1.2/IDrmPlugin.hal | 18 | ||||
| -rw-r--r-- | drm/1.2/IDrmPluginListener.hal | 18 | ||||
| -rw-r--r-- | drm/1.2/types.hal | 23 | ||||
| -rw-r--r-- | drm/1.2/vts/functional/drm_hal_common.cpp | 15 | ||||
| -rw-r--r-- | drm/1.2/vts/functional/drm_hal_common.h | 20 | ||||
| -rw-r--r-- | drm/1.2/vts/functional/drm_hal_test.cpp | 34 |
6 files changed, 119 insertions, 9 deletions
diff --git a/drm/1.2/IDrmPlugin.hal b/drm/1.2/IDrmPlugin.hal index 7d266f4c7..df09ccf91 100644 --- a/drm/1.2/IDrmPlugin.hal +++ b/drm/1.2/IDrmPlugin.hal @@ -226,4 +226,22 @@ interface IDrmPlugin extends @1.1::IDrmPlugin { * @param sessionId identifies the session the event originated from */ sendSessionLostState(SessionId sessionId); + + /** + * Send a keys change event to the listener. The keys change event + * indicates the status of each key in the session. Keys can be + * indicated as being usable, expired, outputnotallowed or statuspending. + * + * This method only differs from @1.0 version by the addition of new + * KeyStatusType(s) in keyStatusList. + * + * @param sessionId identifies the session the event originated from + * @param keyStatusList indicates the status for each key ID in the + * session. + * @param hasNewUsableKey indicates if the event includes at least one + * key that has become usable. + */ + sendKeysChange_1_2(SessionId sessionId, vec<KeyStatus> keyStatusList, + bool hasNewUsableKey); + }; diff --git a/drm/1.2/IDrmPluginListener.hal b/drm/1.2/IDrmPluginListener.hal index a6bd6c9ad..e8cb91a9c 100644 --- a/drm/1.2/IDrmPluginListener.hal +++ b/drm/1.2/IDrmPluginListener.hal @@ -36,4 +36,22 @@ interface IDrmPluginListener extends @1.0::IDrmPluginListener { * @param sessionId identifies the session that has been invalidated */ oneway sendSessionLostState(SessionId sessionId); + + /** + * Send a keys change event to the listener. The keys change event + * indicates the status of each key in the session. Keys can be + * indicated as being usable, expired, outputnotallowed or statuspending. + * + * This method only differs from @1.0 version by the addition of new + * KeyStatusType(s) in keyStatusList. + * + * @param sessionId identifies the session the event originated from + * @param keyStatusList indicates the status for each key ID in the + * session. + * @param hasNewUsableKey indicates if the event includes at least one + * key that has become usable. + */ + oneway sendKeysChange_1_2(SessionId sessionId, vec<KeyStatus> keyStatusList, + bool hasNewUsableKey); + }; diff --git a/drm/1.2/types.hal b/drm/1.2/types.hal index 28c8e67b7..87218a420 100644 --- a/drm/1.2/types.hal +++ b/drm/1.2/types.hal @@ -16,6 +16,7 @@ package android.hardware.drm@1.2; +import @1.0::KeyStatusType; import @1.0::Status; import @1.1::HdcpLevel; @@ -93,3 +94,25 @@ enum HdcpLevel : @1.1::HdcpLevel { * set in methods that take a KeySetId as an input parameter. */ typedef vec<uint8_t> KeySetId; + +enum KeyStatusType : @1.0::KeyStatusType { + /** + * 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 +}; + +/** + * Used by sendKeysChange_1_2 to report the usability status of each key to the + * app. + * + * This struct only differs from @1.0 version by the addition of new + * KeyStatusType(s). + * + */ +struct KeyStatus { + KeySetId keyId; + KeyStatusType type; +}; diff --git a/drm/1.2/vts/functional/drm_hal_common.cpp b/drm/1.2/vts/functional/drm_hal_common.cpp index b9a8425fc..bfffbe8d2 100644 --- a/drm/1.2/vts/functional/drm_hal_common.cpp +++ b/drm/1.2/vts/functional/drm_hal_common.cpp @@ -56,6 +56,7 @@ namespace V1_2 { namespace vts { const char *kCallbackLostState = "LostState"; +const char *kCallbackKeysChange = "KeysChange"; drm_vts::VendorModules *DrmHalTest::gVendorModules = nullptr; @@ -64,7 +65,19 @@ drm_vts::VendorModules *DrmHalTest::gVendorModules = nullptr; */ Return<void> DrmHalPluginListener::sendSessionLostState(const hidl_vec<uint8_t>& sessionId) { - NotifyFromCallback(kCallbackLostState, sessionId); + ListenerEventArgs args; + args.sessionId = sessionId; + NotifyFromCallback(kCallbackLostState, args); + return Void(); +} + +Return<void> DrmHalPluginListener::sendKeysChange_1_2(const hidl_vec<uint8_t>& sessionId, + const hidl_vec<KeyStatus>& keyStatusList, bool hasNewUsableKey) { + ListenerEventArgs args; + args.sessionId = sessionId; + args.keyStatusList = keyStatusList; + args.hasNewUsableKey = hasNewUsableKey; + NotifyFromCallback(kCallbackKeysChange, args); return Void(); } diff --git a/drm/1.2/vts/functional/drm_hal_common.h b/drm/1.2/vts/functional/drm_hal_common.h index 1b95ddeea..e34866474 100644 --- a/drm/1.2/vts/functional/drm_hal_common.h +++ b/drm/1.2/vts/functional/drm_hal_common.h @@ -37,7 +37,7 @@ using ::android::hardware::drm::V1_0::EventType; using ::android::hardware::drm::V1_0::KeyedVector; -using ::android::hardware::drm::V1_0::KeyStatus; +using KeyStatusV1_0 = ::android::hardware::drm::V1_0::KeyStatus; using ::android::hardware::drm::V1_0::KeyType; using ::android::hardware::drm::V1_0::Mode; using ::android::hardware::drm::V1_0::Pattern; @@ -46,10 +46,6 @@ using ::android::hardware::drm::V1_0::SubSample; using ::android::hardware::drm::V1_1::ICryptoFactory; -using ::android::hardware::drm::V1_2::ICryptoPlugin; -using ::android::hardware::drm::V1_2::IDrmFactory; -using ::android::hardware::drm::V1_2::IDrmPlugin; -using ::android::hardware::drm::V1_2::IDrmPluginListener; using StatusV1_2 = ::android::hardware::drm::V1_2::Status; using ::android::hardware::hidl_array; @@ -166,9 +162,16 @@ class DrmHalClearkeyTest : public DrmHalTest { * Event Handling tests */ extern const char *kCallbackLostState; +extern const char *kCallbackKeysChange; + +struct ListenerEventArgs { + SessionId sessionId; + hidl_vec<KeyStatus> keyStatusList; + bool hasNewUsableKey; +}; class DrmHalPluginListener - : public ::testing::VtsHalHidlTargetCallbackBase<SessionId>, + : public ::testing::VtsHalHidlTargetCallbackBase<ListenerEventArgs>, public IDrmPluginListener { public: DrmHalPluginListener() { @@ -183,10 +186,13 @@ public: int64_t) override { return Void(); } virtual Return<void> sendKeysChange(const hidl_vec<uint8_t>&, - const hidl_vec<KeyStatus>&, bool) override { return Void(); } + const hidl_vec<KeyStatusV1_0>&, bool) override { return Void(); } virtual Return<void> sendSessionLostState(const hidl_vec<uint8_t>& sessionId) override; + virtual Return<void> sendKeysChange_1_2(const hidl_vec<uint8_t>&, + const hidl_vec<KeyStatus>&, bool) override; + }; } // namespace vts diff --git a/drm/1.2/vts/functional/drm_hal_test.cpp b/drm/1.2/vts/functional/drm_hal_test.cpp index 252ebb95f..37ecc2543 100644 --- a/drm/1.2/vts/functional/drm_hal_test.cpp +++ b/drm/1.2/vts/functional/drm_hal_test.cpp @@ -28,6 +28,8 @@ using ::android::hardware::drm::V1_1::KeyRequestType; using ::android::hardware::drm::V1_1::SecurityLevel; using ::android::hardware::drm::V1_2::HdcpLevel; using ::android::hardware::drm::V1_2::KeySetId; +using ::android::hardware::drm::V1_2::KeyStatus; +using ::android::hardware::drm::V1_2::KeyStatusType; using ::android::hardware::drm::V1_2::OfflineLicenseState; using ::android::hardware::drm::V1_2::vts::DrmHalClearkeyTest; @@ -35,6 +37,7 @@ using ::android::hardware::drm::V1_2::vts::DrmHalPluginListener; using ::android::hardware::drm::V1_2::vts::DrmHalTest; using ::android::hardware::drm::V1_2::vts::DrmHidlEnvironment; using ::android::hardware::drm::V1_2::vts::kCallbackLostState; +using ::android::hardware::drm::V1_2::vts::kCallbackKeysChange; using ::android::hardware::hidl_string; @@ -275,6 +278,35 @@ TEST_P(DrmHalTest, GetHdcpLevels) { } /** + * Simulate the plugin sending keys change and make sure + * the listener gets them. + */ +TEST_P(DrmHalTest, ListenerKeysChange) { + RETURN_IF_SKIPPED; + sp<DrmHalPluginListener> listener = new DrmHalPluginListener(); + auto res = drmPlugin->setListener(listener); + EXPECT_OK(res); + + auto sessionId = openSession(); + const hidl_vec<KeyStatus> keyStatusList = { + {{1}, KeyStatusType::USABLE}, + {{2}, KeyStatusType::EXPIRED}, + {{3}, KeyStatusType::OUTPUTNOTALLOWED}, + {{4}, KeyStatusType::STATUSPENDING}, + {{5}, KeyStatusType::INTERNALERROR}, + {{6}, KeyStatusType::USABLEINFUTURE}, + }; + + drmPlugin->sendKeysChange_1_2(sessionId, keyStatusList, true); + auto result = listener->WaitForCallback(kCallbackKeysChange); + EXPECT_TRUE(result.no_timeout); + EXPECT_TRUE(result.args); + EXPECT_EQ(sessionId, result.args->sessionId); + EXPECT_EQ(keyStatusList, result.args->keyStatusList); + closeSession(sessionId); +} + +/** * CryptoPlugin Decrypt tests */ @@ -452,7 +484,7 @@ TEST_P(DrmHalClearkeyTest, SessionLostState) { auto result = listener->WaitForCallback(kCallbackLostState); EXPECT_TRUE(result.no_timeout); EXPECT_TRUE(result.args); - EXPECT_EQ(sessionId, *(result.args)); + EXPECT_EQ(sessionId, result.args->sessionId); } /** |
