Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | //#define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "DrmHal" |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 19 | |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 20 | #include <aidl/android/media/BnResourceManagerClient.h> |
Robert Shih | bd79012 | 2021-03-01 20:45:31 -0800 | [diff] [blame] | 21 | #include <android/binder_manager.h> |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 22 | #include <android/hardware/drm/1.2/types.h> |
Peter Kalauskas | ca5642c | 2018-11-12 12:34:42 -0800 | [diff] [blame] | 23 | #include <android/hidl/manager/1.2/IServiceManager.h> |
Jeff Tinker | 593111f | 2017-05-25 16:00:21 -0700 | [diff] [blame] | 24 | #include <hidl/ServiceManagement.h> |
Adam Stone | f0e618d | 2018-01-17 19:20:41 -0800 | [diff] [blame] | 25 | #include <media/EventMetric.h> |
Robert Shih | 82ea6be | 2019-11-07 17:47:23 -0800 | [diff] [blame] | 26 | #include <media/MediaMetrics.h> |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 27 | #include <media/PluginMetricsReporting.h> |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 28 | #include <media/drm/DrmAPI.h> |
| 29 | #include <media/stagefright/foundation/ADebug.h> |
| 30 | #include <media/stagefright/foundation/AString.h> |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 31 | #include <media/stagefright/foundation/base64.h> |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 32 | #include <media/stagefright/foundation/hexdump.h> |
| 33 | #include <media/stagefright/MediaErrors.h> |
Jeff Tinker | 7d2c6e8 | 2018-02-16 16:14:59 -0800 | [diff] [blame] | 34 | #include <mediadrm/DrmHal.h> |
| 35 | #include <mediadrm/DrmSessionClientInterface.h> |
| 36 | #include <mediadrm/DrmSessionManager.h> |
Robert Shih | 9353881 | 2019-11-12 12:21:35 -0800 | [diff] [blame] | 37 | #include <mediadrm/IDrmMetricsConsumer.h> |
Robert Shih | c0d1d0e | 2019-11-24 13:21:04 -0800 | [diff] [blame] | 38 | #include <mediadrm/DrmUtils.h> |
Robert Shih | bd79012 | 2021-03-01 20:45:31 -0800 | [diff] [blame] | 39 | #include <utils/Log.h> |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 40 | |
Robert Shih | bd79012 | 2021-03-01 20:45:31 -0800 | [diff] [blame] | 41 | #include <iomanip> |
Robert Shih | 61e1c76 | 2019-10-31 21:26:58 -0700 | [diff] [blame] | 42 | #include <vector> |
| 43 | |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 44 | using drm::V1_0::KeyedVector; |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 45 | using drm::V1_0::KeyRequestType; |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 46 | using drm::V1_0::KeyType; |
| 47 | using drm::V1_0::KeyValue; |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 48 | using drm::V1_0::SecureStop; |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 49 | using drm::V1_0::SecureStopId; |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 50 | using drm::V1_0::Status; |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 51 | using drm::V1_1::HdcpLevel; |
| 52 | using drm::V1_1::SecureStopRelease; |
| 53 | using drm::V1_1::SecurityLevel; |
| 54 | using drm::V1_2::KeySetId; |
Robert Shih | a503326 | 2019-05-06 14:15:12 -0700 | [diff] [blame] | 55 | using drm::V1_2::KeyStatusType; |
Robert Shih | 5944a0b | 2021-02-10 04:26:33 -0800 | [diff] [blame] | 56 | using ::android::DrmUtils::toStatusT; |
Adam Stone | 28f27c3 | 2018-02-05 15:07:48 -0800 | [diff] [blame] | 57 | using ::android::hardware::drm::V1_1::DrmMetricGroup; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 58 | using ::android::hardware::hidl_array; |
| 59 | using ::android::hardware::hidl_string; |
| 60 | using ::android::hardware::hidl_vec; |
| 61 | using ::android::hardware::Return; |
| 62 | using ::android::hardware::Void; |
Adam Stone | 637b785 | 2018-01-30 12:09:36 -0800 | [diff] [blame] | 63 | using ::android::os::PersistableBundle; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 64 | using ::android::sp; |
| 65 | |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 66 | typedef drm::V1_1::KeyRequestType KeyRequestType_V1_1; |
| 67 | typedef drm::V1_2::Status Status_V1_2; |
Jeff Tinker | 44c2cc4 | 2019-01-14 10:24:18 -0800 | [diff] [blame] | 68 | typedef drm::V1_2::HdcpLevel HdcpLevel_V1_2; |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 69 | |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 70 | namespace { |
| 71 | |
| 72 | // This constant corresponds to the PROPERTY_DEVICE_UNIQUE_ID constant |
| 73 | // in the MediaDrm API. |
| 74 | constexpr char kPropertyDeviceUniqueId[] = "deviceUniqueId"; |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 75 | constexpr char kEqualsSign[] = "="; |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 76 | |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 77 | template<typename T> |
| 78 | std::string toBase64StringNoPad(const T* data, size_t size) { |
Adam Stone | 630092e | 2018-05-02 13:06:34 -0700 | [diff] [blame] | 79 | // Note that the base 64 conversion only works with arrays of single-byte |
| 80 | // values. If the source is empty or is not an array of single-byte values, |
| 81 | // return empty string. |
| 82 | if (size == 0 || sizeof(data[0]) != 1) { |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 83 | return ""; |
| 84 | } |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 85 | |
| 86 | android::AString outputString; |
| 87 | encodeBase64(data, size, &outputString); |
| 88 | // Remove trailing equals padding if it exists. |
| 89 | while (outputString.size() > 0 && outputString.endsWith(kEqualsSign)) { |
| 90 | outputString.erase(outputString.size() - 1, 1); |
| 91 | } |
| 92 | |
| 93 | return std::string(outputString.c_str(), outputString.size()); |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 94 | } |
| 95 | |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 96 | } // anonymous namespace |
| 97 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 98 | namespace android { |
| 99 | |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 100 | #define INIT_CHECK() {if (mInitCheck != OK) return mInitCheck;} |
| 101 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 102 | static const Vector<uint8_t> toVector(const hidl_vec<uint8_t> &vec) { |
| 103 | Vector<uint8_t> vector; |
| 104 | vector.appendArray(vec.data(), vec.size()); |
| 105 | return *const_cast<const Vector<uint8_t> *>(&vector); |
| 106 | } |
| 107 | |
| 108 | static hidl_vec<uint8_t> toHidlVec(const Vector<uint8_t> &vector) { |
| 109 | hidl_vec<uint8_t> vec; |
| 110 | vec.setToExternal(const_cast<uint8_t *>(vector.array()), vector.size()); |
| 111 | return vec; |
| 112 | } |
| 113 | |
| 114 | static String8 toString8(const hidl_string &string) { |
| 115 | return String8(string.c_str()); |
| 116 | } |
| 117 | |
| 118 | static hidl_string toHidlString(const String8& string) { |
| 119 | return hidl_string(string.string()); |
| 120 | } |
| 121 | |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 122 | static DrmPlugin::SecurityLevel toSecurityLevel(SecurityLevel level) { |
| 123 | switch(level) { |
| 124 | case SecurityLevel::SW_SECURE_CRYPTO: |
| 125 | return DrmPlugin::kSecurityLevelSwSecureCrypto; |
| 126 | case SecurityLevel::SW_SECURE_DECODE: |
| 127 | return DrmPlugin::kSecurityLevelSwSecureDecode; |
| 128 | case SecurityLevel::HW_SECURE_CRYPTO: |
| 129 | return DrmPlugin::kSecurityLevelHwSecureCrypto; |
| 130 | case SecurityLevel::HW_SECURE_DECODE: |
| 131 | return DrmPlugin::kSecurityLevelHwSecureDecode; |
| 132 | case SecurityLevel::HW_SECURE_ALL: |
| 133 | return DrmPlugin::kSecurityLevelHwSecureAll; |
| 134 | default: |
| 135 | return DrmPlugin::kSecurityLevelUnknown; |
| 136 | } |
| 137 | } |
| 138 | |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame] | 139 | static SecurityLevel toHidlSecurityLevel(DrmPlugin::SecurityLevel level) { |
| 140 | switch(level) { |
| 141 | case DrmPlugin::kSecurityLevelSwSecureCrypto: |
| 142 | return SecurityLevel::SW_SECURE_CRYPTO; |
| 143 | case DrmPlugin::kSecurityLevelSwSecureDecode: |
| 144 | return SecurityLevel::SW_SECURE_DECODE; |
| 145 | case DrmPlugin::kSecurityLevelHwSecureCrypto: |
| 146 | return SecurityLevel::HW_SECURE_CRYPTO; |
| 147 | case DrmPlugin::kSecurityLevelHwSecureDecode: |
| 148 | return SecurityLevel::HW_SECURE_DECODE; |
| 149 | case DrmPlugin::kSecurityLevelHwSecureAll: |
| 150 | return SecurityLevel::HW_SECURE_ALL; |
| 151 | default: |
| 152 | return SecurityLevel::UNKNOWN; |
| 153 | } |
| 154 | } |
| 155 | |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 156 | static DrmPlugin::OfflineLicenseState toOfflineLicenseState( |
| 157 | OfflineLicenseState licenseState) { |
| 158 | switch(licenseState) { |
| 159 | case OfflineLicenseState::USABLE: |
| 160 | return DrmPlugin::kOfflineLicenseStateUsable; |
| 161 | case OfflineLicenseState::INACTIVE: |
Jeff Tinker | 9a95b0f | 2019-01-30 17:39:20 -0800 | [diff] [blame] | 162 | return DrmPlugin::kOfflineLicenseStateReleased; |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 163 | default: |
| 164 | return DrmPlugin::kOfflineLicenseStateUnknown; |
| 165 | } |
| 166 | } |
| 167 | |
Jeff Tinker | 44c2cc4 | 2019-01-14 10:24:18 -0800 | [diff] [blame] | 168 | static DrmPlugin::HdcpLevel toHdcpLevel(HdcpLevel_V1_2 level) { |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 169 | switch(level) { |
Jeff Tinker | 44c2cc4 | 2019-01-14 10:24:18 -0800 | [diff] [blame] | 170 | case HdcpLevel_V1_2::HDCP_NONE: |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 171 | return DrmPlugin::kHdcpNone; |
Jeff Tinker | 44c2cc4 | 2019-01-14 10:24:18 -0800 | [diff] [blame] | 172 | case HdcpLevel_V1_2::HDCP_V1: |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 173 | return DrmPlugin::kHdcpV1; |
Jeff Tinker | 44c2cc4 | 2019-01-14 10:24:18 -0800 | [diff] [blame] | 174 | case HdcpLevel_V1_2::HDCP_V2: |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 175 | return DrmPlugin::kHdcpV2; |
Jeff Tinker | 44c2cc4 | 2019-01-14 10:24:18 -0800 | [diff] [blame] | 176 | case HdcpLevel_V1_2::HDCP_V2_1: |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 177 | return DrmPlugin::kHdcpV2_1; |
Jeff Tinker | 44c2cc4 | 2019-01-14 10:24:18 -0800 | [diff] [blame] | 178 | case HdcpLevel_V1_2::HDCP_V2_2: |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 179 | return DrmPlugin::kHdcpV2_2; |
Jeff Tinker | 44c2cc4 | 2019-01-14 10:24:18 -0800 | [diff] [blame] | 180 | case HdcpLevel_V1_2::HDCP_V2_3: |
| 181 | return DrmPlugin::kHdcpV2_3; |
| 182 | case HdcpLevel_V1_2::HDCP_NO_OUTPUT: |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 183 | return DrmPlugin::kHdcpNoOutput; |
| 184 | default: |
| 185 | return DrmPlugin::kHdcpLevelUnknown; |
| 186 | } |
| 187 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 188 | static ::KeyedVector toHidlKeyedVector(const KeyedVector<String8, String8>& |
| 189 | keyedVector) { |
| 190 | std::vector<KeyValue> stdKeyedVector; |
| 191 | for (size_t i = 0; i < keyedVector.size(); i++) { |
| 192 | KeyValue keyValue; |
| 193 | keyValue.key = toHidlString(keyedVector.keyAt(i)); |
| 194 | keyValue.value = toHidlString(keyedVector.valueAt(i)); |
| 195 | stdKeyedVector.push_back(keyValue); |
| 196 | } |
| 197 | return ::KeyedVector(stdKeyedVector); |
| 198 | } |
| 199 | |
| 200 | static KeyedVector<String8, String8> toKeyedVector(const ::KeyedVector& |
| 201 | hKeyedVector) { |
| 202 | KeyedVector<String8, String8> keyedVector; |
| 203 | for (size_t i = 0; i < hKeyedVector.size(); i++) { |
| 204 | keyedVector.add(toString8(hKeyedVector[i].key), |
| 205 | toString8(hKeyedVector[i].value)); |
| 206 | } |
| 207 | return keyedVector; |
| 208 | } |
| 209 | |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 210 | static List<Vector<uint8_t>> toSecureStops(const hidl_vec<SecureStop>& |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 211 | hSecureStops) { |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 212 | List<Vector<uint8_t>> secureStops; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 213 | for (size_t i = 0; i < hSecureStops.size(); i++) { |
| 214 | secureStops.push_back(toVector(hSecureStops[i].opaqueData)); |
| 215 | } |
| 216 | return secureStops; |
| 217 | } |
| 218 | |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 219 | static List<Vector<uint8_t>> toSecureStopIds(const hidl_vec<SecureStopId>& |
| 220 | hSecureStopIds) { |
| 221 | List<Vector<uint8_t>> secureStopIds; |
| 222 | for (size_t i = 0; i < hSecureStopIds.size(); i++) { |
| 223 | secureStopIds.push_back(toVector(hSecureStopIds[i])); |
| 224 | } |
| 225 | return secureStopIds; |
| 226 | } |
| 227 | |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 228 | static List<Vector<uint8_t>> toKeySetIds(const hidl_vec<KeySetId>& |
| 229 | hKeySetIds) { |
| 230 | List<Vector<uint8_t>> keySetIds; |
| 231 | for (size_t i = 0; i < hKeySetIds.size(); i++) { |
| 232 | keySetIds.push_back(toVector(hKeySetIds[i])); |
| 233 | } |
| 234 | return keySetIds; |
| 235 | } |
| 236 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 237 | Mutex DrmHal::mLock; |
| 238 | |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 239 | struct DrmHal::DrmSessionClient : public aidl::android::media::BnResourceManagerClient { |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 240 | explicit DrmSessionClient(DrmHal* drm, const Vector<uint8_t>& sessionId) |
| 241 | : mSessionId(sessionId), |
| 242 | mDrm(drm) {} |
| 243 | |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 244 | ::ndk::ScopedAStatus reclaimResource(bool* _aidl_return) override; |
| 245 | ::ndk::ScopedAStatus getName(::std::string* _aidl_return) override; |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 246 | |
| 247 | const Vector<uint8_t> mSessionId; |
| 248 | |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 249 | virtual ~DrmSessionClient(); |
| 250 | |
| 251 | private: |
| 252 | wp<DrmHal> mDrm; |
| 253 | |
| 254 | DISALLOW_EVIL_CONSTRUCTORS(DrmSessionClient); |
| 255 | }; |
| 256 | |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 257 | ::ndk::ScopedAStatus DrmHal::DrmSessionClient::reclaimResource(bool* _aidl_return) { |
| 258 | auto sessionId = mSessionId; |
Robert Shih | c3af31b | 2019-09-20 21:45:01 -0700 | [diff] [blame] | 259 | sp<DrmHal> drm = mDrm.promote(); |
| 260 | if (drm == NULL) { |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 261 | *_aidl_return = true; |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 262 | return ::ndk::ScopedAStatus::ok(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 263 | } |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 264 | status_t err = drm->closeSession(sessionId); |
Robert Shih | c3af31b | 2019-09-20 21:45:01 -0700 | [diff] [blame] | 265 | if (err != OK) { |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 266 | *_aidl_return = false; |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 267 | return ::ndk::ScopedAStatus::ok(); |
Robert Shih | c3af31b | 2019-09-20 21:45:01 -0700 | [diff] [blame] | 268 | } |
| 269 | drm->sendEvent(EventType::SESSION_RECLAIMED, |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 270 | toHidlVec(sessionId), hidl_vec<uint8_t>()); |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 271 | *_aidl_return = true; |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 272 | return ::ndk::ScopedAStatus::ok(); |
Robert Shih | c3af31b | 2019-09-20 21:45:01 -0700 | [diff] [blame] | 273 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 274 | |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 275 | ::ndk::ScopedAStatus DrmHal::DrmSessionClient::getName(::std::string* _aidl_return) { |
Robert Shih | c3af31b | 2019-09-20 21:45:01 -0700 | [diff] [blame] | 276 | String8 name; |
| 277 | sp<DrmHal> drm = mDrm.promote(); |
| 278 | if (drm == NULL) { |
| 279 | name.append("<deleted>"); |
| 280 | } else if (drm->getPropertyStringInternal(String8("vendor"), name) != OK |
| 281 | || name.isEmpty()) { |
| 282 | name.append("<Get vendor failed or is empty>"); |
| 283 | } |
| 284 | name.append("["); |
| 285 | for (size_t i = 0; i < mSessionId.size(); ++i) { |
| 286 | name.appendFormat("%02x", mSessionId[i]); |
| 287 | } |
| 288 | name.append("]"); |
Chong Zhang | 181e695 | 2019-10-09 13:23:39 -0700 | [diff] [blame] | 289 | *_aidl_return = name; |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 290 | return ::ndk::ScopedAStatus::ok(); |
Robert Shih | c3af31b | 2019-09-20 21:45:01 -0700 | [diff] [blame] | 291 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 292 | |
Robert Shih | c3af31b | 2019-09-20 21:45:01 -0700 | [diff] [blame] | 293 | DrmHal::DrmSessionClient::~DrmSessionClient() { |
| 294 | DrmSessionManager::Instance()->removeSession(mSessionId); |
| 295 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 296 | |
| 297 | DrmHal::DrmHal() |
Robert Shih | c3af31b | 2019-09-20 21:45:01 -0700 | [diff] [blame] | 298 | : mFactories(makeDrmFactories()), |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 299 | mInitCheck((mFactories.size() == 0) ? ERROR_UNSUPPORTED : NO_INIT) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 300 | } |
| 301 | |
Jeff Tinker | 6133281 | 2017-05-15 16:53:10 -0700 | [diff] [blame] | 302 | void DrmHal::closeOpenSessions() { |
Jeff Tinker | 7dfe28f | 2018-02-15 12:17:40 -0800 | [diff] [blame] | 303 | Mutex::Autolock autoLock(mLock); |
| 304 | auto openSessions = mOpenSessions; |
| 305 | for (size_t i = 0; i < openSessions.size(); i++) { |
| 306 | mLock.unlock(); |
Robert Shih | c3af31b | 2019-09-20 21:45:01 -0700 | [diff] [blame] | 307 | closeSession(openSessions[i]->mSessionId); |
Jeff Tinker | 7dfe28f | 2018-02-15 12:17:40 -0800 | [diff] [blame] | 308 | mLock.lock(); |
Jeff Tinker | 6133281 | 2017-05-15 16:53:10 -0700 | [diff] [blame] | 309 | } |
| 310 | mOpenSessions.clear(); |
| 311 | } |
| 312 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 313 | DrmHal::~DrmHal() { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 314 | } |
| 315 | |
Jeff Tinker | 7dfe28f | 2018-02-15 12:17:40 -0800 | [diff] [blame] | 316 | void DrmHal::cleanup() { |
| 317 | closeOpenSessions(); |
| 318 | |
| 319 | Mutex::Autolock autoLock(mLock); |
Robert Shih | 7e36f26 | 2021-03-10 05:32:23 -0800 | [diff] [blame] | 320 | reportFrameworkMetrics(reportPluginMetrics()); |
Jeff Tinker | 7dfe28f | 2018-02-15 12:17:40 -0800 | [diff] [blame] | 321 | |
| 322 | setListener(NULL); |
| 323 | mInitCheck = NO_INIT; |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 324 | if (mPluginV1_2 != NULL) { |
| 325 | if (!mPluginV1_2->setListener(NULL).isOk()) { |
| 326 | mInitCheck = DEAD_OBJECT; |
| 327 | } |
| 328 | } else if (mPlugin != NULL) { |
Jeff Tinker | 7dfe28f | 2018-02-15 12:17:40 -0800 | [diff] [blame] | 329 | if (!mPlugin->setListener(NULL).isOk()) { |
| 330 | mInitCheck = DEAD_OBJECT; |
| 331 | } |
| 332 | } |
| 333 | mPlugin.clear(); |
| 334 | mPluginV1_1.clear(); |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 335 | mPluginV1_2.clear(); |
Robert Shih | fbe581e | 2021-01-14 05:12:04 -0800 | [diff] [blame] | 336 | mPluginV1_4.clear(); |
Jeff Tinker | 7dfe28f | 2018-02-15 12:17:40 -0800 | [diff] [blame] | 337 | } |
| 338 | |
Robert Shih | c0d1d0e | 2019-11-24 13:21:04 -0800 | [diff] [blame] | 339 | std::vector<sp<IDrmFactory>> DrmHal::makeDrmFactories() { |
Robert Shih | 54e1d21 | 2021-03-03 20:17:24 -0800 | [diff] [blame] | 340 | static std::vector<sp<IDrmFactory>> factories(DrmUtils::MakeDrmFactories()); |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 341 | if (factories.size() == 0) { |
| 342 | // must be in passthrough mode, load the default passthrough service |
Jeff Tinker | e309b22 | 2017-04-05 08:01:28 -0700 | [diff] [blame] | 343 | auto passthrough = IDrmFactory::getService(); |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 344 | if (passthrough != NULL) { |
Robert Shih | 8635cb1 | 2021-02-26 07:57:55 -0800 | [diff] [blame] | 345 | DrmUtils::LOG2BI("makeDrmFactories: using default passthrough drm instance"); |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 346 | factories.push_back(passthrough); |
| 347 | } else { |
Robert Shih | 8635cb1 | 2021-02-26 07:57:55 -0800 | [diff] [blame] | 348 | DrmUtils::LOG2BE("Failed to find any drm factories"); |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 349 | } |
| 350 | } |
| 351 | return factories; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 352 | } |
| 353 | |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 354 | sp<IDrmPlugin> DrmHal::makeDrmPlugin(const sp<IDrmFactory>& factory, |
| 355 | const uint8_t uuid[16], const String8& appPackageName) { |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 356 | mAppPackageName = appPackageName; |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 357 | mMetrics.SetAppPackageName(appPackageName); |
Robert Shih | 6152d7c | 2019-11-19 22:54:27 -0800 | [diff] [blame] | 358 | mMetrics.SetAppUid(AIBinder_getCallingUid()); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 359 | |
| 360 | sp<IDrmPlugin> plugin; |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 361 | Return<void> hResult = factory->createPlugin(uuid, appPackageName.string(), |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 362 | [&](Status status, const sp<IDrmPlugin>& hPlugin) { |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 363 | if (status != Status::OK) { |
Robert Shih | bd79012 | 2021-03-01 20:45:31 -0800 | [diff] [blame] | 364 | DrmUtils::LOG2BE(uuid, "Failed to make drm plugin: %d", status); |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 365 | return; |
| 366 | } |
| 367 | plugin = hPlugin; |
| 368 | } |
| 369 | ); |
Jeff Tinker | f0e89b0 | 2017-08-07 15:58:41 -0700 | [diff] [blame] | 370 | |
| 371 | if (!hResult.isOk()) { |
Robert Shih | bd79012 | 2021-03-01 20:45:31 -0800 | [diff] [blame] | 372 | DrmUtils::LOG2BE(uuid, "createPlugin remote call failed: %s", |
| 373 | hResult.description().c_str()); |
Jeff Tinker | f0e89b0 | 2017-08-07 15:58:41 -0700 | [diff] [blame] | 374 | } |
| 375 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 376 | return plugin; |
| 377 | } |
| 378 | |
| 379 | status_t DrmHal::initCheck() const { |
| 380 | return mInitCheck; |
| 381 | } |
| 382 | |
| 383 | status_t DrmHal::setListener(const sp<IDrmClient>& listener) |
| 384 | { |
| 385 | Mutex::Autolock lock(mEventLock); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 386 | mListener = listener; |
| 387 | return NO_ERROR; |
| 388 | } |
| 389 | |
| 390 | Return<void> DrmHal::sendEvent(EventType hEventType, |
| 391 | const hidl_vec<uint8_t>& sessionId, const hidl_vec<uint8_t>& data) { |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 392 | mMetrics.mEventCounter.Increment(hEventType); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 393 | |
| 394 | mEventLock.lock(); |
| 395 | sp<IDrmClient> listener = mListener; |
| 396 | mEventLock.unlock(); |
| 397 | |
| 398 | if (listener != NULL) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 399 | Mutex::Autolock lock(mNotifyLock); |
| 400 | DrmPlugin::EventType eventType; |
| 401 | switch(hEventType) { |
| 402 | case EventType::PROVISION_REQUIRED: |
| 403 | eventType = DrmPlugin::kDrmPluginEventProvisionRequired; |
| 404 | break; |
| 405 | case EventType::KEY_NEEDED: |
| 406 | eventType = DrmPlugin::kDrmPluginEventKeyNeeded; |
| 407 | break; |
| 408 | case EventType::KEY_EXPIRED: |
| 409 | eventType = DrmPlugin::kDrmPluginEventKeyExpired; |
| 410 | break; |
| 411 | case EventType::VENDOR_DEFINED: |
| 412 | eventType = DrmPlugin::kDrmPluginEventVendorDefined; |
| 413 | break; |
Rahul Frias | b86f4b3 | 2017-03-27 15:13:30 -0700 | [diff] [blame] | 414 | case EventType::SESSION_RECLAIMED: |
| 415 | eventType = DrmPlugin::kDrmPluginEventSessionReclaimed; |
| 416 | break; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 417 | default: |
| 418 | return Void(); |
| 419 | } |
Robert Shih | 61e1c76 | 2019-10-31 21:26:58 -0700 | [diff] [blame] | 420 | listener->sendEvent(eventType, sessionId, data); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 421 | } |
| 422 | return Void(); |
| 423 | } |
| 424 | |
| 425 | Return<void> DrmHal::sendExpirationUpdate(const hidl_vec<uint8_t>& sessionId, |
| 426 | int64_t expiryTimeInMS) { |
| 427 | |
| 428 | mEventLock.lock(); |
| 429 | sp<IDrmClient> listener = mListener; |
| 430 | mEventLock.unlock(); |
| 431 | |
| 432 | if (listener != NULL) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 433 | Mutex::Autolock lock(mNotifyLock); |
Robert Shih | 61e1c76 | 2019-10-31 21:26:58 -0700 | [diff] [blame] | 434 | listener->sendExpirationUpdate(sessionId, expiryTimeInMS); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 435 | } |
| 436 | return Void(); |
| 437 | } |
| 438 | |
| 439 | Return<void> DrmHal::sendKeysChange(const hidl_vec<uint8_t>& sessionId, |
Robert Shih | a503326 | 2019-05-06 14:15:12 -0700 | [diff] [blame] | 440 | const hidl_vec<KeyStatus_V1_0>& keyStatusList_V1_0, bool hasNewUsableKey) { |
| 441 | std::vector<KeyStatus> keyStatusVec; |
| 442 | for (const auto &keyStatus_V1_0 : keyStatusList_V1_0) { |
| 443 | keyStatusVec.push_back({keyStatus_V1_0.keyId, |
| 444 | static_cast<KeyStatusType>(keyStatus_V1_0.type)}); |
| 445 | } |
| 446 | hidl_vec<KeyStatus> keyStatusList_V1_2(keyStatusVec); |
| 447 | return sendKeysChange_1_2(sessionId, keyStatusList_V1_2, hasNewUsableKey); |
| 448 | } |
| 449 | |
| 450 | Return<void> DrmHal::sendKeysChange_1_2(const hidl_vec<uint8_t>& sessionId, |
Robert Shih | 61e1c76 | 2019-10-31 21:26:58 -0700 | [diff] [blame] | 451 | const hidl_vec<KeyStatus>& hKeyStatusList, bool hasNewUsableKey) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 452 | |
| 453 | mEventLock.lock(); |
| 454 | sp<IDrmClient> listener = mListener; |
| 455 | mEventLock.unlock(); |
| 456 | |
| 457 | if (listener != NULL) { |
Robert Shih | 61e1c76 | 2019-10-31 21:26:58 -0700 | [diff] [blame] | 458 | std::vector<DrmKeyStatus> keyStatusList; |
| 459 | size_t nKeys = hKeyStatusList.size(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 460 | for (size_t i = 0; i < nKeys; ++i) { |
Robert Shih | 61e1c76 | 2019-10-31 21:26:58 -0700 | [diff] [blame] | 461 | const KeyStatus &keyStatus = hKeyStatusList[i]; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 462 | uint32_t type; |
| 463 | switch(keyStatus.type) { |
| 464 | case KeyStatusType::USABLE: |
| 465 | type = DrmPlugin::kKeyStatusType_Usable; |
| 466 | break; |
| 467 | case KeyStatusType::EXPIRED: |
| 468 | type = DrmPlugin::kKeyStatusType_Expired; |
| 469 | break; |
| 470 | case KeyStatusType::OUTPUTNOTALLOWED: |
| 471 | type = DrmPlugin::kKeyStatusType_OutputNotAllowed; |
| 472 | break; |
| 473 | case KeyStatusType::STATUSPENDING: |
| 474 | type = DrmPlugin::kKeyStatusType_StatusPending; |
| 475 | break; |
Robert Shih | a503326 | 2019-05-06 14:15:12 -0700 | [diff] [blame] | 476 | case KeyStatusType::USABLEINFUTURE: |
| 477 | type = DrmPlugin::kKeyStatusType_UsableInFuture; |
| 478 | break; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 479 | case KeyStatusType::INTERNALERROR: |
| 480 | default: |
| 481 | type = DrmPlugin::kKeyStatusType_InternalError; |
| 482 | break; |
| 483 | } |
Robert Shih | 61e1c76 | 2019-10-31 21:26:58 -0700 | [diff] [blame] | 484 | keyStatusList.push_back({type, keyStatus.keyId}); |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 485 | mMetrics.mKeyStatusChangeCounter.Increment(keyStatus.type); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 486 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 487 | |
| 488 | Mutex::Autolock lock(mNotifyLock); |
Robert Shih | 61e1c76 | 2019-10-31 21:26:58 -0700 | [diff] [blame] | 489 | listener->sendKeysChange(sessionId, keyStatusList, hasNewUsableKey); |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 490 | } else { |
| 491 | // There's no listener. But we still want to count the key change |
| 492 | // events. |
Robert Shih | 61e1c76 | 2019-10-31 21:26:58 -0700 | [diff] [blame] | 493 | size_t nKeys = hKeyStatusList.size(); |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 494 | for (size_t i = 0; i < nKeys; i++) { |
Robert Shih | 61e1c76 | 2019-10-31 21:26:58 -0700 | [diff] [blame] | 495 | mMetrics.mKeyStatusChangeCounter.Increment(hKeyStatusList[i].type); |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 496 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 497 | } |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 498 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 499 | return Void(); |
| 500 | } |
| 501 | |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 502 | Return<void> DrmHal::sendSessionLostState( |
| 503 | const hidl_vec<uint8_t>& sessionId) { |
| 504 | |
| 505 | mEventLock.lock(); |
| 506 | sp<IDrmClient> listener = mListener; |
| 507 | mEventLock.unlock(); |
| 508 | |
| 509 | if (listener != NULL) { |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 510 | Mutex::Autolock lock(mNotifyLock); |
Robert Shih | 61e1c76 | 2019-10-31 21:26:58 -0700 | [diff] [blame] | 511 | listener->sendSessionLostState(sessionId); |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 512 | } |
| 513 | return Void(); |
| 514 | } |
| 515 | |
Jeff Tinker | db3fa5f | 2019-01-25 22:56:56 -0800 | [diff] [blame] | 516 | status_t DrmHal::matchMimeTypeAndSecurityLevel(const sp<IDrmFactory> &factory, |
| 517 | const uint8_t uuid[16], |
| 518 | const String8 &mimeType, |
| 519 | DrmPlugin::SecurityLevel level, |
| 520 | bool *isSupported) { |
| 521 | *isSupported = false; |
| 522 | |
| 523 | // handle default value cases |
| 524 | if (level == DrmPlugin::kSecurityLevelUnknown) { |
| 525 | if (mimeType == "") { |
| 526 | // isCryptoSchemeSupported(uuid) |
| 527 | *isSupported = true; |
| 528 | } else { |
| 529 | // isCryptoSchemeSupported(uuid, mimeType) |
| 530 | *isSupported = factory->isContentTypeSupported(mimeType.string()); |
| 531 | } |
| 532 | return OK; |
| 533 | } else if (mimeType == "") { |
| 534 | return BAD_VALUE; |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame] | 535 | } |
| 536 | |
Jeff Tinker | db3fa5f | 2019-01-25 22:56:56 -0800 | [diff] [blame] | 537 | sp<drm::V1_2::IDrmFactory> factoryV1_2 = drm::V1_2::IDrmFactory::castFrom(factory); |
| 538 | if (factoryV1_2 == NULL) { |
| 539 | return ERROR_UNSUPPORTED; |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame] | 540 | } else { |
Jeff Tinker | db3fa5f | 2019-01-25 22:56:56 -0800 | [diff] [blame] | 541 | *isSupported = factoryV1_2->isCryptoSchemeSupported_1_2(uuid, |
| 542 | mimeType.string(), toHidlSecurityLevel(level)); |
| 543 | return OK; |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame] | 544 | } |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame] | 545 | } |
| 546 | |
Jeff Tinker | db3fa5f | 2019-01-25 22:56:56 -0800 | [diff] [blame] | 547 | status_t DrmHal::isCryptoSchemeSupported(const uint8_t uuid[16], |
| 548 | const String8 &mimeType, |
| 549 | DrmPlugin::SecurityLevel level, |
| 550 | bool *isSupported) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 551 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | db3fa5f | 2019-01-25 22:56:56 -0800 | [diff] [blame] | 552 | *isSupported = false; |
| 553 | for (ssize_t i = mFactories.size() - 1; i >= 0; i--) { |
| 554 | if (mFactories[i]->isCryptoSchemeSupported(uuid)) { |
| 555 | return matchMimeTypeAndSecurityLevel(mFactories[i], |
| 556 | uuid, mimeType, level, isSupported); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 557 | } |
| 558 | } |
Jeff Tinker | db3fa5f | 2019-01-25 22:56:56 -0800 | [diff] [blame] | 559 | return OK; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 560 | } |
| 561 | |
Edwin Wong | 68b3d9f | 2017-01-06 19:07:54 -0800 | [diff] [blame] | 562 | status_t DrmHal::createPlugin(const uint8_t uuid[16], |
| 563 | const String8& appPackageName) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 564 | Mutex::Autolock autoLock(mLock); |
| 565 | |
Jeff Tinker | db3fa5f | 2019-01-25 22:56:56 -0800 | [diff] [blame] | 566 | for (ssize_t i = mFactories.size() - 1; i >= 0; i--) { |
Robert Shih | 8635cb1 | 2021-02-26 07:57:55 -0800 | [diff] [blame] | 567 | auto hResult = mFactories[i]->isCryptoSchemeSupported(uuid); |
| 568 | if (hResult.isOk() && hResult) { |
Peter Kalauskas | 7676a40 | 2018-12-27 11:04:16 -0800 | [diff] [blame] | 569 | auto plugin = makeDrmPlugin(mFactories[i], uuid, appPackageName); |
| 570 | if (plugin != NULL) { |
| 571 | mPlugin = plugin; |
Edwin Wong | 5641aa2 | 2018-01-30 17:52:21 -0800 | [diff] [blame] | 572 | mPluginV1_1 = drm::V1_1::IDrmPlugin::castFrom(mPlugin); |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 573 | mPluginV1_2 = drm::V1_2::IDrmPlugin::castFrom(mPlugin); |
Robert Shih | fbe581e | 2021-01-14 05:12:04 -0800 | [diff] [blame] | 574 | mPluginV1_4 = drm::V1_4::IDrmPlugin::castFrom(mPlugin); |
Peter Kalauskas | 7676a40 | 2018-12-27 11:04:16 -0800 | [diff] [blame] | 575 | break; |
Edwin Wong | 5641aa2 | 2018-01-30 17:52:21 -0800 | [diff] [blame] | 576 | } |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 577 | } |
| 578 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 579 | |
| 580 | if (mPlugin == NULL) { |
Robert Shih | bd79012 | 2021-03-01 20:45:31 -0800 | [diff] [blame] | 581 | DrmUtils::LOG2BE(uuid, "No supported hal instance found"); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 582 | mInitCheck = ERROR_UNSUPPORTED; |
| 583 | } else { |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 584 | mInitCheck = OK; |
| 585 | if (mPluginV1_2 != NULL) { |
| 586 | if (!mPluginV1_2->setListener(this).isOk()) { |
| 587 | mInitCheck = DEAD_OBJECT; |
| 588 | } |
| 589 | } else if (!mPlugin->setListener(this).isOk()) { |
Jeff Tinker | 319d5f4 | 2017-07-26 15:44:33 -0700 | [diff] [blame] | 590 | mInitCheck = DEAD_OBJECT; |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 591 | } |
| 592 | if (mInitCheck != OK) { |
| 593 | mPlugin.clear(); |
| 594 | mPluginV1_1.clear(); |
| 595 | mPluginV1_2.clear(); |
Robert Shih | fbe581e | 2021-01-14 05:12:04 -0800 | [diff] [blame] | 596 | mPluginV1_4.clear(); |
Jeff Tinker | 319d5f4 | 2017-07-26 15:44:33 -0700 | [diff] [blame] | 597 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 598 | } |
| 599 | |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 600 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 601 | return mInitCheck; |
| 602 | } |
| 603 | |
| 604 | status_t DrmHal::destroyPlugin() { |
Jeff Tinker | 7dfe28f | 2018-02-15 12:17:40 -0800 | [diff] [blame] | 605 | cleanup(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 606 | return OK; |
| 607 | } |
| 608 | |
Jeff Tinker | 41d279a | 2018-02-11 19:52:08 +0000 | [diff] [blame] | 609 | status_t DrmHal::openSession(DrmPlugin::SecurityLevel level, |
| 610 | Vector<uint8_t> &sessionId) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 611 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 612 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 613 | |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame] | 614 | SecurityLevel hSecurityLevel = toHidlSecurityLevel(level); |
Jeff Tinker | 41d279a | 2018-02-11 19:52:08 +0000 | [diff] [blame] | 615 | bool setSecurityLevel = true; |
Tobias Thierer | 5f5e43f | 2018-02-11 15:00:57 +0000 | [diff] [blame] | 616 | |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame] | 617 | if (level == DrmPlugin::kSecurityLevelMax) { |
Jeff Tinker | 41d279a | 2018-02-11 19:52:08 +0000 | [diff] [blame] | 618 | setSecurityLevel = false; |
Jeff Tinker | 99dbfa8 | 2019-01-17 17:27:06 -0800 | [diff] [blame] | 619 | } else { |
| 620 | if (hSecurityLevel == SecurityLevel::UNKNOWN) { |
| 621 | return ERROR_DRM_CANNOT_HANDLE; |
| 622 | } |
Jeff Tinker | 41d279a | 2018-02-11 19:52:08 +0000 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | status_t err = UNKNOWN_ERROR; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 626 | bool retry = true; |
| 627 | do { |
| 628 | hidl_vec<uint8_t> hSessionId; |
| 629 | |
Jeff Tinker | 41d279a | 2018-02-11 19:52:08 +0000 | [diff] [blame] | 630 | Return<void> hResult; |
| 631 | if (mPluginV1_1 == NULL || !setSecurityLevel) { |
| 632 | hResult = mPlugin->openSession( |
| 633 | [&](Status status,const hidl_vec<uint8_t>& id) { |
| 634 | if (status == Status::OK) { |
| 635 | sessionId = toVector(id); |
| 636 | } |
| 637 | err = toStatusT(status); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 638 | } |
Jeff Tinker | 41d279a | 2018-02-11 19:52:08 +0000 | [diff] [blame] | 639 | ); |
| 640 | } else { |
| 641 | hResult = mPluginV1_1->openSession_1_1(hSecurityLevel, |
| 642 | [&](Status status, const hidl_vec<uint8_t>& id) { |
| 643 | if (status == Status::OK) { |
| 644 | sessionId = toVector(id); |
| 645 | } |
| 646 | err = toStatusT(status); |
| 647 | } |
| 648 | ); |
| 649 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 650 | |
| 651 | if (!hResult.isOk()) { |
| 652 | err = DEAD_OBJECT; |
| 653 | } |
| 654 | |
| 655 | if (err == ERROR_DRM_RESOURCE_BUSY && retry) { |
| 656 | mLock.unlock(); |
| 657 | // reclaimSession may call back to closeSession, since mLock is |
| 658 | // shared between Drm instances, we should unlock here to avoid |
| 659 | // deadlock. |
Robert Shih | 6152d7c | 2019-11-19 22:54:27 -0800 | [diff] [blame] | 660 | retry = DrmSessionManager::Instance()->reclaimSession(AIBinder_getCallingPid()); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 661 | mLock.lock(); |
| 662 | } else { |
| 663 | retry = false; |
| 664 | } |
| 665 | } while (retry); |
| 666 | |
| 667 | if (err == OK) { |
Steven Moreland | e0496a2 | 2020-02-13 13:13:52 -0800 | [diff] [blame] | 668 | std::shared_ptr<DrmSessionClient> client = |
| 669 | ndk::SharedRefBase::make<DrmSessionClient>(this, sessionId); |
Robert Shih | 6152d7c | 2019-11-19 22:54:27 -0800 | [diff] [blame] | 670 | DrmSessionManager::Instance()->addSession(AIBinder_getCallingPid(), |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 671 | std::static_pointer_cast<IResourceManagerClient>(client), sessionId); |
| 672 | mOpenSessions.push_back(client); |
Adam Stone | 568b3c4 | 2018-01-31 12:57:16 -0800 | [diff] [blame] | 673 | mMetrics.SetSessionStart(sessionId); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 674 | } |
Adam Stone | aaf87dd | 2018-01-08 11:55:06 -0800 | [diff] [blame] | 675 | |
Adam Stone | f0e618d | 2018-01-17 19:20:41 -0800 | [diff] [blame] | 676 | mMetrics.mOpenSessionCounter.Increment(err); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 677 | return err; |
| 678 | } |
| 679 | |
| 680 | status_t DrmHal::closeSession(Vector<uint8_t> const &sessionId) { |
| 681 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 682 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 683 | |
Jeff Tinker | 319d5f4 | 2017-07-26 15:44:33 -0700 | [diff] [blame] | 684 | Return<Status> status = mPlugin->closeSession(toHidlVec(sessionId)); |
| 685 | if (status.isOk()) { |
| 686 | if (status == Status::OK) { |
| 687 | DrmSessionManager::Instance()->removeSession(sessionId); |
Robert Shih | 0f3a8a0 | 2019-11-14 15:43:39 -0800 | [diff] [blame] | 688 | for (auto i = mOpenSessions.begin(); i != mOpenSessions.end(); i++) { |
| 689 | if (isEqualSessionId((*i)->mSessionId, sessionId)) { |
| 690 | mOpenSessions.erase(i); |
Jeff Tinker | 319d5f4 | 2017-07-26 15:44:33 -0700 | [diff] [blame] | 691 | break; |
| 692 | } |
Jeff Tinker | 6133281 | 2017-05-15 16:53:10 -0700 | [diff] [blame] | 693 | } |
| 694 | } |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 695 | status_t response = toStatusT(status); |
Adam Stone | 568b3c4 | 2018-01-31 12:57:16 -0800 | [diff] [blame] | 696 | mMetrics.SetSessionEnd(sessionId); |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 697 | mMetrics.mCloseSessionCounter.Increment(response); |
| 698 | return response; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 699 | } |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 700 | mMetrics.mCloseSessionCounter.Increment(DEAD_OBJECT); |
Jeff Tinker | 319d5f4 | 2017-07-26 15:44:33 -0700 | [diff] [blame] | 701 | return DEAD_OBJECT; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 702 | } |
| 703 | |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 704 | static DrmPlugin::KeyRequestType toKeyRequestType( |
| 705 | KeyRequestType keyRequestType) { |
| 706 | switch (keyRequestType) { |
| 707 | case KeyRequestType::INITIAL: |
| 708 | return DrmPlugin::kKeyRequestType_Initial; |
| 709 | break; |
| 710 | case KeyRequestType::RENEWAL: |
| 711 | return DrmPlugin::kKeyRequestType_Renewal; |
| 712 | break; |
| 713 | case KeyRequestType::RELEASE: |
| 714 | return DrmPlugin::kKeyRequestType_Release; |
| 715 | break; |
| 716 | default: |
| 717 | return DrmPlugin::kKeyRequestType_Unknown; |
| 718 | break; |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | static DrmPlugin::KeyRequestType toKeyRequestType_1_1( |
| 723 | KeyRequestType_V1_1 keyRequestType) { |
| 724 | switch (keyRequestType) { |
| 725 | case KeyRequestType_V1_1::NONE: |
| 726 | return DrmPlugin::kKeyRequestType_None; |
| 727 | break; |
| 728 | case KeyRequestType_V1_1::UPDATE: |
| 729 | return DrmPlugin::kKeyRequestType_Update; |
| 730 | break; |
| 731 | default: |
| 732 | return toKeyRequestType(static_cast<KeyRequestType>(keyRequestType)); |
| 733 | break; |
| 734 | } |
| 735 | } |
| 736 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 737 | status_t DrmHal::getKeyRequest(Vector<uint8_t> const &sessionId, |
| 738 | Vector<uint8_t> const &initData, String8 const &mimeType, |
| 739 | DrmPlugin::KeyType keyType, KeyedVector<String8, |
| 740 | String8> const &optionalParameters, Vector<uint8_t> &request, |
| 741 | String8 &defaultUrl, DrmPlugin::KeyRequestType *keyRequestType) { |
| 742 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 743 | INIT_CHECK(); |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 744 | EventTimer<status_t> keyRequestTimer(&mMetrics.mGetKeyRequestTimeUs); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 745 | |
| 746 | DrmSessionManager::Instance()->useSession(sessionId); |
| 747 | |
| 748 | KeyType hKeyType; |
| 749 | if (keyType == DrmPlugin::kKeyType_Streaming) { |
| 750 | hKeyType = KeyType::STREAMING; |
| 751 | } else if (keyType == DrmPlugin::kKeyType_Offline) { |
| 752 | hKeyType = KeyType::OFFLINE; |
| 753 | } else if (keyType == DrmPlugin::kKeyType_Release) { |
| 754 | hKeyType = KeyType::RELEASE; |
| 755 | } else { |
Adam Stone | f0e618d | 2018-01-17 19:20:41 -0800 | [diff] [blame] | 756 | keyRequestTimer.SetAttribute(BAD_VALUE); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 757 | return BAD_VALUE; |
| 758 | } |
| 759 | |
| 760 | ::KeyedVector hOptionalParameters = toHidlKeyedVector(optionalParameters); |
| 761 | |
| 762 | status_t err = UNKNOWN_ERROR; |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 763 | Return<void> hResult; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 764 | |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 765 | if (mPluginV1_2 != NULL) { |
| 766 | hResult = mPluginV1_2->getKeyRequest_1_2( |
| 767 | toHidlVec(sessionId), toHidlVec(initData), |
| 768 | toHidlString(mimeType), hKeyType, hOptionalParameters, |
| 769 | [&](Status_V1_2 status, const hidl_vec<uint8_t>& hRequest, |
| 770 | KeyRequestType_V1_1 hKeyRequestType, |
| 771 | const hidl_string& hDefaultUrl) { |
| 772 | if (status == Status_V1_2::OK) { |
| 773 | request = toVector(hRequest); |
| 774 | defaultUrl = toString8(hDefaultUrl); |
| 775 | *keyRequestType = toKeyRequestType_1_1(hKeyRequestType); |
| 776 | } |
Robert Shih | 5944a0b | 2021-02-10 04:26:33 -0800 | [diff] [blame] | 777 | err = toStatusT(status); |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 778 | }); |
| 779 | } else if (mPluginV1_1 != NULL) { |
| 780 | hResult = mPluginV1_1->getKeyRequest_1_1( |
Rahul Frias | 59bc3fa | 2018-01-22 23:48:52 -0800 | [diff] [blame] | 781 | toHidlVec(sessionId), toHidlVec(initData), |
| 782 | toHidlString(mimeType), hKeyType, hOptionalParameters, |
| 783 | [&](Status status, const hidl_vec<uint8_t>& hRequest, |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 784 | KeyRequestType_V1_1 hKeyRequestType, |
| 785 | const hidl_string& hDefaultUrl) { |
| 786 | if (status == Status::OK) { |
| 787 | request = toVector(hRequest); |
| 788 | defaultUrl = toString8(hDefaultUrl); |
| 789 | *keyRequestType = toKeyRequestType_1_1(hKeyRequestType); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 790 | } |
| 791 | err = toStatusT(status); |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 792 | }); |
| 793 | } else { |
| 794 | hResult = mPlugin->getKeyRequest( |
| 795 | toHidlVec(sessionId), toHidlVec(initData), |
| 796 | toHidlString(mimeType), hKeyType, hOptionalParameters, |
| 797 | [&](Status status, const hidl_vec<uint8_t>& hRequest, |
| 798 | KeyRequestType hKeyRequestType, |
| 799 | const hidl_string& hDefaultUrl) { |
| 800 | if (status == Status::OK) { |
| 801 | request = toVector(hRequest); |
| 802 | defaultUrl = toString8(hDefaultUrl); |
| 803 | *keyRequestType = toKeyRequestType(hKeyRequestType); |
| 804 | } |
| 805 | err = toStatusT(status); |
| 806 | }); |
| 807 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 808 | |
Adam Stone | f0e618d | 2018-01-17 19:20:41 -0800 | [diff] [blame] | 809 | err = hResult.isOk() ? err : DEAD_OBJECT; |
| 810 | keyRequestTimer.SetAttribute(err); |
| 811 | return err; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | status_t DrmHal::provideKeyResponse(Vector<uint8_t> const &sessionId, |
| 815 | Vector<uint8_t> const &response, Vector<uint8_t> &keySetId) { |
| 816 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 817 | INIT_CHECK(); |
George Burgess IV | c42403d | 2019-10-18 09:54:32 -0700 | [diff] [blame] | 818 | EventTimer<status_t> keyResponseTimer(&mMetrics.mProvideKeyResponseTimeUs); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 819 | |
| 820 | DrmSessionManager::Instance()->useSession(sessionId); |
| 821 | |
| 822 | status_t err = UNKNOWN_ERROR; |
| 823 | |
| 824 | Return<void> hResult = mPlugin->provideKeyResponse(toHidlVec(sessionId), |
| 825 | toHidlVec(response), |
| 826 | [&](Status status, const hidl_vec<uint8_t>& hKeySetId) { |
| 827 | if (status == Status::OK) { |
| 828 | keySetId = toVector(hKeySetId); |
| 829 | } |
| 830 | err = toStatusT(status); |
| 831 | } |
| 832 | ); |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 833 | err = hResult.isOk() ? err : DEAD_OBJECT; |
| 834 | keyResponseTimer.SetAttribute(err); |
| 835 | return err; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 836 | } |
| 837 | |
| 838 | status_t DrmHal::removeKeys(Vector<uint8_t> const &keySetId) { |
| 839 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 840 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 841 | |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 842 | Return<Status> status = mPlugin->removeKeys(toHidlVec(keySetId)); |
| 843 | return status.isOk() ? toStatusT(status) : DEAD_OBJECT; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 844 | } |
| 845 | |
| 846 | status_t DrmHal::restoreKeys(Vector<uint8_t> const &sessionId, |
| 847 | Vector<uint8_t> const &keySetId) { |
| 848 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 849 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 850 | |
| 851 | DrmSessionManager::Instance()->useSession(sessionId); |
| 852 | |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 853 | Return<Status> status = mPlugin->restoreKeys(toHidlVec(sessionId), |
| 854 | toHidlVec(keySetId)); |
| 855 | return status.isOk() ? toStatusT(status) : DEAD_OBJECT; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | status_t DrmHal::queryKeyStatus(Vector<uint8_t> const &sessionId, |
| 859 | KeyedVector<String8, String8> &infoMap) const { |
| 860 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 861 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 862 | |
| 863 | DrmSessionManager::Instance()->useSession(sessionId); |
| 864 | |
| 865 | ::KeyedVector hInfoMap; |
| 866 | |
| 867 | status_t err = UNKNOWN_ERROR; |
| 868 | |
| 869 | Return<void> hResult = mPlugin->queryKeyStatus(toHidlVec(sessionId), |
| 870 | [&](Status status, const hidl_vec<KeyValue>& map) { |
| 871 | if (status == Status::OK) { |
| 872 | infoMap = toKeyedVector(map); |
| 873 | } |
| 874 | err = toStatusT(status); |
| 875 | } |
| 876 | ); |
| 877 | |
| 878 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 879 | } |
| 880 | |
| 881 | status_t DrmHal::getProvisionRequest(String8 const &certType, |
| 882 | String8 const &certAuthority, Vector<uint8_t> &request, |
| 883 | String8 &defaultUrl) { |
| 884 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 885 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 886 | |
| 887 | status_t err = UNKNOWN_ERROR; |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 888 | Return<void> hResult; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 889 | |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 890 | if (mPluginV1_2 != NULL) { |
| 891 | Return<void> hResult = mPluginV1_2->getProvisionRequest_1_2( |
| 892 | toHidlString(certType), toHidlString(certAuthority), |
| 893 | [&](Status_V1_2 status, const hidl_vec<uint8_t>& hRequest, |
| 894 | const hidl_string& hDefaultUrl) { |
| 895 | if (status == Status_V1_2::OK) { |
| 896 | request = toVector(hRequest); |
| 897 | defaultUrl = toString8(hDefaultUrl); |
| 898 | } |
Robert Shih | 5944a0b | 2021-02-10 04:26:33 -0800 | [diff] [blame] | 899 | err = toStatusT(status); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 900 | } |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 901 | ); |
| 902 | } else { |
| 903 | Return<void> hResult = mPlugin->getProvisionRequest( |
| 904 | toHidlString(certType), toHidlString(certAuthority), |
| 905 | [&](Status status, const hidl_vec<uint8_t>& hRequest, |
| 906 | const hidl_string& hDefaultUrl) { |
| 907 | if (status == Status::OK) { |
| 908 | request = toVector(hRequest); |
| 909 | defaultUrl = toString8(hDefaultUrl); |
| 910 | } |
| 911 | err = toStatusT(status); |
| 912 | } |
| 913 | ); |
| 914 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 915 | |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 916 | err = hResult.isOk() ? err : DEAD_OBJECT; |
| 917 | mMetrics.mGetProvisionRequestCounter.Increment(err); |
| 918 | return err; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | status_t DrmHal::provideProvisionResponse(Vector<uint8_t> const &response, |
Edwin Wong | 68b3d9f | 2017-01-06 19:07:54 -0800 | [diff] [blame] | 922 | Vector<uint8_t> &certificate, Vector<uint8_t> &wrappedKey) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 923 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 924 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 925 | |
| 926 | status_t err = UNKNOWN_ERROR; |
| 927 | |
| 928 | Return<void> hResult = mPlugin->provideProvisionResponse(toHidlVec(response), |
| 929 | [&](Status status, const hidl_vec<uint8_t>& hCertificate, |
| 930 | const hidl_vec<uint8_t>& hWrappedKey) { |
| 931 | if (status == Status::OK) { |
| 932 | certificate = toVector(hCertificate); |
| 933 | wrappedKey = toVector(hWrappedKey); |
| 934 | } |
| 935 | err = toStatusT(status); |
| 936 | } |
| 937 | ); |
| 938 | |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 939 | err = hResult.isOk() ? err : DEAD_OBJECT; |
| 940 | mMetrics.mProvideProvisionResponseCounter.Increment(err); |
| 941 | return err; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 942 | } |
| 943 | |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 944 | status_t DrmHal::getSecureStops(List<Vector<uint8_t>> &secureStops) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 945 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 946 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 947 | |
| 948 | status_t err = UNKNOWN_ERROR; |
| 949 | |
| 950 | Return<void> hResult = mPlugin->getSecureStops( |
| 951 | [&](Status status, const hidl_vec<SecureStop>& hSecureStops) { |
| 952 | if (status == Status::OK) { |
| 953 | secureStops = toSecureStops(hSecureStops); |
| 954 | } |
| 955 | err = toStatusT(status); |
| 956 | } |
| 957 | ); |
| 958 | |
| 959 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 960 | } |
| 961 | |
| 962 | |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 963 | status_t DrmHal::getSecureStopIds(List<Vector<uint8_t>> &secureStopIds) { |
| 964 | Mutex::Autolock autoLock(mLock); |
| 965 | |
| 966 | if (mInitCheck != OK) { |
| 967 | return mInitCheck; |
| 968 | } |
| 969 | |
| 970 | if (mPluginV1_1 == NULL) { |
| 971 | return ERROR_DRM_CANNOT_HANDLE; |
| 972 | } |
| 973 | |
| 974 | status_t err = UNKNOWN_ERROR; |
| 975 | |
| 976 | Return<void> hResult = mPluginV1_1->getSecureStopIds( |
| 977 | [&](Status status, const hidl_vec<SecureStopId>& hSecureStopIds) { |
| 978 | if (status == Status::OK) { |
| 979 | secureStopIds = toSecureStopIds(hSecureStopIds); |
| 980 | } |
| 981 | err = toStatusT(status); |
| 982 | } |
| 983 | ); |
| 984 | |
| 985 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 986 | } |
| 987 | |
| 988 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 989 | status_t DrmHal::getSecureStop(Vector<uint8_t> const &ssid, Vector<uint8_t> &secureStop) { |
| 990 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 991 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 992 | |
| 993 | status_t err = UNKNOWN_ERROR; |
| 994 | |
| 995 | Return<void> hResult = mPlugin->getSecureStop(toHidlVec(ssid), |
| 996 | [&](Status status, const SecureStop& hSecureStop) { |
| 997 | if (status == Status::OK) { |
| 998 | secureStop = toVector(hSecureStop.opaqueData); |
| 999 | } |
| 1000 | err = toStatusT(status); |
| 1001 | } |
| 1002 | ); |
| 1003 | |
| 1004 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1005 | } |
| 1006 | |
| 1007 | status_t DrmHal::releaseSecureStops(Vector<uint8_t> const &ssRelease) { |
| 1008 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1009 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1010 | |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 1011 | Return<Status> status(Status::ERROR_DRM_UNKNOWN); |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 1012 | if (mPluginV1_1 != NULL) { |
| 1013 | SecureStopRelease secureStopRelease; |
| 1014 | secureStopRelease.opaqueData = toHidlVec(ssRelease); |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 1015 | status = mPluginV1_1->releaseSecureStops(secureStopRelease); |
| 1016 | } else { |
| 1017 | status = mPlugin->releaseSecureStop(toHidlVec(ssRelease)); |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 1018 | } |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 1019 | return status.isOk() ? toStatusT(status) : DEAD_OBJECT; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1020 | } |
| 1021 | |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 1022 | status_t DrmHal::removeSecureStop(Vector<uint8_t> const &ssid) { |
| 1023 | Mutex::Autolock autoLock(mLock); |
| 1024 | |
| 1025 | if (mInitCheck != OK) { |
| 1026 | return mInitCheck; |
| 1027 | } |
| 1028 | |
| 1029 | if (mPluginV1_1 == NULL) { |
| 1030 | return ERROR_DRM_CANNOT_HANDLE; |
| 1031 | } |
| 1032 | |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 1033 | Return<Status> status = mPluginV1_1->removeSecureStop(toHidlVec(ssid)); |
| 1034 | return status.isOk() ? toStatusT(status) : DEAD_OBJECT; |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 1035 | } |
| 1036 | |
| 1037 | status_t DrmHal::removeAllSecureStops() { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1038 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1039 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1040 | |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 1041 | Return<Status> status(Status::ERROR_DRM_UNKNOWN); |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 1042 | if (mPluginV1_1 != NULL) { |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 1043 | status = mPluginV1_1->removeAllSecureStops(); |
| 1044 | } else { |
| 1045 | status = mPlugin->releaseAllSecureStops(); |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 1046 | } |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 1047 | return status.isOk() ? toStatusT(status) : DEAD_OBJECT; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1048 | } |
| 1049 | |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1050 | status_t DrmHal::getHdcpLevels(DrmPlugin::HdcpLevel *connected, |
| 1051 | DrmPlugin::HdcpLevel *max) const { |
| 1052 | Mutex::Autolock autoLock(mLock); |
| 1053 | INIT_CHECK(); |
| 1054 | |
| 1055 | if (connected == NULL || max == NULL) { |
| 1056 | return BAD_VALUE; |
| 1057 | } |
| 1058 | status_t err = UNKNOWN_ERROR; |
| 1059 | |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1060 | *connected = DrmPlugin::kHdcpLevelUnknown; |
| 1061 | *max = DrmPlugin::kHdcpLevelUnknown; |
| 1062 | |
Jeff Tinker | 44c2cc4 | 2019-01-14 10:24:18 -0800 | [diff] [blame] | 1063 | Return<void> hResult; |
| 1064 | if (mPluginV1_2 != NULL) { |
| 1065 | hResult = mPluginV1_2->getHdcpLevels_1_2( |
| 1066 | [&](Status_V1_2 status, const HdcpLevel_V1_2& hConnected, const HdcpLevel_V1_2& hMax) { |
| 1067 | if (status == Status_V1_2::OK) { |
| 1068 | *connected = toHdcpLevel(hConnected); |
| 1069 | *max = toHdcpLevel(hMax); |
| 1070 | } |
Robert Shih | 5944a0b | 2021-02-10 04:26:33 -0800 | [diff] [blame] | 1071 | err = toStatusT(status); |
Jeff Tinker | 44c2cc4 | 2019-01-14 10:24:18 -0800 | [diff] [blame] | 1072 | }); |
| 1073 | } else if (mPluginV1_1 != NULL) { |
| 1074 | hResult = mPluginV1_1->getHdcpLevels( |
| 1075 | [&](Status status, const HdcpLevel& hConnected, const HdcpLevel& hMax) { |
| 1076 | if (status == Status::OK) { |
| 1077 | *connected = toHdcpLevel(static_cast<HdcpLevel_V1_2>(hConnected)); |
| 1078 | *max = toHdcpLevel(static_cast<HdcpLevel_V1_2>(hMax)); |
| 1079 | } |
| 1080 | err = toStatusT(status); |
| 1081 | }); |
| 1082 | } else { |
| 1083 | return ERROR_DRM_CANNOT_HANDLE; |
| 1084 | } |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1085 | |
| 1086 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1087 | } |
| 1088 | |
| 1089 | status_t DrmHal::getNumberOfSessions(uint32_t *open, uint32_t *max) const { |
| 1090 | Mutex::Autolock autoLock(mLock); |
| 1091 | INIT_CHECK(); |
| 1092 | |
| 1093 | if (open == NULL || max == NULL) { |
| 1094 | return BAD_VALUE; |
| 1095 | } |
| 1096 | status_t err = UNKNOWN_ERROR; |
| 1097 | |
| 1098 | *open = 0; |
| 1099 | *max = 0; |
| 1100 | |
| 1101 | if (mPluginV1_1 == NULL) { |
| 1102 | return ERROR_DRM_CANNOT_HANDLE; |
| 1103 | } |
| 1104 | |
| 1105 | Return<void> hResult = mPluginV1_1->getNumberOfSessions( |
| 1106 | [&](Status status, uint32_t hOpen, uint32_t hMax) { |
| 1107 | if (status == Status::OK) { |
| 1108 | *open = hOpen; |
| 1109 | *max = hMax; |
| 1110 | } |
| 1111 | err = toStatusT(status); |
| 1112 | } |
| 1113 | ); |
| 1114 | |
| 1115 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1116 | } |
| 1117 | |
| 1118 | status_t DrmHal::getSecurityLevel(Vector<uint8_t> const &sessionId, |
| 1119 | DrmPlugin::SecurityLevel *level) const { |
| 1120 | Mutex::Autolock autoLock(mLock); |
| 1121 | INIT_CHECK(); |
| 1122 | |
| 1123 | if (level == NULL) { |
| 1124 | return BAD_VALUE; |
| 1125 | } |
| 1126 | status_t err = UNKNOWN_ERROR; |
| 1127 | |
| 1128 | if (mPluginV1_1 == NULL) { |
| 1129 | return ERROR_DRM_CANNOT_HANDLE; |
| 1130 | } |
| 1131 | |
| 1132 | *level = DrmPlugin::kSecurityLevelUnknown; |
| 1133 | |
| 1134 | Return<void> hResult = mPluginV1_1->getSecurityLevel(toHidlVec(sessionId), |
| 1135 | [&](Status status, SecurityLevel hLevel) { |
| 1136 | if (status == Status::OK) { |
| 1137 | *level = toSecurityLevel(hLevel); |
| 1138 | } |
| 1139 | err = toStatusT(status); |
| 1140 | } |
| 1141 | ); |
| 1142 | |
| 1143 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1144 | } |
| 1145 | |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 1146 | status_t DrmHal::getOfflineLicenseKeySetIds(List<Vector<uint8_t>> &keySetIds) const { |
| 1147 | Mutex::Autolock autoLock(mLock); |
| 1148 | |
| 1149 | if (mInitCheck != OK) { |
| 1150 | return mInitCheck; |
| 1151 | } |
| 1152 | |
| 1153 | if (mPluginV1_2 == NULL) { |
Jeff Tinker | db3fa5f | 2019-01-25 22:56:56 -0800 | [diff] [blame] | 1154 | return ERROR_UNSUPPORTED; |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | status_t err = UNKNOWN_ERROR; |
| 1158 | |
| 1159 | Return<void> hResult = mPluginV1_2->getOfflineLicenseKeySetIds( |
| 1160 | [&](Status status, const hidl_vec<KeySetId>& hKeySetIds) { |
| 1161 | if (status == Status::OK) { |
| 1162 | keySetIds = toKeySetIds(hKeySetIds); |
| 1163 | } |
| 1164 | err = toStatusT(status); |
| 1165 | } |
| 1166 | ); |
| 1167 | |
| 1168 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1169 | } |
| 1170 | |
| 1171 | status_t DrmHal::removeOfflineLicense(Vector<uint8_t> const &keySetId) { |
| 1172 | Mutex::Autolock autoLock(mLock); |
| 1173 | |
| 1174 | if (mInitCheck != OK) { |
| 1175 | return mInitCheck; |
| 1176 | } |
| 1177 | |
| 1178 | if (mPluginV1_2 == NULL) { |
Jeff Tinker | db3fa5f | 2019-01-25 22:56:56 -0800 | [diff] [blame] | 1179 | return ERROR_UNSUPPORTED; |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 1180 | } |
| 1181 | |
| 1182 | Return<Status> status = mPluginV1_2->removeOfflineLicense(toHidlVec(keySetId)); |
| 1183 | return status.isOk() ? toStatusT(status) : DEAD_OBJECT; |
| 1184 | } |
| 1185 | |
| 1186 | status_t DrmHal::getOfflineLicenseState(Vector<uint8_t> const &keySetId, |
| 1187 | DrmPlugin::OfflineLicenseState *licenseState) const { |
| 1188 | Mutex::Autolock autoLock(mLock); |
| 1189 | |
| 1190 | if (mInitCheck != OK) { |
| 1191 | return mInitCheck; |
| 1192 | } |
| 1193 | |
| 1194 | if (mPluginV1_2 == NULL) { |
Jeff Tinker | db3fa5f | 2019-01-25 22:56:56 -0800 | [diff] [blame] | 1195 | return ERROR_UNSUPPORTED; |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 1196 | } |
| 1197 | *licenseState = DrmPlugin::kOfflineLicenseStateUnknown; |
| 1198 | |
| 1199 | status_t err = UNKNOWN_ERROR; |
| 1200 | |
| 1201 | Return<void> hResult = mPluginV1_2->getOfflineLicenseState(toHidlVec(keySetId), |
| 1202 | [&](Status status, OfflineLicenseState hLicenseState) { |
| 1203 | if (status == Status::OK) { |
| 1204 | *licenseState = toOfflineLicenseState(hLicenseState); |
| 1205 | } |
| 1206 | err = toStatusT(status); |
| 1207 | } |
| 1208 | ); |
| 1209 | |
| 1210 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1211 | } |
| 1212 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1213 | status_t DrmHal::getPropertyString(String8 const &name, String8 &value ) const { |
| 1214 | Mutex::Autolock autoLock(mLock); |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 1215 | return getPropertyStringInternal(name, value); |
| 1216 | } |
| 1217 | |
| 1218 | status_t DrmHal::getPropertyStringInternal(String8 const &name, String8 &value) const { |
| 1219 | // This function is internal to the class and should only be called while |
| 1220 | // mLock is already held. |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1221 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1222 | |
| 1223 | status_t err = UNKNOWN_ERROR; |
| 1224 | |
| 1225 | Return<void> hResult = mPlugin->getPropertyString(toHidlString(name), |
| 1226 | [&](Status status, const hidl_string& hValue) { |
| 1227 | if (status == Status::OK) { |
| 1228 | value = toString8(hValue); |
| 1229 | } |
| 1230 | err = toStatusT(status); |
| 1231 | } |
| 1232 | ); |
| 1233 | |
| 1234 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1235 | } |
| 1236 | |
| 1237 | status_t DrmHal::getPropertyByteArray(String8 const &name, Vector<uint8_t> &value ) const { |
| 1238 | Mutex::Autolock autoLock(mLock); |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 1239 | return getPropertyByteArrayInternal(name, value); |
| 1240 | } |
| 1241 | |
| 1242 | status_t DrmHal::getPropertyByteArrayInternal(String8 const &name, Vector<uint8_t> &value ) const { |
| 1243 | // This function is internal to the class and should only be called while |
| 1244 | // mLock is already held. |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1245 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1246 | |
| 1247 | status_t err = UNKNOWN_ERROR; |
| 1248 | |
| 1249 | Return<void> hResult = mPlugin->getPropertyByteArray(toHidlString(name), |
| 1250 | [&](Status status, const hidl_vec<uint8_t>& hValue) { |
| 1251 | if (status == Status::OK) { |
| 1252 | value = toVector(hValue); |
| 1253 | } |
| 1254 | err = toStatusT(status); |
| 1255 | } |
| 1256 | ); |
| 1257 | |
Adam Stone | cea91ce | 2018-01-22 19:23:28 -0800 | [diff] [blame] | 1258 | err = hResult.isOk() ? err : DEAD_OBJECT; |
| 1259 | if (name == kPropertyDeviceUniqueId) { |
| 1260 | mMetrics.mGetDeviceUniqueIdCounter.Increment(err); |
| 1261 | } |
| 1262 | return err; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | status_t DrmHal::setPropertyString(String8 const &name, String8 const &value ) const { |
| 1266 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1267 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1268 | |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 1269 | Return<Status> status = mPlugin->setPropertyString(toHidlString(name), |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1270 | toHidlString(value)); |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 1271 | return status.isOk() ? toStatusT(status) : DEAD_OBJECT; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1272 | } |
| 1273 | |
| 1274 | status_t DrmHal::setPropertyByteArray(String8 const &name, |
| 1275 | Vector<uint8_t> const &value ) const { |
| 1276 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1277 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1278 | |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 1279 | Return<Status> status = mPlugin->setPropertyByteArray(toHidlString(name), |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1280 | toHidlVec(value)); |
Jeff Tinker | 58ad475 | 2018-02-16 16:51:59 -0800 | [diff] [blame] | 1281 | return status.isOk() ? toStatusT(status) : DEAD_OBJECT; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1282 | } |
| 1283 | |
Robert Shih | 9353881 | 2019-11-12 12:21:35 -0800 | [diff] [blame] | 1284 | status_t DrmHal::getMetrics(const sp<IDrmMetricsConsumer> &consumer) { |
| 1285 | if (consumer == nullptr) { |
Adam Stone | 28f27c3 | 2018-02-05 15:07:48 -0800 | [diff] [blame] | 1286 | return UNEXPECTED_NULL; |
| 1287 | } |
Robert Shih | 9353881 | 2019-11-12 12:21:35 -0800 | [diff] [blame] | 1288 | consumer->consumeFrameworkMetrics(mMetrics); |
Adam Stone | 28f27c3 | 2018-02-05 15:07:48 -0800 | [diff] [blame] | 1289 | |
| 1290 | // Append vendor metrics if they are supported. |
| 1291 | if (mPluginV1_1 != NULL) { |
| 1292 | String8 vendor; |
| 1293 | String8 description; |
| 1294 | if (getPropertyStringInternal(String8("vendor"), vendor) != OK |
| 1295 | || vendor.isEmpty()) { |
| 1296 | ALOGE("Get vendor failed or is empty"); |
| 1297 | vendor = "NONE"; |
| 1298 | } |
| 1299 | if (getPropertyStringInternal(String8("description"), description) != OK |
| 1300 | || description.isEmpty()) { |
| 1301 | ALOGE("Get description failed or is empty."); |
| 1302 | description = "NONE"; |
| 1303 | } |
| 1304 | vendor += "."; |
| 1305 | vendor += description; |
| 1306 | |
| 1307 | hidl_vec<DrmMetricGroup> pluginMetrics; |
| 1308 | status_t err = UNKNOWN_ERROR; |
| 1309 | |
| 1310 | Return<void> status = mPluginV1_1->getMetrics( |
| 1311 | [&](Status status, hidl_vec<DrmMetricGroup> pluginMetrics) { |
| 1312 | if (status != Status::OK) { |
| 1313 | ALOGV("Error getting plugin metrics: %d", status); |
| 1314 | } else { |
Robert Shih | 9353881 | 2019-11-12 12:21:35 -0800 | [diff] [blame] | 1315 | consumer->consumeHidlMetrics(vendor, pluginMetrics); |
Adam Stone | 28f27c3 | 2018-02-05 15:07:48 -0800 | [diff] [blame] | 1316 | } |
| 1317 | err = toStatusT(status); |
| 1318 | }); |
| 1319 | return status.isOk() ? err : DEAD_OBJECT; |
Adam Stone | f0e618d | 2018-01-17 19:20:41 -0800 | [diff] [blame] | 1320 | } |
| 1321 | |
Adam Stone | ab394d1 | 2017-12-22 12:34:20 -0800 | [diff] [blame] | 1322 | return OK; |
| 1323 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1324 | |
| 1325 | status_t DrmHal::setCipherAlgorithm(Vector<uint8_t> const &sessionId, |
| 1326 | String8 const &algorithm) { |
| 1327 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1328 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1329 | |
| 1330 | DrmSessionManager::Instance()->useSession(sessionId); |
| 1331 | |
Jeff Tinker | e641294 | 2018-04-30 17:35:16 -0700 | [diff] [blame] | 1332 | Return<Status> status = mPlugin->setCipherAlgorithm(toHidlVec(sessionId), |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1333 | toHidlString(algorithm)); |
Jeff Tinker | e641294 | 2018-04-30 17:35:16 -0700 | [diff] [blame] | 1334 | return status.isOk() ? toStatusT(status) : DEAD_OBJECT; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1335 | } |
| 1336 | |
| 1337 | status_t DrmHal::setMacAlgorithm(Vector<uint8_t> const &sessionId, |
| 1338 | String8 const &algorithm) { |
| 1339 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1340 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1341 | |
| 1342 | DrmSessionManager::Instance()->useSession(sessionId); |
| 1343 | |
Jeff Tinker | e641294 | 2018-04-30 17:35:16 -0700 | [diff] [blame] | 1344 | Return<Status> status = mPlugin->setMacAlgorithm(toHidlVec(sessionId), |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1345 | toHidlString(algorithm)); |
Jeff Tinker | e641294 | 2018-04-30 17:35:16 -0700 | [diff] [blame] | 1346 | return status.isOk() ? toStatusT(status) : DEAD_OBJECT; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1347 | } |
| 1348 | |
| 1349 | status_t DrmHal::encrypt(Vector<uint8_t> const &sessionId, |
Edwin Wong | 68b3d9f | 2017-01-06 19:07:54 -0800 | [diff] [blame] | 1350 | Vector<uint8_t> const &keyId, Vector<uint8_t> const &input, |
| 1351 | Vector<uint8_t> const &iv, Vector<uint8_t> &output) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1352 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1353 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1354 | |
| 1355 | DrmSessionManager::Instance()->useSession(sessionId); |
| 1356 | |
| 1357 | status_t err = UNKNOWN_ERROR; |
| 1358 | |
| 1359 | Return<void> hResult = mPlugin->encrypt(toHidlVec(sessionId), |
| 1360 | toHidlVec(keyId), toHidlVec(input), toHidlVec(iv), |
| 1361 | [&](Status status, const hidl_vec<uint8_t>& hOutput) { |
| 1362 | if (status == Status::OK) { |
| 1363 | output = toVector(hOutput); |
| 1364 | } |
| 1365 | err = toStatusT(status); |
| 1366 | } |
| 1367 | ); |
| 1368 | |
| 1369 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1370 | } |
| 1371 | |
| 1372 | status_t DrmHal::decrypt(Vector<uint8_t> const &sessionId, |
Edwin Wong | 68b3d9f | 2017-01-06 19:07:54 -0800 | [diff] [blame] | 1373 | Vector<uint8_t> const &keyId, Vector<uint8_t> const &input, |
| 1374 | Vector<uint8_t> const &iv, Vector<uint8_t> &output) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1375 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1376 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1377 | |
| 1378 | DrmSessionManager::Instance()->useSession(sessionId); |
| 1379 | |
| 1380 | status_t err = UNKNOWN_ERROR; |
| 1381 | |
| 1382 | Return<void> hResult = mPlugin->decrypt(toHidlVec(sessionId), |
| 1383 | toHidlVec(keyId), toHidlVec(input), toHidlVec(iv), |
| 1384 | [&](Status status, const hidl_vec<uint8_t>& hOutput) { |
| 1385 | if (status == Status::OK) { |
| 1386 | output = toVector(hOutput); |
| 1387 | } |
| 1388 | err = toStatusT(status); |
| 1389 | } |
| 1390 | ); |
| 1391 | |
| 1392 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1393 | } |
| 1394 | |
| 1395 | status_t DrmHal::sign(Vector<uint8_t> const &sessionId, |
Edwin Wong | 68b3d9f | 2017-01-06 19:07:54 -0800 | [diff] [blame] | 1396 | Vector<uint8_t> const &keyId, Vector<uint8_t> const &message, |
| 1397 | Vector<uint8_t> &signature) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1398 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1399 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1400 | |
| 1401 | DrmSessionManager::Instance()->useSession(sessionId); |
| 1402 | |
| 1403 | status_t err = UNKNOWN_ERROR; |
| 1404 | |
| 1405 | Return<void> hResult = mPlugin->sign(toHidlVec(sessionId), |
| 1406 | toHidlVec(keyId), toHidlVec(message), |
| 1407 | [&](Status status, const hidl_vec<uint8_t>& hSignature) { |
| 1408 | if (status == Status::OK) { |
| 1409 | signature = toVector(hSignature); |
| 1410 | } |
| 1411 | err = toStatusT(status); |
| 1412 | } |
| 1413 | ); |
| 1414 | |
| 1415 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1416 | } |
| 1417 | |
| 1418 | status_t DrmHal::verify(Vector<uint8_t> const &sessionId, |
Edwin Wong | 68b3d9f | 2017-01-06 19:07:54 -0800 | [diff] [blame] | 1419 | Vector<uint8_t> const &keyId, Vector<uint8_t> const &message, |
| 1420 | Vector<uint8_t> const &signature, bool &match) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1421 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1422 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1423 | |
| 1424 | DrmSessionManager::Instance()->useSession(sessionId); |
| 1425 | |
| 1426 | status_t err = UNKNOWN_ERROR; |
| 1427 | |
| 1428 | Return<void> hResult = mPlugin->verify(toHidlVec(sessionId),toHidlVec(keyId), |
| 1429 | toHidlVec(message), toHidlVec(signature), |
| 1430 | [&](Status status, bool hMatch) { |
| 1431 | if (status == Status::OK) { |
| 1432 | match = hMatch; |
| 1433 | } else { |
| 1434 | match = false; |
| 1435 | } |
| 1436 | err = toStatusT(status); |
| 1437 | } |
| 1438 | ); |
| 1439 | |
| 1440 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1441 | } |
| 1442 | |
| 1443 | status_t DrmHal::signRSA(Vector<uint8_t> const &sessionId, |
Edwin Wong | 68b3d9f | 2017-01-06 19:07:54 -0800 | [diff] [blame] | 1444 | String8 const &algorithm, Vector<uint8_t> const &message, |
| 1445 | Vector<uint8_t> const &wrappedKey, Vector<uint8_t> &signature) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1446 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 1447 | INIT_CHECK(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1448 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1449 | DrmSessionManager::Instance()->useSession(sessionId); |
| 1450 | |
| 1451 | status_t err = UNKNOWN_ERROR; |
| 1452 | |
| 1453 | Return<void> hResult = mPlugin->signRSA(toHidlVec(sessionId), |
| 1454 | toHidlString(algorithm), toHidlVec(message), toHidlVec(wrappedKey), |
| 1455 | [&](Status status, const hidl_vec<uint8_t>& hSignature) { |
| 1456 | if (status == Status::OK) { |
| 1457 | signature = toVector(hSignature); |
| 1458 | } |
| 1459 | err = toStatusT(status); |
| 1460 | } |
| 1461 | ); |
| 1462 | |
| 1463 | return hResult.isOk() ? err : DEAD_OBJECT; |
| 1464 | } |
| 1465 | |
Robert Shih | 7e36f26 | 2021-03-10 05:32:23 -0800 | [diff] [blame] | 1466 | std::string DrmHal::reportFrameworkMetrics(const std::string& pluginMetrics) const |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 1467 | { |
Robert Shih | 82ea6be | 2019-11-07 17:47:23 -0800 | [diff] [blame] | 1468 | mediametrics_handle_t item(mediametrics_create("mediadrm")); |
| 1469 | mediametrics_setUid(item, mMetrics.GetAppUid()); |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 1470 | String8 vendor; |
| 1471 | String8 description; |
| 1472 | status_t result = getPropertyStringInternal(String8("vendor"), vendor); |
| 1473 | if (result != OK) { |
Jeff Tinker | 987ac70 | 2018-02-15 17:02:22 -0800 | [diff] [blame] | 1474 | ALOGE("Failed to get vendor from drm plugin: %d", result); |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 1475 | } else { |
Robert Shih | 82ea6be | 2019-11-07 17:47:23 -0800 | [diff] [blame] | 1476 | mediametrics_setCString(item, "vendor", vendor.c_str()); |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 1477 | } |
| 1478 | result = getPropertyStringInternal(String8("description"), description); |
| 1479 | if (result != OK) { |
Jeff Tinker | 987ac70 | 2018-02-15 17:02:22 -0800 | [diff] [blame] | 1480 | ALOGE("Failed to get description from drm plugin: %d", result); |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 1481 | } else { |
Robert Shih | 82ea6be | 2019-11-07 17:47:23 -0800 | [diff] [blame] | 1482 | mediametrics_setCString(item, "description", description.c_str()); |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 1483 | } |
Adam Stone | ab394d1 | 2017-12-22 12:34:20 -0800 | [diff] [blame] | 1484 | |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 1485 | std::string serializedMetrics; |
| 1486 | result = mMetrics.GetSerializedMetrics(&serializedMetrics); |
| 1487 | if (result != OK) { |
Jeff Tinker | 987ac70 | 2018-02-15 17:02:22 -0800 | [diff] [blame] | 1488 | ALOGE("Failed to serialize framework metrics: %d", result); |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 1489 | } |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 1490 | std::string b64EncodedMetrics = toBase64StringNoPad(serializedMetrics.data(), |
| 1491 | serializedMetrics.size()); |
| 1492 | if (!b64EncodedMetrics.empty()) { |
Robert Shih | 82ea6be | 2019-11-07 17:47:23 -0800 | [diff] [blame] | 1493 | mediametrics_setCString(item, "serialized_metrics", b64EncodedMetrics.c_str()); |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 1494 | } |
Robert Shih | 7e36f26 | 2021-03-10 05:32:23 -0800 | [diff] [blame] | 1495 | if (!pluginMetrics.empty()) { |
| 1496 | mediametrics_setCString(item, "plugin_metrics", pluginMetrics.c_str()); |
| 1497 | } |
Robert Shih | 82ea6be | 2019-11-07 17:47:23 -0800 | [diff] [blame] | 1498 | if (!mediametrics_selfRecord(item)) { |
Jeff Tinker | 987ac70 | 2018-02-15 17:02:22 -0800 | [diff] [blame] | 1499 | ALOGE("Failed to self record framework metrics"); |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 1500 | } |
Robert Shih | 82ea6be | 2019-11-07 17:47:23 -0800 | [diff] [blame] | 1501 | mediametrics_delete(item); |
Robert Shih | 7e36f26 | 2021-03-10 05:32:23 -0800 | [diff] [blame] | 1502 | return serializedMetrics; |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 1503 | } |
| 1504 | |
Robert Shih | 7e36f26 | 2021-03-10 05:32:23 -0800 | [diff] [blame] | 1505 | std::string DrmHal::reportPluginMetrics() const |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 1506 | { |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 1507 | Vector<uint8_t> metricsVector; |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 1508 | String8 vendor; |
| 1509 | String8 description; |
Robert Shih | 7e36f26 | 2021-03-10 05:32:23 -0800 | [diff] [blame] | 1510 | std::string metricsString; |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 1511 | if (getPropertyStringInternal(String8("vendor"), vendor) == OK && |
| 1512 | getPropertyStringInternal(String8("description"), description) == OK && |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 1513 | getPropertyByteArrayInternal(String8("metrics"), metricsVector) == OK) { |
Robert Shih | 7e36f26 | 2021-03-10 05:32:23 -0800 | [diff] [blame] | 1514 | metricsString = toBase64StringNoPad(metricsVector.array(), |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 1515 | metricsVector.size()); |
| 1516 | status_t res = android::reportDrmPluginMetrics(metricsString, vendor, |
Robert Shih | 82ea6be | 2019-11-07 17:47:23 -0800 | [diff] [blame] | 1517 | description, mMetrics.GetAppUid()); |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 1518 | if (res != OK) { |
Jeff Tinker | 987ac70 | 2018-02-15 17:02:22 -0800 | [diff] [blame] | 1519 | ALOGE("Metrics were retrieved but could not be reported: %d", res); |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 1520 | } |
| 1521 | } |
Robert Shih | 7e36f26 | 2021-03-10 05:32:23 -0800 | [diff] [blame] | 1522 | return metricsString; |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 1523 | } |
| 1524 | |
Robert Shih | fbe581e | 2021-01-14 05:12:04 -0800 | [diff] [blame] | 1525 | bool DrmHal::requiresSecureDecoder(const char *mime) const { |
| 1526 | Mutex::Autolock autoLock(mLock); |
| 1527 | if (mPluginV1_4 == NULL) { |
| 1528 | return false; |
| 1529 | } |
| 1530 | return mPluginV1_4->requiresSecureDecoderDefault(hidl_string(mime)); |
| 1531 | } |
| 1532 | |
| 1533 | bool DrmHal::requiresSecureDecoder(const char *mime, |
| 1534 | DrmPlugin::SecurityLevel securityLevel) const { |
| 1535 | Mutex::Autolock autoLock(mLock); |
| 1536 | if (mPluginV1_4 == NULL) { |
| 1537 | return false; |
| 1538 | } |
| 1539 | auto hLevel = toHidlSecurityLevel(securityLevel); |
| 1540 | return mPluginV1_4->requiresSecureDecoder(hidl_string(mime), hLevel); |
| 1541 | } |
| 1542 | |
Robert Shih | 726afea | 2021-01-17 23:41:12 -0800 | [diff] [blame] | 1543 | status_t DrmHal::setPlaybackId(Vector<uint8_t> const &sessionId, const char *playbackId) { |
| 1544 | Mutex::Autolock autoLock(mLock); |
| 1545 | if (mPluginV1_4 == NULL) { |
| 1546 | return ERROR_UNSUPPORTED; |
| 1547 | } |
| 1548 | drm::V1_0::Status err = mPluginV1_4->setPlaybackId( |
| 1549 | toHidlVec(sessionId), |
| 1550 | hidl_string(playbackId)); |
| 1551 | return toStatusT(err); |
| 1552 | } |
| 1553 | |
Robert Shih | 9afca95 | 2021-02-12 01:36:06 -0800 | [diff] [blame] | 1554 | status_t DrmHal::getLogMessages(Vector<drm::V1_4::LogMessage> &logs) const { |
| 1555 | Mutex::Autolock autoLock(mLock); |
| 1556 | return DrmUtils::GetLogMessages<drm::V1_4::IDrmPlugin>(mPlugin, logs); |
| 1557 | } |
| 1558 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 1559 | } // namespace android |