blob: 04d72117d28ada2b5a13ddf965ac0fde93dae353 [file] [log] [blame]
Daichi Hirono3ff1c012016-10-28 12:53:44 +09001/*
2 * Copyright (C) 2016 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
17package com.android.internal.os;
18
19import android.os.Parcel;
20import android.os.ParcelFileDescriptor;
21import android.os.Parcelable;
Daichi Hirono9fb00182016-11-08 14:12:17 +090022import android.os.storage.IStorageManager;
23import com.android.internal.util.Preconditions;
Daichi Hirono3ff1c012016-10-28 12:53:44 +090024
Daichi Hirono9fb00182016-11-08 14:12:17 +090025/**
26 * Parcelable class representing AppFuse mount.
27 * This conveys the result for IStorageManager#openProxyFileDescriptor.
28 * @see IStorageManager#openProxyFileDescriptor
29 */
Daichi Hirono3ff1c012016-10-28 12:53:44 +090030public class AppFuseMount implements Parcelable {
Daichi Hirono9fb00182016-11-08 14:12:17 +090031 final public int mountPointId;
Daichi Hirono3ff1c012016-10-28 12:53:44 +090032 final public ParcelFileDescriptor fd;
33
Daichi Hirono9fb00182016-11-08 14:12:17 +090034 /**
35 * @param mountPointId Integer number for mount point that is unique in the lifetime of
36 * StorageManagerService.
37 * @param fd File descriptor pointing /dev/fuse and tagged with the mount point.
38 */
39 public AppFuseMount(int mountPointId, ParcelFileDescriptor fd) {
40 Preconditions.checkNotNull(fd);
41 this.mountPointId = mountPointId;
Daichi Hirono3ff1c012016-10-28 12:53:44 +090042 this.fd = fd;
43 }
44
45 @Override
46 public int describeContents() {
47 return 0;
48 }
49
50 @Override
51 public void writeToParcel(Parcel dest, int flags) {
Daichi Hirono9fb00182016-11-08 14:12:17 +090052 dest.writeInt(this.mountPointId);
Daichi Hirono3ff1c012016-10-28 12:53:44 +090053 dest.writeParcelable(fd, flags);
54 }
55
56 public static final Parcelable.Creator<AppFuseMount> CREATOR =
57 new Parcelable.Creator<AppFuseMount>() {
58 @Override
59 public AppFuseMount createFromParcel(Parcel in) {
Daichi Hirono9fb00182016-11-08 14:12:17 +090060 return new AppFuseMount(in.readInt(), in.readParcelable(null));
Daichi Hirono3ff1c012016-10-28 12:53:44 +090061 }
62
63 @Override
64 public AppFuseMount[] newArray(int size) {
65 return new AppFuseMount[size];
66 }
67 };
68}