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 | |
| 624 | if (NULL != decryptHandle->decryptInfo) { |
| 625 | LOGV("deleting decryptInfo"); |
| 626 | delete decryptHandle->decryptInfo; decryptHandle->decryptInfo = NULL; |
| 627 | } |
| 628 | delete decryptHandle; decryptHandle = NULL; |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 629 | return reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 630 | } |
| 631 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 632 | status_t BpDrmManagerService::initializeDecryptUnit( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 633 | int uniqueId, DecryptHandle* decryptHandle, |
| 634 | int decryptUnitId, const DrmBuffer* headerInfo) { |
| 635 | LOGV("initializeDecryptUnit"); |
| 636 | Parcel data, reply; |
| 637 | |
| 638 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 639 | data.writeInt32(uniqueId); |
| 640 | |
| 641 | data.writeInt32(decryptHandle->decryptId); |
| 642 | data.writeString8(decryptHandle->mimeType); |
| 643 | data.writeInt32(decryptHandle->decryptApiType); |
| 644 | data.writeInt32(decryptHandle->status); |
| 645 | |
| 646 | if (NULL != decryptHandle->decryptInfo) { |
| 647 | data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength); |
| 648 | } else { |
| 649 | data.writeInt32(INVALID_BUFFER_LENGTH); |
| 650 | } |
| 651 | data.writeInt32(decryptUnitId); |
| 652 | |
| 653 | data.writeInt32(headerInfo->length); |
| 654 | data.write(headerInfo->data, headerInfo->length); |
| 655 | |
| 656 | remote()->transact(INITIALIZE_DECRYPT_UNIT, data, &reply); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 657 | return reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | status_t BpDrmManagerService::decrypt( |
| 661 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 662 | const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 663 | LOGV("decrypt"); |
| 664 | Parcel data, reply; |
| 665 | |
| 666 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 667 | data.writeInt32(uniqueId); |
| 668 | |
| 669 | data.writeInt32(decryptHandle->decryptId); |
| 670 | data.writeString8(decryptHandle->mimeType); |
| 671 | data.writeInt32(decryptHandle->decryptApiType); |
| 672 | data.writeInt32(decryptHandle->status); |
| 673 | |
| 674 | if (NULL != decryptHandle->decryptInfo) { |
| 675 | data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength); |
| 676 | } else { |
| 677 | data.writeInt32(INVALID_BUFFER_LENGTH); |
| 678 | } |
| 679 | |
| 680 | data.writeInt32(decryptUnitId); |
| 681 | data.writeInt32((*decBuffer)->length); |
| 682 | |
| 683 | data.writeInt32(encBuffer->length); |
| 684 | data.write(encBuffer->data, encBuffer->length); |
| 685 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 686 | if (NULL != IV) { |
| 687 | data.writeInt32(IV->length); |
| 688 | data.write(IV->data, IV->length); |
| 689 | } |
| 690 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 691 | remote()->transact(DECRYPT, data, &reply); |
| 692 | |
| 693 | const status_t status = reply.readInt32(); |
| 694 | LOGV("Return value of decrypt() is %d", status); |
| 695 | |
| 696 | const int size = reply.readInt32(); |
| 697 | (*decBuffer)->length = size; |
| 698 | reply.read((void *)(*decBuffer)->data, size); |
| 699 | |
| 700 | return status; |
| 701 | } |
| 702 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 703 | status_t BpDrmManagerService::finalizeDecryptUnit( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 704 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) { |
| 705 | LOGV("finalizeDecryptUnit"); |
| 706 | Parcel data, reply; |
| 707 | |
| 708 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 709 | data.writeInt32(uniqueId); |
| 710 | |
| 711 | data.writeInt32(decryptHandle->decryptId); |
| 712 | data.writeString8(decryptHandle->mimeType); |
| 713 | data.writeInt32(decryptHandle->decryptApiType); |
| 714 | data.writeInt32(decryptHandle->status); |
| 715 | |
| 716 | if (NULL != decryptHandle->decryptInfo) { |
| 717 | data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength); |
| 718 | } else { |
| 719 | data.writeInt32(INVALID_BUFFER_LENGTH); |
| 720 | } |
| 721 | |
| 722 | data.writeInt32(decryptUnitId); |
| 723 | |
| 724 | remote()->transact(FINALIZE_DECRYPT_UNIT, data, &reply); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 725 | return reply.readInt32(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | ssize_t BpDrmManagerService::pread( |
| 729 | int uniqueId, DecryptHandle* decryptHandle, void* buffer, |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 730 | ssize_t numBytes, off64_t offset) { |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 731 | LOGV("read"); |
| 732 | Parcel data, reply; |
| 733 | int result; |
| 734 | |
| 735 | data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); |
| 736 | data.writeInt32(uniqueId); |
| 737 | |
| 738 | data.writeInt32(decryptHandle->decryptId); |
| 739 | data.writeString8(decryptHandle->mimeType); |
| 740 | data.writeInt32(decryptHandle->decryptApiType); |
| 741 | data.writeInt32(decryptHandle->status); |
| 742 | |
| 743 | if (NULL != decryptHandle->decryptInfo) { |
| 744 | data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength); |
| 745 | } else { |
| 746 | data.writeInt32(INVALID_BUFFER_LENGTH); |
| 747 | } |
| 748 | |
| 749 | data.writeInt32(numBytes); |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 750 | data.writeInt64(offset); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 751 | |
| 752 | remote()->transact(PREAD, data, &reply); |
| 753 | result = reply.readInt32(); |
| 754 | if (0 < result) { |
| 755 | reply.read(buffer, result); |
| 756 | } |
| 757 | return result; |
| 758 | } |
| 759 | |
| 760 | IMPLEMENT_META_INTERFACE(DrmManagerService, "drm.IDrmManagerService"); |
| 761 | |
| 762 | status_t BnDrmManagerService::onTransact( |
| 763 | uint32_t code, const Parcel& data, |
| 764 | Parcel* reply, uint32_t flags) { |
| 765 | LOGV("Entering BnDrmManagerService::onTransact with code %d", code); |
| 766 | |
| 767 | switch (code) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 768 | case ADD_UNIQUEID: |
| 769 | { |
| 770 | LOGV("BnDrmManagerService::onTransact :ADD_UNIQUEID"); |
| 771 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 772 | int uniqueId = addUniqueId(data.readInt32()); |
| 773 | reply->writeInt32(uniqueId); |
| 774 | return DRM_NO_ERROR; |
| 775 | } |
| 776 | |
| 777 | case REMOVE_UNIQUEID: |
| 778 | { |
| 779 | LOGV("BnDrmManagerService::onTransact :REMOVE_UNIQUEID"); |
| 780 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 781 | removeUniqueId(data.readInt32()); |
| 782 | return DRM_NO_ERROR; |
| 783 | } |
| 784 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 785 | case ADD_CLIENT: |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 786 | { |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 787 | LOGV("BnDrmManagerService::onTransact :ADD_CLIENT"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 788 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 789 | addClient(data.readInt32()); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 790 | return DRM_NO_ERROR; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 791 | } |
| 792 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 793 | case REMOVE_CLIENT: |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 794 | { |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 795 | LOGV("BnDrmManagerService::onTransact :REMOVE_CLIENT"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 796 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 797 | removeClient(data.readInt32()); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 798 | return DRM_NO_ERROR; |
| 799 | } |
| 800 | |
| 801 | case SET_DRM_SERVICE_LISTENER: |
| 802 | { |
| 803 | LOGV("BnDrmManagerService::onTransact :SET_DRM_SERVICE_LISTENER"); |
| 804 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 805 | |
| 806 | const int uniqueId = data.readInt32(); |
| 807 | const sp<IDrmServiceListener> drmServiceListener |
| 808 | = interface_cast<IDrmServiceListener> (data.readStrongBinder()); |
| 809 | |
| 810 | status_t status = setDrmServiceListener(uniqueId, drmServiceListener); |
| 811 | |
| 812 | reply->writeInt32(status); |
| 813 | return DRM_NO_ERROR; |
| 814 | } |
| 815 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 816 | case INSTALL_DRM_ENGINE: |
| 817 | { |
| 818 | LOGV("BnDrmManagerService::onTransact :INSTALL_DRM_ENGINE"); |
| 819 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 820 | |
| 821 | status_t status = installDrmEngine(data.readInt32(), data.readString8()); |
| 822 | |
| 823 | reply->writeInt32(status); |
| 824 | return DRM_NO_ERROR; |
| 825 | } |
| 826 | |
| 827 | case GET_CONSTRAINTS_FROM_CONTENT: |
| 828 | { |
| 829 | LOGV("BnDrmManagerService::onTransact :GET_CONSTRAINTS_FROM_CONTENT"); |
| 830 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 831 | |
| 832 | const int uniqueId = data.readInt32(); |
| 833 | const String8 path = data.readString8(); |
| 834 | |
| 835 | DrmConstraints* drmConstraints = getConstraints(uniqueId, &path, data.readInt32()); |
| 836 | |
| 837 | if (NULL != drmConstraints) { |
| 838 | //Filling DRM Constraints contents |
| 839 | reply->writeInt32(drmConstraints->getCount()); |
| 840 | |
| 841 | DrmConstraints::KeyIterator keyIt = drmConstraints->keyIterator(); |
| 842 | while (keyIt.hasNext()) { |
| 843 | const String8 key = keyIt.next(); |
| 844 | reply->writeString8(key); |
| 845 | const char* value = drmConstraints->getAsByteArray(&key); |
| 846 | int bufferSize = 0; |
| 847 | if (NULL != value) { |
| 848 | bufferSize = strlen(value); |
| 849 | } |
| 850 | reply->writeInt32(bufferSize + 1); |
| 851 | reply->write(value, bufferSize + 1); |
| 852 | } |
| 853 | } |
| 854 | delete drmConstraints; drmConstraints = NULL; |
| 855 | return DRM_NO_ERROR; |
| 856 | } |
| 857 | |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 858 | case GET_METADATA_FROM_CONTENT: |
| 859 | { |
| 860 | LOGV("BnDrmManagerService::onTransact :GET_METADATA_FROM_CONTENT"); |
| 861 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 862 | |
| 863 | const int uniqueId = data.readInt32(); |
| 864 | const String8 path = data.readString8(); |
| 865 | |
| 866 | DrmMetadata* drmMetadata = getMetadata(uniqueId, &path); |
| 867 | if (NULL != drmMetadata) { |
| 868 | //Filling DRM Metadata contents |
| 869 | reply->writeInt32(drmMetadata->getCount()); |
| 870 | |
| 871 | DrmMetadata::KeyIterator keyIt = drmMetadata->keyIterator(); |
| 872 | while (keyIt.hasNext()) { |
| 873 | const String8 key = keyIt.next(); |
| 874 | reply->writeString8(key); |
| 875 | const char* value = drmMetadata->getAsByteArray(&key); |
| 876 | int bufferSize = 0; |
| 877 | if (NULL != value) { |
| 878 | bufferSize = strlen(value); |
| 879 | reply->writeInt32(bufferSize + 1); |
| 880 | reply->write(value, bufferSize + 1); |
| 881 | } else { |
| 882 | reply->writeInt32(0); |
| 883 | } |
| 884 | } |
| 885 | } |
| 886 | delete drmMetadata; drmMetadata = NULL; |
| 887 | return NO_ERROR; |
| 888 | } |
| 889 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 890 | case CAN_HANDLE: |
| 891 | { |
| 892 | LOGV("BnDrmManagerService::onTransact :CAN_HANDLE"); |
| 893 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 894 | |
| 895 | const int uniqueId = data.readInt32(); |
| 896 | const String8 path = data.readString8(); |
| 897 | const String8 mimeType = data.readString8(); |
| 898 | |
| 899 | bool result = canHandle(uniqueId, path, mimeType); |
| 900 | |
| 901 | reply->writeInt32(result); |
| 902 | return DRM_NO_ERROR; |
| 903 | } |
| 904 | |
| 905 | case PROCESS_DRM_INFO: |
| 906 | { |
| 907 | LOGV("BnDrmManagerService::onTransact :PROCESS_DRM_INFO"); |
| 908 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 909 | |
| 910 | const int uniqueId = data.readInt32(); |
| 911 | |
| 912 | //Filling DRM info |
| 913 | const int infoType = data.readInt32(); |
| 914 | const int bufferSize = data.readInt32(); |
| 915 | char* buffer = NULL; |
| 916 | if (0 < bufferSize) { |
| 917 | buffer = (char *)data.readInplace(bufferSize); |
| 918 | } |
| 919 | const DrmBuffer drmBuffer(buffer, bufferSize); |
| 920 | DrmInfo* drmInfo = new DrmInfo(infoType, drmBuffer, data.readString8()); |
| 921 | |
| 922 | const int size = data.readInt32(); |
| 923 | for (int index = 0; index < size; ++index) { |
| 924 | const String8 key(data.readString8()); |
| 925 | const String8 value(data.readString8()); |
| 926 | drmInfo->put(key, (value == String8("NULL")) ? String8("") : value); |
| 927 | } |
| 928 | |
| 929 | DrmInfoStatus* drmInfoStatus = processDrmInfo(uniqueId, drmInfo); |
| 930 | |
| 931 | if (NULL != drmInfoStatus) { |
| 932 | //Filling DRM Info Status contents |
| 933 | reply->writeInt32(drmInfoStatus->statusCode); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 934 | reply->writeInt32(drmInfoStatus->infoType); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 935 | reply->writeString8(drmInfoStatus->mimeType); |
| 936 | |
| 937 | if (NULL != drmInfoStatus->drmBuffer) { |
| 938 | const DrmBuffer* drmBuffer = drmInfoStatus->drmBuffer; |
| 939 | const int bufferSize = drmBuffer->length; |
| 940 | reply->writeInt32(bufferSize); |
| 941 | if (0 < bufferSize) { |
| 942 | reply->write(drmBuffer->data, bufferSize); |
| 943 | } |
| 944 | delete [] drmBuffer->data; |
| 945 | delete drmBuffer; drmBuffer = NULL; |
| 946 | } |
| 947 | } |
| 948 | delete drmInfo; drmInfo = NULL; |
| 949 | delete drmInfoStatus; drmInfoStatus = NULL; |
| 950 | return DRM_NO_ERROR; |
| 951 | } |
| 952 | |
| 953 | case ACQUIRE_DRM_INFO: |
| 954 | { |
| 955 | LOGV("BnDrmManagerService::onTransact :ACQUIRE_DRM_INFO"); |
| 956 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 957 | |
| 958 | const int uniqueId = data.readInt32(); |
| 959 | |
| 960 | //Filling DRM info Request |
| 961 | DrmInfoRequest* drmInfoRequest = new DrmInfoRequest(data.readInt32(), data.readString8()); |
| 962 | |
| 963 | const int size = data.readInt32(); |
| 964 | for (int index = 0; index < size; ++index) { |
| 965 | const String8 key(data.readString8()); |
| 966 | const String8 value(data.readString8()); |
| 967 | drmInfoRequest->put(key, (value == String8("NULL")) ? String8("") : value); |
| 968 | } |
| 969 | |
| 970 | DrmInfo* drmInfo = acquireDrmInfo(uniqueId, drmInfoRequest); |
| 971 | |
| 972 | if (NULL != drmInfo) { |
| 973 | //Filling DRM Info |
| 974 | const DrmBuffer drmBuffer = drmInfo->getData(); |
| 975 | reply->writeInt32(drmInfo->getInfoType()); |
| 976 | |
| 977 | const int bufferSize = drmBuffer.length; |
| 978 | reply->writeInt32(bufferSize); |
| 979 | if (0 < bufferSize) { |
| 980 | reply->write(drmBuffer.data, bufferSize); |
| 981 | } |
| 982 | reply->writeString8(drmInfo->getMimeType()); |
| 983 | reply->writeInt32(drmInfo->getCount()); |
| 984 | |
| 985 | DrmInfo::KeyIterator keyIt = drmInfo->keyIterator(); |
| 986 | while (keyIt.hasNext()) { |
| 987 | const String8 key = keyIt.next(); |
| 988 | reply->writeString8(key); |
| 989 | const String8 value = drmInfo->get(key); |
| 990 | reply->writeString8((value == String8("")) ? String8("NULL") : value); |
| 991 | } |
| 992 | delete [] drmBuffer.data; |
| 993 | } |
| 994 | delete drmInfoRequest; drmInfoRequest = NULL; |
| 995 | delete drmInfo; drmInfo = NULL; |
| 996 | return DRM_NO_ERROR; |
| 997 | } |
| 998 | |
| 999 | case SAVE_RIGHTS: |
| 1000 | { |
| 1001 | LOGV("BnDrmManagerService::onTransact :SAVE_RIGHTS"); |
| 1002 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1003 | |
| 1004 | const int uniqueId = data.readInt32(); |
| 1005 | |
| 1006 | //Filling DRM Rights |
| 1007 | const int bufferSize = data.readInt32(); |
| 1008 | const DrmBuffer drmBuffer((char *)data.readInplace(bufferSize), bufferSize); |
| 1009 | |
| 1010 | const String8 mimeType(data.readString8()); |
| 1011 | const String8 accountId(data.readString8()); |
| 1012 | const String8 subscriptionId(data.readString8()); |
| 1013 | const String8 rightsPath(data.readString8()); |
| 1014 | const String8 contentPath(data.readString8()); |
| 1015 | |
| 1016 | DrmRights drmRights(drmBuffer, |
| 1017 | ((mimeType == String8("NULL")) ? String8("") : mimeType), |
| 1018 | ((accountId == String8("NULL")) ? String8("") : accountId), |
| 1019 | ((subscriptionId == String8("NULL")) ? String8("") : subscriptionId)); |
| 1020 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1021 | const status_t status = saveRights(uniqueId, drmRights, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1022 | ((rightsPath == String8("NULL")) ? String8("") : rightsPath), |
| 1023 | ((contentPath == String8("NULL")) ? String8("") : contentPath)); |
| 1024 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1025 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1026 | return DRM_NO_ERROR; |
| 1027 | } |
| 1028 | |
| 1029 | case GET_ORIGINAL_MIMETYPE: |
| 1030 | { |
| 1031 | LOGV("BnDrmManagerService::onTransact :GET_ORIGINAL_MIMETYPE"); |
| 1032 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1033 | |
| 1034 | const String8 originalMimeType = getOriginalMimeType(data.readInt32(), data.readString8()); |
| 1035 | |
| 1036 | reply->writeString8(originalMimeType); |
| 1037 | return DRM_NO_ERROR; |
| 1038 | } |
| 1039 | |
| 1040 | case GET_DRM_OBJECT_TYPE: |
| 1041 | { |
| 1042 | LOGV("BnDrmManagerService::onTransact :GET_DRM_OBJECT_TYPE"); |
| 1043 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1044 | |
| 1045 | const int drmObjectType |
| 1046 | = getDrmObjectType(data.readInt32(), data.readString8(), data.readString8()); |
| 1047 | |
| 1048 | reply->writeInt32(drmObjectType); |
| 1049 | return DRM_NO_ERROR; |
| 1050 | } |
| 1051 | |
| 1052 | case CHECK_RIGHTS_STATUS: |
| 1053 | { |
| 1054 | LOGV("BnDrmManagerService::onTransact :CHECK_RIGHTS_STATUS"); |
| 1055 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1056 | |
| 1057 | const int result |
| 1058 | = checkRightsStatus(data.readInt32(), data.readString8(), data.readInt32()); |
| 1059 | |
| 1060 | reply->writeInt32(result); |
| 1061 | return DRM_NO_ERROR; |
| 1062 | } |
| 1063 | |
| 1064 | case CONSUME_RIGHTS: |
| 1065 | { |
| 1066 | LOGV("BnDrmManagerService::onTransact :CONSUME_RIGHTS"); |
| 1067 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1068 | |
| 1069 | const int uniqueId = data.readInt32(); |
| 1070 | |
| 1071 | DecryptHandle handle; |
| 1072 | handle.decryptId = data.readInt32(); |
| 1073 | handle.mimeType = data.readString8(); |
| 1074 | handle.decryptApiType = data.readInt32(); |
| 1075 | handle.status = data.readInt32(); |
| 1076 | handle.decryptInfo = NULL; |
| 1077 | |
| 1078 | const int bufferLength = data.readInt32(); |
| 1079 | if (INVALID_BUFFER_LENGTH != bufferLength) { |
| 1080 | handle.decryptInfo = new DecryptInfo(); |
| 1081 | handle.decryptInfo->decryptBufferLength = bufferLength; |
| 1082 | } |
| 1083 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1084 | const status_t status |
| 1085 | = consumeRights(uniqueId, &handle, data.readInt32(), |
| 1086 | static_cast<bool>(data.readInt32())); |
| 1087 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1088 | |
| 1089 | delete handle.decryptInfo; handle.decryptInfo = NULL; |
| 1090 | return DRM_NO_ERROR; |
| 1091 | } |
| 1092 | |
| 1093 | case SET_PLAYBACK_STATUS: |
| 1094 | { |
| 1095 | LOGV("BnDrmManagerService::onTransact :SET_PLAYBACK_STATUS"); |
| 1096 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1097 | |
| 1098 | const int uniqueId = data.readInt32(); |
| 1099 | |
| 1100 | DecryptHandle handle; |
| 1101 | handle.decryptId = data.readInt32(); |
| 1102 | handle.mimeType = data.readString8(); |
| 1103 | handle.decryptApiType = data.readInt32(); |
| 1104 | handle.status = data.readInt32(); |
| 1105 | handle.decryptInfo = NULL; |
| 1106 | |
| 1107 | const int bufferLength = data.readInt32(); |
| 1108 | if (INVALID_BUFFER_LENGTH != bufferLength) { |
| 1109 | handle.decryptInfo = new DecryptInfo(); |
| 1110 | handle.decryptInfo->decryptBufferLength = bufferLength; |
| 1111 | } |
| 1112 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1113 | const status_t status |
Gloria Wang | 2ed8a92 | 2011-01-19 15:38:16 -0800 | [diff] [blame] | 1114 | = setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt64()); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1115 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1116 | |
| 1117 | delete handle.decryptInfo; handle.decryptInfo = NULL; |
| 1118 | return DRM_NO_ERROR; |
| 1119 | } |
| 1120 | |
| 1121 | case VALIDATE_ACTION: |
| 1122 | { |
| 1123 | LOGV("BnDrmManagerService::onTransact :VALIDATE_ACTION"); |
| 1124 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1125 | |
| 1126 | bool result = validateAction( |
| 1127 | data.readInt32(), |
| 1128 | data.readString8(), |
| 1129 | data.readInt32(), |
| 1130 | ActionDescription(data.readInt32(), data.readInt32())); |
| 1131 | |
| 1132 | reply->writeInt32(result); |
| 1133 | return DRM_NO_ERROR; |
| 1134 | } |
| 1135 | |
| 1136 | case REMOVE_RIGHTS: |
| 1137 | { |
| 1138 | LOGV("BnDrmManagerService::onTransact :REMOVE_RIGHTS"); |
| 1139 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1140 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1141 | const status_t status = removeRights(data.readInt32(), data.readString8()); |
| 1142 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1143 | |
| 1144 | return DRM_NO_ERROR; |
| 1145 | } |
| 1146 | |
| 1147 | case REMOVE_ALL_RIGHTS: |
| 1148 | { |
| 1149 | LOGV("BnDrmManagerService::onTransact :REMOVE_ALL_RIGHTS"); |
| 1150 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1151 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1152 | const status_t status = removeAllRights(data.readInt32()); |
| 1153 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1154 | |
| 1155 | return DRM_NO_ERROR; |
| 1156 | } |
| 1157 | |
| 1158 | case OPEN_CONVERT_SESSION: |
| 1159 | { |
| 1160 | LOGV("BnDrmManagerService::onTransact :OPEN_CONVERT_SESSION"); |
| 1161 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1162 | |
| 1163 | const int convertId = openConvertSession(data.readInt32(), data.readString8()); |
| 1164 | |
| 1165 | reply->writeInt32(convertId); |
| 1166 | return DRM_NO_ERROR; |
| 1167 | } |
| 1168 | |
| 1169 | case CONVERT_DATA: |
| 1170 | { |
| 1171 | LOGV("BnDrmManagerService::onTransact :CONVERT_DATA"); |
| 1172 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1173 | |
| 1174 | const int uniqueId = data.readInt32(); |
| 1175 | const int convertId = data.readInt32(); |
| 1176 | |
| 1177 | //Filling input data |
| 1178 | const int bufferSize = data.readInt32(); |
| 1179 | DrmBuffer* inputData = new DrmBuffer((char *)data.readInplace(bufferSize), bufferSize); |
| 1180 | |
| 1181 | DrmConvertedStatus* drmConvertedStatus = convertData(uniqueId, convertId, inputData); |
| 1182 | |
| 1183 | if (NULL != drmConvertedStatus) { |
| 1184 | //Filling Drm Converted Ststus |
| 1185 | reply->writeInt32(drmConvertedStatus->statusCode); |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 1186 | reply->writeInt64(drmConvertedStatus->offset); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1187 | |
| 1188 | if (NULL != drmConvertedStatus->convertedData) { |
| 1189 | const DrmBuffer* convertedData = drmConvertedStatus->convertedData; |
| 1190 | const int bufferSize = convertedData->length; |
| 1191 | reply->writeInt32(bufferSize); |
| 1192 | if (0 < bufferSize) { |
| 1193 | reply->write(convertedData->data, bufferSize); |
| 1194 | } |
| 1195 | delete [] convertedData->data; |
| 1196 | delete convertedData; convertedData = NULL; |
| 1197 | } |
| 1198 | } |
| 1199 | delete inputData; inputData = NULL; |
| 1200 | delete drmConvertedStatus; drmConvertedStatus = NULL; |
| 1201 | return DRM_NO_ERROR; |
| 1202 | } |
| 1203 | |
| 1204 | case CLOSE_CONVERT_SESSION: |
| 1205 | { |
| 1206 | LOGV("BnDrmManagerService::onTransact :CLOSE_CONVERT_SESSION"); |
| 1207 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1208 | |
| 1209 | DrmConvertedStatus* drmConvertedStatus |
| 1210 | = closeConvertSession(data.readInt32(), data.readInt32()); |
| 1211 | |
| 1212 | if (NULL != drmConvertedStatus) { |
| 1213 | //Filling Drm Converted Ststus |
| 1214 | reply->writeInt32(drmConvertedStatus->statusCode); |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 1215 | reply->writeInt64(drmConvertedStatus->offset); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1216 | |
| 1217 | if (NULL != drmConvertedStatus->convertedData) { |
| 1218 | const DrmBuffer* convertedData = drmConvertedStatus->convertedData; |
| 1219 | const int bufferSize = convertedData->length; |
| 1220 | reply->writeInt32(bufferSize); |
| 1221 | if (0 < bufferSize) { |
| 1222 | reply->write(convertedData->data, bufferSize); |
| 1223 | } |
| 1224 | delete [] convertedData->data; |
| 1225 | delete convertedData; convertedData = NULL; |
| 1226 | } |
| 1227 | } |
| 1228 | delete drmConvertedStatus; drmConvertedStatus = NULL; |
| 1229 | return DRM_NO_ERROR; |
| 1230 | } |
| 1231 | |
| 1232 | case GET_ALL_SUPPORT_INFO: |
| 1233 | { |
| 1234 | LOGV("BnDrmManagerService::onTransact :GET_ALL_SUPPORT_INFO"); |
| 1235 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1236 | |
| 1237 | const int uniqueId = data.readInt32(); |
| 1238 | int length = 0; |
| 1239 | DrmSupportInfo* drmSupportInfoArray = NULL; |
| 1240 | |
| 1241 | status_t status = getAllSupportInfo(uniqueId, &length, &drmSupportInfoArray); |
| 1242 | |
| 1243 | reply->writeInt32(length); |
| 1244 | for (int i = 0; i < length; ++i) { |
| 1245 | DrmSupportInfo drmSupportInfo = drmSupportInfoArray[i]; |
| 1246 | |
| 1247 | reply->writeInt32(drmSupportInfo.getFileSuffixCount()); |
| 1248 | DrmSupportInfo::FileSuffixIterator fileSuffixIt |
| 1249 | = drmSupportInfo.getFileSuffixIterator(); |
| 1250 | while (fileSuffixIt.hasNext()) { |
| 1251 | reply->writeString8(fileSuffixIt.next()); |
| 1252 | } |
| 1253 | |
| 1254 | reply->writeInt32(drmSupportInfo.getMimeTypeCount()); |
| 1255 | DrmSupportInfo::MimeTypeIterator mimeTypeIt = drmSupportInfo.getMimeTypeIterator(); |
| 1256 | while (mimeTypeIt.hasNext()) { |
| 1257 | reply->writeString8(mimeTypeIt.next()); |
| 1258 | } |
| 1259 | reply->writeString8(drmSupportInfo.getDescription()); |
| 1260 | } |
| 1261 | delete [] drmSupportInfoArray; drmSupportInfoArray = NULL; |
| 1262 | reply->writeInt32(status); |
| 1263 | return DRM_NO_ERROR; |
| 1264 | } |
| 1265 | |
| 1266 | case OPEN_DECRYPT_SESSION: |
| 1267 | { |
| 1268 | LOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION"); |
| 1269 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1270 | |
| 1271 | const int uniqueId = data.readInt32(); |
| 1272 | const int fd = data.readFileDescriptor(); |
| 1273 | |
| 1274 | DecryptHandle* handle |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 1275 | = openDecryptSession(uniqueId, fd, data.readInt64(), data.readInt64()); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1276 | |
| 1277 | if (NULL != handle) { |
| 1278 | reply->writeInt32(handle->decryptId); |
| 1279 | reply->writeString8(handle->mimeType); |
| 1280 | reply->writeInt32(handle->decryptApiType); |
| 1281 | reply->writeInt32(handle->status); |
| 1282 | if (NULL != handle->decryptInfo) { |
| 1283 | reply->writeInt32(handle->decryptInfo->decryptBufferLength); |
| 1284 | delete handle->decryptInfo; handle->decryptInfo = NULL; |
| 1285 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1286 | } |
| 1287 | delete handle; handle = NULL; |
| 1288 | return DRM_NO_ERROR; |
| 1289 | } |
| 1290 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 1291 | case OPEN_DECRYPT_SESSION_FROM_URI: |
| 1292 | { |
| 1293 | LOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION_FROM_URI"); |
| 1294 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1295 | |
| 1296 | const int uniqueId = data.readInt32(); |
| 1297 | const String8 uri = data.readString8(); |
| 1298 | |
| 1299 | DecryptHandle* handle = openDecryptSession(uniqueId, uri.string()); |
| 1300 | |
| 1301 | if (NULL != handle) { |
| 1302 | reply->writeInt32(handle->decryptId); |
| 1303 | reply->writeString8(handle->mimeType); |
| 1304 | reply->writeInt32(handle->decryptApiType); |
| 1305 | reply->writeInt32(handle->status); |
| 1306 | if (NULL != handle->decryptInfo) { |
| 1307 | reply->writeInt32(handle->decryptInfo->decryptBufferLength); |
| 1308 | delete handle->decryptInfo; handle->decryptInfo = NULL; |
| 1309 | } |
| 1310 | } else { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame^] | 1311 | LOGV("NULL decryptHandle is returned"); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 1312 | } |
| 1313 | delete handle; handle = NULL; |
| 1314 | return DRM_NO_ERROR; |
| 1315 | } |
| 1316 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1317 | case CLOSE_DECRYPT_SESSION: |
| 1318 | { |
| 1319 | LOGV("BnDrmManagerService::onTransact :CLOSE_DECRYPT_SESSION"); |
| 1320 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1321 | |
| 1322 | const int uniqueId = data.readInt32(); |
| 1323 | |
| 1324 | DecryptHandle* handle = new DecryptHandle(); |
| 1325 | handle->decryptId = data.readInt32(); |
| 1326 | handle->mimeType = data.readString8(); |
| 1327 | handle->decryptApiType = data.readInt32(); |
| 1328 | handle->status = data.readInt32(); |
| 1329 | handle->decryptInfo = NULL; |
| 1330 | |
| 1331 | const int bufferLength = data.readInt32(); |
| 1332 | if (INVALID_BUFFER_LENGTH != bufferLength) { |
| 1333 | handle->decryptInfo = new DecryptInfo(); |
| 1334 | handle->decryptInfo->decryptBufferLength = bufferLength; |
| 1335 | } |
| 1336 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1337 | const status_t status = closeDecryptSession(uniqueId, handle); |
| 1338 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1339 | return DRM_NO_ERROR; |
| 1340 | } |
| 1341 | |
| 1342 | case INITIALIZE_DECRYPT_UNIT: |
| 1343 | { |
| 1344 | LOGV("BnDrmManagerService::onTransact :INITIALIZE_DECRYPT_UNIT"); |
| 1345 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1346 | |
| 1347 | const int uniqueId = data.readInt32(); |
| 1348 | |
| 1349 | DecryptHandle handle; |
| 1350 | handle.decryptId = data.readInt32(); |
| 1351 | handle.mimeType = data.readString8(); |
| 1352 | handle.decryptApiType = data.readInt32(); |
| 1353 | handle.status = data.readInt32(); |
| 1354 | handle.decryptInfo = NULL; |
| 1355 | |
| 1356 | const int bufferLength = data.readInt32(); |
| 1357 | if (INVALID_BUFFER_LENGTH != bufferLength) { |
| 1358 | handle.decryptInfo = new DecryptInfo(); |
| 1359 | handle.decryptInfo->decryptBufferLength = bufferLength; |
| 1360 | } |
| 1361 | const int decryptUnitId = data.readInt32(); |
| 1362 | |
| 1363 | //Filling Header info |
| 1364 | const int bufferSize = data.readInt32(); |
| 1365 | DrmBuffer* headerInfo = NULL; |
| 1366 | headerInfo = new DrmBuffer((char *)data.readInplace(bufferSize), bufferSize); |
| 1367 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1368 | const status_t status |
| 1369 | = initializeDecryptUnit(uniqueId, &handle, decryptUnitId, headerInfo); |
| 1370 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1371 | |
| 1372 | delete handle.decryptInfo; handle.decryptInfo = NULL; |
| 1373 | delete headerInfo; headerInfo = NULL; |
| 1374 | return DRM_NO_ERROR; |
| 1375 | } |
| 1376 | |
| 1377 | case DECRYPT: |
| 1378 | { |
| 1379 | LOGV("BnDrmManagerService::onTransact :DECRYPT"); |
| 1380 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1381 | |
| 1382 | const int uniqueId = data.readInt32(); |
| 1383 | |
| 1384 | DecryptHandle handle; |
| 1385 | handle.decryptId = data.readInt32(); |
| 1386 | handle.mimeType = data.readString8(); |
| 1387 | handle.decryptApiType = data.readInt32(); |
| 1388 | handle.status = data.readInt32(); |
| 1389 | handle.decryptInfo = NULL; |
| 1390 | |
| 1391 | const int bufferLength = data.readInt32(); |
| 1392 | if (INVALID_BUFFER_LENGTH != bufferLength) { |
| 1393 | handle.decryptInfo = new DecryptInfo(); |
| 1394 | handle.decryptInfo->decryptBufferLength = bufferLength; |
| 1395 | } |
| 1396 | const int decryptUnitId = data.readInt32(); |
| 1397 | const int decBufferSize = data.readInt32(); |
| 1398 | |
| 1399 | const int encBufferSize = data.readInt32(); |
| 1400 | DrmBuffer* encBuffer |
| 1401 | = new DrmBuffer((char *)data.readInplace(encBufferSize), encBufferSize); |
| 1402 | |
| 1403 | char* buffer = NULL; |
| 1404 | buffer = new char[decBufferSize]; |
| 1405 | DrmBuffer* decBuffer = new DrmBuffer(buffer, decBufferSize); |
| 1406 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1407 | DrmBuffer* IV = NULL; |
| 1408 | if (0 != data.dataAvail()) { |
| 1409 | const int ivBufferlength = data.readInt32(); |
| 1410 | IV = new DrmBuffer((char *)data.readInplace(ivBufferlength), ivBufferlength); |
| 1411 | } |
| 1412 | |
| 1413 | const status_t status |
| 1414 | = decrypt(uniqueId, &handle, decryptUnitId, encBuffer, &decBuffer, IV); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1415 | |
| 1416 | reply->writeInt32(status); |
| 1417 | |
| 1418 | const int size = decBuffer->length; |
| 1419 | reply->writeInt32(size); |
| 1420 | reply->write(decBuffer->data, size); |
| 1421 | |
| 1422 | delete handle.decryptInfo; handle.decryptInfo = NULL; |
| 1423 | delete encBuffer; encBuffer = NULL; |
| 1424 | delete decBuffer; decBuffer = NULL; |
| 1425 | delete [] buffer; buffer = NULL; |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1426 | delete IV; IV = NULL; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1427 | return DRM_NO_ERROR; |
| 1428 | } |
| 1429 | |
| 1430 | case FINALIZE_DECRYPT_UNIT: |
| 1431 | { |
| 1432 | LOGV("BnDrmManagerService::onTransact :FINALIZE_DECRYPT_UNIT"); |
| 1433 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1434 | |
| 1435 | const int uniqueId = data.readInt32(); |
| 1436 | |
| 1437 | DecryptHandle handle; |
| 1438 | handle.decryptId = data.readInt32(); |
| 1439 | handle.mimeType = data.readString8(); |
| 1440 | handle.decryptApiType = data.readInt32(); |
| 1441 | handle.status = data.readInt32(); |
| 1442 | handle.decryptInfo = NULL; |
| 1443 | |
| 1444 | const int bufferLength = data.readInt32(); |
| 1445 | if (INVALID_BUFFER_LENGTH != bufferLength) { |
| 1446 | handle.decryptInfo = new DecryptInfo(); |
| 1447 | handle.decryptInfo->decryptBufferLength = bufferLength; |
| 1448 | } |
| 1449 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 1450 | const status_t status = finalizeDecryptUnit(uniqueId, &handle, data.readInt32()); |
| 1451 | reply->writeInt32(status); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1452 | |
| 1453 | delete handle.decryptInfo; handle.decryptInfo = NULL; |
| 1454 | return DRM_NO_ERROR; |
| 1455 | } |
| 1456 | |
| 1457 | case PREAD: |
| 1458 | { |
| 1459 | LOGV("BnDrmManagerService::onTransact :READ"); |
| 1460 | CHECK_INTERFACE(IDrmManagerService, data, reply); |
| 1461 | |
| 1462 | const int uniqueId = data.readInt32(); |
| 1463 | |
| 1464 | DecryptHandle handle; |
| 1465 | handle.decryptId = data.readInt32(); |
| 1466 | handle.mimeType = data.readString8(); |
| 1467 | handle.decryptApiType = data.readInt32(); |
| 1468 | handle.status = data.readInt32(); |
| 1469 | handle.decryptInfo = NULL; |
| 1470 | |
| 1471 | const int bufferLength = data.readInt32(); |
| 1472 | if (INVALID_BUFFER_LENGTH != bufferLength) { |
| 1473 | handle.decryptInfo = new DecryptInfo(); |
| 1474 | handle.decryptInfo->decryptBufferLength = bufferLength; |
| 1475 | } |
| 1476 | |
| 1477 | const int numBytes = data.readInt32(); |
| 1478 | char* buffer = new char[numBytes]; |
| 1479 | |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 1480 | const off64_t offset = data.readInt64(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 1481 | |
| 1482 | ssize_t result = pread(uniqueId, &handle, buffer, numBytes, offset); |
| 1483 | reply->writeInt32(result); |
| 1484 | if (0 < result) { |
| 1485 | reply->write(buffer, result); |
| 1486 | } |
| 1487 | |
| 1488 | delete handle.decryptInfo; handle.decryptInfo = NULL; |
| 1489 | delete [] buffer, buffer = NULL; |
| 1490 | return DRM_NO_ERROR; |
| 1491 | } |
| 1492 | |
| 1493 | default: |
| 1494 | return BBinder::onTransact(code, data, reply, flags); |
| 1495 | } |
| 1496 | } |
| 1497 | |