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

Commit ae6c7170 authored by Brian Attwell's avatar Brian Attwell
Browse files

Don't let Threads.getOrCreateThreadId crash us

Bug: 17657656
Change-Id: Ifab9743d6dcd4c6c960abc006eb5288f753f429f
parent f17f057b
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());