Home | History | Annotate | Download | only in nfc
      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 /**
     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.
     23  *
     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 
     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";
     60             case ERROR_NOT_SUPPORTED: return "NOT_SUPPORTED";
     61             default: return "UNKNOWN ERROR";
     62         }
     63     }
     64 
     65     public static final int SUCCESS = 0;
     66 
     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;
     84 
     85     public static final int ERROR_INSUFFICIENT_RESOURCES = -9;
     86 
     87     public static final int ERROR_SOCKET_CREATION = -10;
     88 
     89     public static final int ERROR_SOCKET_NOT_CONNECTED = -11;
     90 
     91     public static final int ERROR_BUFFER_TO_SMALL = -12;
     92 
     93     public static final int ERROR_SAP_USED = -13;
     94 
     95     public static final int ERROR_SERVICE_NAME_USED = -14;
     96 
     97     public static final int ERROR_SOCKET_OPTIONS = -15;
     98 
     99     public static final int ERROR_NFC_ON = -16;
    100 
    101     public static final int ERROR_NOT_INITIALIZED = -17;
    102 
    103     public static final int ERROR_SE_ALREADY_SELECTED = -18;
    104 
    105     public static final int ERROR_SE_CONNECTED = -19;
    106 
    107     public static final int ERROR_NO_SE_CONNECTED = -20;
    108 
    109     public static final int ERROR_NOT_SUPPORTED = -21;
    110 
    111 }
    112