diff --git a/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionSystemInfo.java b/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionSystemInfo.java index 9b702cfe21..2b4f9d3ea2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionSystemInfo.java +++ b/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionSystemInfo.java @@ -91,6 +91,7 @@ public class LogSectionSystemInfo implements LogSection { builder.append("User-Agent : ").append(StandardUserAgentInterceptor.USER_AGENT).append("\n"); builder.append("SlowNotifications : ").append(SlowNotificationHeuristics.isHavingDelayedNotifications()).append("\n"); builder.append("PotentiallyBattery: ").append(SlowNotificationHeuristics.isPotentiallyCausedByBatteryOptimizations()).append("\n"); + builder.append("APNG Animation : ").append(DeviceProperties.shouldAllowApngStickerAnimation(context)).append("\n"); if (BuildConfig.MANAGES_APP_UPDATES) { builder.append("ApkManifestUrl : ").append(BuildConfig.APK_UPDATE_MANIFEST_URL).append("\n"); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/DeviceProperties.java b/app/src/main/java/org/thoughtcrime/securesms/util/DeviceProperties.java index 493c6146d5..b57cb2f5d2 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/DeviceProperties.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/DeviceProperties.java @@ -9,27 +9,41 @@ import android.os.Build; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; +import org.signal.core.util.logging.Log; + /** * Easy access to various properties of the device, typically to make performance-related decisions. */ public final class DeviceProperties { + private static final String TAG = Log.tag(DeviceProperties.class); + /** * Whether or not we believe the device has the performance capabilities to efficiently render * large numbers of APNGs simultaneously. */ public static boolean shouldAllowApngStickerAnimation(@NonNull Context context) { - if (Build.VERSION.SDK_INT < 26) { - return false; - } - MemoryInfo memoryInfo = getMemoryInfo(context); int memoryMb = (int) ByteUnit.BYTES.toMegabytes(memoryInfo.totalMem); - return !isLowMemoryDevice(context) && - !memoryInfo.lowMemory && - (memoryMb >= FeatureFlags.animatedStickerMinimumTotalMemoryMb() || - getMemoryClass(context) >= FeatureFlags.animatedStickerMinimumMemoryClass()); + if (isLowMemoryDevice(context)) { + return false; + } + + if (memoryMb < FeatureFlags.animatedStickerMinimumTotalMemoryMb()) { + return false; + } + + if (getMemoryClass(context) < FeatureFlags.animatedStickerMinimumMemoryClass()) { + return false; + } + + if (memoryInfo.lowMemory) { + Log.w(TAG, "Currently in a low-memory situation! Can't render APNG."); + return false; + } + + return true; } public static boolean isLowMemoryDevice(@NonNull Context context) {