kopia lustrzana https://github.com/ryukoposting/Signal-Android
Put info about data saver in the logs.
rodzic
f119496da4
commit
1a657a7a19
|
@ -70,10 +70,11 @@ public class LogSectionSystemInfo implements LogSection {
|
|||
builder.append("Device ID : ").append(SignalStore.account().getDeviceId()).append("\n");
|
||||
builder.append("Censored : ").append(ApplicationDependencies.getSignalServiceNetworkAccess().isCensored()).append("\n");
|
||||
builder.append("Network Status: ").append(NetworkUtil.getNetworkStatus(context)).append("\n");
|
||||
builder.append("Data Saver : ").append(DeviceProperties.getDataSaverState(context)).append("\n");
|
||||
builder.append("Play Services : ").append(getPlayServicesString(context)).append("\n");
|
||||
builder.append("FCM : ").append(SignalStore.account().isFcmEnabled()).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("Locale : ").append(Locale.getDefault()).append("\n");
|
||||
builder.append("Linked Devices: ").append(TextSecurePreferences.isMultiDevice(context)).append("\n");
|
||||
builder.append("First Version : ").append(TextSecurePreferences.getFirstInstallVersion(context)).append("\n");
|
||||
builder.append("Days Installed: ").append(VersionTracker.getDaysSinceFirstInstalled(context)).append("\n");
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.util;
|
|||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.MemoryInfo;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -55,4 +56,51 @@ public final class DeviceProperties {
|
|||
ActivityManager activityManager = ServiceUtil.getActivityManager(context);
|
||||
return activityManager.isBackgroundRestricted();
|
||||
}
|
||||
|
||||
public static DataSaverState getDataSaverState(@NonNull Context context) {
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
switch (ServiceUtil.getConnectivityManager(context).getRestrictBackgroundStatus()) {
|
||||
case ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED:
|
||||
return DataSaverState.ENABLED;
|
||||
case ConnectivityManager.RESTRICT_BACKGROUND_STATUS_WHITELISTED:
|
||||
return DataSaverState.ENABLED_BUT_EXEMPTED;
|
||||
case ConnectivityManager.RESTRICT_BACKGROUND_STATUS_DISABLED:
|
||||
return DataSaverState.DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
return DataSaverState.DISABLED;
|
||||
}
|
||||
|
||||
public enum DataSaverState {
|
||||
/** Data saver is enabled system-wide, and we are subject to the restrictions. */
|
||||
ENABLED(true, true),
|
||||
|
||||
/** Data saver is enabled system-wide, but the user has exempted us by giving us 'unrestricted access' to data in the system settings */
|
||||
ENABLED_BUT_EXEMPTED(true, false),
|
||||
|
||||
/** Data saver is disabled. */
|
||||
DISABLED(false, false);
|
||||
|
||||
private final boolean enabled;
|
||||
private final boolean restricted;
|
||||
|
||||
DataSaverState(boolean enabled, boolean restricted) {
|
||||
this.enabled = enabled;
|
||||
this.restricted = restricted;
|
||||
}
|
||||
|
||||
/** True if the device has data saver enabled, otherwise false. */
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if we're subject to data saver restrictions, otherwise false.
|
||||
* Even if data saver is enabled device-wide, this could still be false if the user has given us 'unrestricted access' to data in the system settings.
|
||||
*/
|
||||
public boolean isRestricted() {
|
||||
return restricted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue