Fix reading SMS/MMS on devices with no `sub_id`

Authored by kdziembala on Oct 20 2019, 10:24 PM.

Description

Fix reading SMS/MMS on devices with no sub_id

Some (Xiaomi) devices running >= Android Lollipop (SDK 22+) don't
support Telephony.Sms.SUBSCRIPTION_ID.
This commit adds a verification step to ensure that only devices with
"sub_id" column include it in query.

  • Address review comments

Check was moved to a separate helper function (boolean), it's
performed only on SDK 22+ and Telephony.Sms.SUBSCRIPTION_ID
is used in query (instead of null), so no NullPointerException
is thrown.

Also parseInt shouldn't now fail if Message.SUBSCRIPTION_ID key
exists in messageInfo, but value is null

  • Return false if cursor is null
  • Return true without checking column

If we got the cursor, the query won't fail when executed again, and the "sim_id" column must exist (because an exception wasn't thrown).

Details

Committed
sredmanNov 9 2019, 7:27 PM
Parents
R225:aa25372e91d0: GIT_SILENT made messages (after extraction)
Branches
Unknown
Tags
Unknown