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