blob: 6ca442c7e66fbb0a80fbe1ab2a439d577118a357 [file] [log] [blame]
Mike Lockwood7ae938be2011-04-05 10:21:27 -04001/*
2 * Copyright (C) 2011 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 android.mtp;
18
Fabrice Di Meglio13fe2a52012-05-18 18:08:58 -070019import android.content.Context;
Mike Lockwoodfbfe5552011-05-17 17:19:37 -040020import android.os.storage.StorageVolume;
21
Mike Lockwood7ae938be2011-04-05 10:21:27 -040022/**
23 * This class represents a storage unit on an MTP device.
24 * Used only for MTP support in USB responder mode.
25 * MtpStorageInfo is used in MTP host mode
26 *
27 * @hide
28 */
29public class MtpStorage {
30
31 private final int mStorageId;
32 private final String mPath;
33 private final String mDescription;
34 private final long mReserveSpace;
Mike Lockwood51690542011-05-09 20:16:05 -070035 private final boolean mRemovable;
Mike Lockwood7a59dd22011-07-11 09:18:03 -040036 private final long mMaxFileSize;
Mike Lockwood7ae938be2011-04-05 10:21:27 -040037
Fabrice Di Meglio13fe2a52012-05-18 18:08:58 -070038 public MtpStorage(StorageVolume volume, Context context) {
Mike Lockwoodfbfe5552011-05-17 17:19:37 -040039 mStorageId = volume.getStorageId();
40 mPath = volume.getPath();
Jeff Sharkey1b8ef7e2015-04-03 17:14:45 -070041 mDescription = volume.getDescription(context);
Henrik Engström6393b0712012-11-29 15:29:35 +010042 mReserveSpace = volume.getMtpReserveSpace() * 1024L * 1024L;
Mike Lockwoodfbfe5552011-05-17 17:19:37 -040043 mRemovable = volume.isRemovable();
Mike Lockwood7a59dd22011-07-11 09:18:03 -040044 mMaxFileSize = volume.getMaxFileSize();
Mike Lockwood7ae938be2011-04-05 10:21:27 -040045 }
46
47 /**
48 * Returns the storage ID for the storage unit
49 *
50 * @return the storage ID
51 */
52 public final int getStorageId() {
53 return mStorageId;
54 }
55
Mike Lockwood7ae938be2011-04-05 10:21:27 -040056 /**
57 * Returns the file path for the storage unit's storage in the file system
58 *
59 * @return the storage file path
60 */
61 public final String getPath() {
62 return mPath;
63 }
64
65 /**
66 * Returns the description string for the storage unit
67 *
68 * @return the storage unit description
69 */
70 public final String getDescription() {
71 return mDescription;
72 }
73
74 /**
75 * Returns the amount of space to reserve on the storage file system.
76 * This can be set to a non-zero value to prevent MTP from filling up the entire storage.
77 *
bo huang3b60dac2012-08-06 13:16:57 +080078 * @return reserved space in bytes.
Mike Lockwood7ae938be2011-04-05 10:21:27 -040079 */
80 public final long getReserveSpace() {
81 return mReserveSpace;
82 }
83
Mike Lockwood51690542011-05-09 20:16:05 -070084 /**
85 * Returns true if the storage is removable.
86 *
87 * @return is removable
88 */
89 public final boolean isRemovable() {
90 return mRemovable;
91 }
Mike Lockwood7a59dd22011-07-11 09:18:03 -040092
93 /**
94 * Returns maximum file size for the storage, or zero if it is unbounded.
95 *
96 * @return maximum file size
97 */
98 public long getMaxFileSize() {
99 return mMaxFileSize;
100 }
Mike Lockwood7ae938be2011-04-05 10:21:27 -0400101}