Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 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 | |
| 17 | package android.provider; |
| 18 | |
| 19 | import android.content.ContentUris; |
| 20 | import android.net.Uri; |
| 21 | import android.util.Log; |
| 22 | |
| 23 | |
| 24 | /** |
| 25 | * The MTP provider supports accessing content on MTP and PTP devices. |
| 26 | * @hide |
| 27 | */ |
| 28 | public final class Mtp |
| 29 | { |
| 30 | private final static String TAG = "Mtp"; |
| 31 | |
| 32 | public static final String AUTHORITY = "mtp"; |
| 33 | |
| 34 | private static final String CONTENT_AUTHORITY_SLASH = "content://" + AUTHORITY + "/"; |
| 35 | private static final String CONTENT_AUTHORITY_DEVICE_SLASH = "content://" + AUTHORITY + "/device/"; |
| 36 | |
Mike Lockwood | 2837eef | 2010-08-31 16:25:12 -0400 | [diff] [blame] | 37 | |
| 38 | /** |
| 39 | * Broadcast Action: A broadcast to indicate the end of an MTP session with the host. |
| 40 | * This broadcast is only sent if MTP activity has modified the media database during the |
| 41 | * most recent MTP session |
| 42 | */ |
| 43 | public static final String ACTION_MTP_SESSION_END = "android.provider.action.MTP_SESSION_END"; |
| 44 | |
Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 45 | /** |
| 46 | * Contains list of all MTP/PTP devices |
| 47 | */ |
| 48 | public static final class Device implements BaseColumns { |
| 49 | |
| 50 | public static final Uri CONTENT_URI = Uri.parse(CONTENT_AUTHORITY_SLASH + "device"); |
| 51 | |
Mike Lockwood | 74f094f | 2010-06-12 21:31:36 -0400 | [diff] [blame] | 52 | public static Uri getContentUri(int deviceID) { |
| 53 | return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID); |
| 54 | } |
| 55 | |
Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 56 | /** |
| 57 | * The manufacturer of the device |
| 58 | * <P>Type: TEXT</P> |
| 59 | */ |
| 60 | public static final String MANUFACTURER = "manufacturer"; |
| 61 | |
| 62 | /** |
| 63 | * The model name of the device |
| 64 | * <P>Type: TEXT</P> |
| 65 | */ |
| 66 | public static final String MODEL = "model"; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Contains list of storage units for an MTP/PTP device |
| 71 | */ |
| 72 | public static final class Storage implements BaseColumns { |
| 73 | |
| 74 | public static Uri getContentUri(int deviceID) { |
| 75 | return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID + "/storage"); |
| 76 | } |
| 77 | |
Mike Lockwood | e0a89f6 | 2010-06-11 16:34:52 -0400 | [diff] [blame] | 78 | public static Uri getContentUri(int deviceID, int storageID) { |
| 79 | return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID + "/storage/" + storageID); |
| 80 | } |
| 81 | |
Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 82 | /** |
| 83 | * Storage unit identifier |
| 84 | * <P>Type: TEXT</P> |
| 85 | */ |
| 86 | public static final String IDENTIFIER = "identifier"; |
| 87 | |
| 88 | /** |
| 89 | * Storage unit description |
| 90 | * <P>Type: TEXT</P> |
| 91 | */ |
| 92 | public static final String DESCRIPTION = "description"; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Contains list of objects on an MTP/PTP device |
| 97 | */ |
| 98 | public static final class Object implements BaseColumns { |
| 99 | |
Mike Lockwood | f724eed | 2010-06-08 07:33:14 -0400 | [diff] [blame] | 100 | public static Uri getContentUri(int deviceID, int objectID) { |
| 101 | return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID |
| 102 | + "/object/" + objectID); |
| 103 | } |
| 104 | |
Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 105 | public static Uri getContentUriForObjectChildren(int deviceID, int objectID) { |
| 106 | return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID |
| 107 | + "/object/" + objectID + "/child"); |
| 108 | } |
| 109 | |
| 110 | public static Uri getContentUriForStorageChildren(int deviceID, int storageID) { |
| 111 | return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID |
| 112 | + "/storage/" + storageID + "/child"); |
| 113 | } |
| 114 | |
| 115 | /** |
Mike Lockwood | f724eed | 2010-06-08 07:33:14 -0400 | [diff] [blame] | 116 | * The following columns correspond to the fields in the ObjectInfo dataset |
| 117 | * as described in the MTP specification. |
| 118 | */ |
| 119 | |
| 120 | /** |
| 121 | * The ID of the storage unit containing the object. |
| 122 | * <P>Type: INTEGER</P> |
| 123 | */ |
| 124 | public static final String STORAGE_ID = "storage_id"; |
| 125 | |
| 126 | /** |
| 127 | * The object's format. Can be one of the FORMAT_* symbols below, |
| 128 | * or any of the valid MTP object formats as defined in the MTP specification. |
| 129 | * <P>Type: INTEGER</P> |
| 130 | */ |
| 131 | public static final String FORMAT = "format"; |
| 132 | |
| 133 | /** |
| 134 | * The protection status of the object. See the PROTECTION_STATUS_*symbols below. |
| 135 | * <P>Type: INTEGER</P> |
| 136 | */ |
| 137 | public static final String PROTECTION_STATUS = "protection_status"; |
| 138 | |
| 139 | /** |
| 140 | * The size of the object in bytes. |
| 141 | * <P>Type: INTEGER</P> |
| 142 | */ |
| 143 | public static final String SIZE = "size"; |
| 144 | |
| 145 | /** |
| 146 | * The object's thumbnail format. Can be one of the FORMAT_* symbols below, |
| 147 | * or any of the valid MTP object formats as defined in the MTP specification. |
| 148 | * <P>Type: INTEGER</P> |
| 149 | */ |
| 150 | public static final String THUMB_FORMAT = "format"; |
| 151 | |
| 152 | /** |
| 153 | * The size of the object's thumbnail in bytes. |
| 154 | * <P>Type: INTEGER</P> |
| 155 | */ |
| 156 | public static final String THUMB_SIZE = "thumb_size"; |
| 157 | |
| 158 | /** |
| 159 | * The width of the object's thumbnail in pixels. |
| 160 | * <P>Type: INTEGER</P> |
| 161 | */ |
| 162 | public static final String THUMB_WIDTH = "thumb_width"; |
| 163 | |
| 164 | /** |
| 165 | * The height of the object's thumbnail in pixels. |
| 166 | * <P>Type: INTEGER</P> |
| 167 | */ |
| 168 | public static final String THUMB_HEIGHT = "thumb_height"; |
| 169 | |
| 170 | /** |
Mike Lockwood | dda5686 | 2010-06-10 16:34:20 -0400 | [diff] [blame] | 171 | * The object's thumbnail. |
| 172 | * <P>Type: BLOB</P> |
| 173 | */ |
| 174 | public static final String THUMB = "thumb"; |
| 175 | |
| 176 | /** |
Mike Lockwood | f724eed | 2010-06-08 07:33:14 -0400 | [diff] [blame] | 177 | * The width of the object in pixels. |
| 178 | * <P>Type: INTEGER</P> |
| 179 | */ |
| 180 | public static final String IMAGE_WIDTH = "image_width"; |
| 181 | |
| 182 | /** |
| 183 | * The height of the object in pixels. |
| 184 | * <P>Type: INTEGER</P> |
| 185 | */ |
| 186 | public static final String IMAGE_HEIGHT = "image_height"; |
| 187 | |
| 188 | /** |
| 189 | * The depth of the object in bits per pixel. |
| 190 | * <P>Type: INTEGER</P> |
| 191 | */ |
| 192 | public static final String IMAGE_DEPTH = "image_depth"; |
| 193 | |
| 194 | /** |
| 195 | * The ID of the object's parent, or zero if the object |
| 196 | * is in the root of its storage unit. |
| 197 | * <P>Type: INTEGER</P> |
| 198 | */ |
| 199 | public static final String PARENT = "parent"; |
| 200 | |
| 201 | /** |
| 202 | * The association type for a container object. |
| 203 | * For folders this is typically {@link #ASSOCIATION_TYPE_GENERIC_FOLDER} |
| 204 | * <P>Type: INTEGER</P> |
| 205 | */ |
| 206 | public static final String ASSOCIATION_TYPE = "association_type"; |
| 207 | |
| 208 | /** |
| 209 | * Contains additional information about container objects. |
| 210 | * <P>Type: INTEGER</P> |
| 211 | */ |
| 212 | public static final String ASSOCIATION_DESC = "association_desc"; |
| 213 | |
| 214 | /** |
| 215 | * The sequence number of the object, typically used for an association |
| 216 | * containing images taken in sequence. |
| 217 | * <P>Type: INTEGER</P> |
| 218 | */ |
| 219 | public static final String SEQUENCE_NUMBER = "sequence_number"; |
| 220 | |
| 221 | /** |
| 222 | * The name of the object. |
Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 223 | * <P>Type: TEXT</P> |
| 224 | */ |
| 225 | public static final String NAME = "name"; |
Mike Lockwood | f724eed | 2010-06-08 07:33:14 -0400 | [diff] [blame] | 226 | |
| 227 | /** |
| 228 | * The date the object was created, in seconds since January 1, 1970. |
| 229 | * <P>Type: INTEGER</P> |
| 230 | */ |
| 231 | public static final String DATE_CREATED = "date_created"; |
| 232 | |
| 233 | /** |
| 234 | * The date the object was last modified, in seconds since January 1, 1970. |
| 235 | * <P>Type: INTEGER</P> |
| 236 | */ |
| 237 | public static final String DATE_MODIFIED = "date_modified"; |
| 238 | |
| 239 | /** |
| 240 | * A list of keywords associated with an object, separated by spaces. |
| 241 | * <P>Type: TEXT</P> |
| 242 | */ |
| 243 | public static final String KEYWORDS = "keywords"; |
Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 244 | } |
| 245 | } |