summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/provider/Mtp.java223
-rw-r--r--media/java/android/media/MtpCursor.java47
-rw-r--r--media/mtp/MtpCursor.cpp102
-rw-r--r--media/mtp/MtpObjectInfo.cpp13
4 files changed, 375 insertions, 10 deletions
diff --git a/core/java/android/provider/Mtp.java b/core/java/android/provider/Mtp.java
index ce2aa8d..ec2698f 100644
--- a/core/java/android/provider/Mtp.java
+++ b/core/java/android/provider/Mtp.java
@@ -81,6 +81,11 @@ public final class Mtp
*/
public static final class Object implements BaseColumns {
+ public static Uri getContentUri(int deviceID, int objectID) {
+ return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID
+ + "/object/" + objectID);
+ }
+
public static Uri getContentUriForObjectChildren(int deviceID, int objectID) {
return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID
+ "/object/" + objectID + "/child");
@@ -92,9 +97,225 @@ public final class Mtp
}
/**
- * Name of the object
+ * The following columns correspond to the fields in the ObjectInfo dataset
+ * as described in the MTP specification.
+ */
+
+ /**
+ * The ID of the storage unit containing the object.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String STORAGE_ID = "storage_id";
+
+ /**
+ * The object's format. Can be one of the FORMAT_* symbols below,
+ * or any of the valid MTP object formats as defined in the MTP specification.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String FORMAT = "format";
+
+ /**
+ * The protection status of the object. See the PROTECTION_STATUS_*symbols below.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String PROTECTION_STATUS = "protection_status";
+
+ /**
+ * The size of the object in bytes.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String SIZE = "size";
+
+ /**
+ * The object's thumbnail format. Can be one of the FORMAT_* symbols below,
+ * or any of the valid MTP object formats as defined in the MTP specification.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String THUMB_FORMAT = "format";
+
+ /**
+ * The size of the object's thumbnail in bytes.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String THUMB_SIZE = "thumb_size";
+
+ /**
+ * The width of the object's thumbnail in pixels.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String THUMB_WIDTH = "thumb_width";
+
+ /**
+ * The height of the object's thumbnail in pixels.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String THUMB_HEIGHT = "thumb_height";
+
+ /**
+ * The width of the object in pixels.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String IMAGE_WIDTH = "image_width";
+
+ /**
+ * The height of the object in pixels.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String IMAGE_HEIGHT = "image_height";
+
+ /**
+ * The depth of the object in bits per pixel.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String IMAGE_DEPTH = "image_depth";
+
+ /**
+ * The ID of the object's parent, or zero if the object
+ * is in the root of its storage unit.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String PARENT = "parent";
+
+ /**
+ * The association type for a container object.
+ * For folders this is typically {@link #ASSOCIATION_TYPE_GENERIC_FOLDER}
+ * <P>Type: INTEGER</P>
+ */
+ public static final String ASSOCIATION_TYPE = "association_type";
+
+ /**
+ * Contains additional information about container objects.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String ASSOCIATION_DESC = "association_desc";
+
+ /**
+ * The sequence number of the object, typically used for an association
+ * containing images taken in sequence.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String SEQUENCE_NUMBER = "sequence_number";
+
+ /**
+ * The name of the object.
* <P>Type: TEXT</P>
*/
public static final String NAME = "name";
+
+ /**
+ * The date the object was created, in seconds since January 1, 1970.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String DATE_CREATED = "date_created";
+
+ /**
+ * The date the object was last modified, in seconds since January 1, 1970.
+ * <P>Type: INTEGER</P>
+ */
+ public static final String DATE_MODIFIED = "date_modified";
+
+ /**
+ * A list of keywords associated with an object, separated by spaces.
+ * <P>Type: TEXT</P>
+ */
+ public static final String KEYWORDS = "keywords";
+
+ /**
+ * Contants for {@link #FORMAT} and {@link #THUMB_FORMAT}
+ */
+ public static final int FORMAT_UNDEFINED = 0x3000;
+ public static final int FORMAT_ASSOCIATION = 0x3001;
+ public static final int FORMAT_SCRIPT = 0x3002;
+ public static final int FORMAT_EXECUTABLE = 0x3003;
+ public static final int FORMAT_TEXT = 0x3004;
+ public static final int FORMAT_HTML = 0x3005;
+ public static final int FORMAT_DPOF = 0x3006;
+ public static final int FORMAT_AIFF = 0x3007;
+ public static final int FORMAT_WAV = 0x3008;
+ public static final int FORMAT_MP3 = 0x3009;
+ public static final int FORMAT_AVI = 0x300A;
+ public static final int FORMAT_MPEG = 0x300B;
+ public static final int FORMAT_ASF = 0x300C;
+ public static final int FORMAT_DEFINED = 0x3800;
+ public static final int FORMAT_EXIF_JPEG = 0x3801;
+ public static final int FORMAT_TIFF_EP = 0x3802;
+ public static final int FORMAT_FLASHPIX = 0x3803;
+ public static final int FORMAT_BMP = 0x3804;
+ public static final int FORMAT_CIFF = 0x3805;
+ public static final int FORMAT_GIF = 0x3807;
+ public static final int FORMAT_JFIF = 0x3808;
+ public static final int FORMAT_CD = 0x3809;
+ public static final int FORMAT_PICT = 0x380A;
+ public static final int FORMAT_PNG = 0x380B;
+ public static final int FORMAT_TIFF = 0x380D;
+ public static final int FORMAT_TIFF_IT = 0x380E;
+ public static final int FORMAT_JP2 = 0x380F;
+ public static final int FORMAT_JPX = 0x3810;
+ public static final int FORMAT_UNDEFINED_FIRMWARE = 0xB802;
+ public static final int FORMAT_WINDOWS_IMAGE_FORMAT = 0xB881;
+ public static final int FORMAT_UNDEFINED_AUDIO = 0xB900;
+ public static final int FORMAT_WMA = 0xB901;
+ public static final int FORMAT_OGG = 0xB902;
+ public static final int FORMAT_AAC = 0xB903;
+ public static final int FORMAT_AUDIBLE = 0xB904;
+ public static final int FORMAT_FLAC = 0xB906;
+ public static final int FORMAT_UNDEFINED_VIDEO = 0xB980;
+ public static final int FORMAT_WMV = 0xB981;
+ public static final int FORMAT_MP4_CONTAINER = 0xB982;
+ public static final int FORMAT_MP2 = 0xB983;
+ public static final int FORMAT_3GP_CONTAINER = 0xB984;
+ public static final int FORMAT_UNDEFINED_COLLECTION = 0xBA00;
+ public static final int FORMAT_ABSTRACT_MULTIMEDIA_ALBUM = 0xBA01;
+ public static final int FORMAT_ABSTRACT_IMAGE_ALBUM = 0xBA02;
+ public static final int FORMAT_ABSTRACT_AUDIO_ALBUM = 0xBA03;
+ public static final int FORMAT_ABSTRACT_VIDEO_ALBUM = 0xBA04;
+ public static final int FORMAT_ABSTRACT_AV_PLAYLIST = 0xBA05;
+ public static final int FORMAT_ABSTRACT_CONTACT_GROUP = 0xBA06;
+ public static final int FORMAT_ABSTRACT_MESSAGE_FOLDER = 0xBA07;
+ public static final int FORMAT_ABSTRACT_CHAPTERED_PRODUCTION = 0xBA08;
+ public static final int FORMAT_ABSTRACT_AUDIO_PLAYLIST = 0xBA09;
+ public static final int FORMAT_ABSTRACT_VIDEO_PLAYLIST = 0xBA0A;
+ public static final int FORMAT_ABSTRACT_MEDIACAST = 0xBA0B;
+ public static final int FORMAT_WPL_PLAYLIST = 0xBA10;
+ public static final int FORMAT_M3U_PLAYLIST = 0xBA11;
+ public static final int FORMAT_MPL_PLAYLIST = 0xBA12;
+ public static final int FORMAT_ASX_PLAYLIST = 0xBA13;
+ public static final int FORMAT_PLS_PLAYLIST = 0xBA14;
+ public static final int FORMAT_UNDEFINED_DOCUMENT = 0xBA80;
+ public static final int FORMAT_ABSTRACT_DOCUMENT = 0xBA81;
+ public static final int FORMAT_XML_DOCUMENT = 0xBA82;
+ public static final int FORMAT_MS_WORD_DOCUMENT = 0xBA83;
+ public static final int FORMAT_MHT_COMPILED_HTML_DOCUMENT = 0xBA84;
+ public static final int FORMAT_MS_EXCEL_SPREADSHEET = 0xBA85;
+ public static final int FORMAT_MS_POWERPOINT_PRESENTATION = 0xBA86;
+ public static final int FORMAT_UNDEFINED_MESSAGE = 0xBB00;
+ public static final int FORMAT_ABSTRACT_MESSSAGE = 0xBB01;
+ public static final int FORMAT_UNDEFINED_CONTACT = 0xBB80;
+ public static final int FORMAT_ABSTRACT_CONTACT = 0xBB81;
+ public static final int FORMAT_VCARD_2 = 0xBB82;
+
+ /**
+ * Object is not protected. It may be modified and deleted, and its properties
+ * may be modified.
+ */
+ public static final int PROTECTION_STATUS_NONE = 0;
+
+ /**
+ * Object can not be modified or deleted and its properties can not be modified.
+ */
+ public static final int PROTECTION_STATUS_READ_ONLY = 0x8001;
+
+ /**
+ * Object can not be modified or deleted but its properties are modifiable.
+ */
+ public static final int PROTECTION_STATUS_READ_ONLY_DATA = 0x8002;
+
+ /**
+ * Object's contents can not be transfered from the device, but the object
+ * may be moved or deleted and its properties may be modified.
+ */
+ public static final int PROTECTION_STATUS_NON_TRANSFERABLE_DATA = 0x8003;
+
+ public static final int ASSOCIATION_TYPE_GENERIC_FOLDER = 0x0001;
}
}
diff --git a/media/java/android/media/MtpCursor.java b/media/java/android/media/MtpCursor.java
index 67ca31b..baf3c12 100644
--- a/media/java/android/media/MtpCursor.java
+++ b/media/java/android/media/MtpCursor.java
@@ -126,18 +126,39 @@ public final class MtpCursor extends AbstractWindowedCursor {
}
/* Device Column IDs */
- private static final int DEVICE_ROW_ID = 1;
+ /* These must match the values in MtpCursor.cpp */
+ private static final int DEVICE_ROW_ID = 1;
private static final int DEVICE_MANUFACTURER = 2;
private static final int DEVICE_MODEL = 3;
/* Storage Column IDs */
+ /* These must match the values in MtpCursor.cpp */
private static final int STORAGE_ROW_ID = 101;
private static final int STORAGE_IDENTIFIER = 102;
private static final int STORAGE_DESCRIPTION = 103;
/* Object Column IDs */
- private static final int OBJECT_ROW_ID = 201;
- private static final int OBJECT_NAME = 202;
+ /* These must match the values in MtpCursor.cpp */
+ private static final int OBJECT_ROW_ID = 201;
+ private static final int OBJECT_STORAGE_ID = 202;
+ private static final int OBJECT_FORMAT = 203;
+ private static final int OBJECT_PROTECTION_STATUS = 204;
+ private static final int OBJECT_SIZE = 205;
+ private static final int OBJECT_THUMB_FORMAT = 206;
+ private static final int OBJECT_THUMB_SIZE = 207;
+ private static final int OBJECT_THUMB_WIDTH = 208;
+ private static final int OBJECT_THUMB_HEIGHT = 209;
+ private static final int OBJECT_IMAGE_WIDTH = 210;
+ private static final int OBJECT_IMAGE_HEIGHT = 211;
+ private static final int OBJECT_IMAGE_DEPTH = 212;
+ private static final int OBJECT_PARENT = 213;
+ private static final int OBJECT_ASSOCIATION_TYPE = 214;
+ private static final int OBJECT_ASSOCIATION_DESC = 215;
+ private static final int OBJECT_SEQUENCE_NUMBER = 216;
+ private static final int OBJECT_NAME = 217;
+ private static final int OBJECT_DATE_CREATED = 218;
+ private static final int OBJECT_DATE_MODIFIED = 219;
+ private static final int OBJECT_KEYWORDS = 220;
private static HashMap<String, Integer> sDeviceProjectionMap;
private static HashMap<String, Integer> sStorageProjectionMap;
@@ -156,6 +177,26 @@ public final class MtpCursor extends AbstractWindowedCursor {
sObjectProjectionMap = new HashMap<String, Integer>();
sObjectProjectionMap.put(Mtp.Object._ID, new Integer(OBJECT_ROW_ID));
+ sObjectProjectionMap.put(Mtp.Object.STORAGE_ID, new Integer(OBJECT_STORAGE_ID));
+ sObjectProjectionMap.put(Mtp.Object.FORMAT, new Integer(OBJECT_FORMAT));
+ sObjectProjectionMap.put(Mtp.Object.PROTECTION_STATUS, new Integer(OBJECT_PROTECTION_STATUS));
+ sObjectProjectionMap.put(Mtp.Object.SIZE, new Integer(OBJECT_SIZE));
+ sObjectProjectionMap.put(Mtp.Object.THUMB_FORMAT, new Integer(OBJECT_THUMB_FORMAT));
+ sObjectProjectionMap.put(Mtp.Object.THUMB_SIZE, new Integer(OBJECT_THUMB_SIZE));
+ sObjectProjectionMap.put(Mtp.Object.THUMB_WIDTH, new Integer(OBJECT_THUMB_WIDTH));
+ sObjectProjectionMap.put(Mtp.Object.THUMB_HEIGHT, new Integer(OBJECT_THUMB_HEIGHT));
+ sObjectProjectionMap.put(Mtp.Object.IMAGE_WIDTH, new Integer(OBJECT_IMAGE_WIDTH));
+ sObjectProjectionMap.put(Mtp.Object.IMAGE_HEIGHT, new Integer(OBJECT_IMAGE_HEIGHT));
+ sObjectProjectionMap.put(Mtp.Object.IMAGE_DEPTH, new Integer(OBJECT_IMAGE_DEPTH));
+ sObjectProjectionMap.put(Mtp.Object.PARENT, new Integer(OBJECT_PARENT));
+ sObjectProjectionMap.put(Mtp.Object.ASSOCIATION_TYPE, new Integer(OBJECT_ASSOCIATION_TYPE));
+ sObjectProjectionMap.put(Mtp.Object.ASSOCIATION_DESC, new Integer(OBJECT_ASSOCIATION_DESC));
+ sObjectProjectionMap.put(Mtp.Object.SEQUENCE_NUMBER, new Integer(OBJECT_SEQUENCE_NUMBER));
+ sObjectProjectionMap.put(Mtp.Object.NAME, new Integer(OBJECT_NAME));
+ sObjectProjectionMap.put(Mtp.Object.DATE_CREATED, new Integer(OBJECT_DATE_CREATED));
+ sObjectProjectionMap.put(Mtp.Object.DATE_MODIFIED, new Integer(OBJECT_DATE_MODIFIED));
+ sObjectProjectionMap.put(Mtp.Object.KEYWORDS, new Integer(OBJECT_KEYWORDS));
+
sObjectProjectionMap.put(Mtp.Object.NAME, new Integer(OBJECT_NAME));
}
diff --git a/media/mtp/MtpCursor.cpp b/media/mtp/MtpCursor.cpp
index 9c9ce64..42d9e38 100644
--- a/media/mtp/MtpCursor.cpp
+++ b/media/mtp/MtpCursor.cpp
@@ -29,18 +29,39 @@
namespace android {
/* Device Column IDs */
+/* These must match the values in MtpCursor.java */
#define DEVICE_ROW_ID 1
#define DEVICE_MANUFACTURER 2
#define DEVICE_MODEL 3
/* Storage Column IDs */
+/* These must match the values in MtpCursor.java */
#define STORAGE_ROW_ID 101
#define STORAGE_IDENTIFIER 102
#define STORAGE_DESCRIPTION 103
/* Object Column IDs */
-#define OBJECT_ROW_ID 201
-#define OBJECT_NAME 202
+/* These must match the values in MtpCursor.java */
+#define OBJECT_ROW_ID 201
+#define OBJECT_STORAGE_ID 202
+#define OBJECT_FORMAT 203
+#define OBJECT_PROTECTION_STATUS 204
+#define OBJECT_SIZE 205
+#define OBJECT_THUMB_FORMAT 206
+#define OBJECT_THUMB_SIZE 207
+#define OBJECT_THUMB_WIDTH 208
+#define OBJECT_THUMB_HEIGHT 209
+#define OBJECT_IMAGE_WIDTH 210
+#define OBJECT_IMAGE_HEIGHT 211
+#define OBJECT_IMAGE_DEPTH 212
+#define OBJECT_PARENT 213
+#define OBJECT_ASSOCIATION_TYPE 214
+#define OBJECT_ASSOCIATION_DESC 215
+#define OBJECT_SEQUENCE_NUMBER 216
+#define OBJECT_NAME 217
+#define OBJECT_DATE_CREATED 218
+#define OBJECT_DATE_MODIFIED 219
+#define OBJECT_KEYWORDS 220
MtpCursor::MtpCursor(MtpClient* client, int queryType, int deviceID,
int storageID, int objectID, int columnCount, int* columns)
@@ -252,11 +273,10 @@ fail:
bool MtpCursor::fillObject(CursorWindow* window, MtpDevice* device,
MtpObjectHandle objectID, int row) {
-LOGD("fillObject %d\n", objectID);
-
MtpObjectInfo* objectInfo = device->getObjectInfo(objectID);
if (!objectInfo)
return false;
+ // objectInfo->print();
if (!prepareRow(window)) {
delete objectInfo;
return false;
@@ -268,17 +288,89 @@ LOGD("fillObject %d\n", objectID);
if (!putLong(window, objectID, row, i))
goto fail;
break;
+ case OBJECT_STORAGE_ID:
+ if (!putLong(window, objectInfo->mStorageID, row, i))
+ goto fail;
+ break;
+ case OBJECT_FORMAT:
+ if (!putLong(window, objectInfo->mFormat, row, i))
+ goto fail;
+ break;
+ case OBJECT_PROTECTION_STATUS:
+ if (!putLong(window, objectInfo->mProtectionStatus, row, i))
+ goto fail;
+ break;
+ case OBJECT_SIZE:
+ if (!putLong(window, objectInfo->mCompressedSize, row, i))
+ goto fail;
+ break;
+ case OBJECT_THUMB_FORMAT:
+ if (!putLong(window, objectInfo->mThumbFormat, row, i))
+ goto fail;
+ break;
+ case OBJECT_THUMB_SIZE:
+ if (!putLong(window, objectInfo->mThumbCompressedSize, row, i))
+ goto fail;
+ break;
+ case OBJECT_THUMB_WIDTH:
+ if (!putLong(window, objectInfo->mThumbPixWidth, row, i))
+ goto fail;
+ break;
+ case OBJECT_THUMB_HEIGHT:
+ if (!putLong(window, objectInfo->mThumbPixHeight, row, i))
+ goto fail;
+ break;
+ case OBJECT_IMAGE_WIDTH:
+ if (!putLong(window, objectInfo->mImagePixWidth, row, i))
+ goto fail;
+ break;
+ case OBJECT_IMAGE_HEIGHT:
+ if (!putLong(window, objectInfo->mImagePixHeight, row, i))
+ goto fail;
+ break;
+ case OBJECT_IMAGE_DEPTH:
+ if (!putLong(window, objectInfo->mImagePixDepth, row, i))
+ goto fail;
+ break;
+ case OBJECT_PARENT:
+ if (!putLong(window, objectInfo->mParent, row, i))
+ goto fail;
+ break;
+ case OBJECT_ASSOCIATION_TYPE:
+ if (!putLong(window, objectInfo->mAssociationType, row, i))
+ goto fail;
+ break;
+ case OBJECT_ASSOCIATION_DESC:
+ if (!putLong(window, objectInfo->mAssociationDesc, row, i))
+ goto fail;
+ break;
+ case OBJECT_SEQUENCE_NUMBER:
+ if (!putLong(window, objectInfo->mSequenceNumber, row, i))
+ goto fail;
+ break;
case OBJECT_NAME:
if (!putString(window, objectInfo->mName, row, i))
goto fail;
break;
+ case OBJECT_DATE_CREATED:
+ if (!putLong(window, objectInfo->mDateCreated, row, i))
+ goto fail;
+ break;
+ case OBJECT_DATE_MODIFIED:
+ if (!putLong(window, objectInfo->mDateModified, row, i))
+ goto fail;
+ break;
+ case OBJECT_KEYWORDS:
+ if (!putString(window, objectInfo->mKeywords, row, i))
+ goto fail;
+ break;
default:
LOGE("fillStorage: unknown column %d\n", mColumns[i]);
goto fail;
}
}
- delete objectInfo;
+ delete objectInfo;
return true;
fail:
diff --git a/media/mtp/MtpObjectInfo.cpp b/media/mtp/MtpObjectInfo.cpp
index a0ee2b6..de0f54a 100644
--- a/media/mtp/MtpObjectInfo.cpp
+++ b/media/mtp/MtpObjectInfo.cpp
@@ -64,7 +64,7 @@ void MtpObjectInfo::read(MtpDataPacket& packet) {
mProtectionStatus = packet.getUInt16();
mCompressedSize = packet.getUInt32();
mThumbFormat = packet.getUInt16();
- mCompressedSize = packet.getUInt32();
+ mThumbCompressedSize = packet.getUInt32();
mThumbPixWidth = packet.getUInt32();
mThumbPixHeight = packet.getUInt32();
mImagePixWidth = packet.getUInt32();
@@ -92,6 +92,17 @@ void MtpObjectInfo::read(MtpDataPacket& packet) {
void MtpObjectInfo::print() {
LOGD("MtpObject Info %08X: %s\n", mHandle, mName);
+ LOGD(" mStorageID: %08X mFormat: %04X mProtectionStatus: %d\n",
+ mStorageID, mFormat, mProtectionStatus);
+ LOGD(" mCompressedSize: %d mThumbFormat: %04X mThumbCompressedSize: %d\n",
+ mCompressedSize, mFormat, mThumbCompressedSize);
+ LOGD(" mThumbPixWidth: %d mThumbPixHeight: %d\n", mThumbPixWidth, mThumbPixHeight);
+ LOGD(" mImagePixWidth: %d mImagePixHeight: %d mImagePixDepth: %d\n",
+ mImagePixWidth, mImagePixHeight, mImagePixDepth);
+ LOGD(" mParent: %08X mAssociationType: %04X mAssociationDesc: %04X\n",
+ mParent, mAssociationType, mAssociationDesc);
+ LOGD(" mSequenceNumber: %d mDateCreated: %d mDateModified: %d mKeywords: %s\n",
+ mSequenceNumber, mDateCreated, mDateModified, mKeywords);
}
} // namespace android