OSDN Git Service

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