Rewrite the AppDependencies system.

This commit is contained in:
Greyson Parrelli
2024-05-22 15:44:24 -04:00
committed by Cody Henthorne
parent a0131bf39b
commit b6a4e1f145
560 changed files with 2909 additions and 3036 deletions

View File

@@ -18,7 +18,7 @@ import org.signal.libsignal.protocol.util.ByteUtil;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.backup.BackupPassphrase;
import org.thoughtcrime.securesms.database.NoExternalStorageException;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.permissions.Permissions;
@@ -127,7 +127,7 @@ public class BackupUtil {
}
private static List<BackupInfo> getAllBackupsNewestFirst() throws NoExternalStorageException {
if (isUserSelectionRequired(ApplicationDependencies.getApplication())) {
if (isUserSelectionRequired(AppDependencies.getApplication())) {
return getAllBackupsNewestFirstApi29();
} else {
return getAllBackupsNewestFirstLegacy();
@@ -142,7 +142,7 @@ public class BackupUtil {
return Collections.emptyList();
}
DocumentFile backupDirectory = DocumentFile.fromTreeUri(ApplicationDependencies.getApplication(), backupDirectoryUri);
DocumentFile backupDirectory = DocumentFile.fromTreeUri(AppDependencies.getApplication(), backupDirectoryUri);
if (backupDirectory == null || !backupDirectory.exists() || !backupDirectory.canRead()) {
Log.w(TAG, "Backup directory is inaccessible. Returning an empty list.");
return Collections.emptyList();
@@ -355,7 +355,7 @@ public class BackupUtil {
Log.w(TAG, "Delete failed: " + file.getAbsolutePath());
}
} else {
DocumentFile document = DocumentFile.fromSingleUri(ApplicationDependencies.getApplication(), uri);
DocumentFile document = DocumentFile.fromSingleUri(AppDependencies.getApplication(), uri);
if (document != null && document.exists()) {
Log.i(TAG, "Deleting DocumentFile: " + uri);

View File

@@ -16,7 +16,7 @@ import com.annimon.stream.Stream;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.notifications.NotificationIds;
import org.thoughtcrime.securesms.notifications.v2.NotificationFactory;
@@ -120,7 +120,7 @@ public final class BubbleUtil {
.orElse(null);
if (activeThreadNotification != null && activeThreadNotification.deleteIntent != null) {
ApplicationDependencies.getMessageNotifier().forceBubbleNotification(context, conversationId);
AppDependencies.getMessageNotifier().forceBubbleNotification(context, conversationId);
} else {
Recipient recipient = Recipient.resolved(recipientId);
NotificationFactory.notifyToBubbleConversation(context, recipient, threadId);

View File

@@ -36,7 +36,7 @@ import org.thoughtcrime.securesms.conversation.ConversationIntents;
import org.thoughtcrime.securesms.database.CallLinkTable;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.database.model.GroupRecord;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.groups.GroupId;
import org.thoughtcrime.securesms.groups.ui.invitesandrequests.joining.GroupJoinBottomSheetDialogFragment;
import org.thoughtcrime.securesms.groups.ui.invitesandrequests.joining.GroupJoinUpdateRequiredBottomSheetDialogFragment;
@@ -84,7 +84,7 @@ public class CommunicationActions {
}
if (recipient.isRegistered()) {
ApplicationDependencies.getSignalCallManager().isCallActive(new ResultReceiver(new Handler(Looper.getMainLooper())) {
AppDependencies.getSignalCallManager().isCallActive(new ResultReceiver(new Handler(Looper.getMainLooper())) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
if (resultCode == 1) {
@@ -127,7 +127,7 @@ public class CommunicationActions {
return;
}
ApplicationDependencies.getSignalCallManager().isCallActive(new ResultReceiver(new Handler(Looper.getMainLooper())) {
AppDependencies.getSignalCallManager().isCallActive(new ResultReceiver(new Handler(Looper.getMainLooper())) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
startCallInternal(callContext, recipient, resultCode != 1, fromCallLink);
@@ -392,7 +392,7 @@ public class CommunicationActions {
.withPermanentDenialDialog(callContext.getContext().getString(R.string.ConversationActivity__to_call_signal_needs_access_to_your_microphone), null, R.string.ConversationActivity_allow_access_microphone, R.string.ConversationActivity__to_start_call, callContext.getFragmentManager())
.onAnyDenied(() -> Toast.makeText(callContext.getContext(), R.string.ConversationActivity_signal_needs_microphone_access_voice_call, Toast.LENGTH_LONG).show())
.onAllGranted(() -> {
ApplicationDependencies.getSignalCallManager().startOutgoingAudioCall(recipient);
AppDependencies.getSignalCallManager().startOutgoingAudioCall(recipient);
MessageSender.onMessageSent();
@@ -406,7 +406,7 @@ public class CommunicationActions {
}
private static void startVideoCallInternal(@NonNull CallContext callContext, @NonNull Recipient recipient, boolean fromCallLink) {
ApplicationDependencies.getSignalCallManager().startPreJoinCall(recipient);
AppDependencies.getSignalCallManager().startPreJoinCall(recipient);
Intent activityIntent = new Intent(callContext.getContext(), WebRtcCallActivity.class);

View File

@@ -25,8 +25,7 @@ import org.thoughtcrime.securesms.contacts.avatars.GeneratedContactPhoto;
import org.thoughtcrime.securesms.contacts.avatars.SystemContactPhoto;
import org.thoughtcrime.securesms.conversation.colors.AvatarColor;
import org.thoughtcrime.securesms.database.model.ProfileAvatarFileDetails;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.profiles.AvatarHelper;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.recipients.Recipient;
import java.security.MessageDigest;
@@ -55,7 +54,7 @@ public final class ConversationShortcutPhoto implements Key {
@Override
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
messageDigest.update(recipient.getDisplayName(ApplicationDependencies.getApplication()).getBytes());
messageDigest.update(recipient.getDisplayName(AppDependencies.getApplication()).getBytes());
messageDigest.update(avatarObject.getBytes());
messageDigest.update(isSystemContactPhoto() ? (byte) 1 : (byte) 0);
messageDigest.update(profileAvatarFileDetails.getDiskCacheKeyBytes());

View File

@@ -13,7 +13,7 @@ import org.json.JSONObject;
import org.signal.core.util.SetUtil;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.groups.SelectionLimits;
import org.thoughtcrime.securesms.jobs.RemoteConfigRefreshJob;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
@@ -313,7 +313,7 @@ public final class FeatureFlags {
* desired test state.
*/
private static final Map<String, OnFlagChange> FLAG_CHANGE_LISTENERS = new HashMap<String, OnFlagChange>() {{
put(MESSAGE_PROCESSOR_ALARM_INTERVAL, change -> RoutineMessageFetchReceiver.startOrUpdateAlarm(ApplicationDependencies.getApplication()));
put(MESSAGE_PROCESSOR_ALARM_INTERVAL, change -> RoutineMessageFetchReceiver.startOrUpdateAlarm(AppDependencies.getApplication()));
}};
private static final Map<String, Object> REMOTE_VALUES = new TreeMap<>();
@@ -337,7 +337,7 @@ public final class FeatureFlags {
if (timeSinceLastFetch < 0 || timeSinceLastFetch > FETCH_INTERVAL) {
Log.i(TAG, "Scheduling remote config refresh.");
ApplicationDependencies.getJobManager().add(new RemoteConfigRefreshJob());
AppDependencies.getJobManager().add(new RemoteConfigRefreshJob());
} else {
Log.i(TAG, "Skipping remote config refresh. Refreshed " + timeSinceLastFetch + " ms ago.");
}
@@ -345,7 +345,7 @@ public final class FeatureFlags {
@WorkerThread
public static void refreshSync() throws IOException {
RemoteConfigResult result = ApplicationDependencies.getSignalServiceAccountManager().getRemoteConfig();
RemoteConfigResult result = AppDependencies.getSignalServiceAccountManager().getRemoteConfig();
FeatureFlags.update(result.getConfig());
}

View File

@@ -26,7 +26,7 @@ import org.thoughtcrime.securesms.database.MessageTable.InsertResult;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.database.model.GroupRecord;
import org.thoughtcrime.securesms.database.model.IdentityRecord;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.mms.IncomingMessage;
import org.thoughtcrime.securesms.mms.MmsException;
import org.thoughtcrime.securesms.mms.OutgoingMessage;
@@ -53,7 +53,7 @@ public final class IdentityUtil {
final RecipientId recipientId = recipient.getId();
SimpleTask.run(SignalExecutors.BOUNDED,
() -> ApplicationDependencies.getProtocolStore().aci().identities().getIdentityRecord(recipientId),
() -> AppDependencies.getProtocolStore().aci().identities().getIdentityRecord(recipientId),
future::set);
return future;
@@ -158,7 +158,7 @@ public final class IdentityUtil {
Optional<InsertResult> insertResult = smsDatabase.insertMessageInbox(individualUpdate);
if (insertResult.isPresent()) {
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.get().getThreadId()));
AppDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.get().getThreadId()));
}
} catch (MmsException e) {
throw new AssertionError(e);
@@ -169,10 +169,10 @@ public final class IdentityUtil {
public static void saveIdentity(String user, IdentityKey identityKey) {
try(SignalSessionLock.Lock unused = ReentrantSessionLock.INSTANCE.acquire()) {
SessionStore sessionStore = ApplicationDependencies.getProtocolStore().aci();
SessionStore sessionStore = AppDependencies.getProtocolStore().aci();
SignalProtocolAddress address = new SignalProtocolAddress(user, SignalServiceAddress.DEFAULT_DEVICE_ID);
if (ApplicationDependencies.getProtocolStore().aci().identities().saveIdentity(address, identityKey)) {
if (AppDependencies.getProtocolStore().aci().identities().saveIdentity(address, identityKey)) {
if (sessionStore.containsSession(address)) {
SessionRecord sessionRecord = sessionStore.loadSession(address);
sessionRecord.archiveCurrentState();
@@ -207,7 +207,7 @@ public final class IdentityUtil {
public static void processVerifiedMessage(Context context, VerifiedMessage verifiedMessage) {
try(SignalSessionLock.Lock unused = ReentrantSessionLock.INSTANCE.acquire()) {
SignalIdentityKeyStore identityStore = ApplicationDependencies.getProtocolStore().aci().identities();
SignalIdentityKeyStore identityStore = AppDependencies.getProtocolStore().aci().identities();
Recipient recipient = Recipient.externalPush(verifiedMessage.getDestination());
if (recipient.isSelf()) {

View File

@@ -9,7 +9,7 @@ import android.net.Network
import android.os.Build
import androidx.annotation.RequiresApi
import io.reactivex.rxjava3.core.Observable
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
object InternetConnectionObserver {
@@ -27,7 +27,7 @@ object InternetConnectionObserver {
@RequiresApi(24)
private fun observeApi24(): Observable<Boolean> {
return Observable.create {
val application = ApplicationDependencies.getApplication()
val application = AppDependencies.application
val connectivityManager = ServiceUtil.getConnectivityManager(application)
val callback = object : ConnectivityManager.NetworkCallback() {
@@ -51,7 +51,7 @@ object InternetConnectionObserver {
@Suppress("DEPRECATION")
private fun observeApi19(): Observable<Boolean> {
return Observable.create {
val application = ApplicationDependencies.getApplication()
val application = AppDependencies.application
val observer = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {

View File

@@ -5,11 +5,11 @@
package org.thoughtcrime.securesms.util
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.jobmanager.JobManager
/** Starts a new chain with this job. */
fun Job.asChain(): JobManager.Chain {
return ApplicationDependencies.getJobManager().startChain(this)
return AppDependencies.jobManager.startChain(this)
}

View File

@@ -7,7 +7,7 @@ import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.database.LocalMetricsDatabase
import org.thoughtcrime.securesms.database.model.LocalMetricsEvent
import org.thoughtcrime.securesms.database.model.LocalMetricsSplit
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.dependencies.AppDependencies
import java.util.concurrent.Executor
import java.util.concurrent.TimeUnit
@@ -33,7 +33,7 @@ object LocalMetrics {
private val lastSplitTimeById: MutableMap<String, Long> = LRUCache(200)
private val executor: Executor = SignalExecutors.newCachedSingleThreadExecutor("signal-LocalMetrics", ThreadUtil.PRIORITY_BACKGROUND_THREAD)
private val db: LocalMetricsDatabase by lazy { LocalMetricsDatabase.getInstance(ApplicationDependencies.getApplication()) }
private val db: LocalMetricsDatabase by lazy { LocalMetricsDatabase.getInstance(AppDependencies.application) }
@JvmStatic
fun getInstance(): LocalMetrics {

View File

@@ -16,7 +16,7 @@ import androidx.core.content.ContextCompat;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.spoiler.SpoilerAnnotation;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import java.lang.ref.WeakReference;
@@ -119,7 +119,7 @@ public class LongClickMovementMethod extends LinkMovementMethod {
/** This signature is available in the base class and can lead to the wrong instance being returned. */
public static LongClickMovementMethod getInstance() {
return getInstance(ApplicationDependencies.getApplication());
return getInstance(AppDependencies.getApplication());
}
public static LongClickMovementMethod getInstance(Context context) {

View File

@@ -7,7 +7,7 @@ import android.os.ParcelFileDescriptor;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import java.io.FileDescriptor;
import java.io.IOException;
@@ -23,7 +23,7 @@ public final class MemoryFileUtil {
throws IOException
{
if (Build.VERSION.SDK_INT >= 26) {
return MemoryFileDescriptorProxy.create(ApplicationDependencies.getApplication(), file);
return MemoryFileDescriptorProxy.create(AppDependencies.getApplication(), file);
} else {
return getParcelFileDescriptorLegacy(file);
}

View File

@@ -20,7 +20,7 @@ import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
import org.thoughtcrime.securesms.database.RecipientTable;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobs.GroupV2UpdateSelfProfileKeyJob;
import org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob;
@@ -81,12 +81,12 @@ public final class ProfileUtil {
Log.w(TAG, "[handleSelfProfileKeyChange] Scheduling jobs, including " + gv2UpdateJobs.size() + " group update jobs.");
ApplicationDependencies.getJobManager()
.startChain(new RefreshAttributesJob())
.then(new ProfileUploadJob())
.then(new MultiDeviceProfileKeyUpdateJob())
.then(gv2UpdateJobs)
.enqueue();
AppDependencies.getJobManager()
.startChain(new RefreshAttributesJob())
.then(new ProfileUploadJob())
.then(new MultiDeviceProfileKeyUpdateJob())
.then(gv2UpdateJobs)
.enqueue();
}
@WorkerThread
@@ -114,7 +114,7 @@ public final class ProfileUtil {
@NonNull SignalServiceProfile.RequestType requestType)
throws IOException
{
ProfileService profileService = ApplicationDependencies.getProfileService();
ProfileService profileService = AppDependencies.getProfileService();
ServiceResponse<ProfileAndCredential> response = Single
.fromCallable(() -> new SignalServiceAddress(pni))
@@ -137,7 +137,7 @@ public final class ProfileUtil {
@NonNull SignalServiceProfile.RequestType requestType,
boolean allowUnidentifiedAccess)
{
ProfileService profileService = ApplicationDependencies.getProfileService();
ProfileService profileService = AppDependencies.getProfileService();
Optional<UnidentifiedAccess> unidentifiedAccess = allowUnidentifiedAccess ? getUnidentifiedAccess(context, recipient) : Optional.empty();
Optional<ProfileKey> profileKey = ProfileKeyUtil.profileKeyOptional(recipient.getProfileKey());
@@ -189,7 +189,7 @@ public final class ProfileUtil {
Log.w(TAG, "Profile key not available for " + recipient.getId());
throw new PaymentsAddressException(PaymentsAddressException.Code.NO_PROFILE_KEY);
}
ProfileAndCredential profileAndCredential = ProfileUtil.retrieveProfileSync(ApplicationDependencies.getApplication(), recipient, SignalServiceProfile.RequestType.PROFILE);
ProfileAndCredential profileAndCredential = ProfileUtil.retrieveProfileSync(AppDependencies.getApplication(), recipient, SignalServiceProfile.RequestType.PROFILE);
SignalServiceProfile profile = profileAndCredential.getProfile();
byte[] encryptedPaymentsAddress = profile.getPaymentAddress();
@@ -323,8 +323,8 @@ public final class ProfileUtil {
if (profileKey != null) {
Log.i(TAG, String.format("Updating profile key credential on recipient %s, fetching", recipient.getId()));
Optional<ExpiringProfileKeyCredential> profileKeyCredentialOptional = ApplicationDependencies.getSignalServiceAccountManager()
.resolveProfileKeyCredential(recipient.requireAci(), profileKey, Locale.getDefault());
Optional<ExpiringProfileKeyCredential> profileKeyCredentialOptional = AppDependencies.getSignalServiceAccountManager()
.resolveProfileKeyCredential(recipient.requireAci(), profileKey, Locale.getDefault());
if (profileKeyCredentialOptional.isPresent()) {
boolean updatedProfileKey = SignalDatabase.recipients().setProfileKeyCredential(recipient.getId(), profileKey, profileKeyCredentialOptional.get());
@@ -367,7 +367,7 @@ public final class ProfileUtil {
}
ProfileKey profileKey = ProfileKeyUtil.getSelfProfileKey();
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
SignalServiceAccountManager accountManager = AppDependencies.getSignalServiceAccountManager();
String avatarPath = accountManager.setVersionedProfile(SignalStore.account().requireAci(),
profileKey,
profileName.serialize(),
@@ -381,7 +381,7 @@ public final class ProfileUtil {
if (!avatar.keepTheSame) {
SignalDatabase.recipients().setProfileAvatar(Recipient.self().getId(), avatarPath);
}
ApplicationDependencies.getJobManager().add(new RefreshOwnProfileJob());
AppDependencies.getJobManager().add(new RefreshOwnProfileJob());
}
private static @Nullable PaymentAddress getSelfPaymentsAddressProtobuf() {
@@ -389,9 +389,9 @@ public final class ProfileUtil {
return null;
} else {
IdentityKeyPair identityKeyPair = SignalStore.account().getAciIdentityKey();
MobileCoinPublicAddress publicAddress = ApplicationDependencies.getPayments()
.getWallet()
.getMobileCoinPublicAddress();
MobileCoinPublicAddress publicAddress = AppDependencies.getPayments()
.getWallet()
.getMobileCoinPublicAddress();
return MobileCoinPublicAddressProfileUtil.signPaymentsAddress(publicAddress.serialize(), identityKeyPair);
}

View File

@@ -27,7 +27,7 @@ import org.signal.core.util.logging.Log
import org.signal.core.util.orNull
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.mms.PartAuthority
import java.io.File
import java.io.FileOutputStream
@@ -110,15 +110,15 @@ object SaveAttachmentUtil {
val updateValues = ContentValues()
val mediaUri = result.mediaUri ?: return null
val inputStream: InputStream = PartAuthority.getAttachmentStream(ApplicationDependencies.getApplication(), attachment.uri) ?: return null
val inputStream: InputStream = PartAuthority.getAttachmentStream(AppDependencies.application, attachment.uri) ?: return null
inputStream.use { inStream ->
if (result.outputUri.scheme == ContentResolver.SCHEME_FILE) {
FileOutputStream(mediaUri.path).use { outStream ->
StreamUtil.copy(inStream, outStream)
MediaScannerConnection.scanFile(ApplicationDependencies.getApplication(), arrayOf(mediaUri.path), arrayOf(contentType), null)
MediaScannerConnection.scanFile(AppDependencies.application, arrayOf(mediaUri.path), arrayOf(contentType), null)
}
} else {
ApplicationDependencies.getApplication().contentResolver.openOutputStream(mediaUri, "w").use { outStream ->
AppDependencies.application.contentResolver.openOutputStream(mediaUri, "w").use { outStream ->
val total = StreamUtil.copy(inStream, outStream)
if (total > 0) {
updateValues.put(MediaStore.MediaColumns.SIZE, total)
@@ -132,7 +132,7 @@ object SaveAttachmentUtil {
}
if (updateValues.size() > 0) {
ApplicationDependencies.getApplication().contentResolver.update(mediaUri, updateValues, null, null)
AppDependencies.application.contentResolver.update(mediaUri, updateValues, null, null)
}
return result.outputUri.lastPathSegment
@@ -231,11 +231,11 @@ object SaveAttachmentUtil {
}
return try {
CreateMediaUriResult(outputUri, ApplicationDependencies.getApplication().contentResolver.insert(outputUri, contentValues))
CreateMediaUriResult(outputUri, AppDependencies.application.contentResolver.insert(outputUri, contentValues))
} catch (e: RuntimeException) {
if (e is IllegalArgumentException || e.cause is IllegalArgumentException) {
Log.w(TAG, "Unable to create uri in $outputUri with mimeType [$mimeType]")
CreateMediaUriResult(StorageUtil.getDownloadUri(), ApplicationDependencies.getApplication().contentResolver.insert(StorageUtil.getDownloadUri(), contentValues))
CreateMediaUriResult(StorageUtil.getDownloadUri(), AppDependencies.application.contentResolver.insert(StorageUtil.getDownloadUri(), contentValues))
} else {
throw e
}
@@ -272,7 +272,7 @@ object SaveAttachmentUtil {
@Throws(IOException::class)
private fun pathTaken(outputUri: Uri, dataPath: String): Boolean {
val cursor: Cursor = ApplicationDependencies.getApplication().contentResolver.query(
val cursor: Cursor = AppDependencies.application.contentResolver.query(
outputUri,
arrayOf(MediaStore.MediaColumns.DATA),
"${MediaStore.MediaColumns.DATA} = ?",
@@ -285,7 +285,7 @@ object SaveAttachmentUtil {
@Throws(IOException::class)
private fun displayNameTaken(outputUri: Uri, displayName: String): Boolean {
val cursor: Cursor = ApplicationDependencies.getApplication().contentResolver.query(
val cursor: Cursor = AppDependencies.application.contentResolver.query(
outputUri,
arrayOf(MediaStore.MediaColumns.DISPLAY_NAME),
"${MediaStore.MediaColumns.DISPLAY_NAME} = ?",

View File

@@ -5,7 +5,7 @@ import android.util.DisplayMetrics;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -54,7 +54,7 @@ public final class ScreenDensity {
}
public static @NonNull String getBestDensityBucketForDevice() {
ScreenDensity density = get(ApplicationDependencies.getApplication());
ScreenDensity density = get(AppDependencies.getApplication());
if (density.isKnownDensity()) {
return density.bucket;

View File

@@ -7,7 +7,7 @@ import androidx.annotation.WorkerThread;
import org.conscrypt.ConscryptSignal;
import org.signal.core.util.concurrent.SignalExecutors;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.push.AccountManagerFactory;
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
@@ -37,12 +37,12 @@ public final class SignalProxyUtil {
private SignalProxyUtil() {}
public static void startListeningToWebsocket() {
if (SignalStore.proxy().isProxyEnabled() && ApplicationDependencies.getSignalWebSocket().getWebSocketState().firstOrError().blockingGet().isFailure()) {
if (SignalStore.proxy().isProxyEnabled() && AppDependencies.getSignalWebSocket().getWebSocketState().firstOrError().blockingGet().isFailure()) {
Log.w(TAG, "Proxy is in a failed state. Restarting.");
ApplicationDependencies.closeConnections();
AppDependencies.resetNetwork();
}
ApplicationDependencies.getIncomingMessageObserver();
AppDependencies.getIncomingMessageObserver();
}
/**
@@ -52,7 +52,7 @@ public final class SignalProxyUtil {
public static void enableProxy(@NonNull SignalProxy proxy) {
SignalStore.proxy().enableProxy(proxy);
ConscryptSignal.setUseEngineSocketByDefault(true);
ApplicationDependencies.resetAllNetworkConnections();
AppDependencies.resetNetwork();
startListeningToWebsocket();
}
@@ -63,7 +63,7 @@ public final class SignalProxyUtil {
public static void disableProxy() {
SignalStore.proxy().disableProxy();
ConscryptSignal.setUseEngineSocketByDefault(false);
ApplicationDependencies.resetAllNetworkConnections();
AppDependencies.resetNetwork();
startListeningToWebsocket();
}
@@ -88,16 +88,16 @@ public final class SignalProxyUtil {
return testWebsocketConnectionUnregistered(timeout);
}
return ApplicationDependencies.getSignalWebSocket()
.getWebSocketState()
.subscribeOn(Schedulers.trampoline())
.observeOn(Schedulers.trampoline())
.timeout(timeout, TimeUnit.MILLISECONDS)
.skipWhile(state -> state != WebSocketConnectionState.CONNECTED && !state.isFailure())
.firstOrError()
.flatMap(state -> Single.just(state == WebSocketConnectionState.CONNECTED))
.onErrorReturn(t -> false)
.blockingGet();
return AppDependencies.getSignalWebSocket()
.getWebSocketState()
.subscribeOn(Schedulers.trampoline())
.observeOn(Schedulers.trampoline())
.timeout(timeout, TimeUnit.MILLISECONDS)
.skipWhile(state -> state != WebSocketConnectionState.CONNECTED && !state.isFailure())
.firstOrError()
.flatMap(state -> Single.just(state == WebSocketConnectionState.CONNECTED))
.onErrorReturn(t -> false)
.blockingGet();
}
/**
@@ -158,7 +158,7 @@ public final class SignalProxyUtil {
private static boolean testWebsocketConnectionUnregistered(long timeout) {
CountDownLatch latch = new CountDownLatch(1);
AtomicBoolean success = new AtomicBoolean(false);
SignalServiceAccountManager accountManager = AccountManagerFactory.getInstance().createUnauthenticated(ApplicationDependencies.getApplication(), "", SignalServiceAddress.DEFAULT_DEVICE_ID, "");
SignalServiceAccountManager accountManager = AccountManagerFactory.getInstance().createUnauthenticated(AppDependencies.getApplication(), "", SignalServiceAddress.DEFAULT_DEVICE_ID, "");
SignalExecutors.UNBOUNDED.execute(() -> {
try {

View File

@@ -7,9 +7,8 @@ import androidx.annotation.NonNull;
import org.signal.core.util.ExceptionUtil;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.database.LogDatabase;
import org.thoughtcrime.securesms.database.SearchTable;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import java.io.IOException;
@@ -59,10 +58,10 @@ public class SignalUncaughtExceptionHandler implements Thread.UncaughtExceptionH
}
Log.e(TAG, "", e, true);
LogDatabase.getInstance(ApplicationDependencies.getApplication()).crashes().saveCrash(System.currentTimeMillis(), exceptionName, e.getMessage(), ExceptionUtil.convertThrowableToString(e));
LogDatabase.getInstance(AppDependencies.getApplication()).crashes().saveCrash(System.currentTimeMillis(), exceptionName, e.getMessage(), ExceptionUtil.convertThrowableToString(e));
SignalStore.blockUntilAllWritesFinished();
Log.blockUntilAllWritesFinished();
ApplicationDependencies.getJobManager().flush();
AppDependencies.getJobManager().flush();
originalHandler.uncaughtException(t, ExceptionUtil.joinStackTraceAndMessage(e));
}
}

View File

@@ -16,7 +16,7 @@ import androidx.annotation.RequiresApi;
import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.database.NoExternalStorageException;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.permissions.PermissionCompat;
import org.thoughtcrime.securesms.permissions.Permissions;
@@ -107,11 +107,11 @@ public class StorageUtil {
public static boolean canWriteToMediaStore() {
return Build.VERSION.SDK_INT > 28 ||
Permissions.hasAll(ApplicationDependencies.getApplication(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
Permissions.hasAll(AppDependencies.getApplication(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
public static boolean canReadFromMediaStore() {
return Permissions.hasAny(ApplicationDependencies.getApplication(), PermissionCompat.forImagesAndVideos());
return Permissions.hasAny(AppDependencies.getApplication(), PermissionCompat.forImagesAndVideos());
}
public static @NonNull Uri getVideoUri() {

View File

@@ -23,7 +23,7 @@ import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.backup.proto.SharedPreference;
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraintObserver;
import org.thoughtcrime.securesms.keyvalue.SettingsValues;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
@@ -1131,7 +1131,7 @@ public class TextSecurePreferences {
Recipient self = Recipient.self();
SignalDatabase.recipients().setProfileKey(self.getId(), newProfileKey);
ApplicationDependencies.getGroupsV2Authorization().clear();
AppDependencies.getGroupsV2Authorization().clear();
}
private static SharedPreferences getSharedPreferences(Context context) {

View File

@@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.util
import android.content.Context
import android.content.pm.PackageManager
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob
import org.thoughtcrime.securesms.jobs.RemoteConfigRefreshJob
import org.thoughtcrime.securesms.jobs.RetrieveRemoteAnnouncementsJob
@@ -27,7 +27,7 @@ object VersionTracker {
Log.i(TAG, "Upgraded from $lastVersionCode to $currentVersionCode")
SignalStore.misc().isClientDeprecated = false
val jobChain = listOf(RemoteConfigRefreshJob(), RefreshAttributesJob())
ApplicationDependencies.getJobManager().startChain(jobChain).enqueue()
AppDependencies.jobManager.startChain(jobChain).enqueue()
RetrieveRemoteAnnouncementsJob.enqueue(true)
LocalMetrics.getInstance().clear()
}

View File

@@ -9,7 +9,7 @@ import androidx.navigation.NavController
import androidx.navigation.NavDirections
import androidx.navigation.NavOptions
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.dependencies.AppDependencies
private const val TAG = "SafeNavigation"
@@ -62,7 +62,7 @@ private fun getDisplayName(id: Int): String? {
id.toString()
} else {
try {
ApplicationDependencies.getApplication().resources.getResourceName(id)
AppDependencies.application.resources.getResourceName(id)
} catch (e: Resources.NotFoundException) {
id.toString()
}

View File

@@ -4,7 +4,7 @@ import android.content.Context;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.dependencies.AppDependencies;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.util.adapter.mapping.MappingModel;
@@ -26,7 +26,7 @@ public abstract class RecipientMappingModel<T extends RecipientMappingModel<T>>
@Override
public boolean areContentsTheSame(@NonNull T newItem) {
Context context = ApplicationDependencies.getApplication();
Context context = AppDependencies.getApplication();
return getName(context).equals(newItem.getName(context)) && Objects.equals(getRecipient().getContactPhoto(), newItem.getRecipient().getContactPhoto());
}