Skip to content

[SMS Plugin] Prevent crashing when trying to send when we do not know the device's local number

Summary

Prevent crashing while trying to send an SMS/MMS message when we don't know the device's local number.

Test Plan

Before:

If TelephonyHelper.getAllPhoneNumbers returned an empty list, attempting to call message.setFromAddress(sendingPhoneNumber.number) would throw a null-pointer exception since sendingPhoneNumber would be null.

After:

Ensure sendingPhoneNumber is non-null so that we can dereference it. I would firmly call this case "undefined behavior", but it might work which is better than certainly not working.

I have tested this locally by faking TelephonyHelper.getAllPhoneNumbers to return an empty list, and it works at least in the simple case I tested.

Merge request reports

Loading