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

Commit 14ab2e36 authored by Mohamed Abdalkader's avatar Mohamed Abdalkader Committed by abdalkader
Browse files

Send SMS over IMS regardless of SMS class

Test: Manual test but on internal with same change and triggering
onSmsReceived from cs.apk since cs.apk hard to get to work on aosp.
Change-Id: Ib4fab57e1786f310878fa314e082c65c49c0b2c2
parent e614e36e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ public class ImsSmsDispatcher extends SMSDispatcher {
                } catch (ImsException e) {
                    Rlog.e(TAG, "Failed to acknowledgeSms(). Error: " + e.getMessage());
                }
            });
            }, true);
        }
    };

+26 −7
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ public class SmsDispatchersController extends Handler {
    }

    /**
     * Inject an SMS PDU into the android platform.
     * Inject an SMS PDU into the android platform only if it is class 1.
     *
     * @param pdu is the byte array of pdu to be injected into android telephony layer
     * @param format is the format of SMS pdu (3gpp or 3gpp2)
@@ -187,6 +187,22 @@ public class SmsDispatchersController extends Handler {
     */
    @VisibleForTesting
    public void injectSmsPdu(byte[] pdu, String format, SmsInjectionCallback callback) {
        injectSmsPdu(pdu, format, callback, false /* ignoreClass */);
    }

    /**
     * Inject an SMS PDU into the android platform.
     *
     * @param pdu is the byte array of pdu to be injected into android telephony layer
     * @param format is the format of SMS pdu (3gpp or 3gpp2)
     * @param callback if not NULL this callback is triggered when the message is successfully
     *                 received by the android telephony layer. This callback is triggered at
     *                 the same time an SMS received from radio is responded back.
     * @param ignoreClass if set to false, this method will inject class 1 sms only.
     */
    @VisibleForTesting
    public void injectSmsPdu(byte[] pdu, String format, SmsInjectionCallback callback,
            boolean ignoreClass) {
        Rlog.d(TAG, "SmsDispatchersController:injectSmsPdu");
        try {
            // TODO We need to decide whether we should allow injecting GSM(3gpp)
@@ -194,12 +210,15 @@ public class SmsDispatchersController extends Handler {
            android.telephony.SmsMessage msg =
                    android.telephony.SmsMessage.createFromPdu(pdu, format);

            // Only class 1 SMS are allowed to be injected.
            if (msg == null
                    || msg.getMessageClass() != android.telephony.SmsMessage.MessageClass.CLASS_1) {
            if (msg == null) {
                Rlog.e(TAG, "injectSmsPdu: createFromPdu returned null");
                callback.onSmsInjectedResult(Intents.RESULT_SMS_GENERIC_ERROR);
                return;
            }

            if (!ignoreClass
                    && msg.getMessageClass() != android.telephony.SmsMessage.MessageClass.CLASS_1) {
                Rlog.e(TAG, "injectSmsPdu: not class 1");
                callback.onSmsInjectedResult(Intents.RESULT_SMS_GENERIC_ERROR);
                return;
            }