Daichi Hirono | 3ff1c01 | 2016-10-28 12:53:44 +0900 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.internal.os; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.ParcelFileDescriptor; |
| 21 | import android.os.Parcelable; |
Daichi Hirono | 9fb0018 | 2016-11-08 14:12:17 +0900 | [diff] [blame] | 22 | import android.os.storage.IStorageManager; |
| 23 | import com.android.internal.util.Preconditions; |
Daichi Hirono | 3ff1c01 | 2016-10-28 12:53:44 +0900 | [diff] [blame] | 24 | |
Daichi Hirono | 9fb0018 | 2016-11-08 14:12:17 +0900 | [diff] [blame] | 25 | /** |
| 26 | * Parcelable class representing AppFuse mount. |
| 27 | * This conveys the result for IStorageManager#openProxyFileDescriptor. |
| 28 | * @see IStorageManager#openProxyFileDescriptor |
| 29 | */ |
Daichi Hirono | 3ff1c01 | 2016-10-28 12:53:44 +0900 | [diff] [blame] | 30 | public class AppFuseMount implements Parcelable { |
Daichi Hirono | 9fb0018 | 2016-11-08 14:12:17 +0900 | [diff] [blame] | 31 | final public int mountPointId; |
Daichi Hirono | 3ff1c01 | 2016-10-28 12:53:44 +0900 | [diff] [blame] | 32 | final public ParcelFileDescriptor fd; |
| 33 | |
Daichi Hirono | 9fb0018 | 2016-11-08 14:12:17 +0900 | [diff] [blame] | 34 | /** |
| 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 Hirono | 3ff1c01 | 2016-10-28 12:53:44 +0900 | [diff] [blame] | 42 | 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 Hirono | 9fb0018 | 2016-11-08 14:12:17 +0900 | [diff] [blame] | 52 | dest.writeInt(this.mountPointId); |
Daichi Hirono | 3ff1c01 | 2016-10-28 12:53:44 +0900 | [diff] [blame] | 53 | 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 Hirono | 9fb0018 | 2016-11-08 14:12:17 +0900 | [diff] [blame] | 60 | return new AppFuseMount(in.readInt(), in.readParcelable(null)); |
Daichi Hirono | 3ff1c01 | 2016-10-28 12:53:44 +0900 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public AppFuseMount[] newArray(int size) { |
| 65 | return new AppFuseMount[size]; |
| 66 | } |
| 67 | }; |
| 68 | } |