BluetoothShare.java revision 09e9cba205af60b3f42e7a4d891a7d1392e1f2a5
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 40 * Share manager's content 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 * Broadcast Action: this is sent by the Device Picker component to indicate 73 * an BT device already selected. 74 */ 75 76 public static final String BLUETOOTH_DEVICE_SELECTED_ACTION = "android.btopp.intent.action.DEVICE_SELECTED"; 77 78 public static final String BLUETOOTH_DEVICE_PICKER_ACTION = "android.btopp.intent.action.DEVICE_SELECTING"; 79 80 /** 81 * The name of the column containing the URI of the file being 82 * sent/received. 83 * <P> 84 * Type: TEXT 85 * </P> 86 * <P> 87 * Owner can Init/Read 88 * </P> 89 */ 90 public static final String URI = "uri"; 91 92 /** 93 * The name of the column containing the filename that the incoming file 94 * request recommends. When possible, the Bluetooth Share manager will 95 * attempt to use this filename, or a variation, as the actual name for the 96 * file. 97 * <P> 98 * Type: TEXT 99 * </P> 100 * <P> 101 * Owner can Init/Read 102 * </P> 103 */ 104 public static final String FILENAME_HINT = "hint"; 105 106 /** 107 * The name of the column containing the filename where the shared file was 108 * actually stored. 109 * <P> 110 * Type: TEXT 111 * </P> 112 * <P> 113 * Owner can Read 114 * </P> 115 */ 116 public static final String _DATA = "_data"; 117 118 /** 119 * The name of the column containing the MIME type of the shared file. 120 * <P> 121 * Type: TEXT 122 * </P> 123 * <P> 124 * Owner can Init/Read 125 * </P> 126 */ 127 public static final String MIMETYPE = "mimetype"; 128 129 /** 130 * The name of the column containing the direction (Inbound/Outbound) of the 131 * transfer. See the DIRECTION_* constants for a list of legal values. 132 * <P> 133 * Type: INTEGER 134 * </P> 135 * <P> 136 * Owner can Init/Read 137 * </P> 138 */ 139 public static final String DIRECTION = "direction"; 140 141 /** 142 * The name of the column containing Bluetooth Device Address that the 143 * transfer is associated with. 144 * <P> 145 * Type: TEXT 146 * </P> 147 * <P> 148 * Owner can Init/Read 149 * </P> 150 */ 151 public static final String DESTINATION = "destination"; 152 153 /** 154 * The name of the column containing the flags that controls whether the 155 * transfer is displayed by the UI. See the VISIBILITY_* constants for a 156 * list of legal values. 157 * <P> 158 * Type: INTEGER 159 * </P> 160 * <P> 161 * Owner can Init/Read/Write 162 * </P> 163 */ 164 public static final String VISIBILITY = "visibility"; 165 166 /** 167 * The name of the column containing the current user confirmation state of 168 * the transfer. Applications can write to this to confirm the transfer. the 169 * USER_CONFIRMATION_* constants for a list of legal values. 170 * <P> 171 * Type: INTEGER 172 * </P> 173 * <P> 174 * Owner can Init/Read/Write 175 * </P> 176 */ 177 public static final String USER_CONFIRMATION = "confirm"; 178 179 /** 180 * The name of the column containing the current status of the transfer. 181 * Applications can read this to follow the progress of each download. See 182 * the STATUS_* constants for a list of legal values. 183 * <P> 184 * Type: INTEGER 185 * </P> 186 * <P> 187 * Owner can Read 188 * </P> 189 */ 190 public static final String STATUS = "status"; 191 192 /** 193 * The name of the column containing the total size of the file being 194 * transferred. 195 * <P> 196 * Type: INTEGER 197 * </P> 198 * <P> 199 * Owner can Read 200 * </P> 201 */ 202 public static final String TOTAL_BYTES = "total_bytes"; 203 204 /** 205 * The name of the column containing the size of the part of the file that 206 * has been transferred so far. 207 * <P> 208 * Type: INTEGER 209 * </P> 210 * <P> 211 * Owner can Read 212 * </P> 213 */ 214 public static final String CURRENT_BYTES = "current_bytes"; 215 216 /** 217 * The name of the column containing the timestamp when the transfer is 218 * initialized. 219 * <P> 220 * Type: INTEGER 221 * </P> 222 * <P> 223 * Owner can Read 224 * </P> 225 */ 226 public static final String TIMESTAMP = "timestamp"; 227 228 /** 229 * This transfer is outbound, e.g. share file to other device. 230 */ 231 public static final int DIRECTION_OUTBOUND = 0; 232 233 /** 234 * This transfer is inbound, e.g. receive file from other device. 235 */ 236 public static final int DIRECTION_INBOUND = 1; 237 238 /** 239 * This transfer is waiting for user confirmation. 240 */ 241 public static final int USER_CONFIRMATION_PENDING = 0; 242 243 /** 244 * This transfer is confirmed by user. 245 */ 246 public static final int USER_CONFIRMATION_CONFIRMED = 1; 247 248 /** 249 * This transfer is auto-confirmed per previous user confirmation. 250 */ 251 public static final int USER_CONFIRMATION_AUTO_CONFIRMED = 2; 252 253 /** 254 * This transfer is denied by user. 255 */ 256 public static final int USER_CONFIRMATION_DENIED = 3; 257 258 /** 259 * This transfer is timeout before user action. 260 */ 261 public static final int USER_CONFIRMATION_TIMEOUT = 4; 262 263 /** 264 * This transfer is visible and shows in the notifications while in progress 265 * and after completion. 266 */ 267 public static final int VISIBILITY_VISIBLE = 0; 268 269 /** 270 * This transfer doesn't show in the notifications. 271 */ 272 public static final int VISIBILITY_HIDDEN = 1; 273 274 /** 275 * Returns whether the status is informational (i.e. 1xx). 276 */ 277 public static boolean isStatusInformational(int status) { 278 return (status >= 100 && status < 200); 279 } 280 281 /** 282 * Returns whether the transfer is suspended. (i.e. whether the transfer 283 * won't complete without some action from outside the transfer manager). 284 */ 285 public static boolean isStatusSuspended(int status) { 286 return (status == STATUS_PENDING); 287 } 288 289 /** 290 * Returns whether the status is a success (i.e. 2xx). 291 */ 292 public static boolean isStatusSuccess(int status) { 293 return (status >= 200 && status < 300); 294 } 295 296 /** 297 * Returns whether the status is an error (i.e. 4xx or 5xx). 298 */ 299 public static boolean isStatusError(int status) { 300 return (status >= 400 && status < 600); 301 } 302 303 /** 304 * Returns whether the status is a client error (i.e. 4xx). 305 */ 306 public static boolean isStatusClientError(int status) { 307 return (status >= 400 && status < 500); 308 } 309 310 /** 311 * Returns whether the status is a server error (i.e. 5xx). 312 */ 313 public static boolean isStatusServerError(int status) { 314 return (status >= 500 && status < 600); 315 } 316 317 /** 318 * Returns whether the transfer has completed (either with success or 319 * error). 320 */ 321 public static boolean isStatusCompleted(int status) { 322 return (status >= 200 && status < 300) || (status >= 400 && status < 600); 323 } 324 325 /** 326 * This transfer hasn't stated yet 327 */ 328 public static final int STATUS_PENDING = 190; 329 330 /** 331 * This transfer has started 332 */ 333 public static final int STATUS_RUNNING = 192; 334 335 /** 336 * This transfer has successfully completed. Warning: there might be other 337 * status values that indicate success in the future. Use isSucccess() to 338 * capture the entire category. 339 */ 340 public static final int STATUS_SUCCESS = 200; 341 342 /** 343 * This request couldn't be parsed. This is also used when processing 344 * requests with unknown/unsupported URI schemes. 345 */ 346 public static final int STATUS_BAD_REQUEST = 400; 347 348 /** 349 * This transfer is forbidden by target device. 350 */ 351 public static final int STATUS_FORBIDDEN = 403; 352 353 /** 354 * This transfer can't be performed because the content cannot be handled. 355 */ 356 public static final int STATUS_NOT_ACCEPTABLE = 406; 357 358 /** 359 * This transfer cannot be performed because the length cannot be determined 360 * accurately. This is the code for the HTTP error "Length Required", which 361 * is typically used when making requests that require a content length but 362 * don't have one, and it is also used in the client when a response is 363 * received whose length cannot be determined accurately (therefore making 364 * it impossible to know when a transfer completes). 365 */ 366 public static final int STATUS_LENGTH_REQUIRED = 411; 367 368 /** 369 * This transfer was interrupted and cannot be resumed. This is the code for 370 * the OBEX error "Precondition Failed", and it is also used in situations 371 * where the client doesn't have an ETag at all. 372 */ 373 public static final int STATUS_PRECONDITION_FAILED = 412; 374 375 /** 376 * This transfer was canceled 377 */ 378 public static final int STATUS_CANCELED = 490; 379 380 /** 381 * This transfer has completed with an error. Warning: there will be other 382 * status values that indicate errors in the future. Use isStatusError() to 383 * capture the entire category. 384 */ 385 public static final int STATUS_UNKNOWN_ERROR = 491; 386 387 /** 388 * This transfer couldn't be completed because of a storage issue. 389 * Typically, that's because the file system is missing or full. 390 */ 391 public static final int STATUS_FILE_ERROR = 492; 392 393 /** 394 * This transfer couldn't be completed because of no sdcard. 395 */ 396 public static final int STATUS_ERROR_NO_SDCARD = 493; 397 398 /** 399 * This transfer couldn't be completed because of sdcard full. 400 */ 401 public static final int STATUS_ERROR_SDCARD_FULL = 494; 402 403 /** 404 * This transfer couldn't be completed because of an unspecified un-handled 405 * OBEX code. 406 */ 407 public static final int STATUS_UNHANDLED_OBEX_CODE = 495; 408 409 /** 410 * This transfer couldn't be completed because of an error receiving or 411 * processing data at the OBEX level. 412 */ 413 public static final int STATUS_OBEX_DATA_ERROR = 496; 414 415 /** 416 * This transfer couldn't be completed because of an error when establishing 417 * connection. 418 */ 419 public static final int STATUS_CONNECTION_ERROR = 497; 420 421} 422