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

Commit 576e0405 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Parse SMS locally upon error to get message ref

Parse the SMS locally to get the message ref when
onSmsReceived fails due to the platform being
unavailable. This allows the correct message ref
to be sent back via acknowledgeSms, instead of
the incorrect "0" value.

Bug: 74551838
Test: Manual
Merged-In: I3b75da909f1f07125c5696f7f9e525736732f3c1
Change-Id: I2f8128d8ff4e07bb3720a344cee70fa5fd5d7535
parent 991f8b0c
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -198,7 +198,10 @@ public class SmsMessage {
     */
    public static SmsMessage createFromPdu(byte[] pdu, String format) {
        SmsMessageBase wrappedMessage;

        if (pdu == null) {
            Rlog.i(LOG_TAG, "createFromPdu(): pdu is null");
            return null;
        }
        if (SmsConstants.FORMAT_3GPP2.equals(format)) {
            wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
        } else if (SmsConstants.FORMAT_3GPP.equals(format)) {
+11 −2
Original line number Diff line number Diff line
@@ -197,7 +197,9 @@ public class ImsSmsImplBase {
     * platform will deliver the message to the messages database and notify the IMS provider of the
     * result by calling {@link #acknowledgeSms(int, int, int)}.
     *
     * This method must not be called before {@link #onReady()} is called.
     * This method must not be called before {@link #onReady()} is called or the call will fail. If
     * the platform is not available, {@link #acknowledgeSms(int, int, int)} will be called with the
     * {@link #DELIVER_STATUS_ERROR_GENERIC} result code.
     *
     * @param token unique token generated by IMS providers that the platform will use to trigger
     *              callbacks for this message.
@@ -215,10 +217,17 @@ public class ImsSmsImplBase {
                mListener.onSmsReceived(token, format, pdu);
            } catch (RemoteException e) {
                Log.e(LOG_TAG, "Can not deliver sms: " + e.getMessage());
                SmsMessage message = SmsMessage.createFromPdu(pdu, format);
                if (message != null && message.mWrappedSmsMessage != null) {
                    acknowledgeSms(token, message.mWrappedSmsMessage.mMessageRef,
                            DELIVER_STATUS_ERROR_GENERIC);
                } else {
                    Log.w(LOG_TAG, "onSmsReceived: Invalid pdu entered.");
                    acknowledgeSms(token, 0, DELIVER_STATUS_ERROR_GENERIC);
                }
            }
        }
    }

    /**
     * This method should be triggered by the IMS providers to pass the result of the sent message