Kenny Root | be857d4 | 2010-08-18 15:59:25 -0700 | [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 | |
| 17 | #define LOG_TAG "IMountService" |
| 18 | |
| 19 | #include <storage/IMountService.h> |
| 20 | #include <binder/Parcel.h> |
| 21 | |
| 22 | namespace android { |
| 23 | |
| 24 | enum { |
| 25 | TRANSACTION_registerListener = IBinder::FIRST_CALL_TRANSACTION, |
| 26 | TRANSACTION_unregisterListener, |
| 27 | TRANSACTION_isUsbMassStorageConnected, |
| 28 | TRANSACTION_setUsbMassStorageEnabled, |
| 29 | TRANSACTION_isUsbMassStorageEnabled, |
| 30 | TRANSACTION_mountVolume, |
| 31 | TRANSACTION_unmountVolume, |
| 32 | TRANSACTION_formatVolume, |
| 33 | TRANSACTION_getStorageUsers, |
| 34 | TRANSACTION_getVolumeState, |
| 35 | TRANSACTION_createSecureContainer, |
| 36 | TRANSACTION_finalizeSecureContainer, |
| 37 | TRANSACTION_destroySecureContainer, |
| 38 | TRANSACTION_mountSecureContainer, |
| 39 | TRANSACTION_unmountSecureContainer, |
| 40 | TRANSACTION_isSecureContainerMounted, |
| 41 | TRANSACTION_renameSecureContainer, |
| 42 | TRANSACTION_getSecureContainerPath, |
| 43 | TRANSACTION_getSecureContainerList, |
| 44 | TRANSACTION_shutdown, |
| 45 | TRANSACTION_finishMediaUpdate, |
| 46 | TRANSACTION_mountObb, |
| 47 | TRANSACTION_unmountObb, |
| 48 | TRANSACTION_isObbMounted, |
| 49 | TRANSACTION_getMountedObbPath, |
Kenny Root | e1ff214 | 2010-10-12 11:20:01 -0700 | [diff] [blame] | 50 | TRANSACTION_isExternalStorageEmulated, |
Jason parks | 5af0b91 | 2010-11-29 09:05:25 -0600 | [diff] [blame] | 51 | TRANSACTION_decryptStorage, |
Jason parks | d633255 | 2011-01-07 09:01:15 -0600 | [diff] [blame^] | 52 | TRANSACTION_encryptStorage, |
Kenny Root | be857d4 | 2010-08-18 15:59:25 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | class BpMountService: public BpInterface<IMountService> |
| 56 | { |
| 57 | public: |
| 58 | BpMountService(const sp<IBinder>& impl) |
| 59 | : BpInterface<IMountService>(impl) |
| 60 | { |
| 61 | } |
| 62 | |
| 63 | virtual void registerListener(const sp<IMountServiceListener>& listener) |
| 64 | { |
| 65 | Parcel data, reply; |
| 66 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 67 | data.writeStrongBinder(listener->asBinder()); |
| 68 | if (remote()->transact(TRANSACTION_registerListener, data, &reply) != NO_ERROR) { |
| 69 | LOGD("registerListener could not contact remote\n"); |
| 70 | return; |
| 71 | } |
| 72 | int32_t err = reply.readExceptionCode(); |
| 73 | if (err < 0) { |
| 74 | LOGD("registerListener caught exception %d\n", err); |
| 75 | return; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | virtual void unregisterListener(const sp<IMountServiceListener>& listener) |
| 80 | { |
| 81 | Parcel data, reply; |
| 82 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 83 | data.writeStrongBinder(listener->asBinder()); |
| 84 | if (remote()->transact(TRANSACTION_unregisterListener, data, &reply) != NO_ERROR) { |
| 85 | LOGD("unregisterListener could not contact remote\n"); |
| 86 | return; |
| 87 | } |
| 88 | int32_t err = reply.readExceptionCode(); |
| 89 | if (err < 0) { |
| 90 | LOGD("unregisterListener caught exception %d\n", err); |
| 91 | return; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | virtual bool isUsbMassStorageConnected() |
| 96 | { |
| 97 | Parcel data, reply; |
| 98 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 99 | if (remote()->transact(TRANSACTION_isUsbMassStorageConnected, data, &reply) != NO_ERROR) { |
| 100 | LOGD("isUsbMassStorageConnected could not contact remote\n"); |
| 101 | return false; |
| 102 | } |
| 103 | int32_t err = reply.readExceptionCode(); |
| 104 | if (err < 0) { |
| 105 | LOGD("isUsbMassStorageConnected caught exception %d\n", err); |
| 106 | return false; |
| 107 | } |
| 108 | return reply.readInt32() != 0; |
| 109 | } |
| 110 | |
| 111 | virtual void setUsbMassStorageEnabled(const bool enable) |
| 112 | { |
| 113 | Parcel data, reply; |
| 114 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 115 | data.writeInt32(enable != 0); |
| 116 | if (remote()->transact(TRANSACTION_setUsbMassStorageEnabled, data, &reply) != NO_ERROR) { |
| 117 | LOGD("setUsbMassStorageEnabled could not contact remote\n"); |
| 118 | return; |
| 119 | } |
| 120 | int32_t err = reply.readExceptionCode(); |
| 121 | if (err < 0) { |
| 122 | LOGD("setUsbMassStorageEnabled caught exception %d\n", err); |
| 123 | return; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | virtual bool isUsbMassStorageEnabled() |
| 128 | { |
| 129 | Parcel data, reply; |
| 130 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 131 | if (remote()->transact(TRANSACTION_isUsbMassStorageEnabled, data, &reply) != NO_ERROR) { |
| 132 | LOGD("isUsbMassStorageEnabled could not contact remote\n"); |
| 133 | return false; |
| 134 | } |
| 135 | int32_t err = reply.readExceptionCode(); |
| 136 | if (err < 0) { |
| 137 | LOGD("isUsbMassStorageEnabled caught exception %d\n", err); |
| 138 | return false; |
| 139 | } |
| 140 | return reply.readInt32() != 0; |
| 141 | } |
| 142 | |
| 143 | int32_t mountVolume(const String16& mountPoint) |
| 144 | { |
| 145 | Parcel data, reply; |
| 146 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 147 | data.writeString16(mountPoint); |
| 148 | if (remote()->transact(TRANSACTION_mountVolume, data, &reply) != NO_ERROR) { |
| 149 | LOGD("mountVolume could not contact remote\n"); |
| 150 | return -1; |
| 151 | } |
| 152 | int32_t err = reply.readExceptionCode(); |
| 153 | if (err < 0) { |
| 154 | LOGD("mountVolume caught exception %d\n", err); |
| 155 | return err; |
| 156 | } |
| 157 | return reply.readInt32(); |
| 158 | } |
| 159 | |
| 160 | int32_t unmountVolume(const String16& mountPoint, const bool force) |
| 161 | { |
| 162 | Parcel data, reply; |
| 163 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 164 | data.writeString16(mountPoint); |
| 165 | data.writeInt32(force ? 1 : 0); |
| 166 | if (remote()->transact(TRANSACTION_unmountVolume, data, &reply) != NO_ERROR) { |
| 167 | LOGD("unmountVolume could not contact remote\n"); |
| 168 | return -1; |
| 169 | } |
| 170 | int32_t err = reply.readExceptionCode(); |
| 171 | if (err < 0) { |
| 172 | LOGD("unmountVolume caught exception %d\n", err); |
| 173 | return err; |
| 174 | } |
| 175 | return reply.readInt32(); |
| 176 | } |
| 177 | |
| 178 | int32_t formatVolume(const String16& mountPoint) |
| 179 | { |
| 180 | Parcel data, reply; |
| 181 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 182 | data.writeString16(mountPoint); |
| 183 | if (remote()->transact(TRANSACTION_formatVolume, data, &reply) != NO_ERROR) { |
| 184 | LOGD("formatVolume could not contact remote\n"); |
| 185 | return -1; |
| 186 | } |
| 187 | int32_t err = reply.readExceptionCode(); |
| 188 | if (err < 0) { |
| 189 | LOGD("formatVolume caught exception %d\n", err); |
| 190 | return err; |
| 191 | } |
| 192 | return reply.readInt32(); |
| 193 | } |
| 194 | |
| 195 | int32_t getStorageUsers(const String16& mountPoint, int32_t** users) |
| 196 | { |
| 197 | Parcel data, reply; |
| 198 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 199 | data.writeString16(mountPoint); |
| 200 | if (remote()->transact(TRANSACTION_getStorageUsers, data, &reply) != NO_ERROR) { |
| 201 | LOGD("getStorageUsers could not contact remote\n"); |
| 202 | return -1; |
| 203 | } |
| 204 | int32_t err = reply.readExceptionCode(); |
| 205 | if (err < 0) { |
| 206 | LOGD("getStorageUsers caught exception %d\n", err); |
| 207 | return err; |
| 208 | } |
| 209 | const int32_t numUsers = reply.readInt32(); |
| 210 | *users = (int32_t*)malloc(sizeof(int32_t)*numUsers); |
| 211 | for (int i = 0; i < numUsers; i++) { |
| 212 | **users++ = reply.readInt32(); |
| 213 | } |
| 214 | return numUsers; |
| 215 | } |
| 216 | |
| 217 | int32_t getVolumeState(const String16& mountPoint) |
| 218 | { |
| 219 | Parcel data, reply; |
| 220 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 221 | data.writeString16(mountPoint); |
| 222 | if (remote()->transact(TRANSACTION_getVolumeState, data, &reply) != NO_ERROR) { |
| 223 | LOGD("getVolumeState could not contact remote\n"); |
| 224 | return -1; |
| 225 | } |
| 226 | int32_t err = reply.readExceptionCode(); |
| 227 | if (err < 0) { |
| 228 | LOGD("getVolumeState caught exception %d\n", err); |
| 229 | return err; |
| 230 | } |
| 231 | return reply.readInt32(); |
| 232 | } |
| 233 | |
| 234 | int32_t createSecureContainer(const String16& id, const int32_t sizeMb, const String16& fstype, |
| 235 | const String16& key, const int32_t ownerUid) |
| 236 | { |
| 237 | Parcel data, reply; |
| 238 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 239 | data.writeString16(id); |
| 240 | data.writeInt32(sizeMb); |
| 241 | data.writeString16(fstype); |
| 242 | data.writeString16(key); |
| 243 | data.writeInt32(ownerUid); |
| 244 | if (remote()->transact(TRANSACTION_createSecureContainer, data, &reply) != NO_ERROR) { |
| 245 | LOGD("createSecureContainer could not contact remote\n"); |
| 246 | return -1; |
| 247 | } |
| 248 | int32_t err = reply.readExceptionCode(); |
| 249 | if (err < 0) { |
| 250 | LOGD("createSecureContainer caught exception %d\n", err); |
| 251 | return err; |
| 252 | } |
| 253 | return reply.readInt32(); |
| 254 | } |
| 255 | |
| 256 | int32_t finalizeSecureContainer(const String16& id) |
| 257 | { |
| 258 | Parcel data, reply; |
| 259 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 260 | data.writeString16(id); |
| 261 | if (remote()->transact(TRANSACTION_finalizeSecureContainer, data, &reply) != NO_ERROR) { |
| 262 | LOGD("finalizeSecureContainer couldn't call remote\n"); |
| 263 | return -1; |
| 264 | } |
| 265 | int32_t err = reply.readExceptionCode(); |
| 266 | if (err < 0) { |
| 267 | LOGD("finalizeSecureContainer caught exception %d\n", err); |
| 268 | return err; |
| 269 | } |
| 270 | return reply.readInt32(); |
| 271 | } |
| 272 | |
| 273 | int32_t destroySecureContainer(const String16& id) |
| 274 | { |
| 275 | Parcel data, reply; |
| 276 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 277 | data.writeString16(id); |
| 278 | if (remote()->transact(TRANSACTION_destroySecureContainer, data, &reply) != NO_ERROR) { |
| 279 | LOGD("destroySecureContainer couldn't call remote"); |
| 280 | return -1; |
| 281 | } |
| 282 | int32_t err = reply.readExceptionCode(); |
| 283 | if (err < 0) { |
| 284 | LOGD("destroySecureContainer caught exception %d\n", err); |
| 285 | return err; |
| 286 | } |
| 287 | return reply.readInt32(); |
| 288 | } |
| 289 | |
| 290 | int32_t mountSecureContainer(const String16& id, const String16& key, const int32_t ownerUid) |
| 291 | { |
| 292 | Parcel data, reply; |
| 293 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 294 | data.writeString16(id); |
| 295 | data.writeString16(key); |
| 296 | data.writeInt32(ownerUid); |
| 297 | if (remote()->transact(TRANSACTION_mountSecureContainer, data, &reply) != NO_ERROR) { |
| 298 | LOGD("mountSecureContainer couldn't call remote"); |
| 299 | return -1; |
| 300 | } |
| 301 | int32_t err = reply.readExceptionCode(); // What to do... |
| 302 | if (err < 0) { |
| 303 | LOGD("mountSecureContainer caught exception %d\n", err); |
| 304 | return err; |
| 305 | } |
| 306 | return reply.readInt32(); |
| 307 | } |
| 308 | |
| 309 | int32_t unmountSecureContainer(const String16& id, const bool force) |
| 310 | { |
| 311 | Parcel data, reply; |
| 312 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 313 | data.writeString16(id); |
| 314 | data.writeInt32(force ? 1 : 0); |
| 315 | if (remote()->transact(TRANSACTION_getSecureContainerPath, data, &reply) != NO_ERROR) { |
| 316 | LOGD("unmountSecureContainer couldn't call remote"); |
| 317 | return -1; |
| 318 | } |
| 319 | int32_t err = reply.readExceptionCode(); // What to do... |
| 320 | if (err < 0) { |
| 321 | LOGD("unmountSecureContainer caught exception %d\n", err); |
| 322 | return err; |
| 323 | } |
| 324 | return reply.readInt32(); |
| 325 | } |
| 326 | |
| 327 | bool isSecureContainerMounted(const String16& id) |
| 328 | { |
| 329 | Parcel data, reply; |
| 330 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 331 | data.writeString16(id); |
| 332 | if (remote()->transact(TRANSACTION_isSecureContainerMounted, data, &reply) != NO_ERROR) { |
| 333 | LOGD("isSecureContainerMounted couldn't call remote"); |
| 334 | return false; |
| 335 | } |
| 336 | int32_t err = reply.readExceptionCode(); // What to do... |
| 337 | if (err < 0) { |
| 338 | LOGD("isSecureContainerMounted caught exception %d\n", err); |
| 339 | return false; |
| 340 | } |
| 341 | return reply.readInt32() != 0; |
| 342 | } |
| 343 | |
| 344 | int32_t renameSecureContainer(const String16& oldId, const String16& newId) |
| 345 | { |
| 346 | Parcel data, reply; |
| 347 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 348 | data.writeString16(oldId); |
| 349 | data.writeString16(newId); |
| 350 | if (remote()->transact(TRANSACTION_renameSecureContainer, data, &reply) != NO_ERROR) { |
| 351 | LOGD("renameSecureContainer couldn't call remote"); |
| 352 | return -1; |
| 353 | } |
| 354 | int32_t err = reply.readExceptionCode(); // What to do... |
| 355 | if (err < 0) { |
| 356 | LOGD("renameSecureContainer caught exception %d\n", err); |
| 357 | return err; |
| 358 | } |
| 359 | return reply.readInt32(); |
| 360 | } |
| 361 | |
| 362 | bool getSecureContainerPath(const String16& id, String16& path) |
| 363 | { |
| 364 | Parcel data, reply; |
| 365 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 366 | data.writeString16(id); |
| 367 | if (remote()->transact(TRANSACTION_getSecureContainerPath, data, &reply) != NO_ERROR) { |
| 368 | LOGD("getSecureContainerPath couldn't call remote"); |
| 369 | return false; |
| 370 | } |
| 371 | int32_t err = reply.readExceptionCode(); // What to do... |
| 372 | if (err < 0) { |
| 373 | LOGD("getSecureContainerPath caught exception %d\n", err); |
| 374 | return false; |
| 375 | } |
| 376 | path = reply.readString16(); |
| 377 | return true; |
| 378 | } |
| 379 | |
| 380 | int32_t getSecureContainerList(const String16& id, String16*& containers) |
| 381 | { |
| 382 | Parcel data, reply; |
| 383 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 384 | data.writeString16(id); |
| 385 | if (remote()->transact(TRANSACTION_getSecureContainerList, data, &reply) != NO_ERROR) { |
| 386 | LOGD("getSecureContainerList couldn't call remote"); |
| 387 | return -1; |
| 388 | } |
| 389 | int32_t err = reply.readExceptionCode(); |
| 390 | if (err < 0) { |
| 391 | LOGD("getSecureContainerList caught exception %d\n", err); |
| 392 | return err; |
| 393 | } |
| 394 | const int32_t numStrings = reply.readInt32(); |
| 395 | containers = new String16[numStrings]; |
| 396 | for (int i = 0; i < numStrings; i++) { |
| 397 | containers[i] = reply.readString16(); |
| 398 | } |
| 399 | return numStrings; |
| 400 | } |
| 401 | |
| 402 | void shutdown(const sp<IMountShutdownObserver>& observer) |
| 403 | { |
| 404 | Parcel data, reply; |
| 405 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 406 | data.writeStrongBinder(observer->asBinder()); |
| 407 | if (remote()->transact(TRANSACTION_shutdown, data, &reply) != NO_ERROR) { |
| 408 | LOGD("shutdown could not contact remote\n"); |
| 409 | return; |
| 410 | } |
| 411 | int32_t err = reply.readExceptionCode(); |
| 412 | if (err < 0) { |
| 413 | LOGD("shutdown caught exception %d\n", err); |
| 414 | return; |
| 415 | } |
| 416 | reply.readExceptionCode(); |
| 417 | } |
| 418 | |
| 419 | void finishMediaUpdate() |
| 420 | { |
| 421 | Parcel data, reply; |
| 422 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 423 | if (remote()->transact(TRANSACTION_finishMediaUpdate, data, &reply) != NO_ERROR) { |
| 424 | LOGD("finishMediaUpdate could not contact remote\n"); |
| 425 | return; |
| 426 | } |
| 427 | int32_t err = reply.readExceptionCode(); |
| 428 | if (err < 0) { |
| 429 | LOGD("finishMediaUpdate caught exception %d\n", err); |
| 430 | return; |
| 431 | } |
| 432 | reply.readExceptionCode(); |
| 433 | } |
| 434 | |
Kenny Root | 05105f7 | 2010-09-22 17:29:43 -0700 | [diff] [blame] | 435 | void mountObb(const String16& filename, const String16& key, |
Kenny Root | af9d667 | 2010-10-08 09:21:39 -0700 | [diff] [blame] | 436 | const sp<IObbActionListener>& token, int32_t nonce) |
Kenny Root | be857d4 | 2010-08-18 15:59:25 -0700 | [diff] [blame] | 437 | { |
| 438 | Parcel data, reply; |
| 439 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 440 | data.writeString16(filename); |
| 441 | data.writeString16(key); |
| 442 | data.writeStrongBinder(token->asBinder()); |
Kenny Root | af9d667 | 2010-10-08 09:21:39 -0700 | [diff] [blame] | 443 | data.writeInt32(nonce); |
Kenny Root | be857d4 | 2010-08-18 15:59:25 -0700 | [diff] [blame] | 444 | if (remote()->transact(TRANSACTION_mountObb, data, &reply) != NO_ERROR) { |
| 445 | LOGD("mountObb could not contact remote\n"); |
| 446 | return; |
| 447 | } |
| 448 | int32_t err = reply.readExceptionCode(); |
| 449 | if (err < 0) { |
| 450 | LOGD("mountObb caught exception %d\n", err); |
| 451 | return; |
| 452 | } |
| 453 | } |
| 454 | |
Kenny Root | 4a99ed8 | 2010-10-11 17:38:51 -0700 | [diff] [blame] | 455 | void unmountObb(const String16& filename, const bool force, |
| 456 | const sp<IObbActionListener>& token, const int32_t nonce) |
Kenny Root | be857d4 | 2010-08-18 15:59:25 -0700 | [diff] [blame] | 457 | { |
| 458 | Parcel data, reply; |
| 459 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 460 | data.writeString16(filename); |
| 461 | data.writeInt32(force ? 1 : 0); |
Kenny Root | 4a99ed8 | 2010-10-11 17:38:51 -0700 | [diff] [blame] | 462 | data.writeStrongBinder(token->asBinder()); |
| 463 | data.writeInt32(nonce); |
Kenny Root | be857d4 | 2010-08-18 15:59:25 -0700 | [diff] [blame] | 464 | if (remote()->transact(TRANSACTION_unmountObb, data, &reply) != NO_ERROR) { |
| 465 | LOGD("unmountObb could not contact remote\n"); |
| 466 | return; |
| 467 | } |
| 468 | int32_t err = reply.readExceptionCode(); |
| 469 | if (err < 0) { |
| 470 | LOGD("unmountObb caught exception %d\n", err); |
| 471 | return; |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | bool isObbMounted(const String16& filename) |
| 476 | { |
| 477 | Parcel data, reply; |
| 478 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 479 | data.writeString16(filename); |
| 480 | if (remote()->transact(TRANSACTION_isObbMounted, data, &reply) != NO_ERROR) { |
| 481 | LOGD("isObbMounted could not contact remote\n"); |
| 482 | return false; |
| 483 | } |
| 484 | int32_t err = reply.readExceptionCode(); |
| 485 | if (err < 0) { |
| 486 | LOGD("isObbMounted caught exception %d\n", err); |
| 487 | return false; |
| 488 | } |
| 489 | return reply.readInt32() != 0; |
| 490 | } |
| 491 | |
| 492 | bool getMountedObbPath(const String16& filename, String16& path) |
| 493 | { |
| 494 | Parcel data, reply; |
| 495 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 496 | data.writeString16(filename); |
| 497 | if (remote()->transact(TRANSACTION_getMountedObbPath, data, &reply) != NO_ERROR) { |
| 498 | LOGD("getMountedObbPath could not contact remote\n"); |
| 499 | return false; |
| 500 | } |
| 501 | int32_t err = reply.readExceptionCode(); |
| 502 | if (err < 0) { |
| 503 | LOGD("getMountedObbPath caught exception %d\n", err); |
| 504 | return false; |
| 505 | } |
| 506 | path = reply.readString16(); |
| 507 | return true; |
| 508 | } |
Jason parks | d633255 | 2011-01-07 09:01:15 -0600 | [diff] [blame^] | 509 | |
Jason parks | 5af0b91 | 2010-11-29 09:05:25 -0600 | [diff] [blame] | 510 | int32_t decryptStorage(const String16& password) |
| 511 | { |
| 512 | Parcel data, reply; |
| 513 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 514 | data.writeString16(password); |
| 515 | if (remote()->transact(TRANSACTION_decryptStorage, data, &reply) != NO_ERROR) { |
| 516 | LOGD("decryptStorage could not contact remote\n"); |
| 517 | return -1; |
| 518 | } |
| 519 | int32_t err = reply.readExceptionCode(); |
| 520 | if (err < 0) { |
| 521 | LOGD("decryptStorage caught exception %d\n", err); |
| 522 | return err; |
| 523 | } |
| 524 | return reply.readInt32(); |
| 525 | } |
Jason parks | d633255 | 2011-01-07 09:01:15 -0600 | [diff] [blame^] | 526 | |
| 527 | int32_t encryptStorage(const String16& password) |
| 528 | { |
| 529 | Parcel data, reply; |
| 530 | data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); |
| 531 | data.writeString16(password); |
| 532 | if (remote()->transact(TRANSACTION_encryptStorage, data, &reply) != NO_ERROR) { |
| 533 | LOGD("encryptStorage could not contact remote\n"); |
| 534 | return -1; |
| 535 | } |
| 536 | int32_t err = reply.readExceptionCode(); |
| 537 | if (err < 0) { |
| 538 | LOGD("encryptStorage caught exception %d\n", err); |
| 539 | return err; |
| 540 | } |
| 541 | return reply.readInt32(); |
| 542 | } |
Kenny Root | be857d4 | 2010-08-18 15:59:25 -0700 | [diff] [blame] | 543 | }; |
| 544 | |
| 545 | IMPLEMENT_META_INTERFACE(MountService, "IMountService"); |
| 546 | |
| 547 | // ---------------------------------------------------------------------- |
| 548 | |
| 549 | }; |