Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 1 | /* |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 2 | * Copyright (C) 2010, The Android Open Source Project |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 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 | * |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 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 | |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 17 | package android.nfc; |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 18 | |
Artur Satayev | afdb23a | 2019-12-10 17:47:53 +0000 | [diff] [blame] | 19 | import android.compat.annotation.UnsupportedAppUsage; |
Mathew Inwood | 57069dc | 2018-07-31 15:33:20 +0100 | [diff] [blame] | 20 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 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. |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 25 | * |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 26 | * @hide |
| 27 | */ |
| 28 | public class ErrorCodes { |
| 29 | |
Mathew Inwood | 57069dc | 2018-07-31 15:33:20 +0100 | [diff] [blame] | 30 | @UnsupportedAppUsage |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 31 | public static boolean isError(int code) { |
| 32 | if (code < 0) { |
| 33 | return true; |
| 34 | } else { |
| 35 | return false; |
| 36 | } |
| 37 | } |
| 38 | |
Jeff Hamilton | 68a5c9f | 2010-10-26 14:09:48 -0500 | [diff] [blame] | 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"; |
Martijn Coenen | ea51a42 | 2011-06-06 12:32:07 +0200 | [diff] [blame] | 63 | case ERROR_NOT_SUPPORTED: return "NOT_SUPPORTED"; |
Jeff Hamilton | 68a5c9f | 2010-10-26 14:09:48 -0500 | [diff] [blame] | 64 | default: return "UNKNOWN ERROR"; |
| 65 | } |
| 66 | } |
| 67 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 68 | public static final int SUCCESS = 0; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 69 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 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; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 87 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 88 | public static final int ERROR_INSUFFICIENT_RESOURCES = -9; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 89 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 90 | public static final int ERROR_SOCKET_CREATION = -10; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 91 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 92 | public static final int ERROR_SOCKET_NOT_CONNECTED = -11; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 93 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 94 | public static final int ERROR_BUFFER_TO_SMALL = -12; |
| 95 | |
| 96 | public static final int ERROR_SAP_USED = -13; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 97 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 98 | public static final int ERROR_SERVICE_NAME_USED = -14; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 99 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 100 | public static final int ERROR_SOCKET_OPTIONS = -15; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 101 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 102 | public static final int ERROR_NFC_ON = -16; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 103 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 104 | public static final int ERROR_NOT_INITIALIZED = -17; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 105 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 106 | public static final int ERROR_SE_ALREADY_SELECTED = -18; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 107 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 108 | public static final int ERROR_SE_CONNECTED = -19; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 109 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 110 | public static final int ERROR_NO_SE_CONNECTED = -20; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 111 | |
Martijn Coenen | ea51a42 | 2011-06-06 12:32:07 +0200 | [diff] [blame] | 112 | public static final int ERROR_NOT_SUPPORTED = -21; |
| 113 | |
| 114 | } |