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 "CryptoHal" |
| 19 | #include <utils/Log.h> |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 20 | |
| 21 | #include <android/hardware/drm/1.0/types.h> |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 22 | #include <android/hidl/manager/1.0/IServiceManager.h> |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 23 | |
| 24 | #include <binder/IMemory.h> |
| 25 | #include <cutils/native_handle.h> |
| 26 | #include <media/CryptoHal.h> |
| 27 | #include <media/hardware/CryptoAPI.h> |
| 28 | #include <media/stagefright/foundation/ADebug.h> |
| 29 | #include <media/stagefright/foundation/AString.h> |
| 30 | #include <media/stagefright/foundation/hexdump.h> |
| 31 | #include <media/stagefright/MediaErrors.h> |
Steven Moreland | 6536606 | 2017-10-05 11:34:01 -0700 | [diff] [blame^] | 32 | #include <hidlmemory/FrameworkUtils.h> |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 33 | |
| 34 | using ::android::hardware::drm::V1_0::BufferType; |
| 35 | using ::android::hardware::drm::V1_0::DestinationBuffer; |
| 36 | using ::android::hardware::drm::V1_0::ICryptoFactory; |
| 37 | using ::android::hardware::drm::V1_0::ICryptoPlugin; |
| 38 | using ::android::hardware::drm::V1_0::Mode; |
| 39 | using ::android::hardware::drm::V1_0::Pattern; |
| 40 | using ::android::hardware::drm::V1_0::SharedBuffer; |
| 41 | using ::android::hardware::drm::V1_0::Status; |
| 42 | using ::android::hardware::drm::V1_0::SubSample; |
| 43 | using ::android::hardware::hidl_array; |
| 44 | using ::android::hardware::hidl_handle; |
| 45 | using ::android::hardware::hidl_memory; |
| 46 | using ::android::hardware::hidl_string; |
| 47 | using ::android::hardware::hidl_vec; |
| 48 | using ::android::hardware::Return; |
| 49 | using ::android::hardware::Void; |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 50 | using ::android::hidl::manager::V1_0::IServiceManager; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 51 | using ::android::sp; |
| 52 | |
| 53 | |
| 54 | namespace android { |
| 55 | |
| 56 | static status_t toStatusT(Status status) { |
| 57 | switch (status) { |
| 58 | case Status::OK: |
| 59 | return OK; |
| 60 | case Status::ERROR_DRM_NO_LICENSE: |
| 61 | return ERROR_DRM_NO_LICENSE; |
| 62 | case Status::ERROR_DRM_LICENSE_EXPIRED: |
| 63 | return ERROR_DRM_LICENSE_EXPIRED; |
| 64 | case Status::ERROR_DRM_RESOURCE_BUSY: |
| 65 | return ERROR_DRM_RESOURCE_BUSY; |
| 66 | case Status::ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION: |
| 67 | return ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION; |
| 68 | case Status::ERROR_DRM_SESSION_NOT_OPENED: |
| 69 | return ERROR_DRM_SESSION_NOT_OPENED; |
| 70 | case Status::ERROR_DRM_CANNOT_HANDLE: |
| 71 | return ERROR_DRM_CANNOT_HANDLE; |
Jeff Tinker | d0cb831 | 2017-03-15 11:17:00 -0700 | [diff] [blame] | 72 | case Status::ERROR_DRM_DECRYPT: |
| 73 | return ERROR_DRM_DECRYPT; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 74 | default: |
| 75 | return UNKNOWN_ERROR; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | |
| 80 | static hidl_vec<uint8_t> toHidlVec(const Vector<uint8_t> &vector) { |
| 81 | hidl_vec<uint8_t> vec; |
| 82 | vec.setToExternal(const_cast<uint8_t *>(vector.array()), vector.size()); |
| 83 | return vec; |
| 84 | } |
| 85 | |
| 86 | static hidl_vec<uint8_t> toHidlVec(const void *ptr, size_t size) { |
| 87 | hidl_vec<uint8_t> vec; |
| 88 | vec.resize(size); |
| 89 | memcpy(vec.data(), ptr, size); |
| 90 | return vec; |
| 91 | } |
| 92 | |
| 93 | static hidl_array<uint8_t, 16> toHidlArray16(const uint8_t *ptr) { |
| 94 | if (!ptr) { |
| 95 | return hidl_array<uint8_t, 16>(); |
| 96 | } |
| 97 | return hidl_array<uint8_t, 16>(ptr); |
| 98 | } |
| 99 | |
| 100 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 101 | static String8 toString8(hidl_string hString) { |
| 102 | return String8(hString.c_str()); |
| 103 | } |
| 104 | |
| 105 | |
| 106 | CryptoHal::CryptoHal() |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 107 | : mFactories(makeCryptoFactories()), |
| 108 | mInitCheck((mFactories.size() == 0) ? ERROR_UNSUPPORTED : NO_INIT), |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 109 | mNextBufferId(0), |
| 110 | mHeapSeqNum(0) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | CryptoHal::~CryptoHal() { |
| 114 | } |
| 115 | |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 116 | Vector<sp<ICryptoFactory>> CryptoHal::makeCryptoFactories() { |
| 117 | Vector<sp<ICryptoFactory>> factories; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 118 | |
Jeff Tinker | 6a4921a | 2017-03-09 23:26:01 -0800 | [diff] [blame] | 119 | auto manager = ::IServiceManager::getService(); |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 120 | if (manager != NULL) { |
| 121 | manager->listByInterface(ICryptoFactory::descriptor, |
| 122 | [&factories](const hidl_vec<hidl_string> ®istered) { |
| 123 | for (const auto &instance : registered) { |
| 124 | auto factory = ICryptoFactory::getService(instance); |
| 125 | if (factory != NULL) { |
| 126 | factories.push_back(factory); |
| 127 | ALOGI("makeCryptoFactories: factory instance %s is %s", |
| 128 | instance.c_str(), |
| 129 | factory->isRemote() ? "Remote" : "Not Remote"); |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | ); |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 134 | } |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 135 | |
| 136 | if (factories.size() == 0) { |
| 137 | // must be in passthrough mode, load the default passthrough service |
Jeff Tinker | e309b22 | 2017-04-05 08:01:28 -0700 | [diff] [blame] | 138 | auto passthrough = ICryptoFactory::getService(); |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 139 | if (passthrough != NULL) { |
| 140 | ALOGI("makeCryptoFactories: using default crypto instance"); |
| 141 | factories.push_back(passthrough); |
| 142 | } else { |
| 143 | ALOGE("Failed to find any crypto factories"); |
| 144 | } |
| 145 | } |
| 146 | return factories; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 147 | } |
| 148 | |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 149 | sp<ICryptoPlugin> CryptoHal::makeCryptoPlugin(const sp<ICryptoFactory>& factory, |
| 150 | const uint8_t uuid[16], const void *initData, size_t initDataSize) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 151 | |
| 152 | sp<ICryptoPlugin> plugin; |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 153 | Return<void> hResult = factory->createPlugin(toHidlArray16(uuid), |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 154 | toHidlVec(initData, initDataSize), |
| 155 | [&](Status status, const sp<ICryptoPlugin>& hPlugin) { |
| 156 | if (status != Status::OK) { |
| 157 | ALOGE("Failed to make crypto plugin"); |
| 158 | return; |
| 159 | } |
| 160 | plugin = hPlugin; |
| 161 | } |
| 162 | ); |
| 163 | return plugin; |
| 164 | } |
| 165 | |
| 166 | |
| 167 | status_t CryptoHal::initCheck() const { |
| 168 | return mInitCheck; |
| 169 | } |
| 170 | |
| 171 | |
| 172 | bool CryptoHal::isCryptoSchemeSupported(const uint8_t uuid[16]) { |
| 173 | Mutex::Autolock autoLock(mLock); |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 174 | |
| 175 | for (size_t i = 0; i < mFactories.size(); i++) { |
| 176 | if (mFactories[i]->isCryptoSchemeSupported(uuid)) { |
| 177 | return true; |
| 178 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 179 | } |
| 180 | return false; |
| 181 | } |
| 182 | |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 183 | status_t CryptoHal::createPlugin(const uint8_t uuid[16], const void *data, |
| 184 | size_t size) { |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 185 | Mutex::Autolock autoLock(mLock); |
| 186 | |
Jeff Tinker | abeb36a | 2017-02-17 09:42:46 -0800 | [diff] [blame] | 187 | for (size_t i = 0; i < mFactories.size(); i++) { |
| 188 | if (mFactories[i]->isCryptoSchemeSupported(uuid)) { |
| 189 | mPlugin = makeCryptoPlugin(mFactories[i], uuid, data, size); |
| 190 | } |
| 191 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 192 | |
| 193 | if (mPlugin == NULL) { |
| 194 | mInitCheck = ERROR_UNSUPPORTED; |
| 195 | } else { |
| 196 | mInitCheck = OK; |
| 197 | } |
| 198 | |
| 199 | return mInitCheck; |
| 200 | } |
| 201 | |
| 202 | status_t CryptoHal::destroyPlugin() { |
| 203 | Mutex::Autolock autoLock(mLock); |
| 204 | |
| 205 | if (mInitCheck != OK) { |
| 206 | return mInitCheck; |
| 207 | } |
| 208 | |
| 209 | mPlugin.clear(); |
| 210 | return OK; |
| 211 | } |
| 212 | |
| 213 | bool CryptoHal::requiresSecureDecoderComponent(const char *mime) const { |
| 214 | Mutex::Autolock autoLock(mLock); |
| 215 | |
| 216 | if (mInitCheck != OK) { |
| 217 | return mInitCheck; |
| 218 | } |
| 219 | |
| 220 | return mPlugin->requiresSecureDecoderComponent(hidl_string(mime)); |
| 221 | } |
| 222 | |
| 223 | |
| 224 | /** |
| 225 | * If the heap base isn't set, get the heap base from the IMemory |
| 226 | * and send it to the HAL so it can map a remote heap of the same |
| 227 | * size. Once the heap base is established, shared memory buffers |
| 228 | * are sent by providing an offset into the heap and a buffer size. |
| 229 | */ |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 230 | int32_t CryptoHal::setHeapBase(const sp<IMemoryHeap>& heap) { |
Steven Moreland | 6536606 | 2017-10-05 11:34:01 -0700 | [diff] [blame^] | 231 | using ::android::hardware::fromHeap; |
| 232 | using ::android::hardware::HidlMemory; |
| 233 | |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 234 | if (heap == NULL) { |
| 235 | ALOGE("setHeapBase(): heap is NULL"); |
| 236 | return -1; |
| 237 | } |
Jeff Tinker | 3cb5316 | 2017-02-16 12:06:32 -0800 | [diff] [blame] | 238 | native_handle_t* nativeHandle = native_handle_create(1, 0); |
| 239 | if (!nativeHandle) { |
Chong Zhang | d07c927 | 2017-03-28 11:02:06 -0700 | [diff] [blame] | 240 | ALOGE("setHeapBase(), failed to create native handle"); |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 241 | return -1; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 242 | } |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 243 | |
| 244 | Mutex::Autolock autoLock(mLock); |
| 245 | |
| 246 | int32_t seqNum = mHeapSeqNum++; |
Steven Moreland | 6536606 | 2017-10-05 11:34:01 -0700 | [diff] [blame^] | 247 | sp<HidlMemory> hidlMemory = fromHeap(heap); |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 248 | mHeapBases.add(seqNum, mNextBufferId); |
Steven Moreland | 6536606 | 2017-10-05 11:34:01 -0700 | [diff] [blame^] | 249 | Return<void> hResult = mPlugin->setSharedBufferBase(*hidlMemory, mNextBufferId++); |
Jeff Tinker | 3cb5316 | 2017-02-16 12:06:32 -0800 | [diff] [blame] | 250 | ALOGE_IF(!hResult.isOk(), "setSharedBufferBase(): remote call failed"); |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 251 | return seqNum; |
Jeff Tinker | 3cb5316 | 2017-02-16 12:06:32 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 254 | void CryptoHal::clearHeapBase(int32_t seqNum) { |
| 255 | Mutex::Autolock autoLock(mLock); |
| 256 | |
| 257 | mHeapBases.removeItem(seqNum); |
Chong Zhang | d07c927 | 2017-03-28 11:02:06 -0700 | [diff] [blame] | 258 | } |
| 259 | |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 260 | status_t CryptoHal::toSharedBuffer(const sp<IMemory>& memory, int32_t seqNum, ::SharedBuffer* buffer) { |
Jeff Tinker | 3cb5316 | 2017-02-16 12:06:32 -0800 | [diff] [blame] | 261 | ssize_t offset; |
| 262 | size_t size; |
| 263 | |
| 264 | if (memory == NULL && buffer == NULL) { |
| 265 | return UNEXPECTED_NULL; |
| 266 | } |
| 267 | |
| 268 | sp<IMemoryHeap> heap = memory->getMemory(&offset, &size); |
| 269 | if (heap == NULL) { |
| 270 | return UNEXPECTED_NULL; |
| 271 | } |
| 272 | |
Chong Zhang | d07c927 | 2017-03-28 11:02:06 -0700 | [diff] [blame] | 273 | // memory must be in the declared heap |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 274 | CHECK(mHeapBases.indexOfKey(seqNum) >= 0); |
Jeff Tinker | 3cb5316 | 2017-02-16 12:06:32 -0800 | [diff] [blame] | 275 | |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 276 | buffer->bufferId = mHeapBases.valueFor(seqNum); |
Jeff Tinker | 3cb5316 | 2017-02-16 12:06:32 -0800 | [diff] [blame] | 277 | buffer->offset = offset >= 0 ? offset : 0; |
| 278 | buffer->size = size; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 279 | return OK; |
| 280 | } |
| 281 | |
| 282 | ssize_t CryptoHal::decrypt(const uint8_t keyId[16], const uint8_t iv[16], |
| 283 | CryptoPlugin::Mode mode, const CryptoPlugin::Pattern &pattern, |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 284 | const ICrypto::SourceBuffer &source, size_t offset, |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 285 | const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, |
| 286 | const ICrypto::DestinationBuffer &destination, AString *errorDetailMsg) { |
| 287 | Mutex::Autolock autoLock(mLock); |
| 288 | |
| 289 | if (mInitCheck != OK) { |
| 290 | return mInitCheck; |
| 291 | } |
| 292 | |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 293 | Mode hMode; |
| 294 | switch(mode) { |
| 295 | case CryptoPlugin::kMode_Unencrypted: |
| 296 | hMode = Mode::UNENCRYPTED ; |
| 297 | break; |
| 298 | case CryptoPlugin::kMode_AES_CTR: |
| 299 | hMode = Mode::AES_CTR; |
| 300 | break; |
| 301 | case CryptoPlugin::kMode_AES_WV: |
| 302 | hMode = Mode::AES_CBC_CTS; |
| 303 | break; |
| 304 | case CryptoPlugin::kMode_AES_CBC: |
| 305 | hMode = Mode::AES_CBC; |
| 306 | break; |
| 307 | default: |
| 308 | return UNKNOWN_ERROR; |
| 309 | } |
| 310 | |
| 311 | Pattern hPattern; |
| 312 | hPattern.encryptBlocks = pattern.mEncryptBlocks; |
| 313 | hPattern.skipBlocks = pattern.mSkipBlocks; |
| 314 | |
| 315 | std::vector<SubSample> stdSubSamples; |
| 316 | for (size_t i = 0; i < numSubSamples; i++) { |
| 317 | SubSample subSample; |
| 318 | subSample.numBytesOfClearData = subSamples[i].mNumBytesOfClearData; |
| 319 | subSample.numBytesOfEncryptedData = subSamples[i].mNumBytesOfEncryptedData; |
| 320 | stdSubSamples.push_back(subSample); |
| 321 | } |
| 322 | auto hSubSamples = hidl_vec<SubSample>(stdSubSamples); |
| 323 | |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 324 | int32_t heapSeqNum = source.mHeapSeqNum; |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 325 | bool secure; |
| 326 | ::DestinationBuffer hDestination; |
| 327 | if (destination.mType == kDestinationTypeSharedMemory) { |
| 328 | hDestination.type = BufferType::SHARED_MEMORY; |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 329 | status_t status = toSharedBuffer(destination.mSharedMemory, heapSeqNum, |
Jeff Tinker | 3cb5316 | 2017-02-16 12:06:32 -0800 | [diff] [blame] | 330 | &hDestination.nonsecureMemory); |
| 331 | if (status != OK) { |
| 332 | return status; |
| 333 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 334 | secure = false; |
| 335 | } else { |
| 336 | hDestination.type = BufferType::NATIVE_HANDLE; |
| 337 | hDestination.secureMemory = hidl_handle(destination.mHandle); |
| 338 | secure = true; |
| 339 | } |
| 340 | |
Jeff Tinker | 3cb5316 | 2017-02-16 12:06:32 -0800 | [diff] [blame] | 341 | ::SharedBuffer hSource; |
Chong Zhang | 6dcab2b | 2017-03-28 14:18:27 -0700 | [diff] [blame] | 342 | status_t status = toSharedBuffer(source.mSharedMemory, heapSeqNum, &hSource); |
Jeff Tinker | 3cb5316 | 2017-02-16 12:06:32 -0800 | [diff] [blame] | 343 | if (status != OK) { |
| 344 | return status; |
| 345 | } |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 346 | |
| 347 | status_t err = UNKNOWN_ERROR; |
| 348 | uint32_t bytesWritten = 0; |
| 349 | |
| 350 | Return<void> hResult = mPlugin->decrypt(secure, toHidlArray16(keyId), toHidlArray16(iv), hMode, |
Jeff Tinker | 3cb5316 | 2017-02-16 12:06:32 -0800 | [diff] [blame] | 351 | hPattern, hSubSamples, hSource, offset, hDestination, |
Jeff Tinker | a53d655 | 2017-01-20 00:31:46 -0800 | [diff] [blame] | 352 | [&](Status status, uint32_t hBytesWritten, hidl_string hDetailedError) { |
| 353 | if (status == Status::OK) { |
| 354 | bytesWritten = hBytesWritten; |
| 355 | *errorDetailMsg = toString8(hDetailedError); |
| 356 | } |
| 357 | err = toStatusT(status); |
| 358 | } |
| 359 | ); |
| 360 | |
| 361 | if (!hResult.isOk()) { |
| 362 | err = DEAD_OBJECT; |
| 363 | } |
| 364 | |
| 365 | if (err == OK) { |
| 366 | return bytesWritten; |
| 367 | } |
| 368 | return err; |
| 369 | } |
| 370 | |
| 371 | void CryptoHal::notifyResolution(uint32_t width, uint32_t height) { |
| 372 | Mutex::Autolock autoLock(mLock); |
| 373 | |
| 374 | if (mInitCheck != OK) { |
| 375 | return; |
| 376 | } |
| 377 | |
| 378 | mPlugin->notifyResolution(width, height); |
| 379 | } |
| 380 | |
| 381 | status_t CryptoHal::setMediaDrmSession(const Vector<uint8_t> &sessionId) { |
| 382 | Mutex::Autolock autoLock(mLock); |
| 383 | |
| 384 | if (mInitCheck != OK) { |
| 385 | return mInitCheck; |
| 386 | } |
| 387 | |
| 388 | return toStatusT(mPlugin->setMediaDrmSession(toHidlVec(sessionId))); |
| 389 | } |
| 390 | |
| 391 | } // namespace android |