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

Commit 99ae7660 authored by Andy McFadden's avatar Andy McFadden
Browse files

Make sure cursors close

Rearrange try/finally.

Bug 5279462

Change-Id: I44d8570b94e9780c78d93c131d88227a04659ddc
parent 68acd51c
Loading
Loading
Loading
Loading
+19 −16
Original line number Original line Diff line number Diff line
@@ -305,17 +305,17 @@ public class Alarms {
        // Now add the scheduled alarms
        // Now add the scheduled alarms
        final Cursor cursor = getFilteredAlarmsCursor(context.getContentResolver());
        final Cursor cursor = getFilteredAlarmsCursor(context.getContentResolver());
        if (cursor != null) {
        if (cursor != null) {
            if (cursor.moveToFirst()) {
            try {
            try {
                if (cursor.moveToFirst()) {
                    do {
                    do {
                        final Alarm a = new Alarm(cursor);
                        final Alarm a = new Alarm(cursor);
                        alarms.add(a);
                        alarms.add(a);
                    } while (cursor.moveToNext());
                    } while (cursor.moveToNext());
                }
            } finally {
            } finally {
                cursor.close();
                cursor.close();
            }
            }
        }
        }
        }


        Alarm alarm = null;
        Alarm alarm = null;


@@ -352,6 +352,7 @@ public class Alarms {
        Cursor cur = getFilteredAlarmsCursor(context.getContentResolver());
        Cursor cur = getFilteredAlarmsCursor(context.getContentResolver());
        long now = System.currentTimeMillis();
        long now = System.currentTimeMillis();


        try {
            if (cur.moveToFirst()) {
            if (cur.moveToFirst()) {
                do {
                do {
                    Alarm alarm = new Alarm(cur);
                    Alarm alarm = new Alarm(cur);
@@ -364,8 +365,10 @@ public class Alarms {
                    }
                    }
                } while (cur.moveToNext());
                } while (cur.moveToNext());
            }
            }
        } finally {
            cur.close();
            cur.close();
        }
        }
    }


    /**
    /**
     * Called at system startup, on time/timezone change, and whenever
     * Called at system startup, on time/timezone change, and whenever