Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6cf2197c authored by mengsun's avatar mengsun Committed by Gerrit - the friendly Code Review server
Browse files

Telephony: Reset the duration after the call is accepted

In android original design, the duration of CDMA MO call is started from
the dial command sent, so it is not the real duration of the active time.
In this patch, a new message is registered to listen the event of the call
accepted, and reset the duration when the event happens.

Change-Id: Ibb4de7c9eed45bd3183722b67854374182c5ef43
parent d7c1ee1d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ public abstract class CallTracker extends Handler {
    protected static final int EVENT_EXIT_ECM_RESPONSE_CDMA        = 14;
    protected static final int EVENT_CALL_WAITING_INFO_CDMA        = 15;
    protected static final int EVENT_THREE_WAY_DIAL_L2_RESULT_CDMA = 16;
    protected static final int EVENT_CDMA_INFO_REC                 = 17;

    protected void pollCallsWhenSafe() {
        mNeedsPoll = true;
+16 −0
Original line number Diff line number Diff line
@@ -100,10 +100,22 @@ public final class CdmaCallTracker extends CallTracker {
        mCi.registerForOn(this, EVENT_RADIO_AVAILABLE, null);
        mCi.registerForNotAvailable(this, EVENT_RADIO_NOT_AVAILABLE, null);
        mCi.registerForCallWaitingInfo(this, EVENT_CALL_WAITING_INFO_CDMA, null);
        mCi.registerForLineControlInfo(this, EVENT_CDMA_INFO_REC, null);
        mForegroundCall.setGeneric(false);
    }

    private void onControlInfoRec() {
        if (mState == PhoneConstants.State.OFFHOOK) {
            Rlog.d(LOG_TAG, "on accepted, reset connection time");
            CdmaConnection c = (CdmaConnection) mForegroundCall.getLatestConnection();
            if (c.getDurationMillis() > 0 && !c.isConnectionTimerReset() && !c.isIncoming()) {
                c.resetConnectionTimer();
            }
        }
    }

    public void dispose() {
        mCi.unregisterForLineControlInfo(this);
        mCi.unregisterForCallStateChanged(this);
        mCi.unregisterForOn(this);
        mCi.unregisterForNotAvailable(this);
@@ -1030,6 +1042,10 @@ public final class CdmaCallTracker extends CallTracker {
                }
            break;

            case EVENT_CDMA_INFO_REC:
                onControlInfoRec();
            break;

            default:{
               throw new RuntimeException("unexpected event not handled");
            }
+14 −0
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ public class CdmaConnection extends Connection {
    static final int WAKE_LOCK_TIMEOUT_MILLIS = 60*1000;
    static final int PAUSE_DELAY_MILLIS = 2 * 1000;

    private boolean mConnTimerReset = false;

    //***** Inner Classes

    class MyHandler extends Handler {
@@ -957,4 +959,16 @@ public class CdmaConnection extends Connection {
        // UUS information not supported in CDMA
        return null;
    }

    void resetConnectionTimer() {
        mConnectTime = System.currentTimeMillis();
        mConnectTimeReal = SystemClock.elapsedRealtime();
        mDuration = 0;
        mConnTimerReset = true;
        log("CdmaConnection time reseted");
    }

    public boolean isConnectionTimerReset() {
        return mConnTimerReset;
    }
}