From c25250cb05495bd6336092cf2763079e8a0ef94e Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Wed, 10 Mar 2021 12:30:21 -0500 Subject: [PATCH] Include background restriction status in the logs. --- .../securesms/logsubmit/LogSectionSystemInfo.java | 1 + .../org/thoughtcrime/securesms/util/DeviceProperties.java | 7 +++++++ 2 files changed, 8 insertions(+) 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 c02e119fa7..549ac3dd2b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionSystemInfo.java +++ b/app/src/main/java/org/thoughtcrime/securesms/logsubmit/LogSectionSystemInfo.java @@ -60,6 +60,7 @@ public class LogSectionSystemInfo implements LogSection { builder.append("Censored : ").append(CensorshipUtil.isCensored(context)).append("\n"); builder.append("Play Services : ").append(getPlayServicesString(context)).append("\n"); builder.append("FCM : ").append(!TextSecurePreferences.isFcmDisabled(context)).append("\n"); + builder.append("BkgRestricted : ").append(Build.VERSION.SDK_INT >= 28 ? DeviceProperties.isBackgroundRestricted(context) : "N/A").append("\n"); builder.append("Locale : ").append(Locale.getDefault().toString()).append("\n"); builder.append("Linked Devices: ").append(TextSecurePreferences.isMultiDevice(context)).append("\n"); builder.append("First Version : ").append(TextSecurePreferences.getFirstInstallVersion(context)).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 3c60c4d8c1..96c5c6175c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/DeviceProperties.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/DeviceProperties.java @@ -6,6 +6,7 @@ import android.content.Context; import android.os.Build; import androidx.annotation.NonNull; +import androidx.annotation.RequiresApi; /** * Easy access to various properties of the device, typically to make performance-related decisions. @@ -48,4 +49,10 @@ public final class DeviceProperties { return info; } + + @RequiresApi(28) + public static boolean isBackgroundRestricted(@NonNull Context context) { + ActivityManager activityManager = ServiceUtil.getActivityManager(context); + return activityManager.isBackgroundRestricted(); + } }