aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 17 | //#define LOG_NDEBUG 0 |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 18 | #define LOG_TAG "IDrmManagerService(Native)" |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include <stdint.h> |
| 22 | #include <sys/types.h> |
| 23 | #include <binder/IPCThreadState.h> |
| 24 | |
| 25 | #include <drm/DrmInfo.h> |
| 26 | #include <drm/DrmConstraints.h> |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 27 | #include <drm/DrmMetadata.h> |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 28 | #include <drm/DrmRights.h> |
| 29 | #include <drm/DrmInfoStatus.h> |
| 30 | #include <drm/DrmConvertedStatus.h> |
| 31 | #include <drm/DrmInfoRequest.h> |
| 32 | #include <drm/DrmSupportInfo.h> |
| 33 | |
| 34 | #include "IDrmManagerService.h" |
| 35 | |
| 36 | #define INVALID_BUFFER_LENGTH -1 |
| 37 | |
| 38 | using namespace android; |
| 39 | |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 40 | static void writeDecryptHandleToParcelData( |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 41 | const DecryptHandle* handle, Parcel* data) { |
| 42 | data->writeInt32(handle->decryptId); |
| 43 | data->writeString8(handle->mimeType); |
| 44 | data->writeInt32(handle->decryptApiType); |
| 45 | data->writeInt32(handle->status); |
| 46 | |
| 47 | int size = handle->copyControlVector.size(); |
| 48 | data->writeInt32(size); |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 49 | for (int i = 0; i < size; i++) { |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 50 | data->writeInt32(handle->copyControlVector.keyAt(i)); |
| 51 | data->writeInt32(handle->copyControlVector.valueAt(i)); |
| 52 | } |
| 53 | |
Gloria Wang | 6b2a35b | 2011-03-21 17:22:13 -0700 | [diff] [blame] | 54 | size = handle->extendedData.size(); |
| 55 | data->writeInt32(size); |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 56 | for (int i = 0; i < size; i++) { |
Gloria Wang | 6b2a35b | 2011-03-21 17:22:13 -0700 | [diff] [blame] | 57 | data->writeString8(handle->extendedData.keyAt(i)); |
| 58 | data->writeString8(handle->extendedData.valueAt(i)); |
| 59 | } |
| 60 | |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 61 | if (NULL != handle->decryptInfo) { |
| 62 | data->writeInt32(handle->decryptInfo->decryptBufferLength); |
| 63 | } else { |
| 64 | data->writeInt32(INVALID_BUFFER_LENGTH); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | static void readDecryptHandleFromParcelData( |
| 69 | DecryptHandle* handle, const Parcel& data) { |
| 70 | if (0 == data.dataAvail()) { |
| 71 | return; |
| 72 | } |
| 73 | |
| 74 | handle->decryptId = data.readInt32(); |
| 75 | handle->mimeType = data.readString8(); |
| 76 | handle->decryptApiType = data.readInt32(); |
| 77 | handle->status = data.readInt32(); |
| 78 | |
| 79 | int size = data.readInt32(); |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 80 | for (int i = 0; i < size; i++) { |
Gloria Wang | 6b2a35b | 2011-03-21 17:22:13 -0700 | [diff] [blame] | 81 | DrmCopyControl key = (DrmCopyControl)data.readInt32(); |
| 82 | int value = data.readInt32(); |
| 83 | handle->copyControlVector.add(key, value); |
| 84 | } |
| 85 | |
| 86 | size = data.readInt32(); |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 87 | for (int i = 0; i < size; i++) { |
Gloria Wang | 6b2a35b | 2011-03-21 17:22:13 -0700 | [diff] [blame] | 88 | String8 key = data.readString8(); |
| 89 | String8 value = data.readString8(); |
| 90 | handle->extendedData.add(key, value); |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | handle->decryptInfo = NULL; |
| 94 | const int bufferLen = data.readInt32(); |
| 95 | if (INVALID_BUFFER_LENGTH != bufferLen) { |
| 96 | handle->decryptInfo = new DecryptInfo(); |
| 97 | handle->decryptInfo->decryptBufferLength = bufferLen; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | static void clearDecryptHandle(DecryptHandle* handle) { |
| 102 | if (handle == NULL) { |
| 103 | return; |
| 104 | } |
| 105 | if (handle->decryptInfo) { |
| 106 | delete handle->decryptInfo; |
| 107 | handle->decryptInfo = NULL; |
| 108 | } |
| 109 | handle->copyControlVector.clear(); |
Gloria Wang | ab00df4 | 2011-06-22 14:55:16 -0700 | [diff] [blame] | 110 | handle->extendedData.clear(); |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Gloria Wang | 8f00151 | 2011-07-21 15:10:22 -0700 | [diff] [blame] | 113 | int BpDrmManagerService::addUniqueId(bool isNative) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 114 | ALOGV("add uniqueid"); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 115 | Parcel data, reply; |
| 116 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
Gloria Wang | 8f00151 | 2011-07-21 15:10:22 -0700 | [diff] [blame] | 117 | data.writeInt32(isNative); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 118 | remote()->transact(ADD_UNIQUEID, data, &reply); |
| 119 | return reply.readInt32(); |
| 120 | } |
| 121 | |
| 122 | void BpDrmManagerService::removeUniqueId(int uniqueId) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 123 | ALOGV("remove uniqueid"); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 124 | Parcel data, reply; |
| 125 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 126 | data.writeInt32(uniqueId); |
| 127 | remote()->transact(REMOVE_UNIQUEID, data, &reply); |
| 128 | } |
| 129 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 130 | void BpDrmManagerService::addClient(int uniqueId) { |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 131 | Parcel data, reply; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 132 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 133 | data.writeInt32(uniqueId); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 134 | remote()->transact(ADD_CLIENT, data, &reply); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 135 | } |
| 136 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 137 | void BpDrmManagerService::removeClient(int uniqueId) { |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 138 | Parcel data, reply; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 139 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 140 | data.writeInt32(uniqueId); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 141 | remote()->transact(REMOVE_CLIENT, data, &reply); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | status_t BpDrmManagerService::setDrmServiceListener( |
| 145 | int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 146 | ALOGV("setDrmServiceListener"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 147 | Parcel data, reply; |
| 148 | |
| 149 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 150 | data.writeInt32(uniqueId); |
| 151 | data.writeStrongBinder(drmServiceListener->asBinder()); |
| 152 | remote()->transact(SET_DRM_SERVICE_LISTENER, data, &reply); |
| 153 | return reply.readInt32(); |
| 154 | } |
| 155 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 156 | status_t BpDrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 157 | ALOGV("Install DRM Engine"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 158 | Parcel data, reply; |
| 159 | |
| 160 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 161 | data.writeInt32(uniqueId); |
| 162 | data.writeString8(drmEngineFile); |
| 163 | |
| 164 | remote()->transact(INSTALL_DRM_ENGINE, data, &reply); |
| 165 | return reply.readInt32(); |
| 166 | } |
| 167 | |
| 168 | DrmConstraints* BpDrmManagerService::getConstraints( |
| 169 | int uniqueId, const String8* path, const int action) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 170 | ALOGV("Get Constraints"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 171 | Parcel data, reply; |
| 172 | |
| 173 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 174 | data.writeInt32(uniqueId); |
| 175 | data.writeString8(*path); |
| 176 | data.writeInt32(action); |
| 177 | |
| 178 | remote()->transact(GET_CONSTRAINTS_FROM_CONTENT, data, &reply); |
| 179 | |
| 180 | DrmConstraints* drmConstraints = NULL; |
| 181 | if (0 != reply.dataAvail()) { |
| 182 | //Filling Drm Constraints |
| 183 | drmConstraints = new DrmConstraints(); |
| 184 | |
| 185 | const int size = reply.readInt32(); |
| 186 | for (int index = 0; index < size; ++index) { |
| 187 | const String8 key(reply.readString8()); |
| 188 | const int bufferSize = reply.readInt32(); |
| 189 | char* data = NULL; |
| 190 | if (0 < bufferSize) { |
| 191 | data = new char[bufferSize]; |
| 192 | reply.read(data, bufferSize); |
| 193 | } |
| 194 | drmConstraints->put(&key, data); |
| 195 | } |
| 196 | } |
| 197 | return drmConstraints; |
| 198 | } |
| 199 | |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 200 | DrmMetadata* BpDrmManagerService::getMetadata(int uniqueId, const String8* path) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 201 | ALOGV("Get Metadata"); |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 202 | Parcel data, reply; |
| 203 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 204 | data.writeInt32(uniqueId); |
| 205 | |
| 206 | DrmMetadata* drmMetadata = NULL; |
| 207 | data.writeString8(*path); |
| 208 | remote()->transact(GET_METADATA_FROM_CONTENT, data, &reply); |
| 209 | |
| 210 | if (0 != reply.dataAvail()) { |
| 211 | //Filling Drm Metadata |
| 212 | drmMetadata = new DrmMetadata(); |
| 213 | |
| 214 | const int size = reply.readInt32(); |
| 215 | for (int index = 0; index < size; ++index) { |
| 216 | const String8 key(reply.readString8()); |
| 217 | const int bufferSize = reply.readInt32(); |
| 218 | char* data = NULL; |
| 219 | if (0 < bufferSize) { |
| 220 | data = new char[bufferSize]; |
| 221 | reply.read(data, bufferSize); |
| 222 | } |
| 223 | drmMetadata->put(&key, data); |
| 224 | } |
| 225 | } |
| 226 | return drmMetadata; |
| 227 | } |
| 228 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 229 | bool BpDrmManagerService::canHandle(int uniqueId, const String8& path, const String8& mimeType) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 230 | ALOGV("Can Handle"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 231 | Parcel data, reply; |
| 232 | |
| 233 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 234 | data.writeInt32(uniqueId); |
| 235 | |
| 236 | data.writeString8(path); |
| 237 | data.writeString8(mimeType); |
| 238 | |
| 239 | remote()->transact(CAN_HANDLE, data, &reply); |
| 240 | |
| 241 | return static_cast<bool>(reply.readInt32()); |
| 242 | } |
| 243 | |
| 244 | DrmInfoStatus* BpDrmManagerService::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 245 | ALOGV("Process DRM Info"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 246 | Parcel data, reply; |
| 247 | |
| 248 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 249 | data.writeInt32(uniqueId); |
| 250 | |
| 251 | //Filling DRM info |
| 252 | data.writeInt32(drmInfo->getInfoType()); |
| 253 | const DrmBuffer dataBuffer = drmInfo->getData(); |
| 254 | const int dataBufferSize = dataBuffer.length; |
| 255 | data.writeInt32(dataBufferSize); |
| 256 | if (0 < dataBufferSize) { |
| 257 | data.write(dataBuffer.data, dataBufferSize); |
| 258 | } |
| 259 | data.writeString8(drmInfo->getMimeType()); |
| 260 | |
| 261 | data.writeInt32(drmInfo->getCount()); |
| 262 | DrmInfo::KeyIterator keyIt = drmInfo->keyIterator(); |
| 263 | |
| 264 | while (keyIt.hasNext()) { |
| 265 | const String8 key = keyIt.next(); |
| 266 | data.writeString8(key); |
| 267 | const String8 value = drmInfo->get(key); |
| 268 | data.writeString8((value == String8("")) ? String8("NULL") : value); |
| 269 | } |
| 270 | |
| 271 | remote()->transact(PROCESS_DRM_INFO, data, &reply); |
| 272 | |
| 273 | DrmInfoStatus* drmInfoStatus = NULL; |
| 274 | if (0 != reply.dataAvail()) { |
| 275 | //Filling DRM Info Status |
| 276 | const int statusCode = reply.readInt32(); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 277 | const int infoType = reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 278 | const String8 mimeType = reply.readString8(); |
| 279 | |
| 280 | DrmBuffer* drmBuffer = NULL; |
| 281 | if (0 != reply.dataAvail()) { |
| 282 | const int bufferSize = reply.readInt32(); |
| 283 | char* data = NULL; |
| 284 | if (0 < bufferSize) { |
| 285 | data = new char[bufferSize]; |
| 286 | reply.read(data, bufferSize); |
| 287 | } |
| 288 | drmBuffer = new DrmBuffer(data, bufferSize); |
| 289 | } |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 290 | drmInfoStatus = new DrmInfoStatus(statusCode, infoType, drmBuffer, mimeType); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 291 | } |
| 292 | return drmInfoStatus; |
| 293 | } |
| 294 | |
| 295 | DrmInfo* BpDrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 296 | ALOGV("Acquire DRM Info"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 297 | Parcel data, reply; |
| 298 | |
| 299 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 300 | data.writeInt32(uniqueId); |
| 301 | |
| 302 | //Filling DRM Info Request |
| 303 | data.writeInt32(drmInforequest->getInfoType()); |
| 304 | data.writeString8(drmInforequest->getMimeType()); |
| 305 | |
| 306 | data.writeInt32(drmInforequest->getCount()); |
| 307 | DrmInfoRequest::KeyIterator keyIt = drmInforequest->keyIterator(); |
| 308 | |
| 309 | while (keyIt.hasNext()) { |
| 310 | const String8 key = keyIt.next(); |
| 311 | data.writeString8(key); |
| 312 | const String8 value = drmInforequest->get(key); |
| 313 | data.writeString8((value == String8("")) ? String8("NULL") : value); |
| 314 | } |
| 315 | |
| 316 | remote()->transact(ACQUIRE_DRM_INFO, data, &reply); |
| 317 | |
| 318 | DrmInfo* drmInfo = NULL; |
| 319 | if (0 != reply.dataAvail()) { |
| 320 | //Filling DRM Info |
| 321 | const int infoType = reply.readInt32(); |
| 322 | const int bufferSize = reply.readInt32(); |
| 323 | char* data = NULL; |
| 324 | |
| 325 | if (0 < bufferSize) { |
| 326 | data = new char[bufferSize]; |
| 327 | reply.read(data, bufferSize); |
| 328 | } |
| 329 | drmInfo = new DrmInfo(infoType, DrmBuffer(data, bufferSize), reply.readString8()); |
| 330 | |
| 331 | const int size = reply.readInt32(); |
| 332 | for (int index = 0; index < size; ++index) { |
| 333 | const String8 key(reply.readString8()); |
| 334 | const String8 value(reply.readString8()); |
| 335 | drmInfo->put(key, (value == String8("NULL")) ? String8("") : value); |
| 336 | } |
| 337 | } |
| 338 | return drmInfo; |
| 339 | } |
| 340 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 341 | status_t BpDrmManagerService::saveRights( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 342 | int uniqueId, const DrmRights& drmRights, |
| 343 | const String8& rightsPath, const String8& contentPath) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 344 | ALOGV("Save Rights"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 345 | Parcel data, reply; |
| 346 | |
| 347 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 348 | data.writeInt32(uniqueId); |
| 349 | |
| 350 | //Filling Drm Rights |
| 351 | const DrmBuffer dataBuffer = drmRights.getData(); |
| 352 | data.writeInt32(dataBuffer.length); |
| 353 | data.write(dataBuffer.data, dataBuffer.length); |
| 354 | |
| 355 | const String8 mimeType = drmRights.getMimeType(); |
| 356 | data.writeString8((mimeType == String8("")) ? String8("NULL") : mimeType); |
| 357 | |
| 358 | const String8 accountId = drmRights.getAccountId(); |
| 359 | data.writeString8((accountId == String8("")) ? String8("NULL") : accountId); |
| 360 | |
| 361 | const String8 subscriptionId = drmRights.getSubscriptionId(); |
| 362 | data.writeString8((subscriptionId == String8("")) ? String8("NULL") : subscriptionId); |
| 363 | |
| 364 | data.writeString8((rightsPath == String8("")) ? String8("NULL") : rightsPath); |
| 365 | data.writeString8((contentPath == String8("")) ? String8("NULL") : contentPath); |
| 366 | |
| 367 | remote()->transact(SAVE_RIGHTS, data, &reply); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 368 | return reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 369 | } |
| 370 | |
James Dong | bf5b3b2 | 2012-07-30 17:57:39 -0700 | [diff] [blame^] | 371 | String8 BpDrmManagerService::getOriginalMimeType(int uniqueId, const String8& path, int fd) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 372 | ALOGV("Get Original MimeType"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 373 | Parcel data, reply; |
| 374 | |
| 375 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 376 | data.writeInt32(uniqueId); |
| 377 | data.writeString8(path); |
James Dong | bf5b3b2 | 2012-07-30 17:57:39 -0700 | [diff] [blame^] | 378 | int32_t isFdValid = (fd >= 0); |
| 379 | data.writeInt32(isFdValid); |
| 380 | if (isFdValid) { |
| 381 | data.writeFileDescriptor(fd); |
| 382 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 383 | |
| 384 | remote()->transact(GET_ORIGINAL_MIMETYPE, data, &reply); |
| 385 | return reply.readString8(); |
| 386 | } |
| 387 | |
| 388 | int BpDrmManagerService::getDrmObjectType( |
| 389 | int uniqueId, const String8& path, const String8& mimeType) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 390 | ALOGV("Get Drm object type"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 391 | Parcel data, reply; |
| 392 | |
| 393 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 394 | data.writeInt32(uniqueId); |
| 395 | data.writeString8(path); |
| 396 | data.writeString8(mimeType); |
| 397 | |
| 398 | remote()->transact(GET_DRM_OBJECT_TYPE, data, &reply); |
| 399 | |
| 400 | return reply.readInt32(); |
| 401 | } |
| 402 | |
| 403 | int BpDrmManagerService::checkRightsStatus(int uniqueId, const String8& path, int action) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 404 | ALOGV("checkRightsStatus"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 405 | Parcel data, reply; |
| 406 | |
| 407 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 408 | data.writeInt32(uniqueId); |
| 409 | data.writeString8(path); |
| 410 | data.writeInt32(action); |
| 411 | |
| 412 | remote()->transact(CHECK_RIGHTS_STATUS, data, &reply); |
| 413 | |
| 414 | return reply.readInt32(); |
| 415 | } |
| 416 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 417 | status_t BpDrmManagerService::consumeRights( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 418 | int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 419 | ALOGV("consumeRights"); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 420 | Parcel data, reply; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 421 | |
| 422 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 423 | data.writeInt32(uniqueId); |
| 424 | |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 425 | writeDecryptHandleToParcelData(decryptHandle, &data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 426 | |
| 427 | data.writeInt32(action); |
| 428 | data.writeInt32(static_cast< int>(reserve)); |
| 429 | |
| 430 | remote()->transact(CONSUME_RIGHTS, data, &reply); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 431 | return reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 432 | } |
| 433 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 434 | status_t BpDrmManagerService::setPlaybackStatus( |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 435 | int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 436 | ALOGV("setPlaybackStatus"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 437 | Parcel data, reply; |
| 438 | |
| 439 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 440 | data.writeInt32(uniqueId); |
| 441 | |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 442 | writeDecryptHandleToParcelData(decryptHandle, &data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 443 | |
| 444 | data.writeInt32(playbackStatus); |
Gloria Wang | 2ed8a92 | 2011-01-19 15:38:16 -0800 | [diff] [blame] | 445 | data.writeInt64(position); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 446 | |
| 447 | remote()->transact(SET_PLAYBACK_STATUS, data, &reply); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 448 | return reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | bool BpDrmManagerService::validateAction( |
| 452 | int uniqueId, const String8& path, |
| 453 | int action, const ActionDescription& description) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 454 | ALOGV("validateAction"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 455 | Parcel data, reply; |
| 456 | |
| 457 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 458 | data.writeInt32(uniqueId); |
| 459 | data.writeString8(path); |
| 460 | data.writeInt32(action); |
| 461 | data.writeInt32(description.outputType); |
| 462 | data.writeInt32(description.configuration); |
| 463 | |
| 464 | remote()->transact(VALIDATE_ACTION, data, &reply); |
| 465 | |
| 466 | return static_cast<bool>(reply.readInt32()); |
| 467 | } |
| 468 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 469 | status_t BpDrmManagerService::removeRights(int uniqueId, const String8& path) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 470 | ALOGV("removeRights"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 471 | Parcel data, reply; |
| 472 | |
| 473 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 474 | data.writeInt32(uniqueId); |
| 475 | data.writeString8(path); |
| 476 | |
| 477 | remote()->transact(REMOVE_RIGHTS, data, &reply); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 478 | return reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 479 | } |
| 480 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 481 | status_t BpDrmManagerService::removeAllRights(int uniqueId) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 482 | ALOGV("removeAllRights"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 483 | Parcel data, reply; |
| 484 | |
| 485 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 486 | data.writeInt32(uniqueId); |
| 487 | |
| 488 | remote()->transact(REMOVE_ALL_RIGHTS, data, &reply); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 489 | return reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | int BpDrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 493 | ALOGV("openConvertSession"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 494 | Parcel data, reply; |
| 495 | |
| 496 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 497 | data.writeInt32(uniqueId); |
| 498 | data.writeString8(mimeType); |
| 499 | |
| 500 | remote()->transact(OPEN_CONVERT_SESSION, data, &reply); |
| 501 | return reply.readInt32(); |
| 502 | } |
| 503 | |
| 504 | DrmConvertedStatus* BpDrmManagerService::convertData( |
| 505 | int uniqueId, int convertId, const DrmBuffer* inputData) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 506 | ALOGV("convertData"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 507 | Parcel data, reply; |
| 508 | |
| 509 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 510 | data.writeInt32(uniqueId); |
| 511 | data.writeInt32(convertId); |
| 512 | data.writeInt32(inputData->length); |
| 513 | data.write(inputData->data, inputData->length); |
| 514 | |
| 515 | remote()->transact(CONVERT_DATA, data, &reply); |
| 516 | |
| 517 | DrmConvertedStatus* drmConvertedStatus = NULL; |
| 518 | |
| 519 | if (0 != reply.dataAvail()) { |
| 520 | //Filling DRM Converted Status |
| 521 | const int statusCode = reply.readInt32(); |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 522 | const off64_t offset = reply.readInt64(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 523 | |
| 524 | DrmBuffer* convertedData = NULL; |
| 525 | if (0 != reply.dataAvail()) { |
| 526 | const int bufferSize = reply.readInt32(); |
| 527 | char* data = NULL; |
| 528 | if (0 < bufferSize) { |
| 529 | data = new char[bufferSize]; |
| 530 | reply.read(data, bufferSize); |
| 531 | } |
| 532 | convertedData = new DrmBuffer(data, bufferSize); |
| 533 | } |
| 534 | drmConvertedStatus = new DrmConvertedStatus(statusCode, convertedData, offset); |
| 535 | } |
| 536 | return drmConvertedStatus; |
| 537 | } |
| 538 | |
| 539 | DrmConvertedStatus* BpDrmManagerService::closeConvertSession(int uniqueId, int convertId) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 540 | ALOGV("closeConvertSession"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 541 | Parcel data, reply; |
| 542 | |
| 543 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 544 | data.writeInt32(uniqueId); |
| 545 | data.writeInt32(convertId); |
| 546 | |
| 547 | remote()->transact(CLOSE_CONVERT_SESSION, data, &reply); |
| 548 | |
| 549 | DrmConvertedStatus* drmConvertedStatus = NULL; |
| 550 | |
| 551 | if (0 != reply.dataAvail()) { |
| 552 | //Filling DRM Converted Status |
| 553 | const int statusCode = reply.readInt32(); |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 554 | const off64_t offset = reply.readInt64(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 555 | |
| 556 | DrmBuffer* convertedData = NULL; |
| 557 | if (0 != reply.dataAvail()) { |
| 558 | const int bufferSize = reply.readInt32(); |
| 559 | char* data = NULL; |
| 560 | if (0 < bufferSize) { |
| 561 | data = new char[bufferSize]; |
| 562 | reply.read(data, bufferSize); |
| 563 | } |
| 564 | convertedData = new DrmBuffer(data, bufferSize); |
| 565 | } |
| 566 | drmConvertedStatus = new DrmConvertedStatus(statusCode, convertedData, offset); |
| 567 | } |
| 568 | return drmConvertedStatus; |
| 569 | } |
| 570 | |
| 571 | status_t BpDrmManagerService::getAllSupportInfo( |
| 572 | int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 573 | ALOGV("Get All Support Info"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 574 | Parcel data, reply; |
| 575 | |
| 576 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 577 | data.writeInt32(uniqueId); |
| 578 | |
| 579 | remote()->transact(GET_ALL_SUPPORT_INFO, data, &reply); |
| 580 | |
| 581 | //Filling DRM Support Info |
| 582 | const int arraySize = reply.readInt32(); |
| 583 | if (0 < arraySize) { |
| 584 | *drmSupportInfoArray = new DrmSupportInfo[arraySize]; |
| 585 | |
| 586 | for (int index = 0; index < arraySize; ++index) { |
| 587 | DrmSupportInfo drmSupportInfo; |
| 588 | |
| 589 | const int fileSuffixVectorSize = reply.readInt32(); |
| 590 | for (int i = 0; i < fileSuffixVectorSize; ++i) { |
| 591 | drmSupportInfo.addFileSuffix(reply.readString8()); |
| 592 | } |
| 593 | |
| 594 | const int mimeTypeVectorSize = reply.readInt32(); |
| 595 | for (int i = 0; i < mimeTypeVectorSize; ++i) { |
| 596 | drmSupportInfo.addMimeType(reply.readString8()); |
| 597 | } |
| 598 | |
| 599 | drmSupportInfo.setDescription(reply.readString8()); |
| 600 | (*drmSupportInfoArray)[index] = drmSupportInfo; |
| 601 | } |
| 602 | } |
| 603 | *length = arraySize; |
| 604 | return reply.readInt32(); |
| 605 | } |
| 606 | |
| 607 | DecryptHandle* BpDrmManagerService::openDecryptSession( |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 608 | int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 609 | ALOGV("Entering BpDrmManagerService::openDecryptSession"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 610 | Parcel data, reply; |
| 611 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 612 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 613 | data.writeInt32(uniqueId); |
| 614 | data.writeFileDescriptor(fd); |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 615 | data.writeInt64(offset); |
| 616 | data.writeInt64(length); |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 617 | String8 mimeType; |
| 618 | if (mime) { |
| 619 | mimeType = mime; |
| 620 | } |
| 621 | data.writeString8(mimeType); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 622 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 623 | remote()->transact(OPEN_DECRYPT_SESSION, data, &reply); |
| 624 | |
| 625 | DecryptHandle* handle = NULL; |
| 626 | if (0 != reply.dataAvail()) { |
| 627 | handle = new DecryptHandle(); |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 628 | readDecryptHandleFromParcelData(handle, reply); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 629 | } |
| 630 | return handle; |
| 631 | } |
| 632 | |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 633 | DecryptHandle* BpDrmManagerService::openDecryptSession( |
| 634 | int uniqueId, const char* uri, const char* mime) { |
| 635 | |
| 636 | ALOGV("Entering BpDrmManagerService::openDecryptSession: mime=%s", mime? mime: "NULL"); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 637 | Parcel data, reply; |
| 638 | |
| 639 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 640 | data.writeInt32(uniqueId); |
| 641 | data.writeString8(String8(uri)); |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 642 | String8 mimeType; |
| 643 | if (mime) { |
| 644 | mimeType = mime; |
| 645 | } |
| 646 | data.writeString8(mimeType); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 647 | |
| 648 | remote()->transact(OPEN_DECRYPT_SESSION_FROM_URI, data, &reply); |
| 649 | |
| 650 | DecryptHandle* handle = NULL; |
| 651 | if (0 != reply.dataAvail()) { |
| 652 | handle = new DecryptHandle(); |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 653 | readDecryptHandleFromParcelData(handle, reply); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 654 | } else { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 655 | ALOGV("no decryptHandle is generated in service side"); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 656 | } |
| 657 | return handle; |
| 658 | } |
| 659 | |
Kei Takahashi | cba7b32 | 2012-01-18 17:10:19 +0900 | [diff] [blame] | 660 | DecryptHandle* BpDrmManagerService::openDecryptSession( |
| 661 | int uniqueId, const DrmBuffer& buf, const String8& mimeType) { |
| 662 | ALOGV("Entering BpDrmManagerService::openDecryptSession"); |
| 663 | Parcel data, reply; |
| 664 | |
| 665 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 666 | data.writeInt32(uniqueId); |
| 667 | if (buf.data != NULL && buf.length > 0) { |
| 668 | data.writeInt32(buf.length); |
| 669 | data.write(buf.data, buf.length); |
| 670 | } else { |
| 671 | data.writeInt32(0); |
| 672 | } |
| 673 | data.writeString8(mimeType); |
| 674 | |
| 675 | remote()->transact(OPEN_DECRYPT_SESSION_FOR_STREAMING, data, &reply); |
| 676 | |
| 677 | DecryptHandle* handle = NULL; |
| 678 | if (0 != reply.dataAvail()) { |
| 679 | handle = new DecryptHandle(); |
| 680 | readDecryptHandleFromParcelData(handle, reply); |
| 681 | } else { |
| 682 | ALOGV("no decryptHandle is generated in service side"); |
| 683 | } |
| 684 | return handle; |
| 685 | } |
| 686 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 687 | status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 688 | ALOGV("closeDecryptSession"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 689 | Parcel data, reply; |
| 690 | |
| 691 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 692 | data.writeInt32(uniqueId); |
| 693 | |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 694 | writeDecryptHandleToParcelData(decryptHandle, &data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 695 | |
| 696 | remote()->transact(CLOSE_DECRYPT_SESSION, data, &reply); |
| 697 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 698 | return reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 699 | } |
| 700 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 701 | status_t BpDrmManagerService::initializeDecryptUnit( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 702 | int uniqueId, DecryptHandle* decryptHandle, |
| 703 | int decryptUnitId, const DrmBuffer* headerInfo) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 704 | ALOGV("initializeDecryptUnit"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 705 | Parcel data, reply; |
| 706 | |
| 707 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 708 | data.writeInt32(uniqueId); |
| 709 | |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 710 | writeDecryptHandleToParcelData(decryptHandle, &data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 711 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 712 | data.writeInt32(decryptUnitId); |
| 713 | |
| 714 | data.writeInt32(headerInfo->length); |
| 715 | data.write(headerInfo->data, headerInfo->length); |
| 716 | |
| 717 | remote()->transact(INITIALIZE_DECRYPT_UNIT, data, &reply); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 718 | return reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | status_t BpDrmManagerService::decrypt( |
| 722 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 723 | const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 724 | ALOGV("decrypt"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 725 | Parcel data, reply; |
| 726 | |
| 727 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 728 | data.writeInt32(uniqueId); |
| 729 | |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 730 | writeDecryptHandleToParcelData(decryptHandle, &data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 731 | |
| 732 | data.writeInt32(decryptUnitId); |
| 733 | data.writeInt32((*decBuffer)->length); |
| 734 | |
| 735 | data.writeInt32(encBuffer->length); |
| 736 | data.write(encBuffer->data, encBuffer->length); |
| 737 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 738 | if (NULL != IV) { |
| 739 | data.writeInt32(IV->length); |
| 740 | data.write(IV->data, IV->length); |
| 741 | } |
| 742 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 743 | remote()->transact(DECRYPT, data, &reply); |
| 744 | |
| 745 | const status_t status = reply.readInt32(); |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 746 | ALOGV("Return value of decrypt() is %d", status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 747 | |
| 748 | const int size = reply.readInt32(); |
| 749 | (*decBuffer)->length = size; |
| 750 | reply.read((void *)(*decBuffer)->data, size); |
| 751 | |
| 752 | return status; |
| 753 | } |
| 754 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 755 | status_t BpDrmManagerService::finalizeDecryptUnit( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 756 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 757 | ALOGV("finalizeDecryptUnit"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 758 | Parcel data, reply; |
| 759 | |
| 760 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 761 | data.writeInt32(uniqueId); |
| 762 | |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 763 | writeDecryptHandleToParcelData(decryptHandle, &data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 764 | |
| 765 | data.writeInt32(decryptUnitId); |
| 766 | |
| 767 | remote()->transact(FINALIZE_DECRYPT_UNIT, data, &reply); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 768 | return reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | ssize_t BpDrmManagerService::pread( |
| 772 | int uniqueId, DecryptHandle* decryptHandle, void* buffer, |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 773 | ssize_t numBytes, off64_t offset) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 774 | ALOGV("read"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 775 | Parcel data, reply; |
| 776 | int result; |
| 777 | |
| 778 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 779 | data.writeInt32(uniqueId); |
| 780 | |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 781 | writeDecryptHandleToParcelData(decryptHandle, &data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 782 | |
| 783 | data.writeInt32(numBytes); |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 784 | data.writeInt64(offset); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 785 | |
| 786 | remote()->transact(PREAD, data, &reply); |
| 787 | result = reply.readInt32(); |
| 788 | if (0 < result) { |
| 789 | reply.read(buffer, result); |
| 790 | } |
| 791 | return result; |
| 792 | } |
| 793 | |
| 794 | IMPLEMENT_META_INTERFACE(DrmManagerService, "drm.IDrmManagerService"); |
| 795 | |
| 796 | status_t BnDrmManagerService::onTransact( |
| 797 | uint32_t code, const Parcel& data, |
| 798 | Parcel* reply, uint32_t flags) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 799 | ALOGV("Entering BnDrmManagerService::onTransact with code %d", code); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 800 | |
| 801 | switch (code) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 802 | case ADD_UNIQUEID: |
| 803 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 804 | ALOGV("BnDrmManagerService::onTransact :ADD_UNIQUEID"); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 805 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 806 | int uniqueId = addUniqueId(data.readInt32()); |
| 807 | reply->writeInt32(uniqueId); |
| 808 | return DRM_NO_ERROR; |
| 809 | } |
| 810 | |
| 811 | case REMOVE_UNIQUEID: |
| 812 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 813 | ALOGV("BnDrmManagerService::onTransact :REMOVE_UNIQUEID"); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 814 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 815 | removeUniqueId(data.readInt32()); |
| 816 | return DRM_NO_ERROR; |
| 817 | } |
| 818 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 819 | case ADD_CLIENT: |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 820 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 821 | ALOGV("BnDrmManagerService::onTransact :ADD_CLIENT"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 822 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 823 | addClient(data.readInt32()); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 824 | return DRM_NO_ERROR; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 825 | } |
| 826 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 827 | case REMOVE_CLIENT: |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 828 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 829 | ALOGV("BnDrmManagerService::onTransact :REMOVE_CLIENT"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 830 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 831 | removeClient(data.readInt32()); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 832 | return DRM_NO_ERROR; |
| 833 | } |
| 834 | |
| 835 | case SET_DRM_SERVICE_LISTENER: |
| 836 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 837 | ALOGV("BnDrmManagerService::onTransact :SET_DRM_SERVICE_LISTENER"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 838 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 839 | |
| 840 | const int uniqueId = data.readInt32(); |
| 841 | const sp<IDrmServiceListener> drmServiceListener |
| 842 | = interface_cast<IDrmServiceListener> (data.readStrongBinder()); |
| 843 | |
| 844 | status_t status = setDrmServiceListener(uniqueId, drmServiceListener); |
| 845 | |
| 846 | reply->writeInt32(status); |
| 847 | return DRM_NO_ERROR; |
| 848 | } |
| 849 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 850 | case INSTALL_DRM_ENGINE: |
| 851 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 852 | ALOGV("BnDrmManagerService::onTransact :INSTALL_DRM_ENGINE"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 853 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 854 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 855 | const int uniqueId = data.readInt32(); |
| 856 | const String8 engineFile = data.readString8(); |
| 857 | status_t status = installDrmEngine(uniqueId, engineFile); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 858 | |
| 859 | reply->writeInt32(status); |
| 860 | return DRM_NO_ERROR; |
| 861 | } |
| 862 | |
| 863 | case GET_CONSTRAINTS_FROM_CONTENT: |
| 864 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 865 | ALOGV("BnDrmManagerService::onTransact :GET_CONSTRAINTS_FROM_CONTENT"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 866 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 867 | |
| 868 | const int uniqueId = data.readInt32(); |
| 869 | const String8 path = data.readString8(); |
| 870 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 871 | DrmConstraints* drmConstraints |
| 872 | = getConstraints(uniqueId, &path, data.readInt32()); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 873 | |
| 874 | if (NULL != drmConstraints) { |
| 875 | //Filling DRM Constraints contents |
| 876 | reply->writeInt32(drmConstraints->getCount()); |
| 877 | |
| 878 | DrmConstraints::KeyIterator keyIt = drmConstraints->keyIterator(); |
| 879 | while (keyIt.hasNext()) { |
| 880 | const String8 key = keyIt.next(); |
| 881 | reply->writeString8(key); |
| 882 | const char* value = drmConstraints->getAsByteArray(&key); |
| 883 | int bufferSize = 0; |
| 884 | if (NULL != value) { |
| 885 | bufferSize = strlen(value); |
| 886 | } |
| 887 | reply->writeInt32(bufferSize + 1); |
| 888 | reply->write(value, bufferSize + 1); |
| 889 | } |
| 890 | } |
| 891 | delete drmConstraints; drmConstraints = NULL; |
| 892 | return DRM_NO_ERROR; |
| 893 | } |
| 894 | |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 895 | case GET_METADATA_FROM_CONTENT: |
| 896 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 897 | ALOGV("BnDrmManagerService::onTransact :GET_METADATA_FROM_CONTENT"); |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 898 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 899 | |
| 900 | const int uniqueId = data.readInt32(); |
| 901 | const String8 path = data.readString8(); |
| 902 | |
| 903 | DrmMetadata* drmMetadata = getMetadata(uniqueId, &path); |
| 904 | if (NULL != drmMetadata) { |
| 905 | //Filling DRM Metadata contents |
| 906 | reply->writeInt32(drmMetadata->getCount()); |
| 907 | |
| 908 | DrmMetadata::KeyIterator keyIt = drmMetadata->keyIterator(); |
| 909 | while (keyIt.hasNext()) { |
| 910 | const String8 key = keyIt.next(); |
| 911 | reply->writeString8(key); |
| 912 | const char* value = drmMetadata->getAsByteArray(&key); |
| 913 | int bufferSize = 0; |
| 914 | if (NULL != value) { |
| 915 | bufferSize = strlen(value); |
| 916 | reply->writeInt32(bufferSize + 1); |
| 917 | reply->write(value, bufferSize + 1); |
| 918 | } else { |
| 919 | reply->writeInt32(0); |
| 920 | } |
| 921 | } |
| 922 | } |
| 923 | delete drmMetadata; drmMetadata = NULL; |
| 924 | return NO_ERROR; |
| 925 | } |
| 926 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 927 | case CAN_HANDLE: |
| 928 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 929 | ALOGV("BnDrmManagerService::onTransact :CAN_HANDLE"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 930 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 931 | |
| 932 | const int uniqueId = data.readInt32(); |
| 933 | const String8 path = data.readString8(); |
| 934 | const String8 mimeType = data.readString8(); |
| 935 | |
| 936 | bool result = canHandle(uniqueId, path, mimeType); |
| 937 | |
| 938 | reply->writeInt32(result); |
| 939 | return DRM_NO_ERROR; |
| 940 | } |
| 941 | |
| 942 | case PROCESS_DRM_INFO: |
| 943 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 944 | ALOGV("BnDrmManagerService::onTransact :PROCESS_DRM_INFO"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 945 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 946 | |
| 947 | const int uniqueId = data.readInt32(); |
| 948 | |
| 949 | //Filling DRM info |
| 950 | const int infoType = data.readInt32(); |
| 951 | const int bufferSize = data.readInt32(); |
| 952 | char* buffer = NULL; |
| 953 | if (0 < bufferSize) { |
| 954 | buffer = (char *)data.readInplace(bufferSize); |
| 955 | } |
| 956 | const DrmBuffer drmBuffer(buffer, bufferSize); |
| 957 | DrmInfo* drmInfo = new DrmInfo(infoType, drmBuffer, data.readString8()); |
| 958 | |
| 959 | const int size = data.readInt32(); |
| 960 | for (int index = 0; index < size; ++index) { |
| 961 | const String8 key(data.readString8()); |
| 962 | const String8 value(data.readString8()); |
| 963 | drmInfo->put(key, (value == String8("NULL")) ? String8("") : value); |
| 964 | } |
| 965 | |
| 966 | DrmInfoStatus* drmInfoStatus = processDrmInfo(uniqueId, drmInfo); |
| 967 | |
| 968 | if (NULL != drmInfoStatus) { |
| 969 | //Filling DRM Info Status contents |
| 970 | reply->writeInt32(drmInfoStatus->statusCode); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 971 | reply->writeInt32(drmInfoStatus->infoType); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 972 | reply->writeString8(drmInfoStatus->mimeType); |
| 973 | |
| 974 | if (NULL != drmInfoStatus->drmBuffer) { |
| 975 | const DrmBuffer* drmBuffer = drmInfoStatus->drmBuffer; |
| 976 | const int bufferSize = drmBuffer->length; |
| 977 | reply->writeInt32(bufferSize); |
| 978 | if (0 < bufferSize) { |
| 979 | reply->write(drmBuffer->data, bufferSize); |
| 980 | } |
| 981 | delete [] drmBuffer->data; |
| 982 | delete drmBuffer; drmBuffer = NULL; |
| 983 | } |
| 984 | } |
| 985 | delete drmInfo; drmInfo = NULL; |
| 986 | delete drmInfoStatus; drmInfoStatus = NULL; |
| 987 | return DRM_NO_ERROR; |
| 988 | } |
| 989 | |
| 990 | case ACQUIRE_DRM_INFO: |
| 991 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 992 | ALOGV("BnDrmManagerService::onTransact :ACQUIRE_DRM_INFO"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 993 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 994 | |
| 995 | const int uniqueId = data.readInt32(); |
| 996 | |
| 997 | //Filling DRM info Request |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 998 | const int infoType = data.readInt32(); |
| 999 | const String8 mimeType = data.readString8(); |
| 1000 | DrmInfoRequest* drmInfoRequest = new DrmInfoRequest(infoType, mimeType); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1001 | |
| 1002 | const int size = data.readInt32(); |
| 1003 | for (int index = 0; index < size; ++index) { |
| 1004 | const String8 key(data.readString8()); |
| 1005 | const String8 value(data.readString8()); |
| 1006 | drmInfoRequest->put(key, (value == String8("NULL")) ? String8("") : value); |
| 1007 | } |
| 1008 | |
| 1009 | DrmInfo* drmInfo = acquireDrmInfo(uniqueId, drmInfoRequest); |
| 1010 | |
| 1011 | if (NULL != drmInfo) { |
| 1012 | //Filling DRM Info |
| 1013 | const DrmBuffer drmBuffer = drmInfo->getData(); |
| 1014 | reply->writeInt32(drmInfo->getInfoType()); |
| 1015 | |
| 1016 | const int bufferSize = drmBuffer.length; |
| 1017 | reply->writeInt32(bufferSize); |
| 1018 | if (0 < bufferSize) { |
| 1019 | reply->write(drmBuffer.data, bufferSize); |
| 1020 | } |
| 1021 | reply->writeString8(drmInfo->getMimeType()); |
| 1022 | reply->writeInt32(drmInfo->getCount()); |
| 1023 | |
| 1024 | DrmInfo::KeyIterator keyIt = drmInfo->keyIterator(); |
| 1025 | while (keyIt.hasNext()) { |
| 1026 | const String8 key = keyIt.next(); |
| 1027 | reply->writeString8(key); |
| 1028 | const String8 value = drmInfo->get(key); |
| 1029 | reply->writeString8((value == String8("")) ? String8("NULL") : value); |
| 1030 | } |
| 1031 | delete [] drmBuffer.data; |
| 1032 | } |
| 1033 | delete drmInfoRequest; drmInfoRequest = NULL; |
| 1034 | delete drmInfo; drmInfo = NULL; |
| 1035 | return DRM_NO_ERROR; |
| 1036 | } |
| 1037 | |
| 1038 | case SAVE_RIGHTS: |
| 1039 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1040 | ALOGV("BnDrmManagerService::onTransact :SAVE_RIGHTS"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1041 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1042 | |
| 1043 | const int uniqueId = data.readInt32(); |
| 1044 | |
| 1045 | //Filling DRM Rights |
| 1046 | const int bufferSize = data.readInt32(); |
| 1047 | const DrmBuffer drmBuffer((char *)data.readInplace(bufferSize), bufferSize); |
| 1048 | |
| 1049 | const String8 mimeType(data.readString8()); |
| 1050 | const String8 accountId(data.readString8()); |
| 1051 | const String8 subscriptionId(data.readString8()); |
| 1052 | const String8 rightsPath(data.readString8()); |
| 1053 | const String8 contentPath(data.readString8()); |
| 1054 | |
| 1055 | DrmRights drmRights(drmBuffer, |
| 1056 | ((mimeType == String8("NULL")) ? String8("") : mimeType), |
| 1057 | ((accountId == String8("NULL")) ? String8("") : accountId), |
| 1058 | ((subscriptionId == String8("NULL")) ? String8("") : subscriptionId)); |
| 1059 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1060 | const status_t status = saveRights(uniqueId, drmRights, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1061 | ((rightsPath == String8("NULL")) ? String8("") : rightsPath), |
| 1062 | ((contentPath == String8("NULL")) ? String8("") : contentPath)); |
| 1063 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1064 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1065 | return DRM_NO_ERROR; |
| 1066 | } |
| 1067 | |
| 1068 | case GET_ORIGINAL_MIMETYPE: |
| 1069 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1070 | ALOGV("BnDrmManagerService::onTransact :GET_ORIGINAL_MIMETYPE"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1071 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1072 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1073 | const int uniqueId = data.readInt32(); |
| 1074 | const String8 path = data.readString8(); |
James Dong | bf5b3b2 | 2012-07-30 17:57:39 -0700 | [diff] [blame^] | 1075 | const int32_t isFdValid = data.readInt32(); |
| 1076 | int fd = -1; |
| 1077 | if (isFdValid) { |
| 1078 | fd = data.readFileDescriptor(); |
| 1079 | } |
| 1080 | const String8 originalMimeType = getOriginalMimeType(uniqueId, path, fd); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1081 | |
| 1082 | reply->writeString8(originalMimeType); |
| 1083 | return DRM_NO_ERROR; |
| 1084 | } |
| 1085 | |
| 1086 | case GET_DRM_OBJECT_TYPE: |
| 1087 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1088 | ALOGV("BnDrmManagerService::onTransact :GET_DRM_OBJECT_TYPE"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1089 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1090 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1091 | const int uniqueId = data.readInt32(); |
| 1092 | const String8 path = data.readString8(); |
| 1093 | const String8 mimeType = data.readString8(); |
| 1094 | const int drmObjectType = getDrmObjectType(uniqueId, path, mimeType); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1095 | |
| 1096 | reply->writeInt32(drmObjectType); |
| 1097 | return DRM_NO_ERROR; |
| 1098 | } |
| 1099 | |
| 1100 | case CHECK_RIGHTS_STATUS: |
| 1101 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1102 | ALOGV("BnDrmManagerService::onTransact :CHECK_RIGHTS_STATUS"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1103 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1104 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1105 | const int uniqueId = data.readInt32(); |
| 1106 | const String8 path = data.readString8(); |
| 1107 | const int action = data.readInt32(); |
| 1108 | const int result = checkRightsStatus(uniqueId, path, action); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1109 | |
| 1110 | reply->writeInt32(result); |
| 1111 | return DRM_NO_ERROR; |
| 1112 | } |
| 1113 | |
| 1114 | case CONSUME_RIGHTS: |
| 1115 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1116 | ALOGV("BnDrmManagerService::onTransact :CONSUME_RIGHTS"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1117 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1118 | |
| 1119 | const int uniqueId = data.readInt32(); |
| 1120 | |
| 1121 | DecryptHandle handle; |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1122 | readDecryptHandleFromParcelData(&handle, data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1123 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1124 | const int action = data.readInt32(); |
| 1125 | const bool reserve = static_cast<bool>(data.readInt32()); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1126 | const status_t status |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1127 | = consumeRights(uniqueId, &handle, action, reserve); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1128 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1129 | |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1130 | clearDecryptHandle(&handle); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1131 | return DRM_NO_ERROR; |
| 1132 | } |
| 1133 | |
| 1134 | case SET_PLAYBACK_STATUS: |
| 1135 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1136 | ALOGV("BnDrmManagerService::onTransact :SET_PLAYBACK_STATUS"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1137 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1138 | |
| 1139 | const int uniqueId = data.readInt32(); |
| 1140 | |
| 1141 | DecryptHandle handle; |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1142 | readDecryptHandleFromParcelData(&handle, data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1143 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1144 | const int playbackStatus = data.readInt32(); |
| 1145 | const int64_t position = data.readInt64(); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1146 | const status_t status |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1147 | = setPlaybackStatus(uniqueId, &handle, playbackStatus, position); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1148 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1149 | |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1150 | clearDecryptHandle(&handle); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1151 | return DRM_NO_ERROR; |
| 1152 | } |
| 1153 | |
| 1154 | case VALIDATE_ACTION: |
| 1155 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1156 | ALOGV("BnDrmManagerService::onTransact :VALIDATE_ACTION"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1157 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1158 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1159 | const int uniqueId = data.readInt32(); |
| 1160 | const String8 path = data.readString8(); |
| 1161 | const int action = data.readInt32(); |
| 1162 | const int outputType = data.readInt32(); |
| 1163 | const int configuration = data.readInt32(); |
| 1164 | bool result = validateAction(uniqueId, path, action, |
| 1165 | ActionDescription(outputType, configuration)); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1166 | |
| 1167 | reply->writeInt32(result); |
| 1168 | return DRM_NO_ERROR; |
| 1169 | } |
| 1170 | |
| 1171 | case REMOVE_RIGHTS: |
| 1172 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1173 | ALOGV("BnDrmManagerService::onTransact :REMOVE_RIGHTS"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1174 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1175 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1176 | int uniqueId = data.readInt32(); |
| 1177 | String8 path = data.readString8(); |
| 1178 | const status_t status = removeRights(uniqueId, path); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1179 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1180 | |
| 1181 | return DRM_NO_ERROR; |
| 1182 | } |
| 1183 | |
| 1184 | case REMOVE_ALL_RIGHTS: |
| 1185 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1186 | ALOGV("BnDrmManagerService::onTransact :REMOVE_ALL_RIGHTS"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1187 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1188 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1189 | const status_t status = removeAllRights(data.readInt32()); |
| 1190 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1191 | |
| 1192 | return DRM_NO_ERROR; |
| 1193 | } |
| 1194 | |
| 1195 | case OPEN_CONVERT_SESSION: |
| 1196 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1197 | ALOGV("BnDrmManagerService::onTransact :OPEN_CONVERT_SESSION"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1198 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1199 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1200 | const int uniqueId = data.readInt32(); |
| 1201 | const String8 mimeType = data.readString8(); |
| 1202 | const int convertId = openConvertSession(uniqueId, mimeType); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1203 | |
| 1204 | reply->writeInt32(convertId); |
| 1205 | return DRM_NO_ERROR; |
| 1206 | } |
| 1207 | |
| 1208 | case CONVERT_DATA: |
| 1209 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1210 | ALOGV("BnDrmManagerService::onTransact :CONVERT_DATA"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1211 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1212 | |
| 1213 | const int uniqueId = data.readInt32(); |
| 1214 | const int convertId = data.readInt32(); |
| 1215 | |
| 1216 | //Filling input data |
| 1217 | const int bufferSize = data.readInt32(); |
| 1218 | DrmBuffer* inputData = new DrmBuffer((char *)data.readInplace(bufferSize), bufferSize); |
| 1219 | |
| 1220 | DrmConvertedStatus* drmConvertedStatus = convertData(uniqueId, convertId, inputData); |
| 1221 | |
| 1222 | if (NULL != drmConvertedStatus) { |
| 1223 | //Filling Drm Converted Ststus |
| 1224 | reply->writeInt32(drmConvertedStatus->statusCode); |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 1225 | reply->writeInt64(drmConvertedStatus->offset); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1226 | |
| 1227 | if (NULL != drmConvertedStatus->convertedData) { |
| 1228 | const DrmBuffer* convertedData = drmConvertedStatus->convertedData; |
| 1229 | const int bufferSize = convertedData->length; |
| 1230 | reply->writeInt32(bufferSize); |
| 1231 | if (0 < bufferSize) { |
| 1232 | reply->write(convertedData->data, bufferSize); |
| 1233 | } |
| 1234 | delete [] convertedData->data; |
| 1235 | delete convertedData; convertedData = NULL; |
| 1236 | } |
| 1237 | } |
| 1238 | delete inputData; inputData = NULL; |
| 1239 | delete drmConvertedStatus; drmConvertedStatus = NULL; |
| 1240 | return DRM_NO_ERROR; |
| 1241 | } |
| 1242 | |
| 1243 | case CLOSE_CONVERT_SESSION: |
| 1244 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1245 | ALOGV("BnDrmManagerService::onTransact :CLOSE_CONVERT_SESSION"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1246 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1247 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1248 | const int uniqueId = data.readInt32(); |
| 1249 | const int convertId = data.readInt32(); |
| 1250 | DrmConvertedStatus* drmConvertedStatus |
| 1251 | = closeConvertSession(uniqueId, convertId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1252 | |
| 1253 | if (NULL != drmConvertedStatus) { |
| 1254 | //Filling Drm Converted Ststus |
| 1255 | reply->writeInt32(drmConvertedStatus->statusCode); |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 1256 | reply->writeInt64(drmConvertedStatus->offset); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1257 | |
| 1258 | if (NULL != drmConvertedStatus->convertedData) { |
| 1259 | const DrmBuffer* convertedData = drmConvertedStatus->convertedData; |
| 1260 | const int bufferSize = convertedData->length; |
| 1261 | reply->writeInt32(bufferSize); |
| 1262 | if (0 < bufferSize) { |
| 1263 | reply->write(convertedData->data, bufferSize); |
| 1264 | } |
| 1265 | delete [] convertedData->data; |
| 1266 | delete convertedData; convertedData = NULL; |
| 1267 | } |
| 1268 | } |
| 1269 | delete drmConvertedStatus; drmConvertedStatus = NULL; |
| 1270 | return DRM_NO_ERROR; |
| 1271 | } |
| 1272 | |
| 1273 | case GET_ALL_SUPPORT_INFO: |
| 1274 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1275 | ALOGV("BnDrmManagerService::onTransact :GET_ALL_SUPPORT_INFO"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1276 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1277 | |
| 1278 | const int uniqueId = data.readInt32(); |
| 1279 | int length = 0; |
| 1280 | DrmSupportInfo* drmSupportInfoArray = NULL; |
| 1281 | |
| 1282 | status_t status = getAllSupportInfo(uniqueId, &length, &drmSupportInfoArray); |
| 1283 | |
| 1284 | reply->writeInt32(length); |
| 1285 | for (int i = 0; i < length; ++i) { |
| 1286 | DrmSupportInfo drmSupportInfo = drmSupportInfoArray[i]; |
| 1287 | |
| 1288 | reply->writeInt32(drmSupportInfo.getFileSuffixCount()); |
| 1289 | DrmSupportInfo::FileSuffixIterator fileSuffixIt |
| 1290 | = drmSupportInfo.getFileSuffixIterator(); |
| 1291 | while (fileSuffixIt.hasNext()) { |
| 1292 | reply->writeString8(fileSuffixIt.next()); |
| 1293 | } |
| 1294 | |
| 1295 | reply->writeInt32(drmSupportInfo.getMimeTypeCount()); |
| 1296 | DrmSupportInfo::MimeTypeIterator mimeTypeIt = drmSupportInfo.getMimeTypeIterator(); |
| 1297 | while (mimeTypeIt.hasNext()) { |
| 1298 | reply->writeString8(mimeTypeIt.next()); |
| 1299 | } |
| 1300 | reply->writeString8(drmSupportInfo.getDescription()); |
| 1301 | } |
| 1302 | delete [] drmSupportInfoArray; drmSupportInfoArray = NULL; |
| 1303 | reply->writeInt32(status); |
| 1304 | return DRM_NO_ERROR; |
| 1305 | } |
| 1306 | |
| 1307 | case OPEN_DECRYPT_SESSION: |
| 1308 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1309 | ALOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1310 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1311 | |
| 1312 | const int uniqueId = data.readInt32(); |
| 1313 | const int fd = data.readFileDescriptor(); |
| 1314 | |
Gloria Wang | 197f047 | 2011-08-01 10:31:24 -0700 | [diff] [blame] | 1315 | const off64_t offset = data.readInt64(); |
| 1316 | const off64_t length = data.readInt64(); |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 1317 | const String8 mime = data.readString8(); |
| 1318 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1319 | DecryptHandle* handle |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 1320 | = openDecryptSession(uniqueId, fd, offset, length, mime.string()); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1321 | |
| 1322 | if (NULL != handle) { |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 1323 | writeDecryptHandleToParcelData(handle, reply); |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1324 | clearDecryptHandle(handle); |
| 1325 | delete handle; handle = NULL; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1326 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1327 | return DRM_NO_ERROR; |
| 1328 | } |
| 1329 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 1330 | case OPEN_DECRYPT_SESSION_FROM_URI: |
| 1331 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1332 | ALOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION_FROM_URI"); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 1333 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1334 | |
| 1335 | const int uniqueId = data.readInt32(); |
| 1336 | const String8 uri = data.readString8(); |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 1337 | const String8 mime = data.readString8(); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 1338 | |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 1339 | DecryptHandle* handle = openDecryptSession(uniqueId, uri.string(), mime.string()); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 1340 | |
| 1341 | if (NULL != handle) { |
Gloria Wang | c10ce33 | 2011-06-15 10:27:52 -0700 | [diff] [blame] | 1342 | writeDecryptHandleToParcelData(handle, reply); |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1343 | |
| 1344 | clearDecryptHandle(handle); |
| 1345 | delete handle; handle = NULL; |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 1346 | } else { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1347 | ALOGV("NULL decryptHandle is returned"); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 1348 | } |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 1349 | return DRM_NO_ERROR; |
| 1350 | } |
| 1351 | |
Kei Takahashi | cba7b32 | 2012-01-18 17:10:19 +0900 | [diff] [blame] | 1352 | case OPEN_DECRYPT_SESSION_FOR_STREAMING: |
| 1353 | { |
| 1354 | ALOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION_FOR_STREAMING"); |
| 1355 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1356 | |
| 1357 | const int uniqueId = data.readInt32(); |
| 1358 | const int bufferSize = data.readInt32(); |
| 1359 | DrmBuffer buf((bufferSize > 0) ? (char *)data.readInplace(bufferSize) : NULL, |
| 1360 | bufferSize); |
| 1361 | const String8 mimeType(data.readString8()); |
| 1362 | |
| 1363 | DecryptHandle* handle = openDecryptSession(uniqueId, buf, mimeType); |
| 1364 | |
| 1365 | if (handle != NULL) { |
| 1366 | writeDecryptHandleToParcelData(handle, reply); |
| 1367 | clearDecryptHandle(handle); |
| 1368 | delete handle; |
| 1369 | handle = NULL; |
| 1370 | } else { |
| 1371 | ALOGV("NULL decryptHandle is returned"); |
| 1372 | } |
| 1373 | return DRM_NO_ERROR; |
| 1374 | } |
| 1375 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1376 | case CLOSE_DECRYPT_SESSION: |
| 1377 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1378 | ALOGV("BnDrmManagerService::onTransact :CLOSE_DECRYPT_SESSION"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1379 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1380 | |
| 1381 | const int uniqueId = data.readInt32(); |
| 1382 | |
| 1383 | DecryptHandle* handle = new DecryptHandle(); |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1384 | readDecryptHandleFromParcelData(handle, data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1385 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1386 | const status_t status = closeDecryptSession(uniqueId, handle); |
| 1387 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1388 | return DRM_NO_ERROR; |
| 1389 | } |
| 1390 | |
| 1391 | case INITIALIZE_DECRYPT_UNIT: |
| 1392 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1393 | ALOGV("BnDrmManagerService::onTransact :INITIALIZE_DECRYPT_UNIT"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1394 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1395 | |
| 1396 | const int uniqueId = data.readInt32(); |
| 1397 | |
| 1398 | DecryptHandle handle; |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1399 | readDecryptHandleFromParcelData(&handle, data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1400 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1401 | const int decryptUnitId = data.readInt32(); |
| 1402 | |
| 1403 | //Filling Header info |
| 1404 | const int bufferSize = data.readInt32(); |
| 1405 | DrmBuffer* headerInfo = NULL; |
| 1406 | headerInfo = new DrmBuffer((char *)data.readInplace(bufferSize), bufferSize); |
| 1407 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1408 | const status_t status |
| 1409 | = initializeDecryptUnit(uniqueId, &handle, decryptUnitId, headerInfo); |
| 1410 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1411 | |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1412 | clearDecryptHandle(&handle); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1413 | delete headerInfo; headerInfo = NULL; |
| 1414 | return DRM_NO_ERROR; |
| 1415 | } |
| 1416 | |
| 1417 | case DECRYPT: |
| 1418 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1419 | ALOGV("BnDrmManagerService::onTransact :DECRYPT"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1420 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1421 | |
| 1422 | const int uniqueId = data.readInt32(); |
| 1423 | |
| 1424 | DecryptHandle handle; |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1425 | readDecryptHandleFromParcelData(&handle, data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1426 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1427 | const int decryptUnitId = data.readInt32(); |
| 1428 | const int decBufferSize = data.readInt32(); |
| 1429 | |
| 1430 | const int encBufferSize = data.readInt32(); |
| 1431 | DrmBuffer* encBuffer |
| 1432 | = new DrmBuffer((char *)data.readInplace(encBufferSize), encBufferSize); |
| 1433 | |
| 1434 | char* buffer = NULL; |
| 1435 | buffer = new char[decBufferSize]; |
| 1436 | DrmBuffer* decBuffer = new DrmBuffer(buffer, decBufferSize); |
| 1437 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1438 | DrmBuffer* IV = NULL; |
| 1439 | if (0 != data.dataAvail()) { |
| 1440 | const int ivBufferlength = data.readInt32(); |
| 1441 | IV = new DrmBuffer((char *)data.readInplace(ivBufferlength), ivBufferlength); |
| 1442 | } |
| 1443 | |
| 1444 | const status_t status |
| 1445 | = decrypt(uniqueId, &handle, decryptUnitId, encBuffer, &decBuffer, IV); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1446 | |
| 1447 | reply->writeInt32(status); |
| 1448 | |
| 1449 | const int size = decBuffer->length; |
| 1450 | reply->writeInt32(size); |
| 1451 | reply->write(decBuffer->data, size); |
| 1452 | |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1453 | clearDecryptHandle(&handle); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1454 | delete encBuffer; encBuffer = NULL; |
| 1455 | delete decBuffer; decBuffer = NULL; |
| 1456 | delete [] buffer; buffer = NULL; |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1457 | delete IV; IV = NULL; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1458 | return DRM_NO_ERROR; |
| 1459 | } |
| 1460 | |
| 1461 | case FINALIZE_DECRYPT_UNIT: |
| 1462 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1463 | ALOGV("BnDrmManagerService::onTransact :FINALIZE_DECRYPT_UNIT"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1464 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1465 | |
| 1466 | const int uniqueId = data.readInt32(); |
| 1467 | |
| 1468 | DecryptHandle handle; |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1469 | readDecryptHandleFromParcelData(&handle, data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1470 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1471 | const status_t status = finalizeDecryptUnit(uniqueId, &handle, data.readInt32()); |
| 1472 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1473 | |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1474 | clearDecryptHandle(&handle); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1475 | return DRM_NO_ERROR; |
| 1476 | } |
| 1477 | |
| 1478 | case PREAD: |
| 1479 | { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 1480 | ALOGV("BnDrmManagerService::onTransact :READ"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1481 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1482 | |
| 1483 | const int uniqueId = data.readInt32(); |
| 1484 | |
| 1485 | DecryptHandle handle; |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1486 | readDecryptHandleFromParcelData(&handle, data); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1487 | |
| 1488 | const int numBytes = data.readInt32(); |
| 1489 | char* buffer = new char[numBytes]; |
| 1490 | |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 1491 | const off64_t offset = data.readInt64(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1492 | |
| 1493 | ssize_t result = pread(uniqueId, &handle, buffer, numBytes, offset); |
| 1494 | reply->writeInt32(result); |
| 1495 | if (0 < result) { |
| 1496 | reply->write(buffer, result); |
| 1497 | } |
| 1498 | |
Gloria Wang | 1da9aa6 | 2011-03-20 10:25:16 -0700 | [diff] [blame] | 1499 | clearDecryptHandle(&handle); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1500 | delete [] buffer, buffer = NULL; |
| 1501 | return DRM_NO_ERROR; |
| 1502 | } |
| 1503 | |
| 1504 | default: |
| 1505 | return BBinder::onTransact(code, data, reply, flags); |
| 1506 | } |
| 1507 | } |
| 1508 | |