mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-02 08:23:00 +01:00
committed by
jeffrey-signal
parent
1a70449c4c
commit
30426ee42a
@@ -1,32 +0,0 @@
|
||||
package org.thoughtcrime.securesms.devicelist;
|
||||
|
||||
public class Device {
|
||||
|
||||
private final long id;
|
||||
private final String name;
|
||||
private final long created;
|
||||
private final long lastSeen;
|
||||
|
||||
public Device(long id, String name, long created, long lastSeen) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.created = created;
|
||||
this.lastSeen = lastSeen;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public long getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public long getLastSeen() {
|
||||
return lastSeen;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2014 Open Whisper Systems
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms.jobmanager;
|
||||
|
||||
/**
|
||||
* Interface responsible for injecting dependencies into Jobs.
|
||||
*/
|
||||
public interface DependencyInjector {
|
||||
void injectDependencies(Object object);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package org.thoughtcrime.securesms.logging;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.signal.core.util.Base64;
|
||||
import org.thoughtcrime.securesms.crypto.KeyStoreHelper;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
public class LogSecretProvider {
|
||||
|
||||
public static byte[] getOrCreateAttachmentSecret(@NonNull Context context) {
|
||||
String unencryptedSecret = TextSecurePreferences.getLogUnencryptedSecret(context);
|
||||
String encryptedSecret = TextSecurePreferences.getLogEncryptedSecret(context);
|
||||
|
||||
if (unencryptedSecret != null) return parseUnencryptedSecret(unencryptedSecret);
|
||||
else if (encryptedSecret != null) return parseEncryptedSecret(encryptedSecret);
|
||||
else return createAndStoreSecret(context);
|
||||
}
|
||||
|
||||
private static byte[] parseUnencryptedSecret(String secret) {
|
||||
try {
|
||||
return Base64.decode(secret);
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError("Failed to decode the unecrypted secret.");
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] parseEncryptedSecret(String secret) {
|
||||
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.SealedData.fromString(secret);
|
||||
return KeyStoreHelper.unseal(encryptedSecret);
|
||||
}
|
||||
|
||||
private static byte[] createAndStoreSecret(@NonNull Context context) {
|
||||
SecureRandom random = new SecureRandom();
|
||||
byte[] secret = new byte[32];
|
||||
random.nextBytes(secret);
|
||||
|
||||
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(secret);
|
||||
TextSecurePreferences.setLogEncryptedSecret(context, encryptedSecret.serialize());
|
||||
|
||||
return secret;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import org.signal.core.util.CursorUtil;
|
||||
import org.signal.core.util.StringUtil;
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.contacts.ContactRepository;
|
||||
import org.thoughtcrime.securesms.conversation.MessageStyler;
|
||||
import org.thoughtcrime.securesms.database.BodyAdjustment;
|
||||
import org.thoughtcrime.securesms.database.BodyRangeUtil;
|
||||
@@ -63,7 +62,6 @@ public class SearchRepository {
|
||||
private final Context context;
|
||||
private final String noteToSelfTitle;
|
||||
private final SearchTable searchDatabase;
|
||||
private final ContactRepository contactRepository;
|
||||
private final ThreadTable threadTable;
|
||||
private final RecipientTable recipientTable;
|
||||
private final MentionTable mentionTable;
|
||||
@@ -79,7 +77,6 @@ public class SearchRepository {
|
||||
this.recipientTable = SignalDatabase.recipients();
|
||||
this.mentionTable = SignalDatabase.mentions();
|
||||
this.messageTable = SignalDatabase.messages();
|
||||
this.contactRepository = new ContactRepository(noteToSelfTitle);
|
||||
this.serialExecutor = new SerialExecutor(SignalExecutors.BOUNDED);
|
||||
}
|
||||
|
||||
@@ -436,15 +433,6 @@ public class SearchRepository {
|
||||
return combined;
|
||||
}
|
||||
|
||||
private static class RecipientModelBuilder implements ModelBuilder<Recipient> {
|
||||
|
||||
@Override
|
||||
public Recipient build(@NonNull Cursor cursor) {
|
||||
long recipientId = cursor.getLong(cursor.getColumnIndexOrThrow(ContactRepository.ID_COLUMN));
|
||||
return Recipient.resolved(RecipientId.from(recipientId));
|
||||
}
|
||||
}
|
||||
|
||||
private static class ThreadModelBuilder implements ModelBuilder<ThreadRecord> {
|
||||
|
||||
private final ThreadTable threadTable;
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import org.signal.core.util.StreamUtil;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
/**
|
||||
* Implementation of {@link androidx.lifecycle.LiveData} that will handle closing the contained
|
||||
* {@link Closeable} when the value changes.
|
||||
*/
|
||||
public class CloseableLiveData<E extends Closeable> extends MutableLiveData<E> {
|
||||
|
||||
@Override
|
||||
public void setValue(E value) {
|
||||
setValue(value, true);
|
||||
}
|
||||
|
||||
public void setValue(E value, boolean closePrevious) {
|
||||
E previous = getValue();
|
||||
|
||||
if (previous != null && closePrevious) {
|
||||
StreamUtil.close(previous);
|
||||
}
|
||||
|
||||
super.setValue(value);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
E value = getValue();
|
||||
|
||||
if (value != null) {
|
||||
StreamUtil.close(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user