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 | |
| 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 Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 23 | * |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 24 | * @hide |
| 25 | */ |
| 26 | public 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 Hamilton | 68a5c9f | 2010-10-26 14:09:48 -0500 | [diff] [blame] | 36 | 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 Coenen | ea51a42 | 2011-06-06 12:32:07 +0200 | [diff] [blame] | 60 | case ERROR_NOT_SUPPORTED: return "NOT_SUPPORTED"; |
Jeff Hamilton | 68a5c9f | 2010-10-26 14:09:48 -0500 | [diff] [blame] | 61 | default: return "UNKNOWN ERROR"; |
| 62 | } |
| 63 | } |
| 64 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 65 | public static final int SUCCESS = 0; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 66 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 67 | 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 Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 84 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 85 | public static final int ERROR_INSUFFICIENT_RESOURCES = -9; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 86 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 87 | public static final int ERROR_SOCKET_CREATION = -10; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 88 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 89 | public static final int ERROR_SOCKET_NOT_CONNECTED = -11; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 90 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 91 | public static final int ERROR_BUFFER_TO_SMALL = -12; |
| 92 | |
| 93 | public static final int ERROR_SAP_USED = -13; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 94 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 95 | public static final int ERROR_SERVICE_NAME_USED = -14; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 96 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 97 | public static final int ERROR_SOCKET_OPTIONS = -15; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 98 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 99 | public static final int ERROR_NFC_ON = -16; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 100 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 101 | public static final int ERROR_NOT_INITIALIZED = -17; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 102 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 103 | public static final int ERROR_SE_ALREADY_SELECTED = -18; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 104 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 105 | public static final int ERROR_SE_CONNECTED = -19; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 106 | |
Nick Pelly | 038cabe | 2010-09-23 16:12:11 -0700 | [diff] [blame] | 107 | public static final int ERROR_NO_SE_CONNECTED = -20; |
Nick Pelly | 590b73b | 2010-10-12 13:00:50 -0700 | [diff] [blame] | 108 | |
Martijn Coenen | ea51a42 | 2011-06-06 12:32:07 +0200 | [diff] [blame] | 109 | public static final int ERROR_NOT_SUPPORTED = -21; |
| 110 | |
| 111 | } |