diff --git a/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java b/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java
index 08526ef..7323606 100644
--- a/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java
+++ b/java/com/android/dialer/blocking/FilteredNumberAsyncQueryHandler.java
@@ -98,7 +98,13 @@
         new Listener() {
           @Override
           protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
-            listener.onHasBlockedNumbers(cursor != null && cursor.getCount() > 0);
+            try {
+              listener.onHasBlockedNumbers(cursor != null && cursor.getCount() > 0);
+            } finally {
+              if (cursor != null) {
+                cursor.close();
+              }
+            }
           }
         },
         FilteredNumberCompat.getContentUri(context, null),
@@ -164,23 +170,29 @@
              * example, both '16502530000' and '6502530000' can exist at the same time
              * and will be returned by this query.
              */
-            if (cursor == null || cursor.getCount() == 0) {
-              blockedNumberCache.put(number, BLOCKED_NUMBER_CACHE_NULL_ID);
-              listener.onCheckComplete(null);
-              return;
+            try {
+              if (cursor == null || cursor.getCount() == 0) {
+                blockedNumberCache.put(number, BLOCKED_NUMBER_CACHE_NULL_ID);
+                listener.onCheckComplete(null);
+                return;
+              }
+              cursor.moveToFirst();
+              // New filtering doesn't have a concept of type
+              if (!FilteredNumberCompat.useNewFiltering(context)
+                  && cursor.getInt(cursor.getColumnIndex(FilteredNumberColumns.TYPE))
+                      != FilteredNumberTypes.BLOCKED_NUMBER) {
+                blockedNumberCache.put(number, BLOCKED_NUMBER_CACHE_NULL_ID);
+                listener.onCheckComplete(null);
+                return;
+              }
+              Integer blockedId = cursor.getInt(cursor.getColumnIndex(FilteredNumberColumns._ID));
+              blockedNumberCache.put(number, blockedId);
+              listener.onCheckComplete(blockedId);
+            } finally {
+              if (cursor != null) {
+                cursor.close();
+              }
             }
-            cursor.moveToFirst();
-            // New filtering doesn't have a concept of type
-            if (!FilteredNumberCompat.useNewFiltering(context)
-                && cursor.getInt(cursor.getColumnIndex(FilteredNumberColumns.TYPE))
-                    != FilteredNumberTypes.BLOCKED_NUMBER) {
-              blockedNumberCache.put(number, BLOCKED_NUMBER_CACHE_NULL_ID);
-              listener.onCheckComplete(null);
-              return;
-            }
-            Integer blockedId = cursor.getInt(cursor.getColumnIndex(FilteredNumberColumns._ID));
-            blockedNumberCache.put(number, blockedId);
-            listener.onCheckComplete(blockedId);
           }
         },
         FilteredNumberCompat.getContentUri(context, null),
@@ -221,9 +233,9 @@
     if (TextUtils.isEmpty(formattedNumber)) {
       return null;
     }
-
-    try (Cursor cursor =
-        context
+    Cursor cursor = null;
+    try {
+        cursor = context
             .getContentResolver()
             .query(
                 FilteredNumberCompat.getContentUri(context, null),
@@ -234,7 +246,7 @@
                     }),
                 getIsBlockedNumberSelection(e164Number != null) + " = ?",
                 new String[] {formattedNumber},
-                null)) {
+                null);
       /*
        * In the frameworking blocking, numbers can be blocked in both e164 format
        * and not, resulting in multiple rows being returned for this query. For
@@ -252,6 +264,10 @@
     } catch (SecurityException e) {
       LogUtil.e("FilteredNumberAsyncQueryHandler.getBlockedIdSynchronous", null, e);
       return null;
+    }  finally {
+       if (cursor != null) {
+         cursor.close();
+       }
     }
   }
 
@@ -349,29 +365,35 @@
         new Listener() {
           @Override
           public void onQueryComplete(int token, Object cookie, Cursor cursor) {
-            int rowsReturned = cursor == null ? 0 : cursor.getCount();
-            if (rowsReturned != 1) {
-              throw new SQLiteDatabaseCorruptException(
-                  "Returned " + rowsReturned + " rows for uri " + uri + "where 1 expected.");
-            }
-            cursor.moveToFirst();
-            final ContentValues values = new ContentValues();
-            DatabaseUtils.cursorRowToContentValues(cursor, values);
-            values.remove(FilteredNumberCompat.getIdColumnName(context));
+            try {
+              int rowsReturned = cursor == null ? 0 : cursor.getCount();
+              if (rowsReturned != 1) {
+                throw new SQLiteDatabaseCorruptException(
+                    "Returned " + rowsReturned + " rows for uri " + uri + "where 1 expected.");
+              }
+              cursor.moveToFirst();
+              final ContentValues values = new ContentValues();
+              DatabaseUtils.cursorRowToContentValues(cursor, values);
+              values.remove(FilteredNumberCompat.getIdColumnName(context));
 
-            startDelete(
-                NO_TOKEN,
-                new Listener() {
-                  @Override
-                  public void onDeleteComplete(int token, Object cookie, int result) {
-                    if (listener != null) {
-                      listener.onUnblockComplete(result, values);
+              startDelete(
+                  NO_TOKEN,
+                  new Listener() {
+                    @Override
+                    public void onDeleteComplete(int token, Object cookie, int result) {
+                      if (listener != null) {
+                        listener.onUnblockComplete(result, values);
+                      }
                     }
-                  }
-                },
-                uri,
-                null,
-                null);
+                  },
+                  uri,
+                  null,
+                  null);
+            } finally {
+              if (cursor != null) {
+                cursor.close();
+              }
+            }
           }
         },
         uri,
