Fix crash that may happen upon first sticker install.

This commit is contained in:
Greyson Parrelli 2019-09-04 11:09:30 -04:00
parent 936bd327bd
commit 5362e07a5c
2 changed files with 14 additions and 4 deletions

View File

@ -188,7 +188,7 @@ public class AttachmentDatabase extends Database {
String selection = STICKER_PACK_ID + " = ?";
String[] args = new String[] { stickerPackId };
try (Cursor cursor = databaseHelper.getReadableDatabase().query(TABLE_NAME, null, selection, args, null, null, "1")) {
try (Cursor cursor = databaseHelper.getReadableDatabase().query(TABLE_NAME, null, selection, args, null, null, null, "1")) {
return cursor != null && cursor.moveToFirst();
}
}
@ -563,7 +563,12 @@ public class AttachmentDatabase extends Database {
* database.
*/
public @Nullable Cursor getUnavailableStickerPacks() {
String query = "SELECT DISTINCT " + STICKER_PACK_ID + ", " + STICKER_PACK_KEY + " FROM " + TABLE_NAME + " WHERE " + STICKER_PACK_ID + " NOT IN (" +
String query = "SELECT DISTINCT " + STICKER_PACK_ID + ", " + STICKER_PACK_KEY +
" FROM " + TABLE_NAME +
" WHERE " +
STICKER_PACK_ID + " NOT NULL AND " +
STICKER_PACK_KEY + " NOT NULL AND " +
STICKER_PACK_ID + " NOT IN (" +
"SELECT DISTINCT " + StickerDatabase.PACK_ID + " FROM " + StickerDatabase.TABLE_NAME +
")";

View File

@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.jobs;
import androidx.annotation.NonNull;
import androidx.core.util.Preconditions;
import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.database.DatabaseFactory;
@ -56,6 +57,10 @@ public class StickerPackDownloadJob extends BaseJob {
boolean isReferencePack)
{
super(parameters);
Preconditions.checkNotNull(packId);
Preconditions.checkNotNull(packKey);
this.packId = packId;
this.packKey = packKey;
this.isReferencePack = isReferencePack;