Пример #1
0
  private String retrieve() throws Exception {
    // we need always send the DIM request to get the Ptn Encrypted & isAllowFallback arguments.
    dimProxy =
        (JsonDimProxy)
            ServerProxyFactory.getInstance()
                .createDimProxy(null, CommManager.getInstance().getComm(), this, null);
    dimProxy.requestGetToken();

    synchronized (mutex_overall) {
      mutex_overall.wait(60 * 1000);
    }

    dimProxy.cancel();

    retrievePTN();

    notifyDimFinish();

    if (ptn != null && ptn.length() > 0) {
      return ptn;
    } else if (this.errorMessage != null && this.errorMessage.length() > 0) {
      throw new IllegalStateException(this.errorMessage);
    }

    return ptn;
  }
Пример #2
0
  private void retrievePTN() {
    if (retryIntervals != null && retryIntervals.length > 0) {
      TnTelephonyManager.getInstance().startMMSAtBackground(destination, token);

      while (retryCount < retryIntervals.length) {
        if (isCancelled) break;

        synchronized (mutex_get_ptn) {
          try {
            writeLog(
                "DimProvider - retry time:"
                    + retryCount
                    + ", interval:"
                    + retryIntervals[retryCount]
                    + "ms");
            mutex_get_ptn.wait(retryIntervals[retryCount]);
          } catch (InterruptedException e) {
            Logger.log(this.getClass().getName(), e);
          }
        }

        if (isCancelled) break;

        writeLog("DimProvider - retry time:" + retryCount + ", start request PTN !!!");

        dimProxy =
            (JsonDimProxy)
                ServerProxyFactory.getInstance()
                    .createDimProxy(null, CommManager.getInstance().getComm(), this, null);
        dimProxy.requestGetPtn(token, isPtnEncrypted, (byte) 0, 30000);

        synchronized (mutex_retry) {
          try {
            writeLog(
                "DimProvider - retry time:" + retryCount + ", request work wait:" + timeout + "ms");
            mutex_retry.wait(timeout);
          } catch (InterruptedException e) {
            Logger.log(this.getClass().getName(), e);
          }
        }

        dimProxy.cancel();

        writeLog("DimProvider - retry time:" + retryCount + ", request work wait, wake up now!!!");

        retryCount++;
      }
    }
    notifyDimFinish();
  }