27
27
28
28
package com .onesignal ;
29
29
30
- import java .lang .reflect .Field ;
31
- import java .math .BigInteger ;
32
- import java .net .URL ;
33
- import java .util .ArrayList ;
34
- import java .util .Arrays ;
35
- import java .util .Collection ;
36
- import java .util .List ;
37
- import java .security .SecureRandom ;
38
- import java .util .Random ;
39
-
40
- import org .json .JSONArray ;
41
- import org .json .JSONException ;
42
- import org .json .JSONObject ;
43
-
44
30
import android .R .drawable ;
45
31
import android .app .Activity ;
46
32
import android .app .AlertDialog ;
53
39
import android .content .pm .PackageManager ;
54
40
import android .content .res .Resources ;
55
41
import android .database .Cursor ;
56
- import android .database .sqlite .SQLiteDatabase ;
57
42
import android .graphics .Bitmap ;
58
43
import android .graphics .BitmapFactory ;
59
44
import android .net .Uri ;
68
53
69
54
import com .onesignal .OneSignalDbContract .NotificationTable ;
70
55
56
+ import org .json .JSONArray ;
57
+ import org .json .JSONException ;
58
+ import org .json .JSONObject ;
59
+
60
+ import java .lang .reflect .Field ;
61
+ import java .math .BigInteger ;
62
+ import java .net .URL ;
63
+ import java .security .SecureRandom ;
64
+ import java .util .ArrayList ;
65
+ import java .util .Arrays ;
66
+ import java .util .Collection ;
67
+ import java .util .List ;
68
+ import java .util .Random ;
69
+
71
70
import static com .onesignal .OSUtils .getResourceString ;
72
71
73
72
class GenerateNotification {
@@ -528,8 +527,6 @@ private static void createSummaryNotification(NotificationGenerationJob notifJob
528
527
Cursor cursor = null ;
529
528
530
529
try {
531
- SQLiteDatabase readableDb = dbHelper .getSQLiteDatabaseWithRetries ();
532
-
533
530
String [] retColumn = { NotificationTable .COLUMN_NAME_ANDROID_NOTIFICATION_ID ,
534
531
NotificationTable .COLUMN_NAME_FULL_DATA ,
535
532
NotificationTable .COLUMN_NAME_IS_SUMMARY ,
@@ -545,7 +542,7 @@ private static void createSummaryNotification(NotificationGenerationJob notifJob
545
542
if (!updateSummary && notifJob .getAndroidId () != -1 )
546
543
whereStr += " AND " + NotificationTable .COLUMN_NAME_ANDROID_NOTIFICATION_ID + " <> " + notifJob .getAndroidId ();
547
544
548
- cursor = readableDb .query (
545
+ cursor = dbHelper .query (
549
546
NotificationTable .TABLE_NAME ,
550
547
retColumn ,
551
548
whereStr ,
@@ -769,28 +766,11 @@ private static Intent createBaseSummaryIntent(int summaryNotificationId, JSONObj
769
766
private static void createSummaryIdDatabaseEntry (OneSignalDbHelper dbHelper , String group , int id ) {
770
767
// There currently isn't a visible notification from for this groupid.
771
768
// Save the group summary notification id so it can be updated later.
772
- SQLiteDatabase writableDb = null ;
773
- try {
774
- writableDb = dbHelper .getSQLiteDatabaseWithRetries ();
775
- writableDb .beginTransaction ();
776
-
777
- ContentValues values = new ContentValues ();
778
- values .put (NotificationTable .COLUMN_NAME_ANDROID_NOTIFICATION_ID , id );
779
- values .put (NotificationTable .COLUMN_NAME_GROUP_ID , group );
780
- values .put (NotificationTable .COLUMN_NAME_IS_SUMMARY , 1 );
781
- writableDb .insertOrThrow (NotificationTable .TABLE_NAME , null , values );
782
- writableDb .setTransactionSuccessful ();
783
- } catch (Throwable t ) {
784
- OneSignal .Log (OneSignal .LOG_LEVEL .ERROR , "Error adding summary notification record! " , t );
785
- } finally {
786
- if (writableDb != null ) {
787
- try {
788
- writableDb .endTransaction (); // May throw if transaction was never opened or DB is full.
789
- } catch (Throwable t ) {
790
- OneSignal .Log (OneSignal .LOG_LEVEL .ERROR , "Error closing transaction! " , t );
791
- }
792
- }
793
- }
769
+ ContentValues values = new ContentValues ();
770
+ values .put (NotificationTable .COLUMN_NAME_ANDROID_NOTIFICATION_ID , id );
771
+ values .put (NotificationTable .COLUMN_NAME_GROUP_ID , group );
772
+ values .put (NotificationTable .COLUMN_NAME_IS_SUMMARY , 1 );
773
+ dbHelper .insertOrThrow (NotificationTable .TABLE_NAME , null , values );
794
774
}
795
775
796
776
// Keep 'throws Throwable' as 'onesignal_bgimage_notif_layout' may not be available
0 commit comments