Ejemplo n.º 1
0
  /** Broadcast the results from the query to all registered callback objects. */
  private void broadcastQueryResults(AsyncResult ar) {
    // reset the state.
    synchronized (mCallbacks) {
      mState = QUERY_READY;

      // see if we need to do any work.
      if (ar == null) {
        if (DBG) {
          log("AsyncResult is null.");
        }
        return;
      }

      // TODO: we may need greater accuracy here, but for now, just a
      // simple status integer will suffice.
      int exception = (ar.exception == null) ? QUERY_OK : QUERY_EXCEPTION;
      if (DBG) {
        log("AsyncResult has exception " + exception);
      }

      // Make the calls to all the registered callbacks.
      for (int i = (mCallbacks.beginBroadcast() - 1); i >= 0; i--) {
        INetworkQueryServiceCallback cb = mCallbacks.getBroadcastItem(i);
        if (DBG) {
          log("broadcasting results to " + cb.getClass().toString());
        }
        try {
          cb.onQueryComplete((ArrayList<OperatorInfo>) ar.result, exception);
        } catch (RemoteException e) {
          log("e = " + e);
        }
      }

      // finish up.
      mCallbacks.finishBroadcast();
    }
  }
Ejemplo n.º 2
0
 /** Stops a query with a INetworkQueryServiceCallback object as a token. */
 public void stopNetworkQuery(INetworkQueryServiceCallback cb) {
   // currently we just unregister the callback, since there is
   // no way to tell the RIL to terminate the query request.
   // This means that the RIL may still be busy after the stop
   // request was made, but the state tracking logic ensures
   // that the delay will only last for 1 request even with
   // repeated button presses in the NetworkSetting activity.
   if (cb != null) {
     synchronized (mCallbacks) {
       if (DBG) {
         log("unregistering callback " + cb.getClass().toString());
       }
       mCallbacks.unregister(cb);
     }
   }
 }
Ejemplo n.º 3
0
        /**
         * Starts a query with a INetworkQueryServiceCallback object if one has not been started
         * yet. Ignore the new query request if the query has been started already. Either way,
         * place the callback object in the queue to be notified upon request completion.
         */
        public void startNetworkQuery(INetworkQueryServiceCallback cb) {
          if (cb != null) {
            // register the callback to the list of callbacks.
            synchronized (mCallbacks) {
              mCallbacks.register(cb);
              if (DBG) {
                log("registering callback " + cb.getClass().toString());
              }

              switch (mState) {
                case QUERY_READY:
                  // TODO: we may want to install a timeout here in case we
                  // do not get a timely response from the RIL.
                  /// M: support gemini phone
                  if (FeatureOption.MTK_GEMINI_SUPPORT) {
                    int msgType = getSimMsgType(mSimId);
                    log("startNetworkQuery---msgType=" + msgType);
                    mGeminiPhone.getAvailableNetworksGemini(
                        mHandler.obtainMessage(msgType), mSimId);
                  } else {
                    mPhone.getAvailableNetworks(
                        mHandler.obtainMessage(EVENT_NETWORK_SCAN_COMPLETED));
                  }
                  mState = QUERY_IS_RUNNING;
                  if (DBG) {
                    log("starting new query");
                  }
                  break;

                  // do nothing if we're currently busy.
                case QUERY_IS_RUNNING:
                  if (DBG) {
                    log("query already in progress");
                  }
                  break;
                default:
                  break;
              }
            }
          }
        }