Disable notification thumbnails on some devices.

Relates to #13287
This commit is contained in:
Greyson Parrelli
2023-12-07 13:56:27 -05:00
parent 0bf2ae6075
commit 763025d19b
2 changed files with 25 additions and 2 deletions

View File

@@ -2,6 +2,8 @@ package org.thoughtcrime.securesms.notifications.v2
import android.content.Context
import android.net.Uri
import android.os.Build
import org.signal.core.util.asListContains
import org.signal.core.util.concurrent.SignalExecutors
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.database.model.MessageId
@@ -10,6 +12,7 @@ import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader
import org.thoughtcrime.securesms.mms.Slide
import org.thoughtcrime.securesms.providers.BlobProvider
import org.thoughtcrime.securesms.util.BitmapDecodingException
import org.thoughtcrime.securesms.util.FeatureFlags
import org.thoughtcrime.securesms.util.ImageCompressionUtil
import org.thoughtcrime.securesms.util.kb
import org.thoughtcrime.securesms.util.mb
@@ -33,9 +36,21 @@ object NotificationThumbnails {
private val thumbnailCache = LinkedHashMap<MessageId, CachedThumbnail>(MAX_CACHE_SIZE)
/**
* Some devices are hitting weird issues when rendering notification thumbnails. It's only a few specific older models, so rather than try to figure out the
* specifics here, we'll just disable notification thumbnails for them.
*/
private val isBlocklisted by lazy {
FeatureFlags.notificationThumbnailProductBlocklist().asListContains(Build.PRODUCT)
}
fun getWithoutModifying(notificationItem: NotificationItem): NotificationItem.ThumbnailInfo {
val thumbnailSlide: Slide? = notificationItem.slideDeck?.thumbnailSlide
if (isBlocklisted) {
return NotificationItem.ThumbnailInfo.NONE
}
if (thumbnailSlide == null || thumbnailSlide.uri == null) {
return NotificationItem.ThumbnailInfo.NONE
}

View File

@@ -117,6 +117,7 @@ public final class FeatureFlags {
public static final String IDEAL_ENABLED_REGIONS = "global.donations.idealEnabledRegions";
public static final String SEPA_ENABLED_REGIONS = "global.donations.sepaEnabledRegions";
private static final String CALLING_REACTIONS = "android.calling.reactions";
private static final String NOTIFICATION_THUMBNAIL_BLOCKLIST = "android.notificationThumbnailProductBlocklist";
/**
* We will only store remote values for flags in this set. If you want a flag to be controllable
@@ -185,7 +186,8 @@ public final class FeatureFlags {
IDEAL_DONATIONS,
IDEAL_ENABLED_REGIONS,
SEPA_ENABLED_REGIONS,
CALLING_REACTIONS
CALLING_REACTIONS,
NOTIFICATION_THUMBNAIL_BLOCKLIST
);
@VisibleForTesting
@@ -256,7 +258,8 @@ public final class FeatureFlags {
USERNAMES,
CRASH_PROMPT_CONFIG,
BLOCK_SSE,
CALLING_REACTIONS
CALLING_REACTIONS,
NOTIFICATION_THUMBNAIL_BLOCKLIST
);
/**
@@ -669,6 +672,11 @@ public final class FeatureFlags {
return getBoolean(CALLING_REACTIONS, false);
}
/** List of device products that are blocked from showing notification thumbnails. */
public static String notificationThumbnailProductBlocklist() {
return getString(NOTIFICATION_THUMBNAIL_BLOCKLIST, "");
}
/** Only for rendering debug info. */
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
return new TreeMap<>(REMOTE_VALUES);