FileDocCategorySizeDatePackage
BaseCommands.javaAPI DocAndroid 1.5 API11288Wed May 06 22:42:02 BST 2009com.android.internal.telephony.gsm

BaseCommands

public abstract class BaseCommands extends Object implements CommandsInterface
{@hide}

Fields Summary
static final String
LOG_TAG
protected android.content.Context
mContext
protected RadioState
mState
protected Object
mStateMonitor
protected android.os.RegistrantList
mRadioStateChangedRegistrants
protected android.os.RegistrantList
mOnRegistrants
protected android.os.RegistrantList
mAvailRegistrants
protected android.os.RegistrantList
mOffOrNotAvailRegistrants
protected android.os.RegistrantList
mNotAvailRegistrants
protected android.os.RegistrantList
mSIMReadyRegistrants
protected android.os.RegistrantList
mSIMLockedRegistrants
protected android.os.RegistrantList
mCallStateRegistrants
protected android.os.RegistrantList
mNetworkStateRegistrants
protected android.os.RegistrantList
mPDPRegistrants
protected android.os.Registrant
mSMSRegistrant
protected android.os.Registrant
mNITZTimeRegistrant
protected android.os.Registrant
mSignalStrengthRegistrant
protected android.os.Registrant
mUSSDRegistrant
protected android.os.Registrant
mSmsOnSimRegistrant
protected android.os.Registrant
mSmsStatusRegistrant
Registrant for handling SMS Status Reports
protected android.os.Registrant
mSsnRegistrant
Registrant for handling Supplementary Service Notifications
protected android.os.Registrant
mStkSessionEndRegistrant
protected android.os.Registrant
mStkProCmdRegistrant
protected android.os.Registrant
mStkEventRegistrant
protected android.os.Registrant
mStkCallSetUpRegistrant
protected android.os.Registrant
mSimSmsFullRegistrant
Registrant for handling SIM SMS storage full messages
protected android.os.Registrant
mSimRefreshRegistrant
Registrant for handling SIM Refresh notifications
protected android.os.Registrant
mRingRegistrant
Registrant for handling RING notifications
protected android.os.Registrant
mRestrictedStateRegistrant
Registrant for handling RESTRICTED STATE changed notification
Constructors Summary
public BaseCommands(android.content.Context context)


       
        mContext = context;  // May be null (if so we won't log statistics)
    
Methods Summary
public RadioStategetRadioState()

        return mState;
    
protected voidonRadioAvailable()

    
public voidregisterForAvailable(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);

        synchronized (mStateMonitor) {
            mAvailRegistrants.add(r);

            if (mState.isAvailable()) {
                r.notifyRegistrant(new AsyncResult(null, null, null));
            }
        }
    
public voidregisterForCallStateChanged(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);

        mCallStateRegistrants.add(r);
    
public voidregisterForNetworkStateChanged(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);

        mNetworkStateRegistrants.add(r);
    
public voidregisterForNotAvailable(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);

        synchronized (mStateMonitor) {
            mNotAvailRegistrants.add(r);

            if (!mState.isAvailable()) {
                r.notifyRegistrant(new AsyncResult(null, null, null));
            }
        }
    
public voidregisterForOffOrNotAvailable(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);

        synchronized (mStateMonitor) {
            mOffOrNotAvailRegistrants.add(r);

            if (mState == RadioState.RADIO_OFF || !mState.isAvailable()) {
                r.notifyRegistrant(new AsyncResult(null, null, null));
            }
        }
    
public voidregisterForOn(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);

        synchronized (mStateMonitor) {
            mOnRegistrants.add(r);

            if (mState.isOn()) {
                r.notifyRegistrant(new AsyncResult(null, null, null));
            }
        }
    
public voidregisterForPDPStateChanged(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);

        mPDPRegistrants.add(r);
    
public voidregisterForRadioStateChanged(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);

        synchronized (mStateMonitor) {
            mRadioStateChangedRegistrants.add(r);
            r.notifyRegistrant();
        }
    
public voidregisterForSIMLockedOrAbsent(android.os.Handler h, int what, java.lang.Object obj)

        Registrant r = new Registrant (h, what, obj);

        synchronized (mStateMonitor) {
            mSIMLockedRegistrants.add(r);

            if (mState == RadioState.SIM_LOCKED_OR_ABSENT) {
                r.notifyRegistrant(new AsyncResult(null, null, null));
            }
        }
    
public voidregisterForSIMReady(android.os.Handler h, int what, java.lang.Object obj)
Any transition into SIM_READY

        Registrant r = new Registrant (h, what, obj);

        synchronized (mStateMonitor) {
            mSIMReadyRegistrants.add(r);

            if (mState.isSIMReady()) {
                r.notifyRegistrant(new AsyncResult(null, null, null));
            }
        }
    
public voidsetOnCallRing(android.os.Handler h, int what, java.lang.Object obj)

        mRingRegistrant = new Registrant (h, what, obj);
    
public voidsetOnNITZTime(android.os.Handler h, int what, java.lang.Object obj)

        mNITZTimeRegistrant = new Registrant (h, what, obj);
    
public voidsetOnNewSMS(android.os.Handler h, int what, java.lang.Object obj)

        mSMSRegistrant = new Registrant (h, what, obj);
    
public voidsetOnRestrictedStateChanged(android.os.Handler h, int what, java.lang.Object obj)

        mRestrictedStateRegistrant = new Registrant (h, what, obj);
    
public voidsetOnSignalStrengthUpdate(android.os.Handler h, int what, java.lang.Object obj)

        mSignalStrengthRegistrant = new Registrant (h, what, obj);
    
public voidsetOnSimRefresh(android.os.Handler h, int what, java.lang.Object obj)

        mSimRefreshRegistrant = new Registrant (h, what, obj);
    
public voidsetOnSimSmsFull(android.os.Handler h, int what, java.lang.Object obj)

        mSimSmsFullRegistrant = new Registrant (h, what, obj);
    
public voidsetOnSmsOnSim(android.os.Handler h, int what, java.lang.Object obj)

        mSmsOnSimRegistrant = new Registrant (h, what, obj);
    
public voidsetOnSmsStatus(android.os.Handler h, int what, java.lang.Object obj)

        mSmsStatusRegistrant = new Registrant (h, what, obj);
    
public voidsetOnStkCallSetUp(android.os.Handler h, int what, java.lang.Object obj)

        mStkCallSetUpRegistrant = new Registrant (h, what, obj);
    
public voidsetOnStkEvent(android.os.Handler h, int what, java.lang.Object obj)

        mStkEventRegistrant = new Registrant (h, what, obj);
    
public voidsetOnStkProactiveCmd(android.os.Handler h, int what, java.lang.Object obj)

        mStkProCmdRegistrant = new Registrant (h, what, obj);
    
public voidsetOnStkSessionEnd(android.os.Handler h, int what, java.lang.Object obj)

        mStkSessionEndRegistrant = new Registrant (h, what, obj);
    
public voidsetOnSuppServiceNotification(android.os.Handler h, int what, java.lang.Object obj)

        mSsnRegistrant = new Registrant (h, what, obj);
    
public voidsetOnUSSD(android.os.Handler h, int what, java.lang.Object obj)

        mUSSDRegistrant = new Registrant (h, what, obj);
    
protected voidsetRadioState(RadioState newState)
Store new RadioState and send notification based on the changes This function is called only by RIL.java when receiving unsolicited RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED RadioState has 5 values : RADIO_OFF, RADIO_UNAVAILABLE, SIM_NOT_READY, SIM_LOCKED_OR_ABSENT, and SIM_READY.

param
newState new RadioState decoded from RIL_UNSOL_RADIO_STATE_CHANGED

        RadioState oldState;
        
        synchronized (mStateMonitor) {
            if (Config.LOGV) {
                Log.v(LOG_TAG, "setRadioState old: " + mState
                    + " new " + newState);
            }
        
            oldState = mState;
            mState = newState;
            
            if (oldState == mState) {
                // no state transition
                return;
            }

            if (mContext != null &&
                newState == RadioState.RADIO_UNAVAILABLE &&
                oldState != RadioState.RADIO_OFF) {
                Checkin.updateStats(mContext.getContentResolver(),
                        Checkin.Stats.Tag.PHONE_RADIO_RESETS, 1, 0.0);
            }

            mRadioStateChangedRegistrants.notifyRegistrants();

            if (mState.isAvailable() && !oldState.isAvailable()) {
                Log.d(LOG_TAG,"Notifying: radio available");
                mAvailRegistrants.notifyRegistrants();
                onRadioAvailable();
            }

            if (!mState.isAvailable() && oldState.isAvailable()) {
                Log.d(LOG_TAG,"Notifying: radio not available");
                mNotAvailRegistrants.notifyRegistrants();
            }

            if (mState.isSIMReady() && !oldState.isSIMReady()) {
                Log.d(LOG_TAG,"Notifying: SIM ready");
                mSIMReadyRegistrants.notifyRegistrants();
            }

            if (mState == RadioState.SIM_LOCKED_OR_ABSENT) {
                Log.d(LOG_TAG,"Notifying: SIM locked or absent");
                mSIMLockedRegistrants.notifyRegistrants();
            } 

            if (mState.isOn() && !oldState.isOn()) {
                Log.d(LOG_TAG,"Notifying: Radio On");
                mOnRegistrants.notifyRegistrants();
            } 

            if ((!mState.isOn() || !mState.isAvailable()) 
                && !((!oldState.isOn() || !oldState.isAvailable()))
            ) {
                Log.d(LOG_TAG,"Notifying: radio off or not available");
                mOffOrNotAvailRegistrants.notifyRegistrants();
            }
        }