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

Commit 7569ad7e authored by Aishwarya Mallampati's avatar Aishwarya Mallampati
Browse files

Close cursor after DB operations.

Bug: 275716615
Test: atest DatagramReceiverTest, Flashed build on raven-userdebug: calls and SMS are working.
Change-Id: If20141062efe376b0fd4faae0d4a07ad677e4a01
parent 03add08a
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.database.SQLException;
import android.net.Uri;
import android.os.AsyncResult;
import android.os.Handler;
@@ -260,9 +261,9 @@ public class DatagramReceiver extends Handler {
        private void deleteDatagram(long datagramId) {
            String whereClause = (Telephony.SatelliteDatagrams.COLUMN_UNIQUE_KEY_DATAGRAM_ID
                    + "=" + datagramId);
            Cursor cursor =  sInstance.mContentResolver.query(
            try (Cursor cursor = sInstance.mContentResolver.query(
                    Telephony.SatelliteDatagrams.CONTENT_URI,
                    null, whereClause, null, null);
                    null, whereClause, null, null)) {
                if ((cursor != null) && (cursor.getCount() == 1)) {
                    int numRowsDeleted = sInstance.mContentResolver.delete(
                            Telephony.SatelliteDatagrams.CONTENT_URI, whereClause, null);
@@ -274,6 +275,9 @@ public class DatagramReceiver extends Handler {
                } else {
                    loge("Datagram with datagramId: " + datagramId + " is not present in DB.");
                }
            } catch(SQLException e) {
                loge("deleteDatagram SQLException e:" + e);
            }
        }

        private void onSatelliteDatagramReceived(@NonNull DatagramRetryArgument argument) {