private static void updateNotification( Context context, MasterSecret masterSecret, boolean signal, int reminderCount) { Cursor telcoCursor = null; Cursor pushCursor = null; try { telcoCursor = DatabaseFactory.getMmsSmsDatabase(context).getUnread(); if ((telcoCursor == null || telcoCursor.isAfterLast()) && (pushCursor == null || pushCursor.isAfterLast())) { ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)) .cancel(NOTIFICATION_ID); clearReminder(context); return; } NotificationState notificationState = constructNotificationState(context, masterSecret, telcoCursor); if (notificationState.hasMultipleThreads()) { sendMultipleThreadNotification(context, notificationState, signal); } else { sendSingleThreadNotification(context, masterSecret, notificationState, signal); } if (signal) { scheduleReminder(context, reminderCount); } } finally { if (telcoCursor != null) telcoCursor.close(); if (pushCursor != null) pushCursor.close(); } }