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

Commit df09a784 authored by Umashankar Godachi's avatar Umashankar Godachi Committed by Gerrit - the friendly Code Review server
Browse files

Send 'reject call with sms' on the correct subscription.

Send sms on the subscription on which the call is rejected.
Add subscription info with the intent 'ACTION_RESPOND_VIA_MESSAGE'
on which the call was rejected.

Change-Id: I357184eae875e501b988375261cede68f796f00b
CRs-Fixed: 594214
parent 1910df58
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.telecom;

// TODO: Needed for move to system service: import com.android.internal.R;
import com.android.internal.os.SomeArgs;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.SmsApplication;

import android.content.ComponentName;
@@ -29,9 +30,11 @@ import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import android.telecom.Response;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.widget.Toast;

import java.lang.NumberFormatException;
import java.util.ArrayList;
import java.util.List;

@@ -139,10 +142,18 @@ public class RespondViaSmsManager extends CallsManagerListenerBase {

    @Override
    public void onIncomingCallRejected(Call call, boolean rejectWithMessage, String textMessage) {
        if (rejectWithMessage) {
        if (call != null && rejectWithMessage) {
            long subId = SubscriptionManager.getDefaultSubId();
            if (call.getTargetPhoneAccount() != null) {
                try {
                    subId = Long.parseLong(call.getTargetPhoneAccount().getId());
                } catch (NumberFormatException e) {
                    Log.e(RespondViaSmsManager.this, e , "Exception e ");
                }
            }

            rejectCallWithMessage(call.getContext(), call.getHandle().getSchemeSpecificPart(),
                    textMessage);
                    textMessage, subId);
        }
    }

@@ -175,7 +186,8 @@ public class RespondViaSmsManager extends CallsManagerListenerBase {
    /**
     * Reject the call with the specified message. If message is null this call is ignored.
     */
    private void rejectCallWithMessage(Context context, String phoneNumber, String textMessage) {
    private void rejectCallWithMessage(Context context, String phoneNumber, String textMessage,
            long subId) {
        if (textMessage != null) {
            final ComponentName component =
                    SmsApplication.getDefaultRespondViaMessageApplication(context,
@@ -185,6 +197,7 @@ public class RespondViaSmsManager extends CallsManagerListenerBase {
                final Uri uri = Uri.fromParts(Constants.SCHEME_SMSTO, phoneNumber, null);
                final Intent intent = new Intent(TelephonyManager.ACTION_RESPOND_VIA_MESSAGE, uri);
                intent.putExtra(Intent.EXTRA_TEXT, textMessage);
                intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);

                SomeArgs args = SomeArgs.obtain();
                args.arg1 = phoneNumber;