FileDocCategorySizeDatePackage
NetworkQueryService.javaAPI DocAndroid 1.5 API7952Wed May 06 22:42:46 BST 2009com.android.phone

NetworkQueryService

public class NetworkQueryService extends android.app.Service
Service code used to assist in querying the network for service availability.

Fields Summary
private static final String
LOG_TAG
private static final boolean
DBG
private static final int
EVENT_NETWORK_SCAN_COMPLETED
private static final int
QUERY_READY
private static final int
QUERY_IS_RUNNING
public static final int
QUERY_OK
public static final int
QUERY_EXCEPTION
private int
mState
state of the query service
private com.android.internal.telephony.Phone
mPhone
local handle to the phone object
private final android.os.IBinder
mLocalBinder
android.os.Handler
mHandler
Local handler to receive the network query compete callback from the RIL.
final android.os.RemoteCallbackList
mCallbacks
List of callback objects, also used to synchronize access to itself and to changes in state.
private final INetworkQueryService.Stub
mBinder
Implementation of the INetworkQueryService interface.
Constructors Summary
Methods Summary
private voidbroadcastQueryResults(android.os.AsyncResult ar)
Broadcast the results from the query to all registered callback objects.

        // 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<NetworkInfo>) ar.result, exception);
                } catch (RemoteException e) {
                }
            }
            
            // finish up.
            mCallbacks.finishBroadcast();
        }
    
private static voidlog(java.lang.String msg)

        Log.d(LOG_TAG, msg);
    
public android.os.IBinderonBind(android.content.Intent intent)
Handle the bind request.

        // TODO: Currently, return only the LocalBinder instance.  If we
        // end up requiring support for a remote binder, we will need to 
        // return mBinder as well, depending upon the intent.
        if (DBG) log("binding service implementation");
        return mLocalBinder;
    
public voidonCreate()

    
    
       
        mState = QUERY_READY;
        mPhone = PhoneFactory.getDefaultPhone();
    
public voidonStart(android.content.Intent intent, int startId)
Required for service implementation.