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

Unverified Commit b91591b3 authored by Danny Baumann's avatar Danny Baumann Committed by Michael Bestas
Browse files

Proper supplementary service notification handling (5/5).

Map some pieces of information provided by SSN into the UI.

Change-Id: I6650102a9c464b6c1eb8bfc5a30a12fe68a1cfef
parent d28ae4e3
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!--
     Copyright (C) 2013-2014 The CyanogenMod Project
     Copyright (c) 2013, The Linux Foundation. All rights reserved.

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <!-- In-call screen: call failure reason (call denied because call barring is ON on MT side ) -->
    <string name="callFailed_incoming_cb_enabled">Party has barred all incoming calls.</string>
    <!-- In-call screen: status label for an incoming call that is not answered and forwarded  -->
    <string name="callUnanswered_forwarded">Call unanswered and forwarded</string>

    <!-- In-call screen: "call type" indication for a forwarded call [CHAR LIMIT=30] -->
    <string name="incall_call_type_label_forwarded">Forwarded call</string>

    <!-- In-call screen: status label for a call in the "dialing" state that's waiting for the busy remote side -->
    <string name="card_title_dialing_waiting">Dialing (waiting\u2026)</string>
    <!-- In-call screen: status label for an outgoing call that's routed via a specific
         provider (e.g. MSIM) and is waiting for the busy remote side -->
    <string name="calling_via_waiting_template">Calling via <xliff:g id="provider_name">%s</xliff:g> (Waiting\u2026)</string>
    <!-- In-call screen: status label template for an active call that's routed via a specific
         provider (e.g. MSIM) -->
    <string name="card_title_active_via_template"><xliff:g id="status" example="Call on hold">%1$s</xliff:g> (via <xliff:g id="provider_name">%2$s</xliff:g>)</string>

    <!-- In-call screen: status label for a call that is held remotely  -->
    <string name="card_title_waiting_call">Waiting call</string>
</resources>
+26 −0
Original line number Diff line number Diff line
@@ -815,6 +815,32 @@ public class Call {
        return hasProperty(android.telecom.Call.Details.PROPERTY_CONFERENCE);
    }

    public boolean isForwarded() {
        return hasProperty(android.telecom.Call.Details.PROPERTY_WAS_FORWARDED);
    }

    public boolean isWaitingForRemoteSide() {
        if (mState == State.ACTIVE
                && hasProperty(android.telecom.Call.Details.PROPERTY_HELD_REMOTELY)) {
            return true;
        }
        if (mState == State.DIALING
                && hasProperty(android.telecom.Call.Details.PROPERTY_DIALING_IS_WAITING)) {
            return true;
        }
        return false;
    }

    public boolean wasUnansweredForwarded() {
        return getDisconnectCause().getCode() == DisconnectCause.MISSED
                && hasProperty(android.telecom.Call.Details.PROPERTY_ADDITIONAL_CALL_FORWARDED);
    }

    public boolean missedBecauseIncomingCallsBarredRemotely() {
        return getDisconnectCause().getCode() == DisconnectCause.RESTRICTED
                && hasProperty(android.telecom.Call.Details.PROPERTY_REMOTE_INCOMING_CALLS_BARRED);
    }

    public GatewayInfo getGatewayInfo() {
        return mTelecomCall == null ? null : mTelecomCall.getDetails().getGatewayInfo();
    }
+27 −12
Original line number Diff line number Diff line
@@ -679,7 +679,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
     */
    @Override
    public void setPrimary(String number, String name, boolean nameIsNumber, String label,
            Drawable photo, boolean isSipCall, boolean isContactPhotoShown, boolean isWorkCall) {
            Drawable photo, boolean isSipCall, boolean isForwarded,
            boolean isContactPhotoShown, boolean isWorkCall) {
        Log.d(this, "Setting primary call");
        // set the name field.
        setPrimaryName(name, nameIsNumber);
@@ -697,7 +698,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
        // Set the label (Mobile, Work, etc)
        setPrimaryLabel(label);

        showInternetCallLabel(isSipCall);
        showCallType(isSipCall, isForwarded);

        setDrawableToImageViews(photo);
        showImageView(mPhotoLarge, isContactPhotoShown);
@@ -840,11 +841,12 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
            String gatewayNumber,
            boolean isWifi,
            boolean isConference,
            boolean isWaitingForRemoteSide,
            boolean isWorkCall) {
        boolean isGatewayCall = !TextUtils.isEmpty(gatewayNumber);
        CallStateLabel callStateLabel = getCallStateLabelFromState(state, videoState,
                sessionModificationState, disconnectCause, connectionLabel, isGatewayCall, isWifi,
                isConference, isWorkCall);
                isConference, isWaitingForRemoteSide, isWorkCall);

        updateVbByCall(state);

@@ -1030,12 +1032,13 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
        return mIsAnimating;
    }

    private void showInternetCallLabel(boolean show) {
        if (show) {
            final String label = getView().getContext().getString(
                    R.string.incall_call_type_label_sip);
    private void showCallType(boolean isSipCall, boolean isForwarded) {
        if (isSipCall) {
            mCallTypeLabel.setVisibility(View.VISIBLE);
            mCallTypeLabel.setText(R.string.incall_call_type_label_sip);
        } else if (isForwarded) {
            mCallTypeLabel.setVisibility(View.VISIBLE);
            mCallTypeLabel.setText(label);
            mCallTypeLabel.setText(R.string.incall_call_type_label_forwarded);
        } else {
            mCallTypeLabel.setVisibility(View.GONE);
        }
@@ -1154,7 +1157,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
     */
    private CallStateLabel getCallStateLabelFromState(int state, int videoState,
            int sessionModificationState, DisconnectCause disconnectCause, String label,
            boolean isGatewayCall, boolean isWifi, boolean isConference, boolean isWorkCall) {
            boolean isGatewayCall, boolean isWifi, boolean isConference,
            boolean isWaitingForRemoteSide, boolean isWorkCall) {
        final Context context = getView().getContext();
        CharSequence callStateLabel = null;  // Label to display as part of the call banner

@@ -1185,12 +1189,18 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
                    callStateLabel = context.getString(R.string.card_title_video_call_requesting);
                } else if (VideoUtils.isVideoCall(videoState)) {
                    callStateLabel = context.getString(R.string.card_title_video_call);
                } else if (isWaitingForRemoteSide) {
                    callStateLabel = context.getString(R.string.card_title_waiting_call);
                }

                if ((isAccount || isWifi || isConference) && hasSuggestedLabel) {
                   label += (callStateLabel != null) ? (" " + callStateLabel) : "";
                    if (callStateLabel != null) {
                        callStateLabel = context.getString(R.string.card_title_active_via_template,
                                callStateLabel, label);
                    } else {
                        callStateLabel = label;
                    }
                }
                break;
            case Call.State.ONHOLD:
                callStateLabel = context.getString(R.string.card_title_on_hold);
@@ -1198,7 +1208,12 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr
            case Call.State.CONNECTING:
            case Call.State.DIALING:
                if (hasSuggestedLabel && !isWifi) {
                    callStateLabel = context.getString(R.string.calling_via_template, label);
                    int resId = isWaitingForRemoteSide
                            ? R.string.calling_via_waiting_template
                            : R.string.calling_via_template;
                    callStateLabel = context.getString(resId, label);
                } else if (isWaitingForRemoteSide) {
                    callStateLabel = context.getString(R.string.card_title_dialing_waiting);
                } else {
                    callStateLabel = context.getString(R.string.card_title_dialing);
                }
+17 −4
Original line number Diff line number Diff line
@@ -268,6 +268,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
                Call.areSameNumber(mPrimary, primary));
        final boolean secondaryChanged = !(Call.areSame(mSecondary, secondary) &&
                Call.areSameNumber(mSecondary, secondary));
        final boolean primaryForwardedChanged = isForwarded(primary) != isForwarded(mPrimary);

        mSecondary = secondary;
        Call previousPrimary = mPrimary;
@@ -296,6 +297,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
            updatePrimaryDisplayInfo();
            maybeStartSearch(mPrimary, true);
            maybeClearSessionModificationState(mPrimary);
        } else if (primaryForwardedChanged && mPrimary != null) {
            updatePrimaryDisplayInfo();
        }

        if (previousPrimary != null && mPrimary == null) {
@@ -345,6 +348,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
                    null,
                    false /* isWifi */,
                    false /* isConference */,
                    false /* isWaitingForRemoteSide */,
                    false /* isWorkCall */);
            getUi().showHdAudioIndicator(false);
        }
@@ -420,6 +424,10 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
        updatePrimaryDisplayInfo();
    }

    private static boolean isForwarded(Call call) {
        return call != null && call.isForwarded();
    }

    private boolean shouldRefreshPrimaryInfo(boolean primaryChanged, CallCardUi ui,
            boolean shouldShowCallSubject) {
        if (mPrimary == null) {
@@ -462,6 +470,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
                    getGatewayNumber(),
                    mPrimary.hasProperty(Details.PROPERTY_WIFI),
                    isConfCall,
                    mPrimary.isWaitingForRemoteSide(),
                    isWorkCall);

            maybeShowHdAudioIcon();
@@ -845,7 +854,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>

        if (mPrimary == null) {
            // Clear the primary display info.
            ui.setPrimary(null, null, false, null, null, false, false, false);
            ui.setPrimary(null, null, false, null, null, false, false, false, false);
            return;
        }

@@ -867,6 +876,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
                    null /* label */,
                    getConferencePhoto(mPrimary),
                    false /* isSipCall */,
                    false /* isForwarded */,
                    showContactPhoto,
                    hasWorkCallProperty);
        } else if (mPrimaryContactInfo != null) {
@@ -903,6 +913,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
            // Call with caller that is a work contact.
            boolean isWorkContact = (mPrimaryContactInfo.userType == ContactsUtils.USER_TYPE_WORK);
            boolean isIncoming = mPrimary.getState() == Call.State.INCOMING;
            boolean isForwarded = isForwarded(mPrimary);
            boolean isWithPrefix = mContext.getResources().
                getBoolean(R.bool.phone_number_with_intl_prefix);
            if(isWithPrefix == true){
@@ -915,13 +926,14 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
                    isChildNumberShown || isCallSubjectShown ? null : mPrimaryContactInfo.label,
                    mPrimaryContactInfo.photo,
                    mPrimaryContactInfo.isSipCall,
                    isForwarded,
                    showContactPhoto,
                    hasWorkCallProperty || isWorkContact);

            updateContactInteractions();
        } else {
            // Clear the primary display info.
            ui.setPrimary(null, null, false, null, null, false, false, false);
            ui.setPrimary(null, null, false, null, null, false, false, false, false);
        }

        if (mEmergencyCallListener != null) {
@@ -1273,7 +1285,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
        void showContactContext(boolean show);
        void setCallCardVisible(boolean visible);
        void setPrimary(String number, String name, boolean nameIsNumber, String label,
                Drawable photo, boolean isSipCall, boolean isContactPhotoShown, boolean isWorkCall);
                Drawable photo, boolean isSipCall, boolean isForwarded,
                boolean isContactPhotoShown, boolean isWorkCall);
        void setSecondary(boolean show, String name, boolean nameIsNumber, String label,
                String providerLabel, boolean isConference, boolean isVideoCall,
                boolean isFullscreen);
@@ -1281,7 +1294,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
        void setCallState(int state, int videoState, int sessionModificationState,
                DisconnectCause disconnectCause, String connectionLabel,
                Drawable connectionIcon, String gatewayNumber, boolean isWifi,
                boolean isConference, boolean isWorkCall);
                boolean isConference, boolean isWaitingForRemoteSide, boolean isWorkCall);
        void setPrimaryCallElapsedTime(boolean show, long duration);
        void setPrimaryName(String name, boolean nameIsNumber);
        void setPrimaryImage(Drawable image, boolean isVisible);
+14 −4
Original line number Diff line number Diff line
@@ -915,12 +915,22 @@ public class InCallActivity extends TransactionSafeActivity implements FragmentD
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    public void maybeShowErrorDialogOnDisconnect(DisconnectCause disconnectCause) {
    public void maybeShowErrorDialogOnDisconnect(Call call) {
        Log.d(this, "maybeShowErrorDialogOnDisconnect");

        if (!isFinishing() && !TextUtils.isEmpty(disconnectCause.getDescription())
                && (disconnectCause.getCode() == DisconnectCause.ERROR ||
                disconnectCause.getCode() == DisconnectCause.RESTRICTED)) {
        if (isFinishing()) {
            return;
        }

        DisconnectCause disconnectCause = call.getDisconnectCause();
        int code = disconnectCause.getCode();

        if (call.wasUnansweredForwarded()) {
            showErrorDialog(getString(R.string.callUnanswered_forwarded));
        } else if (call.missedBecauseIncomingCallsBarredRemotely()) {
            showErrorDialog(getString(R.string.callFailed_incoming_cb_enabled));
        } else if (!TextUtils.isEmpty(disconnectCause.getDescription())
                && (code == DisconnectCause.ERROR || code == DisconnectCause.RESTRICTED)) {
            showErrorDialog(disconnectCause.getDescription());
        }
    }
Loading