blob: d2c81cd27d9071340ff0b5a8c52038daa3b51719 [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
Artur Satayevafdb23a2019-12-10 17:47:53 +000019import android.compat.annotation.UnsupportedAppUsage;
Mathew Inwood57069dc2018-07-31 15:33:20 +010020
Nick Pelly038cabe2010-09-23 16:12:11 -070021/**
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.
Nick Pelly590b73b2010-10-12 13:00:50 -070025 *
Nick Pelly038cabe2010-09-23 16:12:11 -070026 * @hide
27 */
28public class ErrorCodes {
29
Mathew Inwood57069dc2018-07-31 15:33:20 +010030 @UnsupportedAppUsage
Nick Pelly038cabe2010-09-23 16:12:11 -070031 public static boolean isError(int code) {
32 if (code < 0) {
33 return true;
34 } else {
35 return false;
36 }
37 }
38
Jeff Hamilton68a5c9f2010-10-26 14:09:48 -050039 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";
Martijn Coenenea51a422011-06-06 12:32:07 +020063 case ERROR_NOT_SUPPORTED: return "NOT_SUPPORTED";
Jeff Hamilton68a5c9f2010-10-26 14:09:48 -050064 default: return "UNKNOWN ERROR";
65 }
66 }
67
Nick Pelly038cabe2010-09-23 16:12:11 -070068 public static final int SUCCESS = 0;
Nick Pelly590b73b2010-10-12 13:00:50 -070069
Nick Pelly038cabe2010-09-23 16:12:11 -070070 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;
Nick Pelly590b73b2010-10-12 13:00:50 -070087
Nick Pelly038cabe2010-09-23 16:12:11 -070088 public static final int ERROR_INSUFFICIENT_RESOURCES = -9;
Nick Pelly590b73b2010-10-12 13:00:50 -070089
Nick Pelly038cabe2010-09-23 16:12:11 -070090 public static final int ERROR_SOCKET_CREATION = -10;
Nick Pelly590b73b2010-10-12 13:00:50 -070091
Nick Pelly038cabe2010-09-23 16:12:11 -070092 public static final int ERROR_SOCKET_NOT_CONNECTED = -11;
Nick Pelly590b73b2010-10-12 13:00:50 -070093
Nick Pelly038cabe2010-09-23 16:12:11 -070094 public static final int ERROR_BUFFER_TO_SMALL = -12;
95
96 public static final int ERROR_SAP_USED = -13;
Nick Pelly590b73b2010-10-12 13:00:50 -070097
Nick Pelly038cabe2010-09-23 16:12:11 -070098 public static final int ERROR_SERVICE_NAME_USED = -14;
Nick Pelly590b73b2010-10-12 13:00:50 -070099
Nick Pelly038cabe2010-09-23 16:12:11 -0700100 public static final int ERROR_SOCKET_OPTIONS = -15;
Nick Pelly590b73b2010-10-12 13:00:50 -0700101
Nick Pelly038cabe2010-09-23 16:12:11 -0700102 public static final int ERROR_NFC_ON = -16;
Nick Pelly590b73b2010-10-12 13:00:50 -0700103
Nick Pelly038cabe2010-09-23 16:12:11 -0700104 public static final int ERROR_NOT_INITIALIZED = -17;
Nick Pelly590b73b2010-10-12 13:00:50 -0700105
Nick Pelly038cabe2010-09-23 16:12:11 -0700106 public static final int ERROR_SE_ALREADY_SELECTED = -18;
Nick Pelly590b73b2010-10-12 13:00:50 -0700107
Nick Pelly038cabe2010-09-23 16:12:11 -0700108 public static final int ERROR_SE_CONNECTED = -19;
Nick Pelly590b73b2010-10-12 13:00:50 -0700109
Nick Pelly038cabe2010-09-23 16:12:11 -0700110 public static final int ERROR_NO_SE_CONNECTED = -20;
Nick Pelly590b73b2010-10-12 13:00:50 -0700111
Martijn Coenenea51a422011-06-06 12:32:07 +0200112 public static final int ERROR_NOT_SUPPORTED = -21;
113
114}