FileDocCategorySizeDatePackage
DefaultPhoneNotifier.javaAPI DocAndroid 1.5 API7466Wed May 06 22:42:00 BST 2009com.android.internal.telephony

DefaultPhoneNotifier

public class DefaultPhoneNotifier extends Object implements PhoneNotifier
broadcast intents

Fields Summary
static final String
LOG_TAG
private static final boolean
DBG
private com.android.internal.telephony.ITelephonyRegistry
mRegistry
Constructors Summary
DefaultPhoneNotifier()


    /*package*/ 
     
        mRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
                    "telephony.registry"));
    
Methods Summary
public static intconvertCallState(Phone.State state)
Convert the {@link State} enum into the TelephonyManager.CALL_STATE_* constants for the public API.

        switch (state) {
            case RINGING:
                return TelephonyManager.CALL_STATE_RINGING;
            case OFFHOOK:
                return TelephonyManager.CALL_STATE_OFFHOOK;
            default:
                return TelephonyManager.CALL_STATE_IDLE;
        }
    
public static Phone.StateconvertCallState(int state)
Convert the TelephonyManager.CALL_STATE_* constants into the {@link State} enum for the public API.

        switch (state) {
            case TelephonyManager.CALL_STATE_RINGING:
                return Phone.State.RINGING;
            case TelephonyManager.CALL_STATE_OFFHOOK:
                return Phone.State.OFFHOOK;
            default:
                return Phone.State.IDLE;
        }
    
public static intconvertDataActivityState(Phone.DataActivityState state)
Convert the {@link DataState} enum into the TelephonyManager.DATA_* constants for the public API.

        switch (state) {
            case DATAIN:
                return TelephonyManager.DATA_ACTIVITY_IN;
            case DATAOUT:
                return TelephonyManager.DATA_ACTIVITY_OUT;
            case DATAINANDOUT:
                return TelephonyManager.DATA_ACTIVITY_INOUT;
            default:
                return TelephonyManager.DATA_ACTIVITY_NONE;
        }
    
public static Phone.DataActivityStateconvertDataActivityState(int state)
Convert the TelephonyManager.DATA_* constants into the {@link DataState} enum for the public API.

        switch (state) {
            case TelephonyManager.DATA_ACTIVITY_IN:
                return Phone.DataActivityState.DATAIN;
            case TelephonyManager.DATA_ACTIVITY_OUT:
                return Phone.DataActivityState.DATAOUT;
            case TelephonyManager.DATA_ACTIVITY_INOUT:
                return Phone.DataActivityState.DATAINANDOUT;
            default:
                return Phone.DataActivityState.NONE;
        }
    
public static intconvertDataState(Phone.DataState state)
Convert the {@link DataState} enum into the TelephonyManager.DATA_* constants for the public API.

        switch (state) {
            case CONNECTING:
                return TelephonyManager.DATA_CONNECTING;
            case CONNECTED:
                return TelephonyManager.DATA_CONNECTED;
            case SUSPENDED:
                return TelephonyManager.DATA_SUSPENDED;
            default:
                return TelephonyManager.DATA_DISCONNECTED;
        }
    
public static Phone.DataStateconvertDataState(int state)
Convert the TelephonyManager.DATA_* constants into {@link DataState} enum for the public API.

        switch (state) {
            case TelephonyManager.DATA_CONNECTING:
                return Phone.DataState.CONNECTING;
            case TelephonyManager.DATA_CONNECTED:
                return Phone.DataState.CONNECTED;
            case TelephonyManager.DATA_SUSPENDED:
                return Phone.DataState.SUSPENDED;
            default:
                return Phone.DataState.DISCONNECTED;
        }
    
private voidlog(java.lang.String s)

        Log.d(LOG_TAG, "[PhoneNotifier] " + s);
    
public voidnotifyCallForwardingChanged(Phone sender)

        try {
            mRegistry.notifyCallForwardingChanged(sender.getCallForwardingIndicator());
        } catch (RemoteException ex) {
            // system process is dead
        }
    
public voidnotifyCellLocation(Phone sender)

        Bundle data = new Bundle();
        sender.getCellLocation().fillInNotifierBundle(data);
        try {
            mRegistry.notifyCellLocation(data);
        } catch (RemoteException ex) {
            // system process is dead
        }
    
public voidnotifyDataActivity(Phone sender)

        try {
            mRegistry.notifyDataActivity(convertDataActivityState(sender.getDataActivityState()));
        } catch (RemoteException ex) {
            // system process is dead
        }
    
public voidnotifyDataConnection(Phone sender, java.lang.String reason)

        try {
            mRegistry.notifyDataConnection(convertDataState(sender.getDataConnectionState()), 
                    sender.isDataConnectivityPossible(), reason, sender.getActiveApn(),
                    sender.getInterfaceName(null));
        } catch (RemoteException ex) {
            // system process is dead
        }
    
public voidnotifyDataConnectionFailed(Phone sender, java.lang.String reason)

        try {
            mRegistry.notifyDataConnectionFailed(reason);
        } catch (RemoteException ex) {
            // system process is dead
        }
    
public voidnotifyMessageWaitingChanged(Phone sender)

        try {
            mRegistry.notifyMessageWaitingChanged(sender.getMessageWaitingIndicator());
        } catch (RemoteException ex) {
            // system process is dead
        }
    
public voidnotifyPhoneState(Phone sender)

        Call ringingCall = sender.getRingingCall();
        String incomingNumber = "";
        if (ringingCall != null && ringingCall.getEarliestConnection() != null){
            incomingNumber = ringingCall.getEarliestConnection().getAddress();
        }
        try {
            mRegistry.notifyCallState(convertCallState(sender.getState()), incomingNumber);
        } catch (RemoteException ex) {
            // system process is dead
        }
    
public voidnotifyServiceState(Phone sender)

        try {
            mRegistry.notifyServiceState(sender.getServiceState());
        } catch (RemoteException ex) {
            // system process is dead
        }
    
public voidnotifySignalStrength(Phone sender)

        try {
            mRegistry.notifySignalStrength(sender.getSignalStrengthASU());
        } catch (RemoteException ex) {
            // system process is dead
        }