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 | |
Jeff Tinker | 7d2c6e8 | 2018-02-16 16:14:59 -0800 | [diff] [blame] | 20 | #include <mediadrm/DrmHal.h> |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 21 | #include <mediadrm/DrmHalAidl.h> |
| 22 | #include <mediadrm/DrmHalHidl.h> |
Robert Shih | c0d1d0e | 2019-11-24 13:21:04 -0800 | [diff] [blame] | 23 | #include <mediadrm/DrmUtils.h> |
Adam Stone | 32494f5 | 2018-02-26 22:53:27 -0800 | [diff] [blame] | 24 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 25 | namespace android { |
| 26 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 27 | DrmHal::DrmHal() { |
| 28 | mDrmHalHidl = sp<DrmHalHidl>::make(); |
Kyle Zhang | a55209d | 2022-02-03 01:52:46 +0000 | [diff] [blame] | 29 | mDrmHalAidl = sp<DrmHalAidl>::make(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 30 | } |
| 31 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 32 | DrmHal::~DrmHal() {} |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 33 | |
| 34 | status_t DrmHal::initCheck() const { |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 35 | if (mDrmHalAidl->initCheck() == OK || mDrmHalHidl->initCheck() == OK) return OK; |
| 36 | if (mDrmHalAidl->initCheck() == NO_INIT || mDrmHalHidl->initCheck() == NO_INIT) return NO_INIT; |
| 37 | return mDrmHalHidl->initCheck(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 38 | } |
| 39 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 40 | status_t DrmHal::isCryptoSchemeSupported(const uint8_t uuid[16], const String8& mimeType, |
| 41 | DrmPlugin::SecurityLevel securityLevel, bool* result) { |
| 42 | status_t statusResult; |
| 43 | statusResult = mDrmHalAidl->isCryptoSchemeSupported(uuid, mimeType, securityLevel, result); |
| 44 | if (*result) return statusResult; |
| 45 | return mDrmHalHidl->isCryptoSchemeSupported(uuid, mimeType, securityLevel, result); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 46 | } |
| 47 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 48 | status_t DrmHal::createPlugin(const uint8_t uuid[16], const String8& appPackageName) { |
| 49 | status_t statusResult; |
| 50 | statusResult = mDrmHalAidl->createPlugin(uuid, appPackageName); |
| 51 | if (statusResult != OK) return mDrmHalHidl->createPlugin(uuid, appPackageName); |
| 52 | return statusResult; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | status_t DrmHal::destroyPlugin() { |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 56 | status_t statusResult = mDrmHalAidl->destroyPlugin(); |
| 57 | status_t statusResultHidl = mDrmHalHidl->destroyPlugin(); |
| 58 | if (statusResult != OK) return statusResult; |
| 59 | return statusResultHidl; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 60 | } |
| 61 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 62 | status_t DrmHal::openSession(DrmPlugin::SecurityLevel securityLevel, Vector<uint8_t>& sessionId) { |
| 63 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->openSession(securityLevel, sessionId); |
| 64 | return mDrmHalHidl->openSession(securityLevel, sessionId); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 65 | } |
| 66 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 67 | status_t DrmHal::closeSession(Vector<uint8_t> const& sessionId) { |
| 68 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->closeSession(sessionId); |
| 69 | return mDrmHalHidl->closeSession(sessionId); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 70 | } |
| 71 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 72 | status_t DrmHal::getKeyRequest(Vector<uint8_t> const& sessionId, Vector<uint8_t> const& initData, |
| 73 | String8 const& mimeType, DrmPlugin::KeyType keyType, |
| 74 | KeyedVector<String8, String8> const& optionalParameters, |
| 75 | Vector<uint8_t>& request, String8& defaultUrl, |
| 76 | DrmPlugin::KeyRequestType* keyRequestType) { |
| 77 | if (mDrmHalAidl->initCheck() == OK) |
| 78 | return mDrmHalAidl->getKeyRequest(sessionId, initData, mimeType, keyType, |
| 79 | optionalParameters, request, defaultUrl, keyRequestType); |
| 80 | return mDrmHalHidl->getKeyRequest(sessionId, initData, mimeType, keyType, optionalParameters, |
| 81 | request, defaultUrl, keyRequestType); |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 82 | } |
| 83 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 84 | status_t DrmHal::provideKeyResponse(Vector<uint8_t> const& sessionId, |
| 85 | Vector<uint8_t> const& response, Vector<uint8_t>& keySetId) { |
| 86 | if (mDrmHalAidl->initCheck() == OK) |
| 87 | return mDrmHalAidl->provideKeyResponse(sessionId, response, keySetId); |
| 88 | return mDrmHalHidl->provideKeyResponse(sessionId, response, keySetId); |
Jeff Tinker | b8684f3 | 2018-12-12 08:41:31 -0800 | [diff] [blame] | 89 | } |
| 90 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 91 | status_t DrmHal::removeKeys(Vector<uint8_t> const& keySetId) { |
| 92 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->removeKeys(keySetId); |
| 93 | return mDrmHalHidl->removeKeys(keySetId); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 94 | } |
| 95 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 96 | status_t DrmHal::restoreKeys(Vector<uint8_t> const& sessionId, Vector<uint8_t> const& keySetId) { |
| 97 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->restoreKeys(sessionId, keySetId); |
| 98 | return mDrmHalHidl->restoreKeys(sessionId, keySetId); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 99 | } |
| 100 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 101 | status_t DrmHal::queryKeyStatus(Vector<uint8_t> const& sessionId, |
| 102 | KeyedVector<String8, String8>& infoMap) const { |
| 103 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->queryKeyStatus(sessionId, infoMap); |
| 104 | return mDrmHalHidl->queryKeyStatus(sessionId, infoMap); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 105 | } |
| 106 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 107 | status_t DrmHal::getProvisionRequest(String8 const& certType, String8 const& certAuthority, |
| 108 | Vector<uint8_t>& request, String8& defaultUrl) { |
| 109 | if (mDrmHalAidl->initCheck() == OK) |
| 110 | return mDrmHalAidl->getProvisionRequest(certType, certAuthority, request, defaultUrl); |
| 111 | return mDrmHalHidl->getProvisionRequest(certType, certAuthority, request, defaultUrl); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 112 | } |
| 113 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 114 | status_t DrmHal::provideProvisionResponse(Vector<uint8_t> const& response, |
| 115 | Vector<uint8_t>& certificate, |
| 116 | Vector<uint8_t>& wrappedKey) { |
| 117 | if (mDrmHalAidl->initCheck() == OK) |
| 118 | return mDrmHalAidl->provideProvisionResponse(response, certificate, wrappedKey); |
| 119 | return mDrmHalHidl->provideProvisionResponse(response, certificate, wrappedKey); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 120 | } |
| 121 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 122 | status_t DrmHal::getSecureStops(List<Vector<uint8_t>>& secureStops) { |
| 123 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->getSecureStops(secureStops); |
| 124 | return mDrmHalHidl->getSecureStops(secureStops); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 125 | } |
| 126 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 127 | status_t DrmHal::getSecureStopIds(List<Vector<uint8_t>>& secureStopIds) { |
| 128 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->getSecureStopIds(secureStopIds); |
| 129 | return mDrmHalHidl->getSecureStopIds(secureStopIds); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 130 | } |
| 131 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 132 | status_t DrmHal::getSecureStop(Vector<uint8_t> const& ssid, Vector<uint8_t>& secureStop) { |
| 133 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->getSecureStop(ssid, secureStop); |
| 134 | return mDrmHalHidl->getSecureStop(ssid, secureStop); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 135 | } |
| 136 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 137 | status_t DrmHal::releaseSecureStops(Vector<uint8_t> const& ssRelease) { |
| 138 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->releaseSecureStops(ssRelease); |
| 139 | return mDrmHalHidl->releaseSecureStops(ssRelease); |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 140 | } |
| 141 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 142 | status_t DrmHal::removeSecureStop(Vector<uint8_t> const& ssid) { |
| 143 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->removeSecureStop(ssid); |
| 144 | return mDrmHalHidl->removeSecureStop(ssid); |
Jeff Tinker | 15177d7 | 2018-01-25 12:57:55 -0800 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | status_t DrmHal::removeAllSecureStops() { |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 148 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->removeAllSecureStops(); |
| 149 | return mDrmHalHidl->removeAllSecureStops(); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 150 | } |
| 151 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 152 | status_t DrmHal::getHdcpLevels(DrmPlugin::HdcpLevel* connectedLevel, |
| 153 | DrmPlugin::HdcpLevel* maxLevel) const { |
| 154 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->getHdcpLevels(connectedLevel, maxLevel); |
| 155 | return mDrmHalHidl->getHdcpLevels(connectedLevel, maxLevel); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 156 | } |
| 157 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 158 | status_t DrmHal::getNumberOfSessions(uint32_t* currentSessions, uint32_t* maxSessions) const { |
| 159 | if (mDrmHalAidl->initCheck() == OK) |
| 160 | return mDrmHalAidl->getNumberOfSessions(currentSessions, maxSessions); |
| 161 | return mDrmHalHidl->getNumberOfSessions(currentSessions, maxSessions); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 162 | } |
| 163 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 164 | status_t DrmHal::getSecurityLevel(Vector<uint8_t> const& sessionId, |
| 165 | DrmPlugin::SecurityLevel* level) const { |
| 166 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->getSecurityLevel(sessionId, level); |
| 167 | return mDrmHalHidl->getSecurityLevel(sessionId, level); |
Jeff Tinker | 6d998b6 | 2017-12-18 14:37:43 -0800 | [diff] [blame] | 168 | } |
| 169 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 170 | status_t DrmHal::getOfflineLicenseKeySetIds(List<Vector<uint8_t>>& keySetIds) const { |
| 171 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->getOfflineLicenseKeySetIds(keySetIds); |
| 172 | return mDrmHalHidl->getOfflineLicenseKeySetIds(keySetIds); |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 175 | status_t DrmHal::removeOfflineLicense(Vector<uint8_t> const& keySetId) { |
| 176 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->removeOfflineLicense(keySetId); |
| 177 | return mDrmHalHidl->removeOfflineLicense(keySetId); |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 178 | } |
| 179 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 180 | status_t DrmHal::getOfflineLicenseState(Vector<uint8_t> const& keySetId, |
| 181 | DrmPlugin::OfflineLicenseState* licenseState) const { |
| 182 | if (mDrmHalAidl->initCheck() == OK) |
| 183 | return mDrmHalAidl->getOfflineLicenseState(keySetId, licenseState); |
| 184 | return mDrmHalHidl->getOfflineLicenseState(keySetId, licenseState); |
Jeff Tinker | c8baaba | 2018-10-23 11:32:36 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 187 | status_t DrmHal::getPropertyString(String8 const& name, String8& value) const { |
| 188 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->getPropertyString(name, value); |
| 189 | return mDrmHalHidl->getPropertyString(name, value); |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 190 | } |
| 191 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 192 | status_t DrmHal::getPropertyByteArray(String8 const& name, Vector<uint8_t>& value) const { |
| 193 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->getPropertyByteArray(name, value); |
| 194 | return mDrmHalHidl->getPropertyByteArray(name, value); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 195 | } |
| 196 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 197 | status_t DrmHal::setPropertyString(String8 const& name, String8 const& value) const { |
| 198 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->setPropertyString(name, value); |
| 199 | return mDrmHalHidl->setPropertyString(name, value); |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 202 | status_t DrmHal::setPropertyByteArray(String8 const& name, Vector<uint8_t> const& value) const { |
| 203 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->setPropertyByteArray(name, value); |
| 204 | return mDrmHalHidl->setPropertyByteArray(name, value); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 205 | } |
| 206 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 207 | status_t DrmHal::getMetrics(const sp<IDrmMetricsConsumer>& consumer) { |
| 208 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->getMetrics(consumer); |
| 209 | return mDrmHalHidl->getMetrics(consumer); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 210 | } |
| 211 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 212 | status_t DrmHal::setCipherAlgorithm(Vector<uint8_t> const& sessionId, String8 const& algorithm) { |
| 213 | if (mDrmHalAidl->initCheck() == OK) |
| 214 | return mDrmHalAidl->setCipherAlgorithm(sessionId, algorithm); |
| 215 | return mDrmHalHidl->setCipherAlgorithm(sessionId, algorithm); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 216 | } |
| 217 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 218 | status_t DrmHal::setMacAlgorithm(Vector<uint8_t> const& sessionId, String8 const& algorithm) { |
| 219 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->setMacAlgorithm(sessionId, algorithm); |
| 220 | return mDrmHalHidl->setMacAlgorithm(sessionId, algorithm); |
Adam Stone | ab394d1 | 2017-12-22 12:34:20 -0800 | [diff] [blame] | 221 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 222 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 223 | status_t DrmHal::encrypt(Vector<uint8_t> const& sessionId, Vector<uint8_t> const& keyId, |
| 224 | Vector<uint8_t> const& input, Vector<uint8_t> const& iv, |
| 225 | Vector<uint8_t>& output) { |
| 226 | if (mDrmHalAidl->initCheck() == OK) |
| 227 | return mDrmHalAidl->encrypt(sessionId, keyId, input, iv, output); |
| 228 | return mDrmHalHidl->encrypt(sessionId, keyId, input, iv, output); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 229 | } |
| 230 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 231 | status_t DrmHal::decrypt(Vector<uint8_t> const& sessionId, Vector<uint8_t> const& keyId, |
| 232 | Vector<uint8_t> const& input, Vector<uint8_t> const& iv, |
| 233 | Vector<uint8_t>& output) { |
| 234 | if (mDrmHalAidl->initCheck() == OK) |
| 235 | return mDrmHalAidl->decrypt(sessionId, keyId, input, iv, output); |
| 236 | return mDrmHalHidl->decrypt(sessionId, keyId, input, iv, output); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 237 | } |
| 238 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 239 | status_t DrmHal::sign(Vector<uint8_t> const& sessionId, Vector<uint8_t> const& keyId, |
| 240 | Vector<uint8_t> const& message, Vector<uint8_t>& signature) { |
| 241 | if (mDrmHalAidl->initCheck() == OK) |
| 242 | return mDrmHalAidl->sign(sessionId, keyId, message, signature); |
| 243 | return mDrmHalHidl->sign(sessionId, keyId, message, signature); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 244 | } |
| 245 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 246 | status_t DrmHal::verify(Vector<uint8_t> const& sessionId, Vector<uint8_t> const& keyId, |
| 247 | Vector<uint8_t> const& message, Vector<uint8_t> const& signature, |
| 248 | bool& match) { |
| 249 | if (mDrmHalAidl->initCheck() == OK) |
| 250 | return mDrmHalAidl->verify(sessionId, keyId, message, signature, match); |
| 251 | return mDrmHalHidl->verify(sessionId, keyId, message, signature, match); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 254 | status_t DrmHal::signRSA(Vector<uint8_t> const& sessionId, String8 const& algorithm, |
| 255 | Vector<uint8_t> const& message, Vector<uint8_t> const& wrappedKey, |
| 256 | Vector<uint8_t>& signature) { |
| 257 | if (mDrmHalAidl->initCheck() == OK) |
| 258 | return mDrmHalAidl->signRSA(sessionId, algorithm, message, wrappedKey, signature); |
| 259 | return mDrmHalHidl->signRSA(sessionId, algorithm, message, wrappedKey, signature); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 260 | } |
| 261 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 262 | status_t DrmHal::setListener(const sp<IDrmClient>& listener) { |
| 263 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->setListener(listener); |
| 264 | return mDrmHalHidl->setListener(listener); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 265 | } |
| 266 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 267 | status_t DrmHal::requiresSecureDecoder(const char* mime, bool* required) const { |
| 268 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->requiresSecureDecoder(mime, required); |
| 269 | return mDrmHalHidl->requiresSecureDecoder(mime, required); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 270 | } |
| 271 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 272 | status_t DrmHal::requiresSecureDecoder(const char* mime, DrmPlugin::SecurityLevel securityLevel, |
| 273 | bool* required) const { |
| 274 | if (mDrmHalAidl->initCheck() == OK) |
| 275 | return mDrmHalAidl->requiresSecureDecoder(mime, securityLevel, required); |
| 276 | return mDrmHalHidl->requiresSecureDecoder(mime, securityLevel, required); |
Adam Stone | fb679e3 | 2018-02-07 10:25:48 -0800 | [diff] [blame] | 277 | } |
| 278 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 279 | status_t DrmHal::setPlaybackId(Vector<uint8_t> const& sessionId, const char* playbackId) { |
| 280 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->setPlaybackId(sessionId, playbackId); |
| 281 | return mDrmHalHidl->setPlaybackId(sessionId, playbackId); |
John W. Bruce | 33ecc4f | 2017-04-03 16:49:05 -0700 | [diff] [blame] | 282 | } |
| 283 | |
Kyle Zhang | 6605add | 2022-01-13 17:51:23 +0000 | [diff] [blame] | 284 | status_t DrmHal::getLogMessages(Vector<drm::V1_4::LogMessage>& logs) const { |
| 285 | if (mDrmHalAidl->initCheck() == OK) return mDrmHalAidl->getLogMessages(logs); |
| 286 | return mDrmHalHidl->getLogMessages(logs); |
Robert Shih | 9afca95 | 2021-02-12 01:36:06 -0800 | [diff] [blame] | 287 | } |
| 288 | |
Kyle Zhang | 2567a5e | 2022-03-17 23:36:26 +0000 | [diff] [blame^] | 289 | status_t DrmHal::getSupportedSchemes(std::vector<uint8_t> &schemes) const { |
| 290 | status_t statusResult; |
| 291 | statusResult = mDrmHalAidl->getSupportedSchemes(schemes); |
| 292 | if (statusResult == OK) return statusResult; |
| 293 | return mDrmHalHidl->getSupportedSchemes(schemes); |
| 294 | } |
| 295 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 296 | } // namespace android |