• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package android.mtp;
18 
19 import android.os.storage.StorageVolume;
20 
21 /**
22  * This class represents a storage unit on an MTP device.
23  * Used only for MTP support in USB responder mode.
24  * MtpStorageInfo is used in MTP host mode
25  *
26  * @hide
27  */
28 public class MtpStorage {
29 
30     private final int mStorageId;
31     private final String mPath;
32     private final String mDescription;
33     private final boolean mRemovable;
34     private final long mMaxFileSize;
35 
MtpStorage(StorageVolume volume, int storageId)36     public MtpStorage(StorageVolume volume, int storageId) {
37         mStorageId = storageId;
38         mPath = volume.getInternalPath();
39         mDescription = volume.getDescription(null);
40         mRemovable = volume.isRemovable();
41         mMaxFileSize = volume.getMaxFileSize();
42     }
43 
44     /**
45      * Returns the storage ID for the storage unit
46      *
47      * @return the storage ID
48      */
getStorageId()49     public final int getStorageId() {
50         return mStorageId;
51     }
52 
53    /**
54      * Returns the file path for the storage unit's storage in the file system
55      *
56      * @return the storage file path
57      */
getPath()58     public final String getPath() {
59         return mPath;
60     }
61 
62    /**
63      * Returns the description string for the storage unit
64      *
65      * @return the storage unit description
66      */
getDescription()67     public final String getDescription() {
68         return mDescription;
69     }
70 
71    /**
72      * Returns true if the storage is removable.
73      *
74      * @return is removable
75      */
isRemovable()76     public final boolean isRemovable() {
77         return mRemovable;
78     }
79 
80    /**
81      * Returns maximum file size for the storage, or zero if it is unbounded.
82      *
83      * @return maximum file size
84      */
getMaxFileSize()85     public long getMaxFileSize() {
86         return mMaxFileSize;
87     }
88 }
89