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

Commit 20cba2d5 authored by Tyler Gunn's avatar Tyler Gunn Committed by android-build-merger
Browse files

Cache call direction along with call duration when merging calls.

am: cbe76eec

Change-Id: I0453f43825c8ec73b1d321f4b391b62e7b4c57b9
parents 6ab27496 cbe76eec
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -354,11 +354,18 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        private long mCachedTime;
        private long mConnectTime;
        private long mConnectElapsedTime;
        /**
         * The direction of the call;
         * {@link android.telecom.Call.Details#DIRECTION_INCOMING} for incoming calls, or
         * {@link android.telecom.Call.Details#DIRECTION_OUTGOING} for outgoing calls.
         */
        private int mCallDirection;

        CacheEntry(long cachedTime, long connectTime, long connectElapsedTime) {
        CacheEntry(long cachedTime, long connectTime, long connectElapsedTime, int callDirection) {
            mCachedTime = cachedTime;
            mConnectTime = connectTime;
            mConnectElapsedTime = connectElapsedTime;
            mCallDirection = callDirection;
        }
    }

@@ -1335,8 +1342,11 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    }

    private void cacheConnectionTimeWithPhoneNumber(@NonNull ImsPhoneConnection connection) {
        int callDirection =
                connection.isIncoming() ? android.telecom.Call.Details.DIRECTION_INCOMING
                        : android.telecom.Call.Details.DIRECTION_OUTGOING;
        CacheEntry cachedConnectTime = new CacheEntry(SystemClock.elapsedRealtime(),
                connection.getConnectTime(), connection.getConnectTimeReal());
                connection.getConnectTime(), connection.getConnectTimeReal(), callDirection);
        maintainConnectTimeCache();
        if (PhoneConstants.PRESENTATION_ALLOWED == connection.getNumberPresentation()) {
            // In case of merging calls with the same number, use the latest connect time. Since
@@ -1364,13 +1374,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                return null;
            }

            String numParts = PhoneNumberUtils
                    .extractNetworkPortion(participant.getHandle().getSchemeSpecificPart());
            if (TextUtils.isEmpty(numParts)) {
            String number = ConferenceParticipant.getParticipantAddress(participant.getHandle(),
                    getCountryIso()).getSchemeSpecificPart();
            if (TextUtils.isEmpty(number)) {
                return null;
            }

            String formattedNumber = getFormattedPhoneNumber(numParts);
            String formattedNumber = getFormattedPhoneNumber(number);
            return mPhoneNumAndConnTime.get(formattedNumber);
        } else {
            return mUnknownPeerConnTime.poll();
@@ -2749,6 +2758,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                if (cachedConnectTime != null) {
                    participant.setConnectTime(cachedConnectTime.mConnectTime);
                    participant.setConnectElapsedTime(cachedConnectTime.mConnectElapsedTime);
                    participant.setCallDirection(cachedConnectTime.mCallDirection);
                }
            }
        }