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