mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Improve logging around APNG animation disabling.
This commit is contained in:
committed by
Cody Henthorne
parent
7a69df42a7
commit
450dc2f368
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user