blob: 99508a2943ff3c7d60d09c7f48543c1a8bdaf7a2 [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,
Kenny Rootbe857d42010-08-18 15:59:25 -070051};
52
53class BpMountService: public BpInterface<IMountService>
54{
55public:
Chih-Hung Hsiehc6baf562016-04-27 11:29:23 -070056 explicit BpMountService(const sp<IBinder>& impl)
Kenny Rootbe857d42010-08-18 15:59:25 -070057 : BpInterface<IMountService>(impl)
58 {
59 }
60
61 virtual void registerListener(const sp<IMountServiceListener>& listener)
62 {
63 Parcel data, reply;
64 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
Marco Nelissendce97402014-11-14 08:00:42 -080065 data.writeStrongBinder(IInterface::asBinder(listener));
Kenny Rootbe857d42010-08-18 15:59:25 -070066 if (remote()->transact(TRANSACTION_registerListener, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +000067 ALOGD("registerListener could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -070068 return;
69 }
70 int32_t err = reply.readExceptionCode();
71 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +000072 ALOGD("registerListener caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -070073 return;
74 }
75 }
76
77 virtual void unregisterListener(const sp<IMountServiceListener>& listener)
78 {
79 Parcel data, reply;
80 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
Marco Nelissendce97402014-11-14 08:00:42 -080081 data.writeStrongBinder(IInterface::asBinder(listener));
Kenny Rootbe857d42010-08-18 15:59:25 -070082 if (remote()->transact(TRANSACTION_unregisterListener, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +000083 ALOGD("unregisterListener could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -070084 return;
85 }
86 int32_t err = reply.readExceptionCode();
87 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +000088 ALOGD("unregisterListener caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -070089 return;
90 }
91 }
92
93 virtual bool isUsbMassStorageConnected()
94 {
95 Parcel data, reply;
96 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
97 if (remote()->transact(TRANSACTION_isUsbMassStorageConnected, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +000098 ALOGD("isUsbMassStorageConnected could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -070099 return false;
100 }
101 int32_t err = reply.readExceptionCode();
102 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000103 ALOGD("isUsbMassStorageConnected caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700104 return false;
105 }
106 return reply.readInt32() != 0;
107 }
108
109 virtual void setUsbMassStorageEnabled(const bool enable)
110 {
111 Parcel data, reply;
112 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
113 data.writeInt32(enable != 0);
114 if (remote()->transact(TRANSACTION_setUsbMassStorageEnabled, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000115 ALOGD("setUsbMassStorageEnabled could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700116 return;
117 }
118 int32_t err = reply.readExceptionCode();
119 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000120 ALOGD("setUsbMassStorageEnabled caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700121 return;
122 }
123 }
124
125 virtual bool isUsbMassStorageEnabled()
126 {
127 Parcel data, reply;
128 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
129 if (remote()->transact(TRANSACTION_isUsbMassStorageEnabled, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000130 ALOGD("isUsbMassStorageEnabled could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700131 return false;
132 }
133 int32_t err = reply.readExceptionCode();
134 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000135 ALOGD("isUsbMassStorageEnabled caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700136 return false;
137 }
138 return reply.readInt32() != 0;
139 }
140
141 int32_t mountVolume(const String16& mountPoint)
142 {
143 Parcel data, reply;
144 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
145 data.writeString16(mountPoint);
146 if (remote()->transact(TRANSACTION_mountVolume, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000147 ALOGD("mountVolume could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700148 return -1;
149 }
150 int32_t err = reply.readExceptionCode();
151 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000152 ALOGD("mountVolume caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700153 return err;
154 }
155 return reply.readInt32();
156 }
157
Ben Komalo13c71972011-09-07 16:35:56 -0700158 int32_t unmountVolume(const String16& mountPoint, const bool force, const bool removeEncryption)
Kenny Rootbe857d42010-08-18 15:59:25 -0700159 {
160 Parcel data, reply;
161 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
162 data.writeString16(mountPoint);
163 data.writeInt32(force ? 1 : 0);
Ben Komalo13c71972011-09-07 16:35:56 -0700164 data.writeInt32(removeEncryption ? 1 : 0);
Kenny Rootbe857d42010-08-18 15:59:25 -0700165 if (remote()->transact(TRANSACTION_unmountVolume, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000166 ALOGD("unmountVolume could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700167 return -1;
168 }
169 int32_t err = reply.readExceptionCode();
170 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000171 ALOGD("unmountVolume caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700172 return err;
173 }
174 return reply.readInt32();
175 }
176
177 int32_t formatVolume(const String16& mountPoint)
178 {
179 Parcel data, reply;
180 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
181 data.writeString16(mountPoint);
182 if (remote()->transact(TRANSACTION_formatVolume, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000183 ALOGD("formatVolume could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700184 return -1;
185 }
186 int32_t err = reply.readExceptionCode();
187 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000188 ALOGD("formatVolume caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700189 return err;
190 }
191 return reply.readInt32();
192 }
193
194 int32_t getStorageUsers(const String16& mountPoint, int32_t** users)
195 {
196 Parcel data, reply;
197 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
198 data.writeString16(mountPoint);
199 if (remote()->transact(TRANSACTION_getStorageUsers, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000200 ALOGD("getStorageUsers could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700201 return -1;
202 }
203 int32_t err = reply.readExceptionCode();
204 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000205 ALOGD("getStorageUsers caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700206 return err;
207 }
Andreas Gampe2b3a8cd2014-10-21 23:38:52 -0700208 int32_t numUsersI = reply.readInt32();
209 uint32_t numUsers;
210 if (numUsersI < 0) {
211 ALOGW("Number of users is negative: %d\n", numUsersI);
212 numUsers = 0;
213 } else {
214 numUsers = static_cast<uint32_t>(numUsersI);
215 }
Kenny Rootbe857d42010-08-18 15:59:25 -0700216 *users = (int32_t*)malloc(sizeof(int32_t)*numUsers);
Andreas Gampe2b3a8cd2014-10-21 23:38:52 -0700217 for (size_t i = 0; i < numUsers; i++) {
Kenny Rootbe857d42010-08-18 15:59:25 -0700218 **users++ = reply.readInt32();
219 }
Andreas Gampe2b3a8cd2014-10-21 23:38:52 -0700220 return static_cast<int32_t>(numUsers);
Kenny Rootbe857d42010-08-18 15:59:25 -0700221 }
222
223 int32_t getVolumeState(const String16& mountPoint)
224 {
225 Parcel data, reply;
226 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
227 data.writeString16(mountPoint);
228 if (remote()->transact(TRANSACTION_getVolumeState, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000229 ALOGD("getVolumeState could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700230 return -1;
231 }
232 int32_t err = reply.readExceptionCode();
233 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000234 ALOGD("getVolumeState caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700235 return err;
236 }
237 return reply.readInt32();
238 }
239
240 int32_t createSecureContainer(const String16& id, const int32_t sizeMb, const String16& fstype,
241 const String16& key, const int32_t ownerUid)
242 {
243 Parcel data, reply;
244 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
245 data.writeString16(id);
246 data.writeInt32(sizeMb);
247 data.writeString16(fstype);
248 data.writeString16(key);
249 data.writeInt32(ownerUid);
250 if (remote()->transact(TRANSACTION_createSecureContainer, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000251 ALOGD("createSecureContainer could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700252 return -1;
253 }
254 int32_t err = reply.readExceptionCode();
255 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000256 ALOGD("createSecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700257 return err;
258 }
259 return reply.readInt32();
260 }
261
262 int32_t finalizeSecureContainer(const String16& id)
263 {
264 Parcel data, reply;
265 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
266 data.writeString16(id);
267 if (remote()->transact(TRANSACTION_finalizeSecureContainer, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000268 ALOGD("finalizeSecureContainer couldn't call remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700269 return -1;
270 }
271 int32_t err = reply.readExceptionCode();
272 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000273 ALOGD("finalizeSecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700274 return err;
275 }
276 return reply.readInt32();
277 }
278
279 int32_t destroySecureContainer(const String16& id)
280 {
281 Parcel data, reply;
282 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
283 data.writeString16(id);
284 if (remote()->transact(TRANSACTION_destroySecureContainer, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000285 ALOGD("destroySecureContainer couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700286 return -1;
287 }
288 int32_t err = reply.readExceptionCode();
289 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000290 ALOGD("destroySecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700291 return err;
292 }
293 return reply.readInt32();
294 }
295
296 int32_t mountSecureContainer(const String16& id, const String16& key, const int32_t ownerUid)
297 {
298 Parcel data, reply;
299 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
300 data.writeString16(id);
301 data.writeString16(key);
302 data.writeInt32(ownerUid);
Jeff Sharkey941a8ba2014-08-20 16:26:32 -0700303 // Assume read-only
304 data.writeInt32(1);
Kenny Rootbe857d42010-08-18 15:59:25 -0700305 if (remote()->transact(TRANSACTION_mountSecureContainer, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000306 ALOGD("mountSecureContainer couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700307 return -1;
308 }
309 int32_t err = reply.readExceptionCode(); // What to do...
310 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000311 ALOGD("mountSecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700312 return err;
313 }
314 return reply.readInt32();
315 }
316
317 int32_t unmountSecureContainer(const String16& id, const bool force)
318 {
319 Parcel data, reply;
320 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
321 data.writeString16(id);
322 data.writeInt32(force ? 1 : 0);
323 if (remote()->transact(TRANSACTION_getSecureContainerPath, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000324 ALOGD("unmountSecureContainer couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700325 return -1;
326 }
327 int32_t err = reply.readExceptionCode(); // What to do...
328 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000329 ALOGD("unmountSecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700330 return err;
331 }
332 return reply.readInt32();
333 }
334
335 bool isSecureContainerMounted(const String16& id)
336 {
337 Parcel data, reply;
338 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
339 data.writeString16(id);
340 if (remote()->transact(TRANSACTION_isSecureContainerMounted, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000341 ALOGD("isSecureContainerMounted couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700342 return false;
343 }
344 int32_t err = reply.readExceptionCode(); // What to do...
345 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000346 ALOGD("isSecureContainerMounted caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700347 return false;
348 }
349 return reply.readInt32() != 0;
350 }
351
352 int32_t renameSecureContainer(const String16& oldId, const String16& newId)
353 {
354 Parcel data, reply;
355 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
356 data.writeString16(oldId);
357 data.writeString16(newId);
358 if (remote()->transact(TRANSACTION_renameSecureContainer, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000359 ALOGD("renameSecureContainer couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700360 return -1;
361 }
362 int32_t err = reply.readExceptionCode(); // What to do...
363 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000364 ALOGD("renameSecureContainer caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700365 return err;
366 }
367 return reply.readInt32();
368 }
369
370 bool getSecureContainerPath(const String16& id, String16& path)
371 {
372 Parcel data, reply;
373 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
374 data.writeString16(id);
375 if (remote()->transact(TRANSACTION_getSecureContainerPath, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000376 ALOGD("getSecureContainerPath couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700377 return false;
378 }
379 int32_t err = reply.readExceptionCode(); // What to do...
380 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000381 ALOGD("getSecureContainerPath caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700382 return false;
383 }
384 path = reply.readString16();
385 return true;
386 }
387
388 int32_t getSecureContainerList(const String16& id, String16*& containers)
389 {
390 Parcel data, reply;
391 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
392 data.writeString16(id);
393 if (remote()->transact(TRANSACTION_getSecureContainerList, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000394 ALOGD("getSecureContainerList couldn't call remote");
Kenny Rootbe857d42010-08-18 15:59:25 -0700395 return -1;
396 }
397 int32_t err = reply.readExceptionCode();
398 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000399 ALOGD("getSecureContainerList caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700400 return err;
401 }
402 const int32_t numStrings = reply.readInt32();
403 containers = new String16[numStrings];
404 for (int i = 0; i < numStrings; i++) {
405 containers[i] = reply.readString16();
406 }
407 return numStrings;
408 }
409
410 void shutdown(const sp<IMountShutdownObserver>& observer)
411 {
412 Parcel data, reply;
413 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
Marco Nelissendce97402014-11-14 08:00:42 -0800414 data.writeStrongBinder(IInterface::asBinder(observer));
Kenny Rootbe857d42010-08-18 15:59:25 -0700415 if (remote()->transact(TRANSACTION_shutdown, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000416 ALOGD("shutdown could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700417 return;
418 }
419 int32_t err = reply.readExceptionCode();
420 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000421 ALOGD("shutdown caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700422 return;
423 }
424 reply.readExceptionCode();
425 }
426
427 void finishMediaUpdate()
428 {
429 Parcel data, reply;
430 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
431 if (remote()->transact(TRANSACTION_finishMediaUpdate, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000432 ALOGD("finishMediaUpdate could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700433 return;
434 }
435 int32_t err = reply.readExceptionCode();
436 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000437 ALOGD("finishMediaUpdate caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700438 return;
439 }
440 reply.readExceptionCode();
441 }
442
Eric Biggers8bc9340b2022-03-01 21:19:10 +0000443 void mountObb(const String16& rawPath, const String16& canonicalPath,
Sudheer Shanka25469aa2018-08-27 15:50:23 -0700444 const sp<IObbActionListener>& token, int32_t nonce, const sp<ObbInfo>& obbInfo)
Kenny Rootbe857d42010-08-18 15:59:25 -0700445 {
446 Parcel data, reply;
447 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
Jeff Sharkey4fbbda42012-09-24 18:34:07 -0700448 data.writeString16(rawPath);
449 data.writeString16(canonicalPath);
Marco Nelissendce97402014-11-14 08:00:42 -0800450 data.writeStrongBinder(IInterface::asBinder(token));
Kenny Rootaf9d6672010-10-08 09:21:39 -0700451 data.writeInt32(nonce);
Sudheer Shanka25469aa2018-08-27 15:50:23 -0700452 obbInfo->writeToParcel(&data);
Kenny Rootbe857d42010-08-18 15:59:25 -0700453 if (remote()->transact(TRANSACTION_mountObb, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000454 ALOGD("mountObb could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700455 return;
456 }
457 int32_t err = reply.readExceptionCode();
458 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000459 ALOGD("mountObb caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700460 return;
461 }
462 }
463
Kenny Root4a99ed82010-10-11 17:38:51 -0700464 void unmountObb(const String16& filename, const bool force,
465 const sp<IObbActionListener>& token, const int32_t nonce)
Kenny Rootbe857d42010-08-18 15:59:25 -0700466 {
467 Parcel data, reply;
468 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
469 data.writeString16(filename);
470 data.writeInt32(force ? 1 : 0);
Marco Nelissendce97402014-11-14 08:00:42 -0800471 data.writeStrongBinder(IInterface::asBinder(token));
Kenny Root4a99ed82010-10-11 17:38:51 -0700472 data.writeInt32(nonce);
Kenny Rootbe857d42010-08-18 15:59:25 -0700473 if (remote()->transact(TRANSACTION_unmountObb, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000474 ALOGD("unmountObb could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700475 return;
476 }
477 int32_t err = reply.readExceptionCode();
478 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000479 ALOGD("unmountObb caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700480 return;
481 }
482 }
483
484 bool isObbMounted(const String16& filename)
485 {
486 Parcel data, reply;
487 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
488 data.writeString16(filename);
489 if (remote()->transact(TRANSACTION_isObbMounted, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000490 ALOGD("isObbMounted could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700491 return false;
492 }
493 int32_t err = reply.readExceptionCode();
494 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000495 ALOGD("isObbMounted caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700496 return false;
497 }
498 return reply.readInt32() != 0;
499 }
500
501 bool getMountedObbPath(const String16& filename, String16& path)
502 {
503 Parcel data, reply;
504 data.writeInterfaceToken(IMountService::getInterfaceDescriptor());
505 data.writeString16(filename);
506 if (remote()->transact(TRANSACTION_getMountedObbPath, data, &reply) != NO_ERROR) {
Steve Block5baa3a62011-12-20 16:23:08 +0000507 ALOGD("getMountedObbPath could not contact remote\n");
Kenny Rootbe857d42010-08-18 15:59:25 -0700508 return false;
509 }
510 int32_t err = reply.readExceptionCode();
511 if (err < 0) {
Steve Block5baa3a62011-12-20 16:23:08 +0000512 ALOGD("getMountedObbPath caught exception %d\n", err);
Kenny Rootbe857d42010-08-18 15:59:25 -0700513 return false;
514 }
515 path = reply.readString16();
516 return true;
517 }
Kenny Rootbe857d42010-08-18 15:59:25 -0700518};
519
Sudheer Shanka2250d562016-11-07 15:41:02 -0800520IMPLEMENT_META_INTERFACE(MountService, "android.os.storage.IStorageManager")
Kenny Rootbe857d42010-08-18 15:59:25 -0700521
522// ----------------------------------------------------------------------
523
Andreas Gampe2b3a8cd2014-10-21 23:38:52 -0700524}