Пример #1
0
  /** Called from GSMPhone.handleMessage; not a Handler subclass */
  public void handleMessage(Message msg) {
    AsyncResult ar;

    switch (msg.what) {
      case EVENT_SET_COMPLETE:
        ar = (AsyncResult) (msg.obj);

        onSetComplete(ar);
        break;

      case EVENT_SET_CFF_COMPLETE:
        ar = (AsyncResult) (msg.obj);

        /*
         * msg.arg1 = 1 means to set unconditional voice call forwarding
         * msg.arg2 = 1 means to enable voice call forwarding
         */
        if ((ar.exception == null) && (msg.arg1 == 1)) {
          boolean cffEnabled = (msg.arg2 == 1);
          if (phone.mSIMRecords != null) {
            phone.mSIMRecords.setVoiceCallForwardingFlag(1, cffEnabled);
            phone.setCallForwardingPreference(cffEnabled);
          } else {
            Log.w(LOG_TAG, "setVoiceCallForwardingFlag aborted. sim records is null.");
          }
        }

        onSetComplete(ar);
        break;

      case EVENT_GET_CLIR_COMPLETE:
        ar = (AsyncResult) (msg.obj);
        onGetClirComplete(ar);
        break;

      case EVENT_QUERY_CF_COMPLETE:
        ar = (AsyncResult) (msg.obj);
        onQueryCfComplete(ar);
        break;

      case EVENT_QUERY_COMPLETE:
        ar = (AsyncResult) (msg.obj);
        onQueryComplete(ar);
        break;

      case EVENT_USSD_COMPLETE:
        ar = (AsyncResult) (msg.obj);

        if (ar.exception != null) {
          state = State.FAILED;
          message = getErrorMessage(ar);

          phone.onMMIDone(this);
        }

        // Note that unlike most everything else, the USSD complete
        // response does not complete this MMI code...we wait for
        // an unsolicited USSD "Notify" or "Request".
        // The matching up of this is done in GSMPhone.

        break;

      case EVENT_USSD_CANCEL_COMPLETE:
        phone.onMMIDone(this);
        break;
    }
  }