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

Commit 261d5d65 authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

Allow PeopleService to make blocking binder calls

Bug: 149788799
Test: presubmit

Change-Id: Ia23c96ce34942e95b029240e0d087b614e19b0f4
parent 086cd770
Loading
Loading
Loading
Loading
+29 −23
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.WorkerThread;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Binder;
import android.provider.Telephony.BaseMmsColumns;
import android.provider.Telephony.Mms;
import android.telephony.PhoneNumberUtils;
@@ -71,6 +72,8 @@ class MmsQueryHelper {
        // NOTE: The field Mms.DATE is stored in seconds, not milliseconds.
        String[] selectionArgs = new String[] { Long.toString(sinceTime / MILLIS_PER_SECONDS) };
        boolean hasResults = false;
        Binder.allowBlockingForCurrentThread();
        try {
            try (Cursor cursor = mContext.getContentResolver().query(
                    Mms.CONTENT_URI, projection, selection, selectionArgs, null)) {
                if (cursor == null) {
@@ -97,6 +100,9 @@ class MmsQueryHelper {
                    }
                }
            }
        } finally {
            Binder.defaultBlockingForCurrentThread();
        }
        return hasResults;
    }

+33 −27
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.people.data;
import android.annotation.WorkerThread;
import android.content.Context;
import android.database.Cursor;
import android.os.Binder;
import android.provider.Telephony.Sms;
import android.provider.Telephony.TextBasedSmsColumns;
import android.telephony.PhoneNumberUtils;
@@ -65,6 +66,8 @@ class SmsQueryHelper {
        String selection = Sms.DATE + " > ?";
        String[] selectionArgs = new String[] { Long.toString(sinceTime) };
        boolean hasResults = false;
        Binder.allowBlockingForCurrentThread();
        try {
            try (Cursor cursor = mContext.getContentResolver().query(
                    Sms.CONTENT_URI, projection, selection, selectionArgs, null)) {
                if (cursor == null) {
@@ -95,6 +98,9 @@ class SmsQueryHelper {
                    }
                }
            }
        } finally {
            Binder.defaultBlockingForCurrentThread();
        }
        return hasResults;
    }