Debian Codegraph @

core/java/android/nfc/ErrorCodes.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2010, The Android Open Source Project
3 *
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 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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
17 package android.nfc;
18
19 import android.compat.annotation.UnsupportedAppUsage;
20
21 /**
22 * This class defines all the error codes that can be returned by the service
23 * and producing an exception on the application level. These are needed since
24 * binders does not support exceptions.
25 *
26 * @hide
27 */
28 public class ErrorCodes {
29
30 @UnsupportedAppUsage
31 public static boolean isError(int code) {
32 if (code < 0) {
33 return true;
34 } else {
35 return false;
36 }
37 }
38
39 public static String asString(int code) {
40 switch (code) {
41 case SUCCESS: return "SUCCESS";
42 case ERROR_IO: return "IO";
43 case ERROR_CANCELLED: return "CANCELLED";
44 case ERROR_TIMEOUT: return "TIMEOUT";
45 case ERROR_BUSY: return "BUSY";
46 case ERROR_CONNECT: return "CONNECT/DISCONNECT";
47 // case ERROR_DISCONNECT: return "DISCONNECT";
48 case ERROR_READ: return "READ";
49 case ERROR_WRITE: return "WRITE";
50 case ERROR_INVALID_PARAM: return "INVALID_PARAM";
51 case ERROR_INSUFFICIENT_RESOURCES: return "INSUFFICIENT_RESOURCES";
52 case ERROR_SOCKET_CREATION: return "SOCKET_CREATION";
53 case ERROR_SOCKET_NOT_CONNECTED: return "SOCKET_NOT_CONNECTED";
54 case ERROR_BUFFER_TO_SMALL: return "BUFFER_TO_SMALL";
55 case ERROR_SAP_USED: return "SAP_USED";
56 case ERROR_SERVICE_NAME_USED: return "SERVICE_NAME_USED";
57 case ERROR_SOCKET_OPTIONS: return "SOCKET_OPTIONS";
58 case ERROR_NFC_ON: return "NFC_ON";
59 case ERROR_NOT_INITIALIZED: return "NOT_INITIALIZED";
60 case ERROR_SE_ALREADY_SELECTED: return "SE_ALREADY_SELECTED";
61 case ERROR_SE_CONNECTED: return "SE_CONNECTED";
62 case ERROR_NO_SE_CONNECTED: return "NO_SE_CONNECTED";
63 case ERROR_NOT_SUPPORTED: return "NOT_SUPPORTED";
64 default: return "UNKNOWN ERROR";
65 }
66 }
67
68 public static final int SUCCESS = 0;
69
70 public static final int ERROR_IO = -1;
71
72 public static final int ERROR_CANCELLED = -2;
73
74 public static final int ERROR_TIMEOUT = -3;
75
76 public static final int ERROR_BUSY = -4;
77
78 public static final int ERROR_CONNECT = -5;
79
80 public static final int ERROR_DISCONNECT = -5;
81
82 public static final int ERROR_READ = -6;
83
84 public static final int ERROR_WRITE = -7;
85
86 public static final int ERROR_INVALID_PARAM = -8;
87
88 public static final int ERROR_INSUFFICIENT_RESOURCES = -9;
89
90 public static final int ERROR_SOCKET_CREATION = -10;
91
92 public static final int ERROR_SOCKET_NOT_CONNECTED = -11;
93
94 public static final int ERROR_BUFFER_TO_SMALL = -12;
95
96 public static final int ERROR_SAP_USED = -13;
97
98 public static final int ERROR_SERVICE_NAME_USED = -14;
99
100 public static final int ERROR_SOCKET_OPTIONS = -15;
101
102 public static final int ERROR_NFC_ON = -16;
103
104 public static final int ERROR_NOT_INITIALIZED = -17;
105
106 public static final int ERROR_SE_ALREADY_SELECTED = -18;
107
108 public static final int ERROR_SE_CONNECTED = -19;
109
110 public static final int ERROR_NO_SE_CONNECTED = -20;
111
112 public static final int ERROR_NOT_SUPPORTED = -21;
113
114 }