private void handleResult(AsyncResult ar) {
    if (ar.exception == null) {
      if (DBG) log("handleResult: success!");

      if (mState == EntryState.ES_PUK) {
        mScrollView.setVisibility(View.VISIBLE);
        mIccPUKPanel.setVisibility(View.GONE);
      }
      // TODO: show success feedback
      showConfirmation();

      mHandler.postDelayed(
          new Runnable() {
            public void run() {
              finish();
            }
          },
          3000);

    } else if (ar.exception instanceof CommandException
    /*  && ((CommandException)ar.exception).getCommandError() ==
    CommandException.Error.PASSWORD_INCORRECT */ ) {
      if (mState == EntryState.ES_PIN) {
        if (DBG) log("handleResult: pin failed!");
        mOldPin.getText().clear();
        mBadPinError.setVisibility(View.VISIBLE);
        CommandException ce = (CommandException) ar.exception;
        if (ce.getCommandError() == CommandException.Error.SIM_PUK2) {
          if (DBG) log("handleResult: puk requested!");
          mState = EntryState.ES_PUK;
          displayPUKAlert();
          mScrollView.setVisibility(View.GONE);
          mIccPUKPanel.setVisibility(View.VISIBLE);
          mPUKCode.requestFocus();
        }
      } else if (mState == EntryState.ES_PUK) {
        // should really check to see if the error is CommandException.PASSWORD_INCORRECT...
        if (DBG) log("handleResult: puk2 failed!");
        displayPUKAlert();
        mPUKCode.getText().clear();
        mPUKCode.requestFocus();
      }
    }
  }
  public int sendOemRilRequestRaw(byte[] request, byte[] response) {
    int returnValue = 0;
    // TODO: Check Permissions of the application

    try {
      AsyncResult result = (AsyncResult) sendRequest(CMD_INVOKE_OEM_RIL_REQUEST, request);
      if (result.exception == null) {
        returnValue = 0;
        if (result.result != null) {
          byte[] responseData = (byte[]) (result.result);
          if (responseData.length > response.length) {
            Log.w(
                LOG_TAG,
                "Buffer to copy response too small: Response length is "
                    + responseData.length
                    + "bytes. Buffer Size is "
                    + response.length
                    + "bytes.");
          }
          System.arraycopy(responseData, 0, response, 0, responseData.length);
          returnValue = responseData.length;
        }

      } else {
        CommandException ex = (CommandException) result.exception;
        returnValue = ex.getCommandError().ordinal();
        if (returnValue > 0) returnValue *= -1;
      }
    } catch (RuntimeException e) {
      Log.w(LOG_TAG, "sendOemRilRequestRaw: Runtime Exception");
      returnValue = (CommandException.Error.GENERIC_FAILURE.ordinal());
      if (returnValue > 0) returnValue *= -1;
    }

    return returnValue;
  }