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 PhoneConstants.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 | 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)");
}
return mSignalStrength.getDbm();
|
public int | getSignalStrengthLevelAsu()Returns current signal strength in as an asu 0..31
Throws RuntimeException if client has not called notifySignalStrength()
// TODO: use new SignalStrength instead of asu
if ((mWants & NOTIF_SIGNAL) == 0) {
throw new RuntimeException
("client must call notifySignalStrength(int)");
}
return mSignalStrength.getAsuLevel();
|
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)) {
mSignalStrength = SignalStrength.newFromBundle(intent.getExtras());
if (mTarget != null && getNotifySignalStrength()) {
Message message = Message.obtain(mTarget, mAsuEventWhat);
mTarget.sendMessage(message);
}
} else if (TelephonyManager.ACTION_PHONE_STATE_CHANGED.equals(action)) {
if (DBG) Rlog.d(LOG_TAG, "onReceiveIntent: ACTION_PHONE_STATE_CHANGED, state="
+ intent.getStringExtra(PhoneConstants.STATE_KEY));
String phoneState = intent.getStringExtra(PhoneConstants.STATE_KEY);
mPhoneState = Enum.valueOf(
PhoneConstants.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) {
Rlog.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);
|