Ejemplo n.º 1
0
  @DSSafe(DSCat.IPC_CALLBACK)
  @DSGenerator(
      tool_name = "Doppelganger",
      tool_version = "2.0",
      generated_on = "2013-12-30 12:58:54.915 -0500",
      hash_original_method = "584E0C361321C2DCD1B11D8CE97AF6DF",
      hash_generated_method = "CAF5DAE398870082803BAF9A29AA061A")
  @Override
  public void handleMessage(Message msg) {
    AsyncResult ar;

    byte data[];

    boolean isRecordLoadResponse = false;

    try {
      switch (msg.what) {
        case EVENT_RUIM_READY:
          onRuimReady();
          break;

        case EVENT_RADIO_OFF_OR_NOT_AVAILABLE:
          onRadioOffOrNotAvailable();
          break;

        case EVENT_GET_DEVICE_IDENTITY_DONE:
          Log.d(LOG_TAG, "Event EVENT_GET_DEVICE_IDENTITY_DONE Received");
          break;

          /* IO events */
        case EVENT_GET_IMSI_DONE:
          isRecordLoadResponse = true;

          ar = (AsyncResult) msg.obj;
          if (ar.exception != null) {
            Log.e(LOG_TAG, "Exception querying IMSI, Exception:" + ar.exception);
            break;
          }

          mImsi = (String) ar.result;

          // IMSI (MCC+MNC+MSIN) is at least 6 digits, but not more
          // than 15 (and usually 15).
          if (mImsi != null && (mImsi.length() < 6 || mImsi.length() > 15)) {
            Log.e(LOG_TAG, "invalid IMSI " + mImsi);
            mImsi = null;
          }

          Log.d(LOG_TAG, "IMSI: " + mImsi.substring(0, 6) + "xxxxxxxxx");

          String operatorNumeric = getRUIMOperatorNumeric();
          if (operatorNumeric != null) {
            if (operatorNumeric.length() <= 6) {
              MccTable.updateMccMncConfiguration(phone, operatorNumeric);
            }
          }
          break;

        case EVENT_GET_CDMA_SUBSCRIPTION_DONE:
          ar = (AsyncResult) msg.obj;
          String localTemp[] = (String[]) ar.result;
          if (ar.exception != null) {
            break;
          }

          mMyMobileNumber = localTemp[0];
          mMin2Min1 = localTemp[3];
          mPrlVersion = localTemp[4];

          Log.d(LOG_TAG, "MDN: " + mMyMobileNumber + " MIN: " + mMin2Min1);

          break;

        case EVENT_GET_ICCID_DONE:
          isRecordLoadResponse = true;

          ar = (AsyncResult) msg.obj;
          data = (byte[]) ar.result;

          if (ar.exception != null) {
            break;
          }

          iccid = IccUtils.bcdToString(data, 0, data.length);

          Log.d(LOG_TAG, "iccid: " + iccid);

          break;

        case EVENT_UPDATE_DONE:
          ar = (AsyncResult) msg.obj;
          if (ar.exception != null) {
            Log.i(LOG_TAG, "RuimRecords update failed", ar.exception);
          }
          break;

        case EVENT_GET_ALL_SMS_DONE:
        case EVENT_MARK_SMS_READ_DONE:
        case EVENT_SMS_ON_RUIM:
        case EVENT_GET_SMS_DONE:
          Log.w(LOG_TAG, "Event not supported: " + msg.what);
          break;

          // TODO: probably EF_CST should be read instead
        case EVENT_GET_SST_DONE:
          Log.d(LOG_TAG, "Event EVENT_GET_SST_DONE Received");
          break;

        case EVENT_RUIM_REFRESH:
          isRecordLoadResponse = false;
          ar = (AsyncResult) msg.obj;
          if (ar.exception == null) {
            handleRuimRefresh((int[]) (ar.result));
          }
          break;
      }
    } catch (RuntimeException exc) {
      // I don't want these exceptions to be fatal
      Log.w(LOG_TAG, "Exception parsing RUIM record", exc);
    } finally {
      // Count up record load responses even if they are fails
      if (isRecordLoadResponse) {
        onRecordLoaded();
      }
    }
  }