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

Commit 40f9b179 authored by Santos Cordon's avatar Santos Cordon
Browse files

Fix call duration for unanswered/missed calls.

Made call times be equivalent to Jellybean/Kitkat.
Missed calls, rejected calls, unanswered outgoing calls all show 0:00.
Missed calls in particular dont show a time at all.

Tested with Conference calls, Active/Hold, Rejected, Missed,
Outgoing->Rejected, Outgoing->End Call.

Bug: 18403859
Change-Id: I60bedc425681808d48d768a435f86f2545916de1
parent aedf4587
Loading
Loading
Loading
Loading
+33 −8
Original line number Diff line number Diff line
@@ -189,6 +189,12 @@ final class Call implements CreateConnectionResponse {
     */
    private long mCreationTimeMillis = System.currentTimeMillis();

    /** The time this call was made active. */
    private long mConnectTimeMillis = 0;

    /** The time this call was disconnected. */
    private long mDisconnectTimeMillis = 0;

    /** The gateway information associated with this call. This stores the original call handle
     * that the user is attempting to connect to via the gateway, the actual handle to dial in
     * order to connect the call via the gateway, as well as the package name of the gateway
@@ -203,8 +209,6 @@ final class Call implements CreateConnectionResponse {

    private final List<Call> mConferenceableCalls = new ArrayList<>();

    private long mConnectTimeMillis = 0;

    /** The state of the call. */
    private int mState;

@@ -386,7 +390,18 @@ final class Call implements CreateConnectionResponse {
            mState = newState;
            maybeLoadCannedSmsResponses();

            if (mState == CallState.DISCONNECTED) {
            if (mState == CallState.ACTIVE || mState == CallState.ON_HOLD) {
                if (mConnectTimeMillis == 0) {
                    // We check to see if mConnectTime is already set to prevent the
                    // call from resetting active time when it goes in and out of
                    // ACTIVE/ON_HOLD
                    mConnectTimeMillis = System.currentTimeMillis();
                }

                // We're clearly not disconnected, so reset the disconnected time.
                mDisconnectTimeMillis = 0;
            } else if (mState == CallState.DISCONNECTED) {
                mDisconnectTimeMillis = System.currentTimeMillis();
                setLocallyDisconnecting(false);
                fixParentAfterDisconnect();
                if ((oldState == CallState.DIALING || oldState == CallState.CONNECTING)
@@ -559,7 +574,21 @@ final class Call implements CreateConnectionResponse {
     *     mCreationTimeMillis.
     */
    long getAgeMillis() {
        return System.currentTimeMillis() - mCreationTimeMillis;
        if (mState == CallState.DISCONNECTED &&
                (mDisconnectCause.getCode() == DisconnectCause.REJECTED ||
                 mDisconnectCause.getCode() == DisconnectCause.MISSED)) {
            // Rejected and missed calls have no age. They're immortal!!
            return 0;
        } else if (mConnectTimeMillis == 0) {
            // Age is measured in the amount of time the call was active. A zero connect time
            // indicates that we never went active, so return 0 for the age.
            return 0;
        } else if (mDisconnectTimeMillis == 0) {
            // We connected, but have not yet disconnected
            return System.currentTimeMillis() - mConnectTimeMillis;
        }

        return mDisconnectTimeMillis - mConnectTimeMillis;
    }

    /**
@@ -578,10 +607,6 @@ final class Call implements CreateConnectionResponse {
        return mConnectTimeMillis;
    }

    void setConnectTimeMillis(long connectTimeMillis) {
        mConnectTimeMillis = connectTimeMillis;
    }

    int getCallCapabilities() {
        return mCallCapabilities;
    }
+0 −8
Original line number Diff line number Diff line
@@ -406,7 +406,6 @@ public final class CallsManager extends Call.ListenerBase {
                // to the existing connection instead of trying to create a new one.
                true /* isIncoming */,
                false /* isConference */);
        call.setConnectTimeMillis(System.currentTimeMillis());
        call.setIsUnknown(true);
        call.setExtras(extras);
        call.addListener(this);
@@ -799,9 +798,6 @@ public final class CallsManager extends Call.ListenerBase {
    }

    void markCallAsActive(Call call) {
        if (call.getConnectTimeMillis() == 0) {
            call.setConnectTimeMillis(System.currentTimeMillis());
        }
        setCallState(call, CallState.ACTIVE);

        if (call.getStartWithSpeakerphoneOn()) {
@@ -993,9 +989,6 @@ public final class CallsManager extends Call.ListenerBase {
                true /* isConference */);

        setCallState(call, Call.getStateFromConnectionState(parcelableConference.getState()));
        if (call.getState() == CallState.ACTIVE) {
            call.setConnectTimeMillis(System.currentTimeMillis());
        }
        call.setCallCapabilities(parcelableConference.getCapabilities());

        // TODO: Move this to be a part of addCall()
@@ -1302,7 +1295,6 @@ public final class CallsManager extends Call.ListenerBase {
                false /* isConference */);

        setCallState(call, Call.getStateFromConnectionState(connection.getState()));
        call.setConnectTimeMillis(System.currentTimeMillis());
        call.setCallCapabilities(connection.getCapabilities());
        call.setCallerDisplayName(connection.getCallerDisplayName(),
                connection.getCallerDisplayNamePresentation());