Skip to content

Commit 44c6682

Browse files
committed
Fixed instability issue after closing an alert with group.
* After closing an in-app alert with a group key set and no other other exist in the shade with the same key, the next notification operation my cause a crash. - Regression bug introduced in 3.4.4.
1 parent 4c9cce1 commit 44c6682

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationSummaryManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ static void updateSummaryNotificationAfterChildRemoved(Context context, SQLiteDa
6565
new String[] { group }, // whereArgs
6666
null, null, null);
6767

68-
cursor.moveToFirst();
68+
boolean hasRecord = cursor.moveToFirst();
69+
if (!hasRecord)
70+
return;
6971
int androidNotifId = cursor.getInt(cursor.getColumnIndex(NotificationTable.COLUMN_NAME_ANDROID_NOTIFICATION_ID));
7072
cursor.close();
7173

OneSignalSDK/unittest/src/test/java/com/onesignal/OneSignalPackagePrivateHelper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Service;
44
import android.content.Context;
55
import android.content.Intent;
6+
import android.database.sqlite.SQLiteDatabase;
67
import android.os.Bundle;
78
import android.os.Looper;
89

@@ -96,4 +97,8 @@ public static void OneSignalRestClientPublic_getSync(final String url, final One
9697
public static void NotificationOpenedProcessor_processFromContext(Context context, Intent intent) {
9798
NotificationOpenedProcessor.processFromContext(context, intent);
9899
}
100+
101+
public static void NotificationSummaryManager_updateSummaryNotificationAfterChildRemoved(Context context, SQLiteDatabase writableDb, String group, boolean dismissed) {
102+
NotificationSummaryManager.updateSummaryNotificationAfterChildRemoved(context, writableDb, group, dismissed);
103+
}
99104
}

OneSignalSDK/unittest/src/test/java/com/test/onesignal/GenerateNotificationRunner.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
import static com.onesignal.OneSignalPackagePrivateHelper.NotificationBundleProcessor_ProcessFromGCMIntentService;
8585
import static com.onesignal.OneSignalPackagePrivateHelper.NotificationBundleProcessor_ProcessFromGCMIntentService_NoWrap;
8686
import static com.onesignal.OneSignalPackagePrivateHelper.NotificationOpenedProcessor_processFromContext;
87+
import static com.onesignal.OneSignalPackagePrivateHelper.NotificationSummaryManager_updateSummaryNotificationAfterChildRemoved;
8788
import static com.onesignal.OneSignalPackagePrivateHelper.createInternalPayloadBundle;
8889
import static com.test.onesignal.TestHelpers.threadAndTaskWait;
8990
import static org.robolectric.Shadows.shadowOf;
@@ -525,8 +526,12 @@ public void shouldGenerate2BasicGroupNotifications() throws Exception {
525526
Assert.assertEquals(1, ShadowBadgeCountUpdater.lastCount);
526527
cursor.close();
527528
}
528-
529-
529+
530+
@Test
531+
public void shouldHandleOpeningInAppAlertWithGroupKeySet() throws Exception {
532+
SQLiteDatabase writableDb = OneSignalDbHelper.getInstance(RuntimeEnvironment.application).getWritableDatabase();
533+
NotificationSummaryManager_updateSummaryNotificationAfterChildRemoved(blankActivity, writableDb, "some_group", false);
534+
}
530535

531536
@Test
532537
public void shouldSetButtonsCorrectly() throws Exception {

0 commit comments

Comments
 (0)