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

Commit d4826ded authored by Arc Wang's avatar Arc Wang
Browse files

Simplify SmsMessage null check in writeInboxMessage.

After below change, we get a null SmsMessage instead of a null SmsMessage.mWrappedSmsMessage if there is a parsing error.

    //Do not create SmsMessage obj if it cannot be parsed correctly.
    https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/opt/telephony/+/1107247

Bug: 115692275
Test: make
Change-Id: I006cc7d9d17ad2358d07df551079db3fc4041244
parent a38578a5
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -1516,14 +1516,10 @@ public abstract class InboundSmsHandler extends StateMachine {
            loge("Failed to parse SMS pdu");
            return null;
        }
        // Sometimes, SmsMessage.mWrappedSmsMessage is null causing NPE when we access
        // the methods on it although the SmsMessage itself is not null. So do this check
        // before we do anything on the parsed SmsMessages.
        // Sometimes, SmsMessage is null if it can’t be parsed correctly.
        for (final SmsMessage sms : messages) {
            try {
                sms.getDisplayMessageBody();
            } catch (NullPointerException e) {
                loge("NPE inside SmsMessage");
            if (sms == null) {
                loge("Can’t write null SmsMessage");
                return null;
            }
        }