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

Commit f663fa08 authored by Nancy Chen's avatar Nancy Chen
Browse files

Make a general call to voicemail when calling back from call log.

A voicemail call log entry is saved with the number of the voicemail
that was called. In the multi-sim case, however, we don't want to call
back to the voicemail number of the original call because it might be
the number of a different phone account.

Bug: 17925501
Change-Id: I528c4039cc227608e040ae71b6b10488376fb357
parent f507886d
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -669,7 +669,6 @@ public class CallLogAdapter extends GroupingListAdapter
        views.number = number;
        views.numberPresentation = numberPresentation;
        views.callType = callType;
        // NOTE: This is currently not being used, but can be used in future versions.
        views.accountHandle = accountHandle;
        views.voicemailUri = c.getString(CallLogQuery.VOICEMAIL_URI);
        // Stash away the Ids of the calls so that we can support deleting a row in the call log.
@@ -688,7 +687,13 @@ public class CallLogAdapter extends GroupingListAdapter
            // Set return call intent, otherwise null.
            if (PhoneNumberUtilsWrapper.canPlaceCallsTo(number, numberPresentation)) {
                // Sets the primary action to call the number.
                views.primaryActionView.setTag(IntentProvider.getReturnCallIntentProvider(number));
                if (isVoicemailNumber) {
                    views.primaryActionView.setTag(
                            IntentProvider.getReturnVoicemailCallIntentProvider());
                } else {
                    views.primaryActionView.setTag(
                            IntentProvider.getReturnCallIntentProvider(number));
                }
            } else {
                // Number is not callable, so hide button.
                views.primaryActionView.setTag(null);
@@ -985,9 +990,18 @@ public class CallLogAdapter extends GroupingListAdapter
                PhoneNumberUtilsWrapper.canPlaceCallsTo(views.number, views.numberPresentation);
        // Set return call intent, otherwise null.
        if (canPlaceCallToNumber) {
            boolean isVoicemailNumber =
                    mPhoneNumberUtilsWrapper.isVoicemailNumber(views.accountHandle, views.number);
            if (isVoicemailNumber) {
                // Make a general call to voicemail to ensure that if there are multiple accounts
                // it does not call the voicemail number of a specific phone account.
                views.callBackButtonView.setTag(
                        IntentProvider.getReturnVoicemailCallIntentProvider());
            } else {
                // Sets the primary action to call the number.
                views.callBackButtonView.setTag(
                        IntentProvider.getReturnCallIntentProvider(views.number));
            }
            views.callBackButtonView.setVisibility(View.VISIBLE);
            views.callBackButtonView.setOnClickListener(mActionListener);
        } else {
+9 −0
Original line number Diff line number Diff line
@@ -65,6 +65,15 @@ public abstract class IntentProvider {
        };
    }

    public static IntentProvider getReturnVoicemailCallIntentProvider() {
        return new IntentProvider() {
            @Override
            public Intent getIntent(Context context) {
                return CallUtil.getVoicemailIntent();
            }
        };
    }

    public static IntentProvider getPlayVoicemailIntentProvider(final long rowId,
            final String voicemailUri) {
        return new IntentProvider() {
+1 −8
Original line number Diff line number Diff line
@@ -255,13 +255,6 @@ public class DialpadFragment extends AnalyticsFragment

    private static final String PREF_DIGITS_FILLED_BY_INTENT = "pref_digits_filled_by_intent";

    /**
     * Return an Intent for launching voicemail screen.
     */
    private static Intent getVoicemailIntent() {
        return CallUtil.getCallIntent(Uri.fromParts(PhoneAccount.SCHEME_VOICEMAIL, "", null));
    }

    private TelephonyManager getTelephonyManager() {
        return (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
    }
@@ -974,7 +967,7 @@ public class DialpadFragment extends AnalyticsFragment
    }

    public void callVoicemail() {
        DialerUtils.startActivityWithErrorToast(getActivity(), getVoicemailIntent());
        DialerUtils.startActivityWithErrorToast(getActivity(), CallUtil.getVoicemailIntent());
        hideAndClearDialpad(false);
    }