のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

FAILED BINDER TRANSACTION

    636 void signalExceptionForError(JNIEnv* env, jobject obj, status_t err,
    637         bool canThrowRemoteException)
    638 {
    639     switch (err) {
    640         case UNKNOWN_ERROR:
    641             jniThrowException(env, "java/lang/RuntimeException", "Unknown error");
    642             break;
    643         case NO_MEMORY:
    644             jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
    645             break;
    646         case INVALID_OPERATION:
    647             jniThrowException(env, "java/lang/UnsupportedOperationException", NULL);
    648             break;
    649         case BAD_VALUE:
    650             jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
    651             break;
    652         case BAD_INDEX:
    653             jniThrowException(env, "java/lang/IndexOutOfBoundsException", NULL);
    654             break;
    655         case BAD_TYPE:
    656             jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
    657             break;
    658         case NAME_NOT_FOUND:
    659             jniThrowException(env, "java/util/NoSuchElementException", NULL);
    660             break;
    661         case PERMISSION_DENIED:
    662             jniThrowException(env, "java/lang/SecurityException", NULL);
    663             break;
    664         case NOT_ENOUGH_DATA:
    665             jniThrowException(env, "android/os/ParcelFormatException", "Not enough data");
    666             break;
    667         case NO_INIT:
    668             jniThrowException(env, "java/lang/RuntimeException", "Not initialized");
    669             break;
    670         case ALREADY_EXISTS:
    671             jniThrowException(env, "java/lang/RuntimeException", "Item already exists");
    672             break;
    673         case DEAD_OBJECT:
    674             // DeadObjectException is a checked exception, only throw from certain methods.
    675             jniThrowException(env, canThrowRemoteException
    676                     ? "android/os/DeadObjectException"
    677                             : "java/lang/RuntimeException", NULL);
    678             break;
    679         case UNKNOWN_TRANSACTION:
    680             jniThrowException(env, "java/lang/RuntimeException", "Unknown transaction code");
    681             break;
    682         case FAILED_TRANSACTION:
    683             ALOGE("!!! FAILED BINDER TRANSACTION !!!");
    684             // TransactionTooLargeException is a checked exception, only throw from certain methods.
    685             // FIXME: Transaction too large is the most common reason for FAILED_TRANSACTION
    686             //        but it is not the only one.  The Binder driver can return BR_FAILED_REPLY
    687             //        for other reasons also, such as if the transaction is malformed or
    688             //        refers to an FD that has been closed.  We should change the driver
    689             //        to enable us to distinguish these cases in the future.
    690             jniThrowException(env, canThrowRemoteException
    691                     ? "android/os/TransactionTooLargeException"
    692                             : "java/lang/RuntimeException", NULL);
    693             break;
    694         case FDS_NOT_ALLOWED:
    695             jniThrowException(env, "java/lang/RuntimeException",
    696                     "Not allowed to write file descriptors here");
    697             break;
    698         case -EBADF:
    699             jniThrowException(env, "java/lang/RuntimeException",
    700                     "Bad file descriptor");
    701             break;
    702         case -ENFILE:
    703             jniThrowException(env, "java/lang/RuntimeException",
    704                     "File table overflow");
    705             break;
    706         case -EMFILE:
    707             jniThrowException(env, "java/lang/RuntimeException",
    708                     "Too many open files");
    709             break;
    710         case -EFBIG:
    711             jniThrowException(env, "java/lang/RuntimeException",
    712                     "File too large");
    713             break;
    714         case -ENOSPC:
    715             jniThrowException(env, "java/lang/RuntimeException",
    716                     "No space left on device");
    717             break;
    718         case -ESPIPE:
    719             jniThrowException(env, "java/lang/RuntimeException",
    720                     "Illegal seek");
    721             break;
    722         case -EROFS:
    723             jniThrowException(env, "java/lang/RuntimeException",
    724                     "Read-only file system");
    725             break;
    726         case -EMLINK:
    727             jniThrowException(env, "java/lang/RuntimeException",
    728                     "Too many links");
    729             break;
    730         default:
    731             ALOGE("Unknown binder error code. 0x%" PRIx32, err);
    732             String8 msg;
    733             msg.appendFormat("Unknown binder error code. 0x%" PRIx32, err);
    734             // RemoteException is a checked exception, only throw from certain methods.
    735             jniThrowException(env, canThrowRemoteException
    736                     ? "android/os/RemoteException" : "java/lang/RuntimeException", msg.string());
    737             break;
    738     }
    739 }