diff --git a/src/org/thoughtcrime/securesms/attachments/DatabaseAttachmentAudioExtras.kt b/src/org/thoughtcrime/securesms/attachments/DatabaseAttachmentAudioExtras.kt index 21de7925c7..f10a02272e 100644 --- a/src/org/thoughtcrime/securesms/attachments/DatabaseAttachmentAudioExtras.kt +++ b/src/org/thoughtcrime/securesms/attachments/DatabaseAttachmentAudioExtras.kt @@ -1,11 +1,11 @@ package org.thoughtcrime.securesms.attachments data class DatabaseAttachmentAudioExtras( - val attachmentId: AttachmentId, - /** Small amount of normalized audio byte samples to visualise the content (e.g. draw waveform). */ - val visualSamples: ByteArray, - /** Duration of the audio track in milliseconds. May be [DURATION_UNDEFINED] when is not known. */ - val durationMs: Long = DURATION_UNDEFINED) { + val attachmentId: AttachmentId, + /** Small amount of normalized audio byte samples to visualise the content (e.g. draw waveform). */ + val visualSamples: ByteArray, + /** Duration of the audio track in milliseconds. May be [DURATION_UNDEFINED] when it is not known. */ + val durationMs: Long = DURATION_UNDEFINED) { companion object { const val DURATION_UNDEFINED = -1L @@ -13,8 +13,8 @@ data class DatabaseAttachmentAudioExtras( override fun equals(other: Any?): Boolean { return other != null && - other is DatabaseAttachmentAudioExtras && - other.attachmentId == attachmentId + other is DatabaseAttachmentAudioExtras && + other.attachmentId == attachmentId } override fun hashCode(): Int { diff --git a/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java b/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java index 583e92a813..2e124f1579 100644 --- a/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java +++ b/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java @@ -24,11 +24,12 @@ import android.graphics.Bitmap; import android.media.MediaMetadataRetriever; import android.net.Uri; import android.os.Build; +import android.text.TextUtils; +import android.util.Pair; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; -import android.text.TextUtils; -import android.util.Pair; import com.bumptech.glide.Glide; @@ -52,10 +53,10 @@ import org.thoughtcrime.securesms.mms.PartAuthority; import org.thoughtcrime.securesms.stickers.StickerLocator; import org.thoughtcrime.securesms.util.BitmapDecodingException; import org.thoughtcrime.securesms.util.BitmapUtil; +import org.thoughtcrime.securesms.util.ExternalStorageUtil; import org.thoughtcrime.securesms.util.JsonUtils; import org.thoughtcrime.securesms.util.MediaUtil; import org.thoughtcrime.securesms.util.MediaUtil.ThumbnailData; -import org.thoughtcrime.securesms.util.ExternalStorageUtil; import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.video.EncryptedMediaDataSource; @@ -839,15 +840,15 @@ public class AttachmentDatabase extends Database { @Synchronized public @Nullable DatabaseAttachmentAudioExtras getAttachmentAudioExtras(@NonNull AttachmentId attachmentId) { try (Cursor cursor = databaseHelper.getReadableDatabase() - // We expect all the audio extra values to be present (not null) or reject the whole record. - .query(TABLE_NAME, - PROJECTION_AUDIO_EXTRAS, - PART_ID_WHERE + - " AND " + AUDIO_VISUAL_SAMPLES + " IS NOT NULL" + - " AND " + AUDIO_DURATION + " IS NOT NULL" + - " AND " + PART_AUDIO_ONLY_WHERE, - attachmentId.toStrings(), - null, null, null, "1")) { + // We expect all the audio extra values to be present (not null) or reject the whole record. + .query(TABLE_NAME, + PROJECTION_AUDIO_EXTRAS, + PART_ID_WHERE + + " AND " + AUDIO_VISUAL_SAMPLES + " IS NOT NULL" + + " AND " + AUDIO_DURATION + " IS NOT NULL" + + " AND " + PART_AUDIO_ONLY_WHERE, + attachmentId.toStrings(), + null, null, null, "1")) { if (cursor == null || !cursor.moveToFirst()) return null; @@ -869,9 +870,9 @@ public class AttachmentDatabase extends Database { values.put(AUDIO_DURATION, extras.getDurationMs()); int alteredRows = databaseHelper.getWritableDatabase().update(TABLE_NAME, - values, - PART_ID_WHERE + " AND " + PART_AUDIO_ONLY_WHERE, - extras.getAttachmentId().toStrings()); + values, + PART_ID_WHERE + " AND " + PART_AUDIO_ONLY_WHERE, + extras.getAttachmentId().toStrings()); return alteredRows > 0; } diff --git a/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java b/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java index f1e7ff8c0d..92109dde40 100644 --- a/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java +++ b/src/org/thoughtcrime/securesms/database/helpers/SQLCipherOpenHelper.java @@ -93,8 +93,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { private static final int lokiV14_BACKUP_FILES = 35; private static final int lokiV15 = 36; private static final int lokiV16 = 37; + private static final int lokiV17 = 38; - private static final int DATABASE_VERSION = lokiV16; + private static final int DATABASE_VERSION = lokiV17; private static final String DATABASE_NAME = "signal.db"; private final Context context; @@ -635,9 +636,12 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper { } if (oldVersion < lokiV16) { + db.execSQL(LokiAPIDatabase.getCreateOpenGroupProfilePictureTableCommand()); + } + + if (oldVersion < lokiV17) { db.execSQL("ALTER TABLE part ADD COLUMN audio_visual_samples BLOB"); db.execSQL("ALTER TABLE part ADD COLUMN audio_duration INTEGER"); - db.execSQL(LokiAPIDatabase.getCreateOpenGroupProfilePictureTableCommand()); } db.setTransactionSuccessful(); diff --git a/src/org/thoughtcrime/securesms/jobmanager/Data.java b/src/org/thoughtcrime/securesms/jobmanager/Data.java index 0eaa2e9e4e..eff9fa1478 100644 --- a/src/org/thoughtcrime/securesms/jobmanager/Data.java +++ b/src/org/thoughtcrime/securesms/jobmanager/Data.java @@ -7,13 +7,12 @@ import androidx.annotation.Nullable; import com.fasterxml.jackson.annotation.JsonProperty; -import org.thoughtcrime.securesms.attachments.AttachmentId; import org.thoughtcrime.securesms.util.ParcelableUtil; import java.util.HashMap; import java.util.Map; -//TODO AC: For now parcelable objects utilize byteArrays field to store their data into. +// TODO AC: For now parcelable objects utilize byteArrays field to store their data into. // Introduce a dedicated Map field specifically for parcelable needs. public class Data {