Add 'constraints' and 'key preferences' sections to logs.

fork-5.53.8
Greyson Parrelli 2021-01-14 19:22:47 -05:00
rodzic 577d2b13ca
commit 727175e4f4
6 zmienionych plików z 79 dodań i 3 usunięć

Wyświetl plik

@ -232,8 +232,10 @@ public abstract class PassphraseRequiredActivity extends BaseActivity implements
this.clearKeyReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "onReceive() for clear key event");
onMasterSecretCleared();
Log.i(TAG, "onReceive() for clear key event. PasswordDisabled: " + TextSecurePreferences.isPasswordDisabled(context) + ", ScreenLock: " + TextSecurePreferences.isScreenLockEnabled(context));
if (TextSecurePreferences.isScreenLockEnabled(context) || !TextSecurePreferences.isPasswordDisabled(context)) {
onMasterSecretCleared();
}
}
};

Wyświetl plik

@ -0,0 +1,35 @@
package org.thoughtcrime.securesms.logsubmit;
import android.content.Context;
import androidx.annotation.NonNull;
import com.annimon.stream.Stream;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.jobmanager.Constraint;
import org.thoughtcrime.securesms.jobs.JobManagerFactories;
import org.thoughtcrime.securesms.util.Util;
import java.util.Map;
final class LogSectionConstraints implements LogSection {
@Override
public @NonNull String getTitle() {
return "CONSTRAINTS";
}
@Override
public @NonNull CharSequence getContent(@NonNull Context context) {
StringBuilder output = new StringBuilder();
Map<String, Constraint.Factory> factories = JobManagerFactories.getConstraintFactories(ApplicationDependencies.getApplication());
int keyLength = Stream.of(factories.keySet()).map(String::length).max(Integer::compareTo).orElse(0);
for (Map.Entry<String, Constraint.Factory> entry : factories.entrySet()) {
output.append(Util.rightPad(entry.getKey(), keyLength)).append(": ").append(entry.getValue().create().isMet()).append("\n");
}
return output;
}
}

Wyświetl plik

@ -0,0 +1,29 @@
package org.thoughtcrime.securesms.logsubmit;
import android.content.Context;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
final class LogSectionKeyPreferences implements LogSection {
@Override
public @NonNull String getTitle() {
return "KEY PREFERENCES";
}
@Override
public @NonNull CharSequence getContent(@NonNull Context context) {
return new StringBuilder().append("Screen Lock : ").append(TextSecurePreferences.isScreenLockEnabled(context)).append("\n")
.append("Screen Lock Timeout : ").append(TextSecurePreferences.getScreenLockTimeout(context)).append("\n")
.append("Password Disabled : ").append(TextSecurePreferences.isPasswordDisabled(context)).append("\n")
.append("WiFi SMS : ").append(TextSecurePreferences.isWifiSmsEnabled(context)).append("\n")
.append("Default SMS : ").append(Util.isDefaultSmsProvider(context)).append("\n")
.append("Prefer Contact Photos: ").append(SignalStore.settings().isPreferSystemContactPhotos()).append("\n")
.append("Call Bandwidth Mode : ").append(SignalStore.settings().getCallBandwidthMode()).append("\n")
.append("Client Deprecated : ").append(SignalStore.misc().isClientDeprecated()).append("\n");
}
}

Wyświetl plik

@ -20,6 +20,7 @@ import org.thoughtcrime.securesms.util.CensorshipUtil;
import org.thoughtcrime.securesms.util.ServiceUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.VersionTracker;
import java.util.Arrays;
import java.util.LinkedHashMap;
@ -60,6 +61,7 @@ public class LogSectionSystemInfo implements LogSection {
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");
builder.append("Days Installed: ").append(VersionTracker.getDaysSinceFirstInstalled(context)).append("\n");
builder.append("App : ");
try {
builder.append(pm.getApplicationLabel(pm.getApplicationInfo(context.getPackageName(), 0)))

Wyświetl plik

@ -54,12 +54,14 @@ public class SubmitDebugLogRepository {
private static final List<LogSection> SECTIONS = new ArrayList<LogSection>() {{
add(new LogSectionSystemInfo());
add(new LogSectionJobs());
add(new LogSectionConstraints());
if (Build.VERSION.SDK_INT >= 28) {
add(new LogSectionPower());
}
add(new LogSectionPin());
add(new LogSectionCapabilities());
add(new LogSectionFeatureFlags());
add(new LogSectionKeyPreferences());
add(new LogSectionPermissions());
add(new LogSectionTrace());
add(new LogSectionThreads());

Wyświetl plik

@ -80,7 +80,13 @@ public class KeyCachingService extends Service {
public KeyCachingService() {}
public static synchronized boolean isLocked(Context context) {
return masterSecret == null && (!TextSecurePreferences.isPasswordDisabled(context) || TextSecurePreferences.isScreenLockEnabled(context));
boolean locked = masterSecret == null && (!TextSecurePreferences.isPasswordDisabled(context) || TextSecurePreferences.isScreenLockEnabled(context));
if (locked) {
Log.d(TAG, "Locked! PasswordDisabled: " + TextSecurePreferences.isPasswordDisabled(context) + ", ScreenLock: " + TextSecurePreferences.isScreenLockEnabled(context));
}
return locked;
}
public static synchronized @Nullable MasterSecret getMasterSecret(Context context) {