• 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.compat.annotation.UnsupportedAppUsage;
20 import android.os.storage.StorageVolume;
21 
22 /**
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  */
29 public class MtpStorage {
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     private final String mVolumeName;
36 
MtpStorage(StorageVolume volume, int storageId)37     public MtpStorage(StorageVolume volume, int storageId) {
38         mStorageId = storageId;
39         mPath = volume.getPath();
40         mDescription = volume.getDescription(null);
41         mRemovable = volume.isRemovable();
42         mMaxFileSize = volume.getMaxFileSize();
43         mVolumeName = volume.getMediaStoreVolumeName();
44     }
45 
46     /**
47      * Returns the storage ID for the storage unit
48      *
49      * @return the storage ID
50      */
51     @UnsupportedAppUsage
getStorageId()52     public final int getStorageId() {
53         return mStorageId;
54     }
55 
56    /**
57      * Returns the file path for the storage unit's storage in the file system
58      *
59      * @return the storage file path
60      */
61     @UnsupportedAppUsage
getPath()62     public final String getPath() {
63         return mPath;
64     }
65 
66    /**
67      * Returns the description string for the storage unit
68      *
69      * @return the storage unit description
70      */
getDescription()71     public final String getDescription() {
72         return mDescription;
73     }
74 
75    /**
76      * Returns true if the storage is removable.
77      *
78      * @return is removable
79      */
isRemovable()80     public final boolean isRemovable() {
81         return mRemovable;
82     }
83 
84    /**
85      * Returns maximum file size for the storage, or zero if it is unbounded.
86      *
87      * @return maximum file size
88      */
getMaxFileSize()89     public long getMaxFileSize() {
90         return mMaxFileSize;
91     }
92 
getVolumeName()93     public String getVolumeName() {
94         return mVolumeName;
95     }
96 }
97