blob: 3adcdc378b7719aab6ab051a70256db4f9f50d83 [file] [log] [blame]
Nick Pelly038cabe2010-09-23 16:12:11 -07001/*
Nick Pelly590b73b2010-10-12 13:00:50 -07002 * Copyright (C) 2010, The Android Open Source Project
Nick Pelly038cabe2010-09-23 16:12:11 -07003 *
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 *
Nick Pelly590b73b2010-10-12 13:00:50 -07008 * http://www.apache.org/licenses/LICENSE-2.0
Nick Pelly038cabe2010-09-23 16:12:11 -07009 *
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
Nick Pelly590b73b2010-10-12 13:00:50 -070017package android.nfc;
Nick Pelly038cabe2010-09-23 16:12:11 -070018
19/**
20 * This class defines all the error codes that can be returned by the service
21 * and producing an exception on the application level. These are needed since
22 * binders does not support exceptions.
Nick Pelly590b73b2010-10-12 13:00:50 -070023 *
Nick Pelly038cabe2010-09-23 16:12:11 -070024 * @hide
25 */
26public class ErrorCodes {
27
28 public static boolean isError(int code) {
29 if (code < 0) {
30 return true;
31 } else {
32 return false;
33 }
34 }
35
Jeff Hamilton68a5c9f2010-10-26 14:09:48 -050036 public static String asString(int code) {
37 switch (code) {
38 case SUCCESS: return "SUCCESS";
39 case ERROR_IO: return "IO";
40 case ERROR_CANCELLED: return "CANCELLED";
41 case ERROR_TIMEOUT: return "TIMEOUT";
42 case ERROR_BUSY: return "BUSY";
43 case ERROR_CONNECT: return "CONNECT/DISCONNECT";
44// case ERROR_DISCONNECT: return "DISCONNECT";
45 case ERROR_READ: return "READ";
46 case ERROR_WRITE: return "WRITE";
47 case ERROR_INVALID_PARAM: return "INVALID_PARAM";
48 case ERROR_INSUFFICIENT_RESOURCES: return "INSUFFICIENT_RESOURCES";
49 case ERROR_SOCKET_CREATION: return "SOCKET_CREATION";
50 case ERROR_SOCKET_NOT_CONNECTED: return "SOCKET_NOT_CONNECTED";
51 case ERROR_BUFFER_TO_SMALL: return "BUFFER_TO_SMALL";
52 case ERROR_SAP_USED: return "SAP_USED";
53 case ERROR_SERVICE_NAME_USED: return "SERVICE_NAME_USED";
54 case ERROR_SOCKET_OPTIONS: return "SOCKET_OPTIONS";
55 case ERROR_NFC_ON: return "NFC_ON";
56 case ERROR_NOT_INITIALIZED: return "NOT_INITIALIZED";
57 case ERROR_SE_ALREADY_SELECTED: return "SE_ALREADY_SELECTED";
58 case ERROR_SE_CONNECTED: return "SE_CONNECTED";
59 case ERROR_NO_SE_CONNECTED: return "NO_SE_CONNECTED";
Martijn Coenenea51a422011-06-06 12:32:07 +020060 case ERROR_NOT_SUPPORTED: return "NOT_SUPPORTED";
Jeff Hamilton68a5c9f2010-10-26 14:09:48 -050061 default: return "UNKNOWN ERROR";
62 }
63 }
64
Nick Pelly038cabe2010-09-23 16:12:11 -070065 public static final int SUCCESS = 0;
Nick Pelly590b73b2010-10-12 13:00:50 -070066
Nick Pelly038cabe2010-09-23 16:12:11 -070067 public static final int ERROR_IO = -1;
68
69 public static final int ERROR_CANCELLED = -2;
70
71 public static final int ERROR_TIMEOUT = -3;
72
73 public static final int ERROR_BUSY = -4;
74
75 public static final int ERROR_CONNECT = -5;
76
77 public static final int ERROR_DISCONNECT = -5;
78
79 public static final int ERROR_READ = -6;
80
81 public static final int ERROR_WRITE = -7;
82
83 public static final int ERROR_INVALID_PARAM = -8;
Nick Pelly590b73b2010-10-12 13:00:50 -070084
Nick Pelly038cabe2010-09-23 16:12:11 -070085 public static final int ERROR_INSUFFICIENT_RESOURCES = -9;
Nick Pelly590b73b2010-10-12 13:00:50 -070086
Nick Pelly038cabe2010-09-23 16:12:11 -070087 public static final int ERROR_SOCKET_CREATION = -10;
Nick Pelly590b73b2010-10-12 13:00:50 -070088
Nick Pelly038cabe2010-09-23 16:12:11 -070089 public static final int ERROR_SOCKET_NOT_CONNECTED = -11;
Nick Pelly590b73b2010-10-12 13:00:50 -070090
Nick Pelly038cabe2010-09-23 16:12:11 -070091 public static final int ERROR_BUFFER_TO_SMALL = -12;
92
93 public static final int ERROR_SAP_USED = -13;
Nick Pelly590b73b2010-10-12 13:00:50 -070094
Nick Pelly038cabe2010-09-23 16:12:11 -070095 public static final int ERROR_SERVICE_NAME_USED = -14;
Nick Pelly590b73b2010-10-12 13:00:50 -070096
Nick Pelly038cabe2010-09-23 16:12:11 -070097 public static final int ERROR_SOCKET_OPTIONS = -15;
Nick Pelly590b73b2010-10-12 13:00:50 -070098
Nick Pelly038cabe2010-09-23 16:12:11 -070099 public static final int ERROR_NFC_ON = -16;
Nick Pelly590b73b2010-10-12 13:00:50 -0700100
Nick Pelly038cabe2010-09-23 16:12:11 -0700101 public static final int ERROR_NOT_INITIALIZED = -17;
Nick Pelly590b73b2010-10-12 13:00:50 -0700102
Nick Pelly038cabe2010-09-23 16:12:11 -0700103 public static final int ERROR_SE_ALREADY_SELECTED = -18;
Nick Pelly590b73b2010-10-12 13:00:50 -0700104
Nick Pelly038cabe2010-09-23 16:12:11 -0700105 public static final int ERROR_SE_CONNECTED = -19;
Nick Pelly590b73b2010-10-12 13:00:50 -0700106
Nick Pelly038cabe2010-09-23 16:12:11 -0700107 public static final int ERROR_NO_SE_CONNECTED = -20;
Nick Pelly590b73b2010-10-12 13:00:50 -0700108
Martijn Coenenea51a422011-06-06 12:32:07 +0200109 public static final int ERROR_NOT_SUPPORTED = -21;
110
111}