Fields Summary |
---|
private static final String | LOG_TAG |
private static final boolean | DBG |
public static final int | LISTEN_NONEStop listening for updates. |
public static final int | LISTEN_SERVICE_STATEListen for changes to the network service state (cellular). |
public static final int | LISTEN_SIGNAL_STRENGTHListen for changes to the network signal strength (cellular).
{@more}
Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE
READ_PHONE_STATE}
|
public static final int | LISTEN_MESSAGE_WAITING_INDICATORListen for changes to the message-waiting indicator.
{@more}
Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE
READ_PHONE_STATE}
Example: The status bar uses this to determine when to display the
voicemail icon. |
public static final int | LISTEN_CALL_FORWARDING_INDICATORListen for changes to the call-forwarding indicator.
{@more}
Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE
READ_PHONE_STATE} |
public static final int | LISTEN_CELL_LOCATIONListen for changes to the device's cell location. Note that
this will result in frequent callbacks to the listener.
{@more}
Requires Permission: {@link android.Manifest.permission#ACCESS_COARSE_LOCATION
ACCESS_COARSE_LOCATION}
If you need regular location updates but want more control over
the update interval or location precision, you can set up a listener
through the {@link android.location.LocationManager location manager}
instead. |
public static final int | LISTEN_CALL_STATEListen for changes to the device call state.
{@more}
Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE
READ_PHONE_STATE} |
public static final int | LISTEN_DATA_CONNECTION_STATEListen for changes to the data connection state (cellular). |
public static final int | LISTEN_DATA_ACTIVITYListen for changes to the direction of data traffic on the data
connection (cellular).
{@more}
Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE
READ_PHONE_STATE}
Example: The status bar uses this to display the appropriate
data-traffic icon. |
public static final int | LISTEN_SIGNAL_STRENGTHSListen for changes to the network signal strengths (cellular).
Example: The status bar uses this to control the signal-strength
icon. |
public static final int | LISTEN_OTASP_CHANGEDListen for changes to OTASP mode. |
public static final int | LISTEN_CELL_INFOListen for changes to observed cell info. |
public static final int | LISTEN_PRECISE_CALL_STATEListen for precise changes and fails to the device calls (cellular).
{@more}
Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE
READ_PRECISE_PHONE_STATE} |
public static final int | LISTEN_PRECISE_DATA_CONNECTION_STATEListen for precise changes and fails on the data connection (cellular).
{@more}
Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE
READ_PRECISE_PHONE_STATE} |
public static final int | LISTEN_DATA_CONNECTION_REAL_TIME_INFOListen for real time info for all data connections (cellular)).
{@more}
Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE
READ_PRECISE_PHONE_STATE} |
public static final int | LISTEN_VOLTE_STATEListen for changes to LTE network state |
public static final int | LISTEN_OEM_HOOK_RAW_EVENTListen for OEM hook raw event |
protected int | mSubId |
private final android.os.Handler | mHandler |
com.android.internal.telephony.IPhoneStateListener | callbackThe callback methods need to be called on the handler thread where
this object was created. If the binder did that for us it'd be nice. |
Constructors Summary |
---|
public PhoneStateListener()Create a PhoneStateListener for the Phone with the default subscription.
This class requires Looper.myLooper() not return null. To supply your
own non-null looper use PhoneStateListener(Looper looper) below.
this(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, Looper.myLooper());
|
public PhoneStateListener(android.os.Looper looper)Create a PhoneStateListener for the Phone with the default subscription
using a particular non-null Looper.
this(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, looper);
|
public PhoneStateListener(int subId)Create a PhoneStateListener for the Phone using the specified subscription.
This class requires Looper.myLooper() not return null. To supply your
own non-null Looper use PhoneStateListener(int subId, Looper looper) below.
this(subId, Looper.myLooper());
|
public PhoneStateListener(int subId, android.os.Looper looper)Create a PhoneStateListener for the Phone using the specified subscription
and non-null Looper.
if (DBG) log("ctor: subId=" + subId + " looper=" + looper);
mSubId = subId;
mHandler = new Handler(looper) {
public void handleMessage(Message msg) {
if (DBG) {
log("mSubId=" + mSubId + " what=0x" + Integer.toHexString(msg.what)
+ " msg=" + msg);
}
switch (msg.what) {
case LISTEN_SERVICE_STATE:
PhoneStateListener.this.onServiceStateChanged((ServiceState)msg.obj);
break;
case LISTEN_SIGNAL_STRENGTH:
PhoneStateListener.this.onSignalStrengthChanged(msg.arg1);
break;
case LISTEN_MESSAGE_WAITING_INDICATOR:
PhoneStateListener.this.onMessageWaitingIndicatorChanged(msg.arg1 != 0);
break;
case LISTEN_CALL_FORWARDING_INDICATOR:
PhoneStateListener.this.onCallForwardingIndicatorChanged(msg.arg1 != 0);
break;
case LISTEN_CELL_LOCATION:
PhoneStateListener.this.onCellLocationChanged((CellLocation)msg.obj);
break;
case LISTEN_CALL_STATE:
PhoneStateListener.this.onCallStateChanged(msg.arg1, (String)msg.obj);
break;
case LISTEN_DATA_CONNECTION_STATE:
PhoneStateListener.this.onDataConnectionStateChanged(msg.arg1, msg.arg2);
PhoneStateListener.this.onDataConnectionStateChanged(msg.arg1);
break;
case LISTEN_DATA_ACTIVITY:
PhoneStateListener.this.onDataActivity(msg.arg1);
break;
case LISTEN_SIGNAL_STRENGTHS:
PhoneStateListener.this.onSignalStrengthsChanged((SignalStrength)msg.obj);
break;
case LISTEN_OTASP_CHANGED:
PhoneStateListener.this.onOtaspChanged(msg.arg1);
break;
case LISTEN_CELL_INFO:
PhoneStateListener.this.onCellInfoChanged((List<CellInfo>)msg.obj);
break;
case LISTEN_PRECISE_CALL_STATE:
PhoneStateListener.this.onPreciseCallStateChanged((PreciseCallState)msg.obj);
break;
case LISTEN_PRECISE_DATA_CONNECTION_STATE:
PhoneStateListener.this.onPreciseDataConnectionStateChanged(
(PreciseDataConnectionState)msg.obj);
break;
case LISTEN_DATA_CONNECTION_REAL_TIME_INFO:
PhoneStateListener.this.onDataConnectionRealTimeInfoChanged(
(DataConnectionRealTimeInfo)msg.obj);
break;
case LISTEN_VOLTE_STATE:
PhoneStateListener.this.onVoLteServiceStateChanged((VoLteServiceState)msg.obj);
break;
case LISTEN_OEM_HOOK_RAW_EVENT:
PhoneStateListener.this.onOemHookRawEvent((byte[])msg.obj);
break;
}
}
};
|
Methods Summary |
---|
private void | log(java.lang.String s)
Rlog.d(LOG_TAG, s);
|
public void | onCallForwardingIndicatorChanged(boolean cfi)Callback invoked when the call-forwarding indicator changes.
// default implementation empty
|
public void | onCallStateChanged(int state, java.lang.String incomingNumber)Callback invoked when device call state changes.
// default implementation empty
|
public void | onCellInfoChanged(java.util.List cellInfo)Callback invoked when a observed cell info has changed,
or new cells have been added or removed.
|
public void | onCellLocationChanged(android.telephony.CellLocation location)Callback invoked when device cell location changes.
// default implementation empty
|
public void | onDataActivity(int direction)Callback invoked when data activity state changes.
// default implementation empty
|
public void | onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo)Callback invoked when data connection state changes with precise information.
// default implementation empty
|
public void | onDataConnectionStateChanged(int state)Callback invoked when connection state changes.
// default implementation empty
|
public void | onDataConnectionStateChanged(int state, int networkType)same as above, but with the network type. Both called.
|
public void | onMessageWaitingIndicatorChanged(boolean mwi)Callback invoked when the message-waiting indicator changes.
// default implementation empty
|
public void | onOemHookRawEvent(byte[] rawData)Callback invoked when OEM hook raw event is received. Requires
the READ_PRIVILEGED_PHONE_STATE permission.
// default implementation empty
|
public void | onOtaspChanged(int otaspMode)The Over The Air Service Provisioning (OTASP) has changed. Requires
the READ_PHONE_STATE permission.
// default implementation empty
|
public void | onPreciseCallStateChanged(android.telephony.PreciseCallState callState)Callback invoked when precise device call state changes.
// default implementation empty
|
public void | onPreciseDataConnectionStateChanged(android.telephony.PreciseDataConnectionState dataConnectionState)Callback invoked when data connection state changes with precise information.
// default implementation empty
|
public void | onServiceStateChanged(android.telephony.ServiceState serviceState)Callback invoked when device service state changes.
// default implementation empty
|
public void | onSignalStrengthChanged(int asu)Callback invoked when network signal strength changes.
// default implementation empty
|
public void | onSignalStrengthsChanged(android.telephony.SignalStrength signalStrength)Callback invoked when network signal strengths changes.
// default implementation empty
|
public void | onVoLteServiceStateChanged(android.telephony.VoLteServiceState stateInfo)Callback invoked when the service state of LTE network
related to the VoLTE service has changed.
|