1/*
2 * Copyright (C) 2010 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
19/**
20 * This class encapsulates information about an object on an MTP device.
21 * This corresponds to the ObjectInfo Dataset described in
22 * section 5.3.1 of the MTP specification.
23 */
24public final class MtpObjectInfo {
25    private int mHandle;
26    private int mStorageId;
27    private int mFormat;
28    private int mProtectionStatus;
29    private int mCompressedSize;
30    private int mThumbFormat;
31    private int mThumbCompressedSize;
32    private int mThumbPixWidth;
33    private int mThumbPixHeight;
34    private int mImagePixWidth;
35    private int mImagePixHeight;
36    private int mImagePixDepth;
37    private int mParent;
38    private int mAssociationType;
39    private int mAssociationDesc;
40    private int mSequenceNumber;
41    private String mName;
42    private long mDateCreated;
43    private long mDateModified;
44    private String mKeywords;
45
46    // only instantiated via JNI
47    private MtpObjectInfo() {
48    }
49
50    /**
51     * Returns the object handle for the MTP object
52     *
53     * @return the object handle
54     */
55    public final int getObjectHandle() {
56        return mHandle;
57    }
58
59    /**
60     * Returns the storage ID for the MTP object's storage unit
61     *
62     * @return the storage ID
63     */
64    public final int getStorageId() {
65        return mStorageId;
66    }
67
68    /**
69     * Returns the format code for the MTP object
70     *
71     * @return the format code
72     */
73    public final int getFormat() {
74        return mFormat;
75    }
76
77    /**
78     * Returns the protection status for the MTP object
79     * Possible values are:
80     *
81     * <ul>
82     * <li> {@link android.mtp.MtpConstants#PROTECTION_STATUS_NONE}
83     * <li> {@link android.mtp.MtpConstants#PROTECTION_STATUS_READ_ONLY}
84     * <li> {@link android.mtp.MtpConstants#PROTECTION_STATUS_NON_TRANSFERABLE_DATA}
85     * </ul>
86     *
87     * @return the protection status
88     */
89    public final int getProtectionStatus() {
90        return mProtectionStatus;
91    }
92
93    /**
94     * Returns the size of the MTP object
95     *
96     * @return the object size
97     */
98    public final int getCompressedSize() {
99        return mCompressedSize;
100    }
101
102    /**
103     * Returns the format code for the MTP object's thumbnail
104     * Will be zero for objects with no thumbnail
105     *
106     * @return the thumbnail format code
107     */
108    public final int getThumbFormat() {
109        return mThumbFormat;
110    }
111
112    /**
113     * Returns the size of the MTP object's thumbnail
114     * Will be zero for objects with no thumbnail
115     *
116     * @return the thumbnail size
117     */
118    public final int getThumbCompressedSize() {
119        return mThumbCompressedSize;
120    }
121
122    /**
123     * Returns the width of the MTP object's thumbnail in pixels
124     * Will be zero for objects with no thumbnail
125     *
126     * @return the thumbnail width
127     */
128    public final int getThumbPixWidth() {
129        return mThumbPixWidth;
130    }
131
132    /**
133     * Returns the height of the MTP object's thumbnail in pixels
134     * Will be zero for objects with no thumbnail
135     *
136     * @return the thumbnail height
137     */
138    public final int getThumbPixHeight() {
139        return mThumbPixHeight;
140    }
141
142    /**
143     * Returns the width of the MTP object in pixels
144     * Will be zero for non-image objects
145     *
146     * @return the image width
147     */
148    public final int getImagePixWidth() {
149        return mImagePixWidth;
150    }
151
152    /**
153     * Returns the height of the MTP object in pixels
154     * Will be zero for non-image objects
155     *
156     * @return the image height
157     */
158    public final int getImagePixHeight() {
159        return mImagePixHeight;
160    }
161
162    /**
163     * Returns the depth of the MTP object in bits per pixel
164     * Will be zero for non-image objects
165     *
166     * @return the image depth
167     */
168    public final int getImagePixDepth() {
169        return mImagePixDepth;
170    }
171
172    /**
173     * Returns the object handle for the object's parent
174     * Will be zero for the root directory of a storage unit
175     *
176     * @return the object's parent
177     */
178    public final int getParent() {
179        return mParent;
180    }
181
182    /**
183     * Returns the association type for the MTP object
184     * Will be zero objects that are not of format
185     * {@link android.mtp.MtpConstants#FORMAT_ASSOCIATION}
186     * For directories the association type is typically
187     * {@link android.mtp.MtpConstants#ASSOCIATION_TYPE_GENERIC_FOLDER}
188     *
189     * @return the object's association type
190     */
191    public final int getAssociationType() {
192        return mAssociationType;
193    }
194
195    /**
196     * Returns the association description for the MTP object
197     * Will be zero objects that are not of format
198     * {@link android.mtp.MtpConstants#FORMAT_ASSOCIATION}
199     *
200     * @return the object's association description
201     */
202    public final int getAssociationDesc() {
203        return mAssociationDesc;
204    }
205
206   /**
207     * Returns the sequence number for the MTP object
208     * This field is typically not used for MTP devices,
209     * but is sometimes used to define a sequence of photos
210     * on PTP cameras.
211     *
212     * @return the object's sequence number
213     */
214    public final int getSequenceNumber() {
215        return mSequenceNumber;
216    }
217
218   /**
219     * Returns the name of the MTP object
220     *
221     * @return the object's name
222     */
223    public final String getName() {
224        return mName;
225    }
226
227   /**
228     * Returns the creation date of the MTP object
229     * The value is represented as milliseconds since January 1, 1970
230     *
231     * @return the object's creation date
232     */
233    public final long getDateCreated() {
234        return mDateCreated;
235    }
236
237   /**
238     * Returns the modification date of the MTP object
239     * The value is represented as milliseconds since January 1, 1970
240     *
241     * @return the object's modification date
242     */
243    public final long getDateModified() {
244        return mDateModified;
245    }
246
247   /**
248     * Returns a comma separated list of keywords for the MTP object
249     *
250     * @return the object's keyword list
251     */
252    public final String getKeywords() {
253        return mKeywords;
254    }
255}
256