Include background restriction status in the logs.

This commit is contained in:
Greyson Parrelli 2021-03-10 12:30:21 -05:00 committed by Cody Henthorne
parent 42c3cc5296
commit c25250cb05
2 changed files with 8 additions and 0 deletions

View file

@ -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");

View file

@ -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();
}
}