Add a log section for remapped recipients.

fork-5.53.8
Greyson Parrelli 2021-11-05 15:57:13 -04:00
rodzic 011f6e6cf4
commit 5ba04936b1
4 zmienionych plików z 47 dodań i 1 usunięć

Wyświetl plik

@ -182,7 +182,7 @@ public class DatabaseFactory {
return getInstance(context).storageIdDatabase;
}
static RemappedRecordsDatabase getRemappedRecordsDatabase(Context context) {
public static RemappedRecordsDatabase getRemappedRecordsDatabase(Context context) {
return getInstance(context).remappedRecordsDatabase;
}

Wyświetl plik

@ -97,6 +97,14 @@ public class RemappedRecordsDatabase extends Database {
addMapping(Threads.TABLE_NAME, new Mapping(oldId, newId));
}
public Cursor getAllRecipients() {
return databaseHelper.getSignalReadableDatabase().query(Recipients.TABLE_NAME, null, null, null, null, null, null);
}
public Cursor getAllThreads() {
return databaseHelper.getSignalReadableDatabase().query(Threads.TABLE_NAME, null, null, null, null, null, null);
}
private @NonNull List<Mapping> getAllMappings(@NonNull String table) {
List<Mapping> mappings = new LinkedList<>();

Wyświetl plik

@ -0,0 +1,37 @@
package org.thoughtcrime.securesms.logsubmit;
import android.content.Context;
import android.database.Cursor;
import androidx.annotation.NonNull;
import org.signal.core.util.AsciiArt;
import org.thoughtcrime.securesms.database.DatabaseFactory;
/**
* Renders data pertaining to sender key. While all private info is obfuscated, this is still only intended to be printed for internal users.
*/
public class LogSectionRemappedRecords implements LogSection {
@Override
public @NonNull String getTitle() {
return "REMAPPED RECORDS";
}
@Override
public @NonNull CharSequence getContent(@NonNull Context context) {
StringBuilder builder = new StringBuilder();
builder.append("--- Recipients").append("\n\n");
try (Cursor cursor = DatabaseFactory.getRemappedRecordsDatabase(context).getAllRecipients()) {
builder.append(AsciiArt.tableFor(cursor)).append("\n\n");
}
builder.append("--- Threads").append("\n\n");
try (Cursor cursor = DatabaseFactory.getRemappedRecordsDatabase(context).getAllThreads()) {
builder.append(AsciiArt.tableFor(cursor)).append("\n");
}
return builder;
}
}

Wyświetl plik

@ -90,6 +90,7 @@ public class SubmitDebugLogRepository {
if (FeatureFlags.internalUser()) {
add(new LogSectionSenderKey());
}
add(new LogSectionRemappedRecords());
add(new LogSectionLogcat());
add(new LogSectionLoggerHeader());
}};