Debian Codegraph @

media/java/android/mtp/MtpStorage.java

raw symbols SCIP
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 import java.util.function.Supplier;
23
24 /**
25 * This class represents a storage unit on an MTP device.
26 * Used only for MTP support in USB responder mode.
27 * MtpStorageInfo is used in MTP host mode
28 *
29 * @hide
30 */
31 public class MtpStorage {
32 private final int mStorageId;
33 private final String mPath;
34 private final String mDescription;
35 private final boolean mRemovable;
36 private final long mMaxFileSize;
37 private final String mVolumeName;
38 private final Supplier<Boolean> mIsHostWindows;
39
40 public MtpStorage(StorageVolume volume, int storageId, Supplier<Boolean> isHostWindows) {
41 mStorageId = storageId;
42 mPath = volume.getPath();
43 mDescription = volume.getDescription(null);
44 mRemovable = volume.isRemovable();
45 mMaxFileSize = volume.getMaxFileSize();
46 mVolumeName = volume.getMediaStoreVolumeName();
47 mIsHostWindows = isHostWindows;
48 }
49
50 /**
51 * Returns the storage ID for the storage unit
52 *
53 * @return the storage ID
54 */
55 @UnsupportedAppUsage
56 public final int getStorageId() {
57 return mStorageId;
58 }
59
60 /**
61 * Returns the file path for the storage unit's storage in the file system
62 *
63 * @return the storage file path
64 */
65 @UnsupportedAppUsage
66 public final String getPath() {
67 return mPath;
68 }
69
70 /**
71 * Returns the description string for the storage unit
72 *
73 * @return the storage unit description
74 */
75 public final String getDescription() {
76 return mDescription;
77 }
78
79 /**
80 * Returns true if the storage is removable.
81 *
82 * @return is removable
83 */
84 public final boolean isRemovable() {
85 return mRemovable;
86 }
87
88 /**
89 * Returns maximum file size for the storage, or zero if it is unbounded.
90 *
91 * @return maximum file size
92 */
93 public long getMaxFileSize() {
94 return mMaxFileSize;
95 }
96
97 public String getVolumeName() {
98 return mVolumeName;
99 }
100
101 /**
102 * Returns true if the mtp host of this storage is Windows.
103 *
104 * @return is host Windows
105 */
106 public boolean isHostWindows() {
107 return mIsHostWindows.get();
108 }
109 }