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

Commit 6a55c618 authored by Brian Attwell's avatar Brian Attwell Committed by Android Git Automerger
Browse files

am ae6c7170: Don\'t let Threads.getOrCreateThreadId crash us

* commit 'ae6c7170':
  Don't let Threads.getOrCreateThreadId crash us
parents d1654b96 ae6c7170
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -66,8 +66,13 @@ public class SmsInteractionsLoader extends AsyncTaskLoader<List<ContactInteracti
        // Retrieve the thread IDs
        List<String> threadIdStrings = new ArrayList<>();
        for (String phone : mPhoneNums) {
            try {
                threadIdStrings.add(String.valueOf(
                        Telephony.Threads.getOrCreateThreadId(getContext(), phone)));
            } catch (Exception e) {
                // Do nothing. Telephony.Threads.getOrCreateThreadId() throws exceptions when
                // it can't find/create a threadId (b/17657656).
            }
        }

        // Query the SMS database for the threads
@@ -94,6 +99,9 @@ public class SmsInteractionsLoader extends AsyncTaskLoader<List<ContactInteracti
     * Return the most recent messages between a list of threads
     */
    private Cursor getSmsCursorFromThreads(List<String> threadIds) {
        if (threadIds.size() == 0) {
            return null;
        }
        String selection = Telephony.Sms.THREAD_ID + " IN "
                + ContactInteractionUtil.questionMarks(threadIds.size());