blob: 74638e7eccc35c771792417d0d455470cd6f8f76 [file] [log] [blame]
Kenny Rootbe857d42010-08-18 15:59:25 -07001/*
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
22namespace android {
23
24enum {
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 Roote1ff2142010-10-12 11:20:01 -070050 TRANSACTION_isExternalStorageEmulated,
Jason parks5af0b912010-11-29 09:05:25 -060051 TRANSACTION_decryptStorage,
Jason parksd6332552011-01-07 09:01:15 -060052 TRANSACTION_encryptStorage,
Kenny Rootbe857d42010-08-18 15:59:25 -070053};
54
55class BpMountService: public BpInterface<IMountService>
56{
57public:
Chih-Hung Hsiehc6baf562016-04-27 11:29:23 -070058 explicit BpMountService(const sp<IBinder>& impl)
Kenny Rootbe857d42010-08-18 15:59:25 -070059 : BpInterface<IMountService>(impl)
60 {
61 }
62
63 virtual void registerListener(const sp<IMountServiceListener>& listener)
64 {
65 Parcel data, reply;
66 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
Marco Nelissendce97402014-11-14 08:00:42 -080067 data.writeStrongBinder(IInterface::asBinder(listener));
Kenny Rootbe857d42010-08-18 15:59:25 -070068 if (remote()->transact(TRANSACTION_registerListener, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +000069 ALOGD("registerListener could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -070070 return;
71 }
72 int32_t err = reply.readExceptionCode();
73 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +000074 ALOGD("registerListener caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -070075 return;
76 }
77 }
78
79 virtual void unregisterListener(const sp<IMountServiceListener>& listener)
80 {
81 Parcel data, reply;
82 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
Marco Nelissendce97402014-11-14 08:00:42 -080083 data.writeStrongBinder(IInterface::asBinder(listener));
Kenny Rootbe857d42010-08-18 15:59:25 -070084 if (remote()->transact(TRANSACTION_unregisterListener, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +000085 ALOGD("unregisterListener could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -070086 return;
87 }
88 int32_t err = reply.readExceptionCode();
89 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +000090 ALOGD("unregisterListener caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -070091 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) {
Steve Block5baa3a62011-12-20 16:23:08 +0000100 ALOGD("isUsbMassStorageConnected could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700101 return false;
102 }
103 int32_t err = reply.readExceptionCode();
104 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000105 ALOGD("isUsbMassStorageConnected caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700106 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) {
Steve Block5baa3a62011-12-20 16:23:08 +0000117 ALOGD("setUsbMassStorageEnabled could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700118 return;
119 }
120 int32_t err = reply.readExceptionCode();
121 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000122 ALOGD("setUsbMassStorageEnabled caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700123 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) {
Steve Block5baa3a62011-12-20 16:23:08 +0000132 ALOGD("isUsbMassStorageEnabled could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700133 return false;
134 }
135 int32_t err = reply.readExceptionCode();
136 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000137 ALOGD("isUsbMassStorageEnabled caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700138 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) {
Steve Block5baa3a62011-12-20 16:23:08 +0000149 ALOGD("mountVolume could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700150 return -1;
151 }
152 int32_t err = reply.readExceptionCode();
153 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000154 ALOGD("mountVolume caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700155 return err;
156 }
157 return reply.readInt32();
158 }
159
Ben Komalo13c71972011-09-07 16:35:56 -0700160 int32_t unmountVolume(const String16& mountPoint, const bool force, const bool removeEncryption)
Kenny Rootbe857d42010-08-18 15:59:25 -0700161 {
162 Parcel data, reply;
163 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
164 data.writeString16(mountPoint);
165 data.writeInt32(force ? 1 : 0);
Ben Komalo13c71972011-09-07 16:35:56 -0700166 data.writeInt32(removeEncryption ? 1 : 0);
Kenny Rootbe857d42010-08-18 15:59:25 -0700167 if (remote()->transact(TRANSACTION_unmountVolume, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000168 ALOGD("unmountVolume could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700169 return -1;
170 }
171 int32_t err = reply.readExceptionCode();
172 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000173 ALOGD("unmountVolume caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700174 return err;
175 }
176 return reply.readInt32();
177 }
178
179 int32_t formatVolume(const String16& mountPoint)
180 {
181 Parcel data, reply;
182 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
183 data.writeString16(mountPoint);
184 if (remote()->transact(TRANSACTION_formatVolume, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000185 ALOGD("formatVolume could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700186 return -1;
187 }
188 int32_t err = reply.readExceptionCode();
189 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000190 ALOGD("formatVolume caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700191 return err;
192 }
193 return reply.readInt32();
194 }
195
196 int32_t getStorageUsers(const String16& mountPoint, int32_t** users)
197 {
198 Parcel data, reply;
199 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
200 data.writeString16(mountPoint);
201 if (remote()->transact(TRANSACTION_getStorageUsers, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000202 ALOGD("getStorageUsers could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700203 return -1;
204 }
205 int32_t err = reply.readExceptionCode();
206 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000207 ALOGD("getStorageUsers caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700208 return err;
209 }
Andreas Gampe2b3a8cd2014-10-21 23:38:52 -0700210 int32_t numUsersI = reply.readInt32();
211 uint32_t numUsers;
212 if (numUsersI < 0) {
213 ALOGW("Number of users is negative: %d\n", numUsersI);
214 numUsers = 0;
215 } else {
216 numUsers = static_cast<uint32_t>(numUsersI);
217 }
Kenny Rootbe857d42010-08-18 15:59:25 -0700218 *users = (int32_t*)malloc(sizeof(int32_t)*numUsers);
Andreas Gampe2b3a8cd2014-10-21 23:38:52 -0700219 for (size_t i = 0; i < numUsers; i++) {
Kenny Rootbe857d42010-08-18 15:59:25 -0700220 **users++ = reply.readInt32();
221 }
Andreas Gampe2b3a8cd2014-10-21 23:38:52 -0700222 return static_cast<int32_t>(numUsers);
Kenny Rootbe857d42010-08-18 15:59:25 -0700223 }
224
225 int32_t getVolumeState(const String16& mountPoint)
226 {
227 Parcel data, reply;
228 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
229 data.writeString16(mountPoint);
230 if (remote()->transact(TRANSACTION_getVolumeState, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000231 ALOGD("getVolumeState could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700232 return -1;
233 }
234 int32_t err = reply.readExceptionCode();
235 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000236 ALOGD("getVolumeState caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700237 return err;
238 }
239 return reply.readInt32();
240 }
241
242 int32_t createSecureContainer(const String16& id, const int32_t sizeMb, const String16& fstype,
243 const String16& key, const int32_t ownerUid)
244 {
245 Parcel data, reply;
246 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
247 data.writeString16(id);
248 data.writeInt32(sizeMb);
249 data.writeString16(fstype);
250 data.writeString16(key);
251 data.writeInt32(ownerUid);
252 if (remote()->transact(TRANSACTION_createSecureContainer, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000253 ALOGD("createSecureContainer could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700254 return -1;
255 }
256 int32_t err = reply.readExceptionCode();
257 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000258 ALOGD("createSecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700259 return err;
260 }
261 return reply.readInt32();
262 }
263
264 int32_t finalizeSecureContainer(const String16& id)
265 {
266 Parcel data, reply;
267 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
268 data.writeString16(id);
269 if (remote()->transact(TRANSACTION_finalizeSecureContainer, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000270 ALOGD("finalizeSecureContainer couldn't call remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700271 return -1;
272 }
273 int32_t err = reply.readExceptionCode();
274 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000275 ALOGD("finalizeSecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700276 return err;
277 }
278 return reply.readInt32();
279 }
280
281 int32_t destroySecureContainer(const String16& id)
282 {
283 Parcel data, reply;
284 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
285 data.writeString16(id);
286 if (remote()->transact(TRANSACTION_destroySecureContainer, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000287 ALOGD("destroySecureContainer couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700288 return -1;
289 }
290 int32_t err = reply.readExceptionCode();
291 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000292 ALOGD("destroySecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700293 return err;
294 }
295 return reply.readInt32();
296 }
297
298 int32_t mountSecureContainer(const String16& id, const String16& key, const int32_t ownerUid)
299 {
300 Parcel data, reply;
301 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
302 data.writeString16(id);
303 data.writeString16(key);
304 data.writeInt32(ownerUid);
Jeff Sharkey941a8ba2014-08-20 16:26:32 -0700305 // Assume read-only
306 data.writeInt32(1);
Kenny Rootbe857d42010-08-18 15:59:25 -0700307 if (remote()->transact(TRANSACTION_mountSecureContainer, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000308 ALOGD("mountSecureContainer couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700309 return -1;
310 }
311 int32_t err = reply.readExceptionCode(); // What to do...
312 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000313 ALOGD("mountSecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700314 return err;
315 }
316 return reply.readInt32();
317 }
318
319 int32_t unmountSecureContainer(const String16& id, const bool force)
320 {
321 Parcel data, reply;
322 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
323 data.writeString16(id);
324 data.writeInt32(force ? 1 : 0);
325 if (remote()->transact(TRANSACTION_getSecureContainerPath, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000326 ALOGD("unmountSecureContainer couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700327 return -1;
328 }
329 int32_t err = reply.readExceptionCode(); // What to do...
330 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000331 ALOGD("unmountSecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700332 return err;
333 }
334 return reply.readInt32();
335 }
336
337 bool isSecureContainerMounted(const String16& id)
338 {
339 Parcel data, reply;
340 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
341 data.writeString16(id);
342 if (remote()->transact(TRANSACTION_isSecureContainerMounted, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000343 ALOGD("isSecureContainerMounted couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700344 return false;
345 }
346 int32_t err = reply.readExceptionCode(); // What to do...
347 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000348 ALOGD("isSecureContainerMounted caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700349 return false;
350 }
351 return reply.readInt32() != 0;
352 }
353
354 int32_t renameSecureContainer(const String16& oldId, const String16& newId)
355 {
356 Parcel data, reply;
357 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
358 data.writeString16(oldId);
359 data.writeString16(newId);
360 if (remote()->transact(TRANSACTION_renameSecureContainer, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000361 ALOGD("renameSecureContainer couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700362 return -1;
363 }
364 int32_t err = reply.readExceptionCode(); // What to do...
365 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000366 ALOGD("renameSecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700367 return err;
368 }
369 return reply.readInt32();
370 }
371
372 bool getSecureContainerPath(const String16& id, String16& path)
373 {
374 Parcel data, reply;
375 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
376 data.writeString16(id);
377 if (remote()->transact(TRANSACTION_getSecureContainerPath, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000378 ALOGD("getSecureContainerPath couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700379 return false;
380 }
381 int32_t err = reply.readExceptionCode(); // What to do...
382 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000383 ALOGD("getSecureContainerPath caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700384 return false;
385 }
386 path = reply.readString16();
387 return true;
388 }
389
390 int32_t getSecureContainerList(const String16& id, String16*& containers)
391 {
392 Parcel data, reply;
393 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
394 data.writeString16(id);
395 if (remote()->transact(TRANSACTION_getSecureContainerList, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000396 ALOGD("getSecureContainerList couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700397 return -1;
398 }
399 int32_t err = reply.readExceptionCode();
400 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000401 ALOGD("getSecureContainerList caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700402 return err;
403 }
404 const int32_t numStrings = reply.readInt32();
405 containers = new String16[numStrings];
406 for (int i = 0; i < numStrings; i++) {
407 containers[i] = reply.readString16();
408 }
409 return numStrings;
410 }
411
412 void shutdown(const sp<IMountShutdownObserver>& observer)
413 {
414 Parcel data, reply;
415 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
Marco Nelissendce97402014-11-14 08:00:42 -0800416 data.writeStrongBinder(IInterface::asBinder(observer));
Kenny Rootbe857d42010-08-18 15:59:25 -0700417 if (remote()->transact(TRANSACTION_shutdown, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000418 ALOGD("shutdown could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700419 return;
420 }
421 int32_t err = reply.readExceptionCode();
422 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000423 ALOGD("shutdown caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700424 return;
425 }
426 reply.readExceptionCode();
427 }
428
429 void finishMediaUpdate()
430 {
431 Parcel data, reply;
432 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
433 if (remote()->transact(TRANSACTION_finishMediaUpdate, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000434 ALOGD("finishMediaUpdate could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700435 return;
436 }
437 int32_t err = reply.readExceptionCode();
438 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000439 ALOGD("finishMediaUpdate caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700440 return;
441 }
442 reply.readExceptionCode();
443 }
444
Jeff Sharkey4fbbda42012-09-24 18:34:07 -0700445 void mountObb(const String16& rawPath, const String16& canonicalPath, const String16& key,
Kenny Rootaf9d6672010-10-08 09:21:39 -0700446 const sp<IObbActionListener>& token, int32_t nonce)
Kenny Rootbe857d42010-08-18 15:59:25 -0700447 {
448 Parcel data, reply;
449 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
Jeff Sharkey4fbbda42012-09-24 18:34:07 -0700450 data.writeString16(rawPath);
451 data.writeString16(canonicalPath);
Kenny Rootbe857d42010-08-18 15:59:25 -0700452 data.writeString16(key);
Marco Nelissendce97402014-11-14 08:00:42 -0800453 data.writeStrongBinder(IInterface::asBinder(token));
Kenny Rootaf9d6672010-10-08 09:21:39 -0700454 data.writeInt32(nonce);
Kenny Rootbe857d42010-08-18 15:59:25 -0700455 if (remote()->transact(TRANSACTION_mountObb, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000456 ALOGD("mountObb could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700457 return;
458 }
459 int32_t err = reply.readExceptionCode();
460 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000461 ALOGD("mountObb caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700462 return;
463 }
464 }
465
Kenny Root4a99ed82010-10-11 17:38:51 -0700466 void unmountObb(const String16& filename, const bool force,
467 const sp<IObbActionListener>& token, const int32_t nonce)
Kenny Rootbe857d42010-08-18 15:59:25 -0700468 {
469 Parcel data, reply;
470 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
471 data.writeString16(filename);
472 data.writeInt32(force ? 1 : 0);
Marco Nelissendce97402014-11-14 08:00:42 -0800473 data.writeStrongBinder(IInterface::asBinder(token));
Kenny Root4a99ed82010-10-11 17:38:51 -0700474 data.writeInt32(nonce);
Kenny Rootbe857d42010-08-18 15:59:25 -0700475 if (remote()->transact(TRANSACTION_unmountObb, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000476 ALOGD("unmountObb could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700477 return;
478 }
479 int32_t err = reply.readExceptionCode();
480 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000481 ALOGD("unmountObb caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700482 return;
483 }
484 }
485
486 bool isObbMounted(const String16& filename)
487 {
488 Parcel data, reply;
489 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
490 data.writeString16(filename);
491 if (remote()->transact(TRANSACTION_isObbMounted, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000492 ALOGD("isObbMounted could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700493 return false;
494 }
495 int32_t err = reply.readExceptionCode();
496 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000497 ALOGD("isObbMounted caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700498 return false;
499 }
500 return reply.readInt32() != 0;
501 }
502
503 bool getMountedObbPath(const String16& filename, String16& path)
504 {
505 Parcel data, reply;
506 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
507 data.writeString16(filename);
508 if (remote()->transact(TRANSACTION_getMountedObbPath, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000509 ALOGD("getMountedObbPath could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700510 return false;
511 }
512 int32_t err = reply.readExceptionCode();
513 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000514 ALOGD("getMountedObbPath caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700515 return false;
516 }
517 path = reply.readString16();
518 return true;
519 }
Jason parksd6332552011-01-07 09:01:15 -0600520
Jason parks5af0b912010-11-29 09:05:25 -0600521 int32_t decryptStorage(const String16& password)
522 {
523 Parcel data, reply;
524 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
525 data.writeString16(password);
526 if (remote()->transact(TRANSACTION_decryptStorage, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000527 ALOGD("decryptStorage could not contact remote\n");
Jason parks5af0b912010-11-29 09:05:25 -0600528 return -1;
529 }
530 int32_t err = reply.readExceptionCode();
531 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000532 ALOGD("decryptStorage caught exception %d\n", err);
Jason parks5af0b912010-11-29 09:05:25 -0600533 return err;
534 }
535 return reply.readInt32();
536 }
Jason parksd6332552011-01-07 09:01:15 -0600537
538 int32_t encryptStorage(const String16& password)
539 {
540 Parcel data, reply;
541 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
542 data.writeString16(password);
543 if (remote()->transact(TRANSACTION_encryptStorage, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000544 ALOGD("encryptStorage could not contact remote\n");
Jason parksd6332552011-01-07 09:01:15 -0600545 return -1;
546 }
547 int32_t err = reply.readExceptionCode();
548 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000549 ALOGD("encryptStorage caught exception %d\n", err);
Jason parksd6332552011-01-07 09:01:15 -0600550 return err;
551 }
552 return reply.readInt32();
553 }
Kenny Rootbe857d42010-08-18 15:59:25 -0700554};
555
Andreas Gampe2b3a8cd2014-10-21 23:38:52 -0700556IMPLEMENT_META_INTERFACE(MountService, "IMountService")
Kenny Rootbe857d42010-08-18 15:59:25 -0700557
558// ----------------------------------------------------------------------
559
Andreas Gampe2b3a8cd2014-10-21 23:38:52 -0700560}