That fuck shit the fascists are using
1package org.tm.archive.logsubmit;
2
3import android.app.ActivityManager;
4import android.content.Context;
5import android.content.pm.PackageManager;
6import android.os.Build;
7import android.provider.Settings;
8import android.text.TextUtils;
9import android.util.DisplayMetrics;
10import android.view.WindowManager;
11
12import androidx.annotation.NonNull;
13
14import com.google.android.gms.common.ConnectionResult;
15import com.google.android.gms.common.GoogleApiAvailability;
16
17import org.signal.core.util.FontUtil;
18import org.tm.archive.BuildConfig;
19import org.tm.archive.dependencies.ApplicationDependencies;
20import org.tm.archive.emoji.EmojiFiles;
21import org.tm.archive.keyvalue.SignalStore;
22import org.tm.archive.net.StandardUserAgentInterceptor;
23import org.tm.archive.notifications.SlowNotificationHeuristics;
24import org.tm.archive.recipients.Recipient;
25import org.tm.archive.service.webrtc.AndroidTelecomUtil;
26import org.tm.archive.util.AppSignatureUtil;
27import org.tm.archive.util.ByteUnit;
28import org.tm.archive.util.ContextUtil;
29import org.tm.archive.util.DeviceProperties;
30import org.tm.archive.util.NetworkUtil;
31import org.tm.archive.util.ScreenDensity;
32import org.tm.archive.util.ServiceUtil;
33import org.tm.archive.util.TextSecurePreferences;
34import org.tm.archive.util.Util;
35import org.tm.archive.util.VersionTracker;
36import org.whispersystems.signalservice.api.push.ServiceId.ACI;
37
38import java.util.Arrays;
39import java.util.LinkedList;
40import java.util.Locale;
41
42public class LogSectionSystemInfo implements LogSection {
43
44 @Override
45 public @NonNull String getTitle() {
46 return "SYSINFO";
47 }
48
49 @Override
50 public @NonNull CharSequence getContent(@NonNull Context context) {
51 final PackageManager pm = context.getPackageManager();
52 final StringBuilder builder = new StringBuilder();
53
54 builder.append("Time : ").append(System.currentTimeMillis()).append('\n');
55 builder.append("Manufacturer : ").append(Build.MANUFACTURER).append("\n");
56 builder.append("Model : ").append(Build.MODEL).append("\n");
57 builder.append("Product : ").append(Build.PRODUCT).append("\n");
58 builder.append("Screen : ").append(getScreenResolution(context)).append(", ")
59 .append(ScreenDensity.get(context)).append(", ")
60 .append(getScreenRefreshRate(context)).append("\n");
61 builder.append("Font Scale : ").append(context.getResources().getConfiguration().fontScale).append("\n");
62 builder.append("Animation Scale : ").append(ContextUtil.getAnimationScale(context)).append("\n");
63 builder.append("Android : ").append(Build.VERSION.RELEASE).append(", API ")
64 .append(Build.VERSION.SDK_INT).append(" (")
65 .append(Build.VERSION.INCREMENTAL).append(", ")
66 .append(Build.DISPLAY).append(")\n");
67 builder.append("ABIs : ").append(TextUtils.join(", ", getSupportedAbis())).append("\n");
68 builder.append("Memory : ").append(getMemoryUsage()).append("\n");
69 builder.append("Memclass : ").append(getMemoryClass(context)).append("\n");
70 builder.append("MemInfo : ").append(getMemoryInfo(context)).append("\n");
71 builder.append("OS Host : ").append(Build.HOST).append("\n");
72 builder.append("RecipientId : ").append(SignalStore.registrationValues().isRegistrationComplete() ? Recipient.self().getId() : "N/A").append("\n");
73 builder.append("ACI : ").append(getCensoredAci(context)).append("\n");
74 builder.append("Device ID : ").append(SignalStore.account().getDeviceId()).append("\n");
75 builder.append("Censored : ").append(ApplicationDependencies.getSignalServiceNetworkAccess().isCensored()).append("\n");
76 builder.append("Network Status : ").append(NetworkUtil.getNetworkStatus(context)).append("\n");
77 builder.append("Data Saver : ").append(DeviceProperties.getDataSaverState(context)).append("\n");
78 builder.append("Play Services : ").append(getPlayServicesString(context)).append("\n");
79 builder.append("FCM : ").append(SignalStore.account().isFcmEnabled()).append("\n");
80 builder.append("BkgRestricted : ").append(Build.VERSION.SDK_INT >= 28 ? DeviceProperties.isBackgroundRestricted(context) : "N/A").append("\n");
81 builder.append("Locale : ").append(Locale.getDefault()).append("\n");
82 builder.append("Linked Devices : ").append(TextSecurePreferences.isMultiDevice(context)).append("\n");
83 builder.append("First Version : ").append(TextSecurePreferences.getFirstInstallVersion(context)).append("\n");
84 builder.append("Days Installed : ").append(VersionTracker.getDaysSinceFirstInstalled(context)).append("\n");
85 builder.append("Build Variant : ").append(BuildConfig.BUILD_DISTRIBUTION_TYPE).append(BuildConfig.BUILD_ENVIRONMENT_TYPE).append(BuildConfig.BUILD_VARIANT_TYPE).append("\n");
86 builder.append("Emoji Version : ").append(getEmojiVersionString(context)).append("\n");
87 builder.append("RenderBigEmoji : ").append(FontUtil.canRenderEmojiAtFontSize(1024)).append("\n");
88 builder.append("DontKeepActivities: ").append(getDontKeepActivities(context)).append("\n");
89 builder.append("Server Time Offset: ").append(SignalStore.misc().getLastKnownServerTimeOffset()).append(" ms (last updated: ").append(SignalStore.misc().getLastKnownServerTimeOffsetUpdateTime()).append(")").append("\n");
90 builder.append("Telecom : ").append(AndroidTelecomUtil.getTelecomSupported()).append("\n");
91 builder.append("User-Agent : ").append(StandardUserAgentInterceptor.USER_AGENT).append("\n");
92 builder.append("SlowNotifications : ").append(SlowNotificationHeuristics.isHavingDelayedNotifications()).append("\n");
93 builder.append("PotentiallyBattery: ").append(SlowNotificationHeuristics.isPotentiallyCausedByBatteryOptimizations()).append("\n");
94 builder.append("APNG Animation : ").append(DeviceProperties.shouldAllowApngStickerAnimation(context)).append("\n");
95 if (BuildConfig.MANAGES_APP_UPDATES) {
96 builder.append("ApkManifestUrl : ").append(BuildConfig.APK_UPDATE_MANIFEST_URL).append("\n");
97 }
98 builder.append("App : ");
99
100 try {
101 builder.append(pm.getApplicationLabel(pm.getApplicationInfo(context.getPackageName(), 0)))
102 .append(" ")
103 .append(pm.getPackageInfo(context.getPackageName(), 0).versionName)
104 .append(" (")
105 .append(BuildConfig.CANONICAL_VERSION_CODE)
106 .append(", ")
107 .append(Util.getManifestApkVersion(context))
108 .append(") (")
109 .append(BuildConfig.GIT_HASH).append(") \n");
110 } catch (PackageManager.NameNotFoundException nnfe) {
111 builder.append("Unknown\n");
112 }
113 builder.append("Package : ").append(BuildConfig.APPLICATION_ID).append(" (").append(getSigningString(context)).append(")");
114
115 return builder;
116 }
117
118 private static @NonNull String getMemoryUsage() {
119 Runtime info = Runtime.getRuntime();
120 long totalMemory = info.totalMemory();
121
122 return String.format(Locale.ENGLISH,
123 "%dM (%.2f%% free, %dM max)",
124 ByteUnit.BYTES.toMegabytes(totalMemory),
125 (float) info.freeMemory() / totalMemory * 100f,
126 ByteUnit.BYTES.toMegabytes(info.maxMemory()));
127 }
128
129 private static @NonNull String getMemoryClass(Context context) {
130 ActivityManager activityManager = ServiceUtil.getActivityManager(context);
131 String lowMem = "";
132
133 if (activityManager.isLowRamDevice()) {
134 lowMem = ", low-mem device";
135 }
136
137 return activityManager.getMemoryClass() + lowMem;
138 }
139
140 private static @NonNull String getMemoryInfo(Context context) {
141 ActivityManager.MemoryInfo info = DeviceProperties.getMemoryInfo(context);
142 return String.format(Locale.US, "availMem: %d mb, totalMem: %d mb, threshold: %d mb, lowMemory: %b",
143 ByteUnit.BYTES.toMegabytes(info.availMem), ByteUnit.BYTES.toMegabytes(info.totalMem), ByteUnit.BYTES.toMegabytes(info.threshold), info.lowMemory);
144 }
145
146 private static @NonNull Iterable<String> getSupportedAbis() {
147 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
148 return Arrays.asList(Build.SUPPORTED_ABIS);
149 } else {
150 LinkedList<String> abis = new LinkedList<>();
151 abis.add(Build.CPU_ABI);
152 if (Build.CPU_ABI2 != null && !"unknown".equals(Build.CPU_ABI2)) {
153 abis.add(Build.CPU_ABI2);
154 }
155 return abis;
156 }
157 }
158
159 private static @NonNull String getScreenResolution(@NonNull Context context) {
160 DisplayMetrics displayMetrics = new DisplayMetrics();
161 WindowManager windowManager = ServiceUtil.getWindowManager(context);
162
163 windowManager.getDefaultDisplay().getMetrics(displayMetrics);
164 return displayMetrics.widthPixels + "x" + displayMetrics.heightPixels;
165 }
166
167 private static @NonNull String getScreenRefreshRate(@NonNull Context context) {
168 return String.format(Locale.ENGLISH, "%.2f hz", ServiceUtil.getWindowManager(context).getDefaultDisplay().getRefreshRate());
169 }
170
171 private static String getSigningString(@NonNull Context context) {
172 return AppSignatureUtil.getAppSignature(context);
173 }
174
175 private static String getPlayServicesString(@NonNull Context context) {
176 int result = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
177 return result == ConnectionResult.SUCCESS ? "true" : "false (" + result + ")";
178 }
179
180 private static String getEmojiVersionString(@NonNull Context context) {
181 EmojiFiles.Version version = EmojiFiles.Version.readVersion(context);
182
183 if (version == null) {
184 return "None";
185 } else {
186 return version.getVersion() + " (" + version.getDensity() + ")";
187 }
188 }
189
190 private static String getCensoredAci(@NonNull Context context) {
191 ACI aci = SignalStore.account().getAci();
192
193 if (aci != null) {
194 String aciString = aci.toString();
195 String lastThree = aciString.substring(aciString.length() - 3);
196
197 return "********-****-****-****-*********" + lastThree;
198 } else {
199 return "N/A";
200 }
201 }
202
203 private static String getDontKeepActivities(@NonNull Context context) {
204 int setting = Settings.Global.getInt(context.getContentResolver(), Settings.Global.ALWAYS_FINISH_ACTIVITIES, 0);
205 return setting == 0 ? "false" : "true";
206 }
207}