Make SmsBroadcastReceiver more robust
Josh ran into a NullPointerException when receiving a SMS message using a Pixel running Google Fi. There are a few possible reasons this could happen: 1. We linked against android.telephony.gms.SmsMessage. If the message was formatted as CDMA (3gpp2) then it is possible that the message returned is null, resulting in the NPE. 2. Any format other than 3gpp or 3gpp2 will result in the same flow as 1 if a new format is introduced in the future, or if the format were something such as a data packet from Google Voice. In API 19, there was a new android.provider.Telephony.Sms.Intents#getMessagesFromIntent introduced to abstract away extracting SmsMessages from Intents. This commit uses this API when the SDK is 19 or higher. We also catch NPE in the broadcast receiver and log it to Logcat to prevent crashing. Change-Id: I9f00d6156f004d3d72938de1e57b31cfb034d241
Showing
Please register or sign in to comment