BluetoothShare.java revision d6641e4a7bb22833e1c07cb3af7989835fa7e16d
1/* 2 * Copyright (c) 2008-2009, Motorola, Inc. 3 * 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * - Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * 12 * - Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * - Neither the name of the Motorola, Inc. nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33package com.android.bluetooth.opp; 34 35import android.provider.BaseColumns; 36import android.net.Uri; 37 38/** 39 * Exposes constants used to interact with the Bluetooth Share manager's content 40 * provider. 41 * @hide 42 */ 43 44public final class BluetoothShare implements BaseColumns { 45 private BluetoothShare() { 46 } 47 48 /** 49 * The permission to access the Bluetooth Share Manager 50 */ 51 public static final String PERMISSION_ACCESS = "android.permission.ACCESS_BLUETOOTH_SHARE"; 52 53 /** 54 * The content:// URI for the data table in the provider 55 */ 56 public static final Uri CONTENT_URI = Uri.parse("content://com.android.bluetooth.opp/btopp"); 57 58 /** 59 * Broadcast Action: this is sent by the Bluetooth Share component to 60 * transfer complete. The request detail could be retrieved by app * as _ID 61 * is specified in the intent's data. 62 */ 63 public static final String TRANSFER_COMPLETED_ACTION = "android.btopp.intent.action.TRANSFER_COMPLETE"; 64 65 /** 66 * This is sent by the Bluetooth Share component to indicate there is an 67 * incoming file need user to confirm. 68 */ 69 public static final String INCOMING_FILE_CONFIRMATION_REQUEST_ACTION = "android.btopp.intent.action.INCOMING_FILE_NOTIFICATION"; 70 71 /** 72 * The name of the column containing the URI of the file being 73 * sent/received. 74 * <P> 75 * Type: TEXT 76 * </P> 77 * <P> 78 * Owner can Init/Read 79 * </P> 80 */ 81 public static final String URI = "uri"; 82 83 /** 84 * The name of the column containing the filename that the incoming file 85 * request recommends. When possible, the Bluetooth Share manager will 86 * attempt to use this filename, or a variation, as the actual name for the 87 * file. 88 * <P> 89 * Type: TEXT 90 * </P> 91 * <P> 92 * Owner can Init/Read 93 * </P> 94 */ 95 public static final String FILENAME_HINT = "hint"; 96 97 /** 98 * The name of the column containing the filename where the shared file was 99 * actually stored. 100 * <P> 101 * Type: TEXT 102 * </P> 103 * <P> 104 * Owner can Read 105 * </P> 106 */ 107 public static final String _DATA = "_data"; 108 109 /** 110 * The name of the column containing the MIME type of the shared file. 111 * <P> 112 * Type: TEXT 113 * </P> 114 * <P> 115 * Owner can Init/Read 116 * </P> 117 */ 118 public static final String MIMETYPE = "mimetype"; 119 120 /** 121 * The name of the column containing the direction (Inbound/Outbound) of the 122 * transfer. See the DIRECTION_* constants for a list of legal values. 123 * <P> 124 * Type: INTEGER 125 * </P> 126 * <P> 127 * Owner can Init/Read 128 * </P> 129 */ 130 public static final String DIRECTION = "direction"; 131 132 /** 133 * The name of the column containing Bluetooth Device Address that the 134 * transfer is associated with. 135 * <P> 136 * Type: TEXT 137 * </P> 138 * <P> 139 * Owner can Init/Read 140 * </P> 141 */ 142 public static final String DESTINATION = "destination"; 143 144 /** 145 * The name of the column containing the flags that controls whether the 146 * transfer is displayed by the UI. See the VISIBILITY_* constants for a 147 * list of legal values. 148 * <P> 149 * Type: INTEGER 150 * </P> 151 * <P> 152 * Owner can Init/Read/Write 153 * </P> 154 */ 155 public static final String VISIBILITY = "visibility"; 156 157 /** 158 * The name of the column containing the current user confirmation state of 159 * the transfer. Applications can write to this to confirm the transfer. the 160 * USER_CONFIRMATION_* constants for a list of legal values. 161 * <P> 162 * Type: INTEGER 163 * </P> 164 * <P> 165 * Owner can Init/Read/Write 166 * </P> 167 */ 168 public static final String USER_CONFIRMATION = "confirm"; 169 170 /** 171 * The name of the column containing the current status of the transfer. 172 * Applications can read this to follow the progress of each download. See 173 * the STATUS_* constants for a list of legal values. 174 * <P> 175 * Type: INTEGER 176 * </P> 177 * <P> 178 * Owner can Read 179 * </P> 180 */ 181 public static final String STATUS = "status"; 182 183 /** 184 * The name of the column containing the total size of the file being 185 * transferred. 186 * <P> 187 * Type: INTEGER 188 * </P> 189 * <P> 190 * Owner can Read 191 * </P> 192 */ 193 public static final String TOTAL_BYTES = "total_bytes"; 194 195 /** 196 * The name of the column containing the size of the part of the file that 197 * has been transferred so far. 198 * <P> 199 * Type: INTEGER 200 * </P> 201 * <P> 202 * Owner can Read 203 * </P> 204 */ 205 public static final String CURRENT_BYTES = "current_bytes"; 206 207 /** 208 * The name of the column containing the timestamp when the transfer is 209 * initialized. 210 * <P> 211 * Type: INTEGER 212 * </P> 213 * <P> 214 * Owner can Read 215 * </P> 216 */ 217 public static final String TIMESTAMP = "timestamp"; 218 219 /** 220 * This transfer is outbound, e.g. share file to other device. 221 */ 222 public static final int DIRECTION_OUTBOUND = 0; 223 224 /** 225 * This transfer is inbound, e.g. receive file from other device. 226 */ 227 public static final int DIRECTION_INBOUND = 1; 228 229 /** 230 * This transfer is waiting for user confirmation. 231 */ 232 public static final int USER_CONFIRMATION_PENDING = 0; 233 234 /** 235 * This transfer is confirmed by user. 236 */ 237 public static final int USER_CONFIRMATION_CONFIRMED = 1; 238 239 /** 240 * This transfer is auto-confirmed per previous user confirmation. 241 */ 242 public static final int USER_CONFIRMATION_AUTO_CONFIRMED = 2; 243 244 /** 245 * This transfer is denied by user. 246 */ 247 public static final int USER_CONFIRMATION_DENIED = 3; 248 249 /** 250 * This transfer is timeout before user action. 251 */ 252 public static final int USER_CONFIRMATION_TIMEOUT = 4; 253 254 /** 255 * This transfer is visible and shows in the notifications while in progress 256 * and after completion. 257 */ 258 public static final int VISIBILITY_VISIBLE = 0; 259 260 /** 261 * This transfer doesn't show in the notifications. 262 */ 263 public static final int VISIBILITY_HIDDEN = 1; 264 265 /** 266 * Returns whether the status is informational (i.e. 1xx). 267 */ 268 public static boolean isStatusInformational(int status) { 269 return (status >= 100 && status < 200); 270 } 271 272 /** 273 * Returns whether the transfer is suspended. (i.e. whether the transfer 274 * won't complete without some action from outside the transfer manager). 275 */ 276 public static boolean isStatusSuspended(int status) { 277 return (status == STATUS_PENDING); 278 } 279 280 /** 281 * Returns whether the status is a success (i.e. 2xx). 282 */ 283 public static boolean isStatusSuccess(int status) { 284 return (status >= 200 && status < 300); 285 } 286 287 /** 288 * Returns whether the status is an error (i.e. 4xx or 5xx). 289 */ 290 public static boolean isStatusError(int status) { 291 return (status >= 400 && status < 600); 292 } 293 294 /** 295 * Returns whether the status is a client error (i.e. 4xx). 296 */ 297 public static boolean isStatusClientError(int status) { 298 return (status >= 400 && status < 500); 299 } 300 301 /** 302 * Returns whether the status is a server error (i.e. 5xx). 303 */ 304 public static boolean isStatusServerError(int status) { 305 return (status >= 500 && status < 600); 306 } 307 308 /** 309 * Returns whether the transfer has completed (either with success or 310 * error). 311 */ 312 public static boolean isStatusCompleted(int status) { 313 return (status >= 200 && status < 300) || (status >= 400 && status < 600); 314 } 315 316 /** 317 * This transfer hasn't stated yet 318 */ 319 public static final int STATUS_PENDING = 190; 320 321 /** 322 * This transfer has started 323 */ 324 public static final int STATUS_RUNNING = 192; 325 326 /** 327 * This transfer has successfully completed. Warning: there might be other 328 * status values that indicate success in the future. Use isSucccess() to 329 * capture the entire category. 330 */ 331 public static final int STATUS_SUCCESS = 200; 332 333 /** 334 * This request couldn't be parsed. This is also used when processing 335 * requests with unknown/unsupported URI schemes. 336 */ 337 public static final int STATUS_BAD_REQUEST = 400; 338 339 /** 340 * This transfer is forbidden by target device. 341 */ 342 public static final int STATUS_FORBIDDEN = 403; 343 344 /** 345 * This transfer can't be performed because the content cannot be handled. 346 */ 347 public static final int STATUS_NOT_ACCEPTABLE = 406; 348 349 /** 350 * This transfer cannot be performed because the length cannot be determined 351 * accurately. This is the code for the HTTP error "Length Required", which 352 * is typically used when making requests that require a content length but 353 * don't have one, and it is also used in the client when a response is 354 * received whose length cannot be determined accurately (therefore making 355 * it impossible to know when a transfer completes). 356 */ 357 public static final int STATUS_LENGTH_REQUIRED = 411; 358 359 /** 360 * This transfer was interrupted and cannot be resumed. This is the code for 361 * the OBEX error "Precondition Failed", and it is also used in situations 362 * where the client doesn't have an ETag at all. 363 */ 364 public static final int STATUS_PRECONDITION_FAILED = 412; 365 366 /** 367 * This transfer was canceled 368 */ 369 public static final int STATUS_CANCELED = 490; 370 371 /** 372 * This transfer has completed with an error. Warning: there will be other 373 * status values that indicate errors in the future. Use isStatusError() to 374 * capture the entire category. 375 */ 376 public static final int STATUS_UNKNOWN_ERROR = 491; 377 378 /** 379 * This transfer couldn't be completed because of a storage issue. 380 * Typically, that's because the file system is missing or full. 381 */ 382 public static final int STATUS_FILE_ERROR = 492; 383 384 /** 385 * This transfer couldn't be completed because of no sdcard. 386 */ 387 public static final int STATUS_ERROR_NO_SDCARD = 493; 388 389 /** 390 * This transfer couldn't be completed because of sdcard full. 391 */ 392 public static final int STATUS_ERROR_SDCARD_FULL = 494; 393 394 /** 395 * This transfer couldn't be completed because of an unspecified un-handled 396 * OBEX code. 397 */ 398 public static final int STATUS_UNHANDLED_OBEX_CODE = 495; 399 400 /** 401 * This transfer couldn't be completed because of an error receiving or 402 * processing data at the OBEX level. 403 */ 404 public static final int STATUS_OBEX_DATA_ERROR = 496; 405 406 /** 407 * This transfer couldn't be completed because of an error when establishing 408 * connection. 409 */ 410 public static final int STATUS_CONNECTION_ERROR = 497; 411 412} 413