Methods Summary |
---|
private void | acquireWakeLock()
log("acquireWakeLock");
mPartialWakeLock.acquire();
|
public void | cancelPostDial()
setPostDialState(PostDialState.CANCELLED);
|
boolean | compareTo(DriverCall c)
// On mobile originated (MO) calls, the phone number may have changed
// due to a SIM Toolkit call control modification.
//
// We assume we know when MO calls are created (since we created them)
// and therefore don't need to compare the phone number anyway.
if (! (isIncoming || c.isMT)) return true;
// ... but we can compare phone numbers on MT calls, and we have
// no control over when they begin, so we might as well
String cAddress = PhoneNumberUtils.stringFromStringAndTOA(c.number, c.TOA);
return isIncoming == c.isMT && equalsHandlesNulls(address, cAddress);
|
private void | createWakeLock(android.content.Context context)
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mPartialWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOG_TAG);
|
DisconnectCause | disconnectCauseFromCode(int causeCode)
/**
* See 22.001 Annex F.4 for mapping of cause codes
* to local tones
*/
switch (causeCode) {
case CallFailCause.USER_BUSY:
return DisconnectCause.BUSY;
case CallFailCause.NO_CIRCUIT_AVAIL:
case CallFailCause.TEMPORARY_FAILURE:
case CallFailCause.SWITCHING_CONGESTION:
case CallFailCause.CHANNEL_NOT_AVAIL:
case CallFailCause.QOS_NOT_AVAIL:
case CallFailCause.BEARER_NOT_AVAIL:
return DisconnectCause.CONGESTION;
case CallFailCause.ACM_LIMIT_EXCEEDED:
return DisconnectCause.LIMIT_EXCEEDED;
case CallFailCause.CALL_BARRED:
return DisconnectCause.CALL_BARRED;
case CallFailCause.FDN_BLOCKED:
return DisconnectCause.FDN_BLOCKED;
case CallFailCause.ERROR_UNSPECIFIED:
case CallFailCause.NORMAL_CLEARING:
default:
GSMPhone phone = owner.phone;
int serviceState = phone.getServiceState().getState();
if (serviceState == ServiceState.STATE_POWER_OFF) {
return DisconnectCause.POWER_OFF;
} else if (serviceState == ServiceState.STATE_OUT_OF_SERVICE
|| serviceState == ServiceState.STATE_EMERGENCY_ONLY ) {
return DisconnectCause.OUT_OF_SERVICE;
} else if (phone.getSimCard().getState() != GsmSimCard.State.READY) {
return DisconnectCause.SIM_ERROR;
} else if (causeCode == CallFailCause.ERROR_UNSPECIFIED) {
if (phone.mSST.rs.isCsRestricted()) {
return DisconnectCause.CS_RESTRICTED;
} else if (phone.mSST.rs.isCsEmergencyRestricted()) {
return DisconnectCause.CS_RESTRICTED_EMERGENCY;
} else if (phone.mSST.rs.isCsNormalRestricted()) {
return DisconnectCause.CS_RESTRICTED_NORMAL;
} else {
return DisconnectCause.NORMAL;
}
} else {
return DisconnectCause.NORMAL;
}
}
|
static boolean | equalsHandlesNulls(java.lang.Object a, java.lang.Object b)
return (a == null) ? (b == null) : a.equals (b);
|
void | fakeHoldBeforeDial()Called when this Connection is in the foregroundCall
when a dial is initiated.
We know we're ACTIVE, and we know we're going to end up
HOLDING in the backgroundCall
if (parent != null) {
parent.detach(this);
}
parent = owner.backgroundCall;
parent.attachFake(this, Call.State.HOLDING);
onStartedHolding();
|
protected void | finalize()
/**
* It is understood that This finializer is not guaranteed
* to be called and the release lock call is here just in
* case there is some path that doesn't call onDisconnect
* and or onConnectedInOrOut.
*/
if (mPartialWakeLock.isHeld()) {
Log.e(LOG_TAG, "[GSMConn] UNEXPECTED; mPartialWakeLock is held when finalizing.");
}
releaseWakeLock();
|
public java.lang.String | getAddress()
return address;
|
public Call | getCall()
return parent;
|
public long | getConnectTime()
return connectTime;
|
public long | getCreateTime()
return createTime;
|
public DisconnectCause | getDisconnectCause()
return cause;
|
public long | getDisconnectTime()
return disconnectTime;
|
public long | getDurationMillis()
if (connectTimeReal == 0) {
return 0;
} else if (duration == 0) {
return SystemClock.elapsedRealtime() - connectTimeReal;
} else {
return duration;
}
|
int | getGSMIndex()
if (index >= 0) {
return index + 1;
} else {
throw new CallStateException ("GSM index not yet assigned");
}
|
public long | getHoldDurationMillis()
if (getState() != Call.State.HOLDING) {
// If not holding, return 0
return 0;
} else {
return SystemClock.elapsedRealtime() - holdingStartTime;
}
|
public int | getNumberPresentation()
return numberPresentation;
|
public PostDialState | getPostDialState()
return postDialState;
|
public java.lang.String | getRemainingPostDialString()
if (postDialState == PostDialState.CANCELLED
|| postDialState == PostDialState.COMPLETE
|| postDialString == null
|| postDialString.length() <= nextPostDialChar
) {
return "";
}
return postDialString.substring(nextPostDialChar);
|
public Call.State | getState()
if (disconnected) {
return Call.State.DISCONNECTED;
} else {
return super.getState();
}
|
public void | hangup()
if (!disconnected) {
owner.hangup(this);
} else {
throw new CallStateException ("disconnected");
}
|
private boolean | isConnectingInOrOut()"connecting" means "has never been ACTIVE" for both incoming
and outgoing calls
return parent == null || parent == owner.ringingCall
|| parent.state == Call.State.DIALING
|| parent.state == Call.State.ALERTING;
|
public boolean | isIncoming()
return isIncoming;
|
private void | log(java.lang.String msg)
Log.d(LOG_TAG, "[GSMConn] " + msg);
|
void | onConnectedInOrOut()An incoming or outgoing call has connected
connectTime = System.currentTimeMillis();
connectTimeReal = SystemClock.elapsedRealtime();
duration = 0;
// bug #678474: incoming call interpreted as missed call, even though
// it sounds like the user has picked up the call.
if (Phone.DEBUG_PHONE) {
log("onConnectedInOrOut: connectTime=" + connectTime);
}
if (!isIncoming) {
// outgoing calls only
processNextPostDialChar();
}
releaseWakeLock();
|
void | onDisconnect(DisconnectCause cause)Called when the radio indicates the connection has been disconnected
this.cause = cause;
if (!disconnected) {
index = -1;
disconnectTime = System.currentTimeMillis();
duration = SystemClock.elapsedRealtime() - connectTimeReal;
disconnected = true;
if (Config.LOGD) Log.d(LOG_TAG,
"[GSMConn] onDisconnect: cause=" + cause);
owner.phone.notifyDisconnect(this);
if (parent != null) {
parent.connectionDisconnected(this);
}
}
releaseWakeLock();
|
void | onHangupLocal()Called when this Connection is being hung up locally (eg, user pressed "end")
Note that at this point, the hangup request has been dispatched to the radio
but no response has yet been received so update() has not yet been called
cause = DisconnectCause.LOCAL;
|
void | onRemoteDisconnect(int causeCode)
onDisconnect(disconnectCauseFromCode(causeCode));
|
private void | onStartedHolding()
holdingStartTime = SystemClock.elapsedRealtime();
|
private GSMCall | parentFromDCState(DriverCall.State state)
switch (state) {
case ACTIVE:
case DIALING:
case ALERTING:
return owner.foregroundCall;
//break;
case HOLDING:
return owner.backgroundCall;
//break;
case INCOMING:
case WAITING:
return owner.ringingCall;
//break;
default:
throw new RuntimeException("illegal call state: " + state);
}
|
public void | proceedAfterWaitChar()
if (postDialState != PostDialState.WAIT) {
Log.w(LOG_TAG, "Connection.proceedAfterWaitChar(): Expected "
+ "getPostDialState() to be WAIT but was " + postDialState);
return;
}
setPostDialState(PostDialState.STARTED);
processNextPostDialChar();
|
public void | proceedAfterWildChar(java.lang.String str)
if (postDialState != PostDialState.WILD) {
Log.w(LOG_TAG, "Connection.proceedAfterWaitChar(): Expected "
+ "getPostDialState() to be WILD but was " + postDialState);
return;
}
setPostDialState(PostDialState.STARTED);
if (false) {
boolean playedTone = false;
int len = (str != null ? str.length() : 0);
for (int i=0; i<len; i++) {
char c = str.charAt(i);
Message msg = null;
if (i == len-1) {
msg = h.obtainMessage(EVENT_DTMF_DONE);
}
if (PhoneNumberUtils.is12Key(c)) {
owner.cm.sendDtmf(c, msg);
playedTone = true;
}
}
if (!playedTone) {
processNextPostDialChar();
}
} else {
// make a new postDialString, with the wild char replacement string
// at the beginning, followed by the remaining postDialString.
StringBuilder buf = new StringBuilder(str);
buf.append(postDialString.substring(nextPostDialChar));
postDialString = buf.toString();
nextPostDialChar = 0;
if (Phone.DEBUG_PHONE) {
log("proceedAfterWildChar: new postDialString is " +
postDialString);
}
processNextPostDialChar();
}
|
private void | processNextPostDialChar()
char c = 0;
Registrant postDialHandler;
if (postDialState == PostDialState.CANCELLED) {
//Log.v("GSM", "##### processNextPostDialChar: postDialState == CANCELLED, bail");
return;
}
if (postDialString == null ||
postDialString.length() <= nextPostDialChar) {
setPostDialState(PostDialState.COMPLETE);
// notifyMessage.arg1 is 0 on complete
c = 0;
} else {
boolean isValid;
setPostDialState(PostDialState.STARTED);
c = postDialString.charAt(nextPostDialChar++);
isValid = processPostDialChar(c);
if (!isValid) {
// Will call processNextPostDialChar
h.obtainMessage(EVENT_NEXT_POST_DIAL).sendToTarget();
// Don't notify application
Log.e("GSM", "processNextPostDialChar: c=" + c + " isn't valid!");
return;
}
}
postDialHandler = owner.phone.mPostDialHandler;
Message notifyMessage;
if (postDialHandler != null && (notifyMessage = postDialHandler.messageForRegistrant()) != null) {
// The AsyncResult.result is the Connection object
PostDialState state = postDialState;
AsyncResult ar = AsyncResult.forMessage(notifyMessage);
ar.result = this;
ar.userObj = state;
// arg1 is the character that was/is being processed
notifyMessage.arg1 = c;
//Log.v("GSM", "##### processNextPostDialChar: send msg to postDialHandler, arg1=" + c);
notifyMessage.sendToTarget();
}
/*
else {
if (postDialHandler == null)
Log.v("GSM", "##### processNextPostDialChar: postDialHandler is NULL!");
else
Log.v("GSM", "##### processNextPostDialChar: postDialHandler.messageForRegistrant() returned NULL!");
}
*/
|
private boolean | processPostDialChar(char c)Performs the appropriate action for a post-dial char, but does not
notify application. returns false if the character is invalid and
should be ignored
if (PhoneNumberUtils.is12Key(c)) {
owner.cm.sendDtmf(c, h.obtainMessage(EVENT_DTMF_DONE));
} else if (c == PhoneNumberUtils.PAUSE) {
// From TS 22.101:
// "The first occurrence of the "DTMF Control Digits Separator"
// shall be used by the ME to distinguish between the addressing
// digits (i.e. the phone number) and the DTMF digits...."
if (nextPostDialChar == 1) {
// The first occurrence.
// We don't need to pause here, but wait for just a bit anyway
h.sendMessageDelayed(h.obtainMessage(EVENT_PAUSE_DONE),
PAUSE_DELAY_FIRST_MILLIS);
} else {
// It continues...
// "Upon subsequent occurrences of the separator, the UE shall
// pause again for 3 seconds (\u00B1 20 %) before sending any
// further DTMF digits."
h.sendMessageDelayed(h.obtainMessage(EVENT_PAUSE_DONE),
PAUSE_DELAY_MILLIS);
}
} else if (c == PhoneNumberUtils.WAIT) {
setPostDialState(PostDialState.WAIT);
} else if (c == PhoneNumberUtils.WILD) {
setPostDialState(PostDialState.WILD);
} else {
return false;
}
return true;
|
private void | releaseWakeLock()
synchronized(mPartialWakeLock) {
if (mPartialWakeLock.isHeld()) {
log("releaseWakeLock");
mPartialWakeLock.release();
}
}
|
public void | separate()
if (!disconnected) {
owner.separate(this);
} else {
throw new CallStateException ("disconnected");
}
|
private void | setPostDialState(PostDialState s)Set post dial state and acquire wake lock while switching to "started"
state, the wake lock will be released if state switches out of "started"
state or after WAKE_LOCK_TIMEOUT_MILLIS.
if (postDialState != PostDialState.STARTED
&& s == PostDialState.STARTED) {
acquireWakeLock();
Message msg = h.obtainMessage(EVENT_WAKE_LOCK_TIMEOUT);
h.sendMessageDelayed(msg, WAKE_LOCK_TIMEOUT_MILLIS);
} else if (postDialState == PostDialState.STARTED
&& s != PostDialState.STARTED) {
h.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
releaseWakeLock();
}
postDialState = s;
|
public java.lang.String | toString()
return (isIncoming ? "incoming" : "outgoing");
|
boolean | update(DriverCall dc)
GSMCall newParent;
boolean changed = false;
boolean wasConnectingInOrOut = isConnectingInOrOut();
boolean wasHolding = (getState() == Call.State.HOLDING);
newParent = parentFromDCState(dc.state);
if (!equalsHandlesNulls(address, dc.number)) {
if (Phone.DEBUG_PHONE) log("update: phone # changed!");
address = dc.number;
changed = true;
}
if (newParent != parent) {
if (parent != null) {
parent.detach(this);
}
newParent.attach(this, dc);
parent = newParent;
changed = true;
} else {
boolean parentStateChange;
parentStateChange = parent.update (this, dc);
changed = changed || parentStateChange;
}
/** Some state-transition events */
if (Phone.DEBUG_PHONE) log(
"update: parent=" + parent +
", hasNewParent=" + (newParent != parent) +
", wasConnectingInOrOut=" + wasConnectingInOrOut +
", wasHolding=" + wasHolding +
", isConnectingInOrOut=" + isConnectingInOrOut() +
", changed=" + changed);
if (wasConnectingInOrOut && !isConnectingInOrOut()) {
onConnectedInOrOut();
}
if (changed && !wasHolding && (getState() == Call.State.HOLDING)) {
// We've transitioned into HOLDING
onStartedHolding();
}
return changed;
|