blob: c714b3cad296b2f7a4c4aa0febd22f42a5c5720f [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
Mathew Inwoodd99b96e2018-08-09 17:22:11 +010019import android.annotation.UnsupportedAppUsage;
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;
Mike Lockwood51690542011-05-09 20:16:05 -070034 private final boolean mRemovable;
Mike Lockwood7a59dd22011-07-11 09:18:03 -040035 private final long mMaxFileSize;
Mike Lockwood7ae938be2011-04-05 10:21:27 -040036
Jerry Zhangf9c5c252017-08-16 18:07:51 -070037 public MtpStorage(StorageVolume volume, int storageId) {
38 mStorageId = storageId;
Jerry Zhang71938e12018-05-10 18:28:29 -070039 mPath = volume.getInternalPath();
Jerry Zhangf9c5c252017-08-16 18:07:51 -070040 mDescription = volume.getDescription(null);
Mike Lockwoodfbfe5552011-05-17 17:19:37 -040041 mRemovable = volume.isRemovable();
Mike Lockwood7a59dd22011-07-11 09:18:03 -040042 mMaxFileSize = volume.getMaxFileSize();
Mike Lockwood7ae938be2011-04-05 10:21:27 -040043 }
44
45 /**
46 * Returns the storage ID for the storage unit
47 *
48 * @return the storage ID
49 */
Mathew Inwoodd99b96e2018-08-09 17:22:11 +010050 @UnsupportedAppUsage
Mike Lockwood7ae938be2011-04-05 10:21:27 -040051 public final int getStorageId() {
52 return mStorageId;
53 }
54
Mike Lockwood7ae938be2011-04-05 10:21:27 -040055 /**
56 * Returns the file path for the storage unit's storage in the file system
57 *
58 * @return the storage file path
59 */
Mathew Inwoodd99b96e2018-08-09 17:22:11 +010060 @UnsupportedAppUsage
Mike Lockwood7ae938be2011-04-05 10:21:27 -040061 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 /**
Mike Lockwood51690542011-05-09 20:16:05 -070075 * Returns true if the storage is removable.
76 *
77 * @return is removable
78 */
79 public final boolean isRemovable() {
80 return mRemovable;
81 }
Mike Lockwood7a59dd22011-07-11 09:18:03 -040082
83 /**
84 * Returns maximum file size for the storage, or zero if it is unbounded.
85 *
86 * @return maximum file size
87 */
88 public long getMaxFileSize() {
89 return mMaxFileSize;
90 }
Mike Lockwood7ae938be2011-04-05 10:21:27 -040091}