Methods Summary |
---|
public boolean | getNotifyPhoneCallState()
return ((mWants & NOTIF_PHONE) != 0);
|
public boolean | getNotifyServiceState()
return ((mWants & NOTIF_SERVICE) != 0);
|
public boolean | getNotifySignalStrength()
return ((mWants & NOTIF_SIGNAL) != 0);
|
public Phone.State | getPhoneState()
if ((mWants & NOTIF_PHONE) == 0) {
throw new RuntimeException
("client must call notifyPhoneCallState(int)");
}
return mPhoneState;
|
public android.telephony.ServiceState | getServiceState()
if ((mWants & NOTIF_SERVICE) == 0) {
throw new RuntimeException
("client must call notifyServiceState(int)");
}
return mServiceState;
|
public int | getSignalStrength()Returns current signal strength in "asu", ranging from 0-31
or -1 if unknown
For GSM, dBm = -113 + 2*asu
0 means "-113 dBm or less"
31 means "-51 dBm or greater"
if ((mWants & NOTIF_SIGNAL) == 0) {
throw new RuntimeException
("client must call notifySignalStrength(int)");
}
return mAsu;
|
public int | getSignalStrengthDbm()Return current signal strength in "dBm", ranging from -113 - -51dBm
or -1 if unknown
if ((mWants & NOTIF_SIGNAL) == 0) {
throw new RuntimeException
("client must call notifySignalStrength(int)");
}
int dBm = -1;
if (mAsu != -1) {
dBm = -113 + 2*mAsu;
}
return dBm;
|
public void | notifyPhoneCallState(int eventWhat)
mWants |= NOTIF_PHONE;
mPhoneStateEventWhat = eventWhat;
mFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
public void | notifyServiceState(int eventWhat)
mWants |= NOTIF_SERVICE;
mServiceStateEventWhat = eventWhat;
mFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
|
public void | notifySignalStrength(int eventWhat)
mWants |= NOTIF_SIGNAL;
mAsuEventWhat = eventWhat;
mFilter.addAction(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
|
public void | onReceive(android.content.Context context, android.content.Intent intent)
String action = intent.getAction();
try {
if (TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED.equals(action)) {
mAsu = intent.getIntExtra(INTENT_KEY_ASU, mAsu);
if (DBG) Log.d(LOG_TAG, "onReceiveIntent: set asu=" + mAsu);
if (mTarget != null && getNotifySignalStrength()) {
Message message = Message.obtain(mTarget, mAsuEventWhat);
mTarget.sendMessage(message);
}
} else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
if (DBG) Log.d(LOG_TAG, "onReceiveIntent: ACTION_PHONE_STATE_CHANGED, state="
+ intent.getStringExtra(Phone.STATE_KEY));
String phoneState = intent.getStringExtra(Phone.STATE_KEY);
mPhoneState = (Phone.State) Enum.valueOf(
Phone.State.class, phoneState);
if (mTarget != null && getNotifyPhoneCallState()) {
Message message = Message.obtain(mTarget,
mPhoneStateEventWhat);
mTarget.sendMessage(message);
}
} else if (TelephonyIntents.ACTION_SERVICE_STATE_CHANGED.equals(action)) {
mServiceState = ServiceState.newFromBundle(intent.getExtras());
if (mTarget != null && getNotifyServiceState()) {
Message message = Message.obtain(mTarget,
mServiceStateEventWhat);
mTarget.sendMessage(message);
}
}
} catch (Exception ex) {
Log.e(LOG_TAG, "[PhoneStateIntentRecv] caught " + ex);
ex.printStackTrace();
}
|
public void | registerIntent()
mContext.registerReceiver(this, mFilter);
|
public void | setContext(android.content.Context c)
mContext = c;
|
public void | setTarget(android.os.Handler h)
mTarget = h;
|
public void | unregisterIntent()
mContext.unregisterReceiver(this);
|