Move from dagger to a service locator pattern.
This commit is contained in:
parent
8d6f1341f1
commit
475c54213d
58 changed files with 405 additions and 685 deletions
|
@ -105,10 +105,7 @@ dependencies {
|
|||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||
implementation 'com.melnykov:floatingactionbutton:1.3.0'
|
||||
implementation 'com.google.zxing:android-integration:3.1.0'
|
||||
implementation 'com.squareup.dagger:dagger:1.2.2'
|
||||
annotationProcessor 'com.squareup.dagger:dagger-compiler:1.2.2'
|
||||
implementation 'mobi.upod:time-duration-picker:1.1.3'
|
||||
compileOnly 'com.squareup.dagger:dagger-compiler:1.2.2'
|
||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||
implementation 'com.google.zxing:core:3.2.1'
|
||||
implementation ('com.davemorrissey.labs:subsampling-scale-image-view:3.6.0') {
|
||||
|
@ -207,7 +204,6 @@ dependencyVerification {
|
|||
'com.makeramen:roundedimageview:1f5a1865796b308c6cdd114acc6e78408b110f0a62fc63553278fbeacd489cd1',
|
||||
'org.greenrobot:eventbus:180d4212467df06f2fbc9c8d8a2984533ac79c87769ad883bc421612f0b4e17c',
|
||||
'com.google.zxing:android-integration:89e56aadf1164bd71e57949163c53abf90af368b51669c0d4a47a163335f95c4',
|
||||
'com.squareup.dagger:dagger:789aca24537022e49f91fc6444078d9de8f1dd99e1bfb090f18491b186967883',
|
||||
'com.amulyakhare:com.amulyakhare.textdrawable:54c92b5fba38cfd316a07e5a30528068f45ce8515a6890f1297df4c401af5dcb',
|
||||
'com.google.zxing:core:b4d82452e7a6bf6ec2698904b332431717ed8f9a850224f295aec89de80f2259',
|
||||
'com.davemorrissey.labs:subsampling-scale-image-view:550c5baa07e0bb4ff0a18b705e96d34436d22619248bd8c08c08c730b1f55cfe',
|
||||
|
@ -273,7 +269,6 @@ dependencyVerification {
|
|||
'com.github.bumptech.glide:disklrucache:4696a81340eb6beee21ab93f703ed6e7ae49fb4ce3bc2fbc546e5bacd21b96b9',
|
||||
'com.github.bumptech.glide:annotations:702a7521cb3f6d7e55edd66e90bda1a1975baf971d25f75b75638579f86bc69b',
|
||||
'com.nineoldandroids:library:68025a14e3e7673d6ad2f95e4b46d78d7d068343aa99256b686fe59de1b3163a',
|
||||
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
|
||||
'com.klinkerapps:logger:177e325259a8b111ad6745ec10db5861723c99f402222b80629f576f49408541',
|
||||
'com.google.android:flexbox:a9989fd13ae2ee42765dfc515fe362edf4f326e74925d02a10369df8092a4935',
|
||||
'org.jsoup:jsoup:abeaf34795a4de70f72aed6de5966d2955ec7eb348eeb813324f23c999575473',
|
||||
|
@ -375,7 +370,6 @@ android {
|
|||
proguardFiles getDefaultProguardFile('proguard-android.txt'),
|
||||
'proguard-firebase-messaging.pro',
|
||||
'proguard-google-play-services.pro',
|
||||
'proguard-dagger.pro',
|
||||
'proguard-jackson.pro',
|
||||
'proguard-sqlite.pro',
|
||||
'proguard-appcompat-v7.pro',
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
-keepattributes *Annotation*,EnclosingMethod
|
||||
-keep @interface dagger.*,javax.inject.*
|
||||
-keep @dagger.Module class *
|
||||
-keepclassmembers class * {
|
||||
@javax.inject.* *;
|
||||
@dagger.* *;
|
||||
<init>();
|
||||
}
|
||||
-keepclasseswithmembernames class * {
|
||||
@javax.inject.* <fields>;
|
||||
}
|
||||
-keep class javax.inject.** { *; }
|
||||
-keep class **$$ModuleAdapter
|
||||
-keep class **$$InjectAdapter
|
||||
-keep class **$$StaticInjection
|
||||
|
||||
-keep class dagger.** { *; }
|
||||
-keep class * extends dagger.** { *; }
|
||||
-keep interface dagger.** {*;}
|
||||
-dontwarn dagger.internal.codegen.**
|
|
@ -36,11 +36,9 @@ import org.signal.aesgcmprovider.AesGcmProvider;
|
|||
import org.thoughtcrime.securesms.components.TypingStatusRepository;
|
||||
import org.thoughtcrime.securesms.components.TypingStatusSender;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.dependencies.AxolotlStorageModule;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.SignalCommunicationModule;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencyProvider;
|
||||
import org.thoughtcrime.securesms.gcm.FcmJobService;
|
||||
import org.thoughtcrime.securesms.jobmanager.DependencyInjector;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.JsonDataSerializer;
|
||||
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
||||
|
@ -80,8 +78,6 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import dagger.ObjectGraph;
|
||||
|
||||
/**
|
||||
* Will be called once when the TextSecure process is created.
|
||||
*
|
||||
|
@ -90,7 +86,7 @@ import dagger.ObjectGraph;
|
|||
*
|
||||
* @author Moxie Marlinspike
|
||||
*/
|
||||
public class ApplicationContext extends MultiDexApplication implements DependencyInjector, DefaultLifecycleObserver {
|
||||
public class ApplicationContext extends MultiDexApplication implements DefaultLifecycleObserver {
|
||||
|
||||
private static final String TAG = ApplicationContext.class.getSimpleName();
|
||||
|
||||
|
@ -99,7 +95,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||
private TypingStatusSender typingStatusSender;
|
||||
private JobManager jobManager;
|
||||
private IncomingMessageObserver incomingMessageObserver;
|
||||
private ObjectGraph objectGraph;
|
||||
private PersistentLogger persistentLogger;
|
||||
|
||||
private volatile boolean isAppVisible;
|
||||
|
@ -115,7 +110,7 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||
initializeSecurityProvider();
|
||||
initializeLogging();
|
||||
initializeCrashHandling();
|
||||
initializeDependencyInjection();
|
||||
initializeAppDependencies();
|
||||
initializeJobManager();
|
||||
initializeMessageRetrieval();
|
||||
initializeExpiringMessageManager();
|
||||
|
@ -151,13 +146,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||
MessageNotifier.setVisibleThread(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectDependencies(Object object) {
|
||||
if (object instanceof InjectableType) {
|
||||
objectGraph.inject(object);
|
||||
}
|
||||
}
|
||||
|
||||
public JobManager getJobManager() {
|
||||
return jobManager;
|
||||
}
|
||||
|
@ -225,7 +213,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||
.setConstraintFactories(JobManagerFactories.getConstraintFactories(this))
|
||||
.setConstraintObservers(JobManagerFactories.getConstraintObservers(this))
|
||||
.setJobStorage(new FastJobStorage(DatabaseFactory.getJobDatabase(this)))
|
||||
.setDependencyInjector(this)
|
||||
.build());
|
||||
}
|
||||
|
||||
|
@ -233,9 +220,8 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||
this.incomingMessageObserver = new IncomingMessageObserver(this);
|
||||
}
|
||||
|
||||
private void initializeDependencyInjection() {
|
||||
this.objectGraph = ObjectGraph.create(new SignalCommunicationModule(this, new SignalServiceNetworkAccess(this)),
|
||||
new AxolotlStorageModule(this));
|
||||
private void initializeAppDependencies() {
|
||||
ApplicationDependencies.init(new ApplicationDependencyProvider(this, new SignalServiceNetworkAccess(this)));
|
||||
}
|
||||
|
||||
private void initializeGcmCheck() {
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.thoughtcrime.securesms.components.emoji.MediaKeyboard;
|
|||
import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
|
@ -64,10 +64,8 @@ import java.io.IOException;
|
|||
import java.security.SecureRandom;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public class CreateProfileActivity extends BaseActionBarActivity implements InjectableType {
|
||||
public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
|
||||
private static final String TAG = CreateProfileActivity.class.getSimpleName();
|
||||
|
||||
|
@ -77,8 +75,6 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje
|
|||
private final DynamicTheme dynamicTheme = new DynamicRegistrationTheme();
|
||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
||||
|
||||
@Inject SignalServiceAccountManager accountManager;
|
||||
|
||||
private InputAwareLayout container;
|
||||
private ImageView avatar;
|
||||
private CircularProgressButton finishButton;
|
||||
|
@ -106,8 +102,6 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje
|
|||
initializeEmojiInput();
|
||||
initializeProfileName(getIntent().getBooleanExtra(EXCLUDE_SYSTEM, false));
|
||||
initializeProfileAvatar(getIntent().getBooleanExtra(EXCLUDE_SYSTEM, false));
|
||||
|
||||
ApplicationContext.getInstance(this).injectDependencies(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -361,8 +355,9 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje
|
|||
new AsyncTask<Void, Void, Boolean>() {
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
Context context = CreateProfileActivity.this;
|
||||
byte[] profileKey = ProfileKeyUtil.getProfileKey(CreateProfileActivity.this);
|
||||
Context context = CreateProfileActivity.this;
|
||||
byte[] profileKey = ProfileKeyUtil.getProfileKey(CreateProfileActivity.this);
|
||||
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
|
||||
try {
|
||||
accountManager.setProfileName(profileKey, name);
|
||||
|
|
|
@ -11,6 +11,7 @@ import androidx.loader.app.LoaderManager;
|
|||
import androidx.loader.content.Loader;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.devicelist.Device;
|
||||
import org.thoughtcrime.securesms.jobs.RefreshUnidentifiedDeliveryAbilityJob;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
|
@ -26,7 +27,6 @@ import android.widget.Toast;
|
|||
import com.melnykov.fab.FloatingActionButton;
|
||||
|
||||
import org.thoughtcrime.securesms.database.loaders.DeviceListLoader;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
@ -36,23 +36,19 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class DeviceListFragment extends ListFragment
|
||||
implements LoaderManager.LoaderCallbacks<List<Device>>,
|
||||
ListView.OnItemClickListener, InjectableType, Button.OnClickListener
|
||||
ListView.OnItemClickListener, Button.OnClickListener
|
||||
{
|
||||
|
||||
private static final String TAG = DeviceListFragment.class.getSimpleName();
|
||||
|
||||
@Inject
|
||||
SignalServiceAccountManager accountManager;
|
||||
|
||||
private Locale locale;
|
||||
private View empty;
|
||||
private View progressContainer;
|
||||
private FloatingActionButton addDeviceButton;
|
||||
private Button.OnClickListener addDeviceButtonListener;
|
||||
private SignalServiceAccountManager accountManager;
|
||||
private Locale locale;
|
||||
private View empty;
|
||||
private View progressContainer;
|
||||
private FloatingActionButton addDeviceButton;
|
||||
private Button.OnClickListener addDeviceButtonListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -63,7 +59,7 @@ public class DeviceListFragment extends ListFragment
|
|||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
ApplicationContext.getInstance(activity).injectDependencies(this);
|
||||
this.accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1590,7 +1590,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
|
||||
|
||||
private void initializeLinkPreviewObserver() {
|
||||
linkPreviewViewModel = ViewModelProviders.of(this, new LinkPreviewViewModel.Factory(new LinkPreviewRepository(this))).get(LinkPreviewViewModel.class);
|
||||
linkPreviewViewModel = ViewModelProviders.of(this, new LinkPreviewViewModel.Factory(new LinkPreviewRepository())).get(LinkPreviewViewModel.class);
|
||||
|
||||
if (!TextSecurePreferences.isLinkPreviewsEnabled(this)) {
|
||||
linkPreviewViewModel.onUserCancel();
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package org.thoughtcrime.securesms.dependencies;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
|
||||
/**
|
||||
* Location for storing and retrieving application-scoped singletons. Users must call
|
||||
* {@link #init(Provider)} before using any of the methods, preferably early on in
|
||||
* {@link Application#onCreate()}.
|
||||
*
|
||||
* All future application-scoped singletons should be written as normal objects, then placed here
|
||||
* to manage their singleton-ness.
|
||||
*/
|
||||
public class ApplicationDependencies {
|
||||
|
||||
private static ApplicationDependencies instance;
|
||||
|
||||
private final Provider provider;
|
||||
|
||||
private ApplicationDependencies(@NonNull Provider provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public static synchronized void init(@NonNull Provider provider) {
|
||||
instance = new ApplicationDependencies(provider);
|
||||
}
|
||||
|
||||
public static synchronized @NonNull SignalServiceAccountManager getSignalServiceAccountManager() {
|
||||
assertInitialization();
|
||||
return instance.provider.getSignalServiceAccountManager();
|
||||
}
|
||||
|
||||
public static synchronized @NonNull SignalServiceMessageSender getSignalServiceMessageSender() {
|
||||
assertInitialization();
|
||||
return instance.provider.getSignalServiceMessageSender();
|
||||
}
|
||||
|
||||
public static synchronized @NonNull SignalServiceMessageReceiver getSignalServiceMessageReceiver() {
|
||||
assertInitialization();
|
||||
return instance.provider.getSignalServiceMessageReceiver();
|
||||
}
|
||||
|
||||
public static synchronized @NonNull SignalServiceNetworkAccess getSignalServiceNetworkAccess() {
|
||||
assertInitialization();
|
||||
return instance.provider.getSignalServiceNetworkAccess();
|
||||
}
|
||||
|
||||
private static void assertInitialization() {
|
||||
if (instance == null) {
|
||||
throw new UninitializedException();
|
||||
}
|
||||
}
|
||||
|
||||
public interface Provider {
|
||||
@NonNull SignalServiceAccountManager getSignalServiceAccountManager();
|
||||
@NonNull SignalServiceMessageSender getSignalServiceMessageSender();
|
||||
@NonNull SignalServiceMessageReceiver getSignalServiceMessageReceiver();
|
||||
@NonNull SignalServiceNetworkAccess getSignalServiceNetworkAccess();
|
||||
}
|
||||
|
||||
private static class UninitializedException extends IllegalStateException {
|
||||
private UninitializedException() {
|
||||
super("You must call init() first!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
package org.thoughtcrime.securesms.dependencies;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.thoughtcrime.securesms.BuildConfig;
|
||||
import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl;
|
||||
import org.thoughtcrime.securesms.events.ReminderUpdateEvent;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.push.SecurityEventListener;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
import org.thoughtcrime.securesms.service.IncomingMessageObserver;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
import org.whispersystems.signalservice.api.util.CredentialsProvider;
|
||||
import org.whispersystems.signalservice.api.util.RealtimeSleepTimer;
|
||||
import org.whispersystems.signalservice.api.util.SleepTimer;
|
||||
import org.whispersystems.signalservice.api.util.UptimeSleepTimer;
|
||||
import org.whispersystems.signalservice.api.websocket.ConnectivityListener;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApplicationDependencies.Provider} that provides real app dependencies.
|
||||
*/
|
||||
public class ApplicationDependencyProvider implements ApplicationDependencies.Provider {
|
||||
|
||||
private static final String TAG = Log.tag(ApplicationDependencyProvider.class);
|
||||
|
||||
private final Context context;
|
||||
private final SignalServiceNetworkAccess networkAccess;
|
||||
|
||||
private SignalServiceAccountManager accountManager;
|
||||
private SignalServiceMessageSender messageSender;
|
||||
private SignalServiceMessageReceiver messageReceiver;
|
||||
|
||||
public ApplicationDependencyProvider(@NonNull Context context, @NonNull SignalServiceNetworkAccess networkAccess) {
|
||||
this.context = context.getApplicationContext();
|
||||
this.networkAccess = networkAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull SignalServiceAccountManager getSignalServiceAccountManager() {
|
||||
if (accountManager == null) {
|
||||
this.accountManager = new SignalServiceAccountManager(networkAccess.getConfiguration(context),
|
||||
new DynamicCredentialsProvider(context),
|
||||
BuildConfig.USER_AGENT);
|
||||
}
|
||||
|
||||
return accountManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull SignalServiceMessageSender getSignalServiceMessageSender() {
|
||||
if (this.messageSender == null) {
|
||||
this.messageSender = new SignalServiceMessageSender(networkAccess.getConfiguration(context),
|
||||
new DynamicCredentialsProvider(context),
|
||||
new SignalProtocolStoreImpl(context),
|
||||
BuildConfig.USER_AGENT,
|
||||
TextSecurePreferences.isMultiDevice(context),
|
||||
Optional.fromNullable(IncomingMessageObserver.getPipe()),
|
||||
Optional.fromNullable(IncomingMessageObserver.getUnidentifiedPipe()),
|
||||
Optional.of(new SecurityEventListener(context)));
|
||||
}else {
|
||||
this.messageSender.setMessagePipe(IncomingMessageObserver.getPipe(), IncomingMessageObserver.getUnidentifiedPipe());
|
||||
this.messageSender.setIsMultiDevice(TextSecurePreferences.isMultiDevice(context));
|
||||
}
|
||||
|
||||
return this.messageSender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull SignalServiceMessageReceiver getSignalServiceMessageReceiver() {
|
||||
if (this.messageReceiver == null) {
|
||||
SleepTimer sleepTimer = TextSecurePreferences.isFcmDisabled(context) ? new RealtimeSleepTimer(context)
|
||||
: new UptimeSleepTimer();
|
||||
|
||||
this.messageReceiver = new SignalServiceMessageReceiver(networkAccess.getConfiguration(context),
|
||||
new DynamicCredentialsProvider(context),
|
||||
BuildConfig.USER_AGENT,
|
||||
new PipeConnectivityListener(),
|
||||
sleepTimer);
|
||||
}
|
||||
|
||||
return this.messageReceiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull SignalServiceNetworkAccess getSignalServiceNetworkAccess() {
|
||||
return networkAccess;
|
||||
}
|
||||
|
||||
private static class DynamicCredentialsProvider implements CredentialsProvider {
|
||||
|
||||
private final Context context;
|
||||
|
||||
private DynamicCredentialsProvider(Context context) {
|
||||
this.context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUser() {
|
||||
return TextSecurePreferences.getLocalNumber(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return TextSecurePreferences.getPushServerPassword(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignalingKey() {
|
||||
return TextSecurePreferences.getSignalingKey(context);
|
||||
}
|
||||
}
|
||||
|
||||
private class PipeConnectivityListener implements ConnectivityListener {
|
||||
|
||||
@Override
|
||||
public void onConnected() {
|
||||
Log.i(TAG, "onConnected()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnecting() {
|
||||
Log.i(TAG, "onConnecting()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
Log.w(TAG, "onDisconnected()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationFailure() {
|
||||
Log.w(TAG, "onAuthenticationFailure()");
|
||||
TextSecurePreferences.setUnauthorizedReceived(context, true);
|
||||
EventBus.getDefault().post(new ReminderUpdateEvent());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package org.thoughtcrime.securesms.dependencies;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl;
|
||||
import org.thoughtcrime.securesms.jobs.CleanPreKeysJob;
|
||||
import org.whispersystems.libsignal.state.SignedPreKeyStore;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module (complete = false, injects = {CleanPreKeysJob.class})
|
||||
public class AxolotlStorageModule {
|
||||
|
||||
private final Context context;
|
||||
|
||||
public AxolotlStorageModule(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Provides SignedPreKeyStoreFactory provideSignedPreKeyStoreFactory() {
|
||||
return new SignedPreKeyStoreFactory() {
|
||||
@Override
|
||||
public SignedPreKeyStore create() {
|
||||
return new SignalProtocolStoreImpl(context);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static interface SignedPreKeyStoreFactory {
|
||||
public SignedPreKeyStore create();
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package org.thoughtcrime.securesms.dependencies;
|
||||
|
||||
public interface InjectableType {
|
||||
}
|
|
@ -1,230 +0,0 @@
|
|||
package org.thoughtcrime.securesms.dependencies;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.thoughtcrime.securesms.BuildConfig;
|
||||
import org.thoughtcrime.securesms.CreateProfileActivity;
|
||||
import org.thoughtcrime.securesms.DeviceListFragment;
|
||||
import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl;
|
||||
import org.thoughtcrime.securesms.events.ReminderUpdateEvent;
|
||||
import org.thoughtcrime.securesms.gcm.FcmJobService;
|
||||
import org.thoughtcrime.securesms.gcm.FcmService;
|
||||
import org.thoughtcrime.securesms.jobs.AttachmentDownloadJob;
|
||||
import org.thoughtcrime.securesms.jobs.AttachmentUploadJob;
|
||||
import org.thoughtcrime.securesms.jobs.AvatarDownloadJob;
|
||||
import org.thoughtcrime.securesms.jobs.CleanPreKeysJob;
|
||||
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
||||
import org.thoughtcrime.securesms.jobs.FcmRefreshJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceConfigurationUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceGroupUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceStickerPackOperationJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceStickerPackSyncJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceVerifiedUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushGroupSendJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushGroupUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushMediaSendJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushTextSendJob;
|
||||
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob;
|
||||
import org.thoughtcrime.securesms.jobs.RefreshPreKeysJob;
|
||||
import org.thoughtcrime.securesms.jobs.RefreshUnidentifiedDeliveryAbilityJob;
|
||||
import org.thoughtcrime.securesms.jobs.RequestGroupInfoJob;
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob;
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileJob;
|
||||
import org.thoughtcrime.securesms.jobs.RotateCertificateJob;
|
||||
import org.thoughtcrime.securesms.jobs.RotateProfileKeyJob;
|
||||
import org.thoughtcrime.securesms.jobs.RotateSignedPreKeyJob;
|
||||
import org.thoughtcrime.securesms.jobs.SendDeliveryReceiptJob;
|
||||
import org.thoughtcrime.securesms.jobs.SendReadReceiptJob;
|
||||
import org.thoughtcrime.securesms.jobs.StickerDownloadJob;
|
||||
import org.thoughtcrime.securesms.jobs.StickerPackDownloadJob;
|
||||
import org.thoughtcrime.securesms.jobs.TypingSendJob;
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreviewRepository;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
|
||||
import org.thoughtcrime.securesms.push.SecurityEventListener;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
import org.thoughtcrime.securesms.service.IncomingMessageObserver;
|
||||
import org.thoughtcrime.securesms.service.WebRtcCallService;
|
||||
import org.thoughtcrime.securesms.stickers.StickerPackPreviewRepository;
|
||||
import org.thoughtcrime.securesms.stickers.StickerRemoteUriLoader;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
import org.whispersystems.signalservice.api.util.CredentialsProvider;
|
||||
import org.whispersystems.signalservice.api.util.RealtimeSleepTimer;
|
||||
import org.whispersystems.signalservice.api.util.SleepTimer;
|
||||
import org.whispersystems.signalservice.api.util.UptimeSleepTimer;
|
||||
import org.whispersystems.signalservice.api.websocket.ConnectivityListener;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module(complete = false, injects = {CleanPreKeysJob.class,
|
||||
CreateSignedPreKeyJob.class,
|
||||
PushGroupSendJob.class,
|
||||
PushTextSendJob.class,
|
||||
PushMediaSendJob.class,
|
||||
AttachmentDownloadJob.class,
|
||||
RefreshPreKeysJob.class,
|
||||
IncomingMessageObserver.class,
|
||||
PushNotificationReceiveJob.class,
|
||||
MultiDeviceContactUpdateJob.class,
|
||||
MultiDeviceGroupUpdateJob.class,
|
||||
MultiDeviceReadUpdateJob.class,
|
||||
MultiDeviceBlockedUpdateJob.class,
|
||||
DeviceListFragment.class,
|
||||
RefreshAttributesJob.class,
|
||||
FcmRefreshJob.class,
|
||||
RequestGroupInfoJob.class,
|
||||
PushGroupUpdateJob.class,
|
||||
AvatarDownloadJob.class,
|
||||
RotateSignedPreKeyJob.class,
|
||||
WebRtcCallService.class,
|
||||
RetrieveProfileJob.class,
|
||||
MultiDeviceVerifiedUpdateJob.class,
|
||||
CreateProfileActivity.class,
|
||||
RetrieveProfileAvatarJob.class,
|
||||
MultiDeviceProfileKeyUpdateJob.class,
|
||||
SendReadReceiptJob.class,
|
||||
AppProtectionPreferenceFragment.class,
|
||||
FcmService.class,
|
||||
RotateCertificateJob.class,
|
||||
SendDeliveryReceiptJob.class,
|
||||
RotateProfileKeyJob.class,
|
||||
MultiDeviceConfigurationUpdateJob.class,
|
||||
RefreshUnidentifiedDeliveryAbilityJob.class,
|
||||
TypingSendJob.class,
|
||||
AttachmentUploadJob.class,
|
||||
StickerDownloadJob.class,
|
||||
StickerPackPreviewRepository.class,
|
||||
StickerRemoteUriLoader.Factory.class,
|
||||
StickerPackDownloadJob.class,
|
||||
MultiDeviceStickerPackOperationJob.class,
|
||||
MultiDeviceStickerPackSyncJob.class,
|
||||
LinkPreviewRepository.class,
|
||||
FcmJobService.class})
|
||||
public class SignalCommunicationModule {
|
||||
|
||||
private static final String TAG = SignalCommunicationModule.class.getSimpleName();
|
||||
|
||||
private final Context context;
|
||||
private final SignalServiceNetworkAccess networkAccess;
|
||||
|
||||
private SignalServiceAccountManager accountManager;
|
||||
private SignalServiceMessageSender messageSender;
|
||||
private SignalServiceMessageReceiver messageReceiver;
|
||||
|
||||
public SignalCommunicationModule(Context context, SignalServiceNetworkAccess networkAccess) {
|
||||
this.context = context;
|
||||
this.networkAccess = networkAccess;
|
||||
}
|
||||
|
||||
@Provides
|
||||
synchronized SignalServiceAccountManager provideSignalAccountManager() {
|
||||
if (this.accountManager == null) {
|
||||
this.accountManager = new SignalServiceAccountManager(networkAccess.getConfiguration(context),
|
||||
new DynamicCredentialsProvider(context),
|
||||
BuildConfig.USER_AGENT);
|
||||
}
|
||||
|
||||
return this.accountManager;
|
||||
}
|
||||
|
||||
@Provides
|
||||
synchronized SignalServiceMessageSender provideSignalMessageSender() {
|
||||
if (this.messageSender == null) {
|
||||
this.messageSender = new SignalServiceMessageSender(networkAccess.getConfiguration(context),
|
||||
new DynamicCredentialsProvider(context),
|
||||
new SignalProtocolStoreImpl(context),
|
||||
BuildConfig.USER_AGENT,
|
||||
TextSecurePreferences.isMultiDevice(context),
|
||||
Optional.fromNullable(IncomingMessageObserver.getPipe()),
|
||||
Optional.fromNullable(IncomingMessageObserver.getUnidentifiedPipe()),
|
||||
Optional.of(new SecurityEventListener(context)));
|
||||
} else {
|
||||
this.messageSender.setMessagePipe(IncomingMessageObserver.getPipe(), IncomingMessageObserver.getUnidentifiedPipe());
|
||||
this.messageSender.setIsMultiDevice(TextSecurePreferences.isMultiDevice(context));
|
||||
}
|
||||
|
||||
return this.messageSender;
|
||||
}
|
||||
|
||||
@Provides
|
||||
synchronized SignalServiceMessageReceiver provideSignalMessageReceiver() {
|
||||
if (this.messageReceiver == null) {
|
||||
SleepTimer sleepTimer = TextSecurePreferences.isFcmDisabled(context) ? new RealtimeSleepTimer(context) : new UptimeSleepTimer();
|
||||
|
||||
this.messageReceiver = new SignalServiceMessageReceiver(networkAccess.getConfiguration(context),
|
||||
new DynamicCredentialsProvider(context),
|
||||
BuildConfig.USER_AGENT,
|
||||
new PipeConnectivityListener(),
|
||||
sleepTimer);
|
||||
}
|
||||
|
||||
return this.messageReceiver;
|
||||
}
|
||||
|
||||
@Provides
|
||||
synchronized SignalServiceNetworkAccess provideSignalServiceNetworkAccess() {
|
||||
return networkAccess;
|
||||
}
|
||||
|
||||
private static class DynamicCredentialsProvider implements CredentialsProvider {
|
||||
|
||||
private final Context context;
|
||||
|
||||
private DynamicCredentialsProvider(Context context) {
|
||||
this.context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUser() {
|
||||
return TextSecurePreferences.getLocalNumber(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return TextSecurePreferences.getPushServerPassword(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignalingKey() {
|
||||
return TextSecurePreferences.getSignalingKey(context);
|
||||
}
|
||||
}
|
||||
|
||||
private class PipeConnectivityListener implements ConnectivityListener {
|
||||
|
||||
@Override
|
||||
public void onConnected() {
|
||||
Log.i(TAG, "onConnected()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnecting() {
|
||||
Log.i(TAG, "onConnecting()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
Log.w(TAG, "onDisconnected()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationFailure() {
|
||||
Log.w(TAG, "onAuthenticationFailure()");
|
||||
TextSecurePreferences.setUnauthorizedReceived(context, true);
|
||||
EventBus.getDefault().post(new ReminderUpdateEvent());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
|
@ -20,20 +20,16 @@ import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Pulls down messages. Used when we fail to pull down messages in {@link FcmService}.
|
||||
*/
|
||||
@RequiresApi(26)
|
||||
public class FcmJobService extends JobService implements InjectableType {
|
||||
public class FcmJobService extends JobService {
|
||||
|
||||
private static final String TAG = FcmJobService.class.getSimpleName();
|
||||
|
||||
private static final int ID = 1337;
|
||||
|
||||
@Inject SignalServiceMessageReceiver messageReceiver;
|
||||
|
||||
@RequiresApi(26)
|
||||
public static void schedule(@NonNull Context context) {
|
||||
JobInfo.Builder jobInfoBuilder = new JobInfo.Builder(ID, new ComponentName(context, FcmJobService.class))
|
||||
|
@ -47,7 +43,6 @@ public class FcmJobService extends JobService implements InjectableType {
|
|||
@Override
|
||||
public boolean onStartJob(JobParameters params) {
|
||||
Log.d(TAG, "onStartJob()");
|
||||
ApplicationContext.getInstance(getApplicationContext()).injectDependencies(this);
|
||||
|
||||
if (ApplicationContext.getInstance(getApplicationContext()).isAppVisible()) {
|
||||
Log.i(TAG, "App is foregrounded. No need to run.");
|
||||
|
@ -56,6 +51,7 @@ public class FcmJobService extends JobService implements InjectableType {
|
|||
|
||||
SignalExecutors.UNBOUNDED.execute(() -> {
|
||||
try {
|
||||
SignalServiceMessageReceiver messageReceiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
new PushNotificationReceiveJob(getApplicationContext()).pullAndProcessMessages(messageReceiver, TAG, System.currentTimeMillis());
|
||||
Log.i(TAG, "Successfully retrieved messages.");
|
||||
jobFinished(params, false);
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.google.firebase.messaging.FirebaseMessagingService;
|
|||
import com.google.firebase.messaging.RemoteMessage;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.jobs.FcmRefreshJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob;
|
||||
|
@ -25,17 +25,13 @@ import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class FcmService extends FirebaseMessagingService implements InjectableType {
|
||||
public class FcmService extends FirebaseMessagingService {
|
||||
|
||||
private static final String TAG = FcmService.class.getSimpleName();
|
||||
|
||||
private static final String WAKE_LOCK_TAG = "FcmMessageProcessing";
|
||||
private static final long SOCKET_TIMEOUT = TimeUnit.SECONDS.toMillis(10);
|
||||
|
||||
@Inject SignalServiceMessageReceiver messageReceiver;
|
||||
|
||||
private static int activeCount;
|
||||
|
||||
@Override
|
||||
|
@ -46,8 +42,6 @@ public class FcmService extends FirebaseMessagingService implements InjectableTy
|
|||
if (challenge != null) {
|
||||
handlePushChallenge(challenge);
|
||||
} else {
|
||||
ApplicationContext.getInstance(getApplicationContext()).injectDependencies(this);
|
||||
|
||||
WakeLockUtil.runWithLock(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK, 60000, WAKE_LOCK_TAG, () ->
|
||||
handleReceivedNotification(getApplicationContext())
|
||||
);
|
||||
|
@ -76,10 +70,11 @@ public class FcmService extends FirebaseMessagingService implements InjectableTy
|
|||
|
||||
TextSecurePreferences.setNeedsMessagePull(context, true);
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
PowerManager powerManager = ServiceUtil.getPowerManager(getApplicationContext());
|
||||
boolean doze = PowerManagerCompat.isDeviceIdleMode(powerManager);
|
||||
boolean network = new NetworkConstraint.Factory(ApplicationContext.getInstance(context)).create().isMet();
|
||||
long startTime = System.currentTimeMillis();
|
||||
SignalServiceMessageReceiver messageReceiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
PowerManager powerManager = ServiceUtil.getPowerManager(getApplicationContext());
|
||||
boolean doze = PowerManagerCompat.isDeviceIdleMode(powerManager);
|
||||
boolean network = new NetworkConstraint.Factory(ApplicationContext.getInstance(context)).create().isMet();
|
||||
|
||||
if (doze || !network) {
|
||||
Log.w(TAG, "We may be operating in a constrained environment. Doze: " + doze + " Network: " + network);
|
||||
|
|
|
@ -36,7 +36,6 @@ class JobController {
|
|||
private final JobInstantiator jobInstantiator;
|
||||
private final ConstraintInstantiator constraintInstantiator;
|
||||
private final Data.Serializer dataSerializer;
|
||||
private final DependencyInjector dependencyInjector;
|
||||
private final Scheduler scheduler;
|
||||
private final Debouncer debouncer;
|
||||
private final Callback callback;
|
||||
|
@ -47,7 +46,6 @@ class JobController {
|
|||
@NonNull JobInstantiator jobInstantiator,
|
||||
@NonNull ConstraintInstantiator constraintInstantiator,
|
||||
@NonNull Data.Serializer dataSerializer,
|
||||
@NonNull DependencyInjector dependencyInjector,
|
||||
@NonNull Scheduler scheduler,
|
||||
@NonNull Debouncer debouncer,
|
||||
@NonNull Callback callback)
|
||||
|
@ -57,7 +55,6 @@ class JobController {
|
|||
this.jobInstantiator = jobInstantiator;
|
||||
this.constraintInstantiator = constraintInstantiator;
|
||||
this.dataSerializer = dataSerializer;
|
||||
this.dependencyInjector = dependencyInjector;
|
||||
this.scheduler = scheduler;
|
||||
this.debouncer = debouncer;
|
||||
this.callback = callback;
|
||||
|
@ -328,8 +325,6 @@ class JobController {
|
|||
job.setNextRunAttemptTime(jobSpec.getNextRunAttemptTime());
|
||||
job.setContext(application);
|
||||
|
||||
dependencyInjector.injectDependencies(job);
|
||||
|
||||
return job;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
configuration.getJobInstantiator(),
|
||||
configuration.getConstraintFactories(),
|
||||
configuration.getDataSerializer(),
|
||||
configuration.getDependencyInjector(),
|
||||
Build.VERSION.SDK_INT < 26 ? new AlarmManagerScheduler(application)
|
||||
: new CompositeScheduler(new InAppScheduler(this), new JobSchedulerScheduler(application)),
|
||||
new Debouncer(500),
|
||||
|
@ -208,7 +207,6 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
private final List<ConstraintObserver> constraintObservers;
|
||||
private final Data.Serializer dataSerializer;
|
||||
private final JobStorage jobStorage;
|
||||
private final DependencyInjector dependencyInjector;
|
||||
|
||||
private Configuration(int jobThreadCount,
|
||||
@NonNull ExecutorFactory executorFactory,
|
||||
|
@ -216,8 +214,7 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
@NonNull ConstraintInstantiator constraintInstantiator,
|
||||
@NonNull List<ConstraintObserver> constraintObservers,
|
||||
@NonNull Data.Serializer dataSerializer,
|
||||
@NonNull JobStorage jobStorage,
|
||||
@NonNull DependencyInjector dependencyInjector)
|
||||
@NonNull JobStorage jobStorage)
|
||||
{
|
||||
this.executorFactory = executorFactory;
|
||||
this.jobThreadCount = jobThreadCount;
|
||||
|
@ -226,7 +223,6 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
this.constraintObservers = constraintObservers;
|
||||
this.dataSerializer = dataSerializer;
|
||||
this.jobStorage = jobStorage;
|
||||
this.dependencyInjector = dependencyInjector;
|
||||
}
|
||||
|
||||
int getJobThreadCount() {
|
||||
|
@ -258,10 +254,6 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
return jobStorage;
|
||||
}
|
||||
|
||||
@NonNull DependencyInjector getDependencyInjector() {
|
||||
return dependencyInjector;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private ExecutorFactory executorFactory = new DefaultExecutorFactory();
|
||||
|
@ -271,7 +263,6 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
private List<ConstraintObserver> constraintObservers = new ArrayList<>();
|
||||
private Data.Serializer dataSerializer = new JsonDataSerializer();
|
||||
private JobStorage jobStorage = null;
|
||||
private DependencyInjector dependencyInjector = o -> { /*noop*/ };
|
||||
|
||||
public @NonNull Builder setJobThreadCount(int jobThreadCount) {
|
||||
this.jobThreadCount = jobThreadCount;
|
||||
|
@ -308,11 +299,6 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Builder setDependencyInjector(@NonNull DependencyInjector dependencyInjector) {
|
||||
this.dependencyInjector = dependencyInjector;
|
||||
return this;
|
||||
}
|
||||
|
||||
public @NonNull Configuration build() {
|
||||
return new Configuration(jobThreadCount,
|
||||
executorFactory,
|
||||
|
@ -320,8 +306,7 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
new ConstraintInstantiator(constraintFactories),
|
||||
new ArrayList<>(constraintObservers),
|
||||
dataSerializer,
|
||||
jobStorage,
|
||||
dependencyInjector);
|
||||
jobStorage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.thoughtcrime.securesms.attachments.AttachmentId;
|
|||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.events.PartProgressEvent;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
|
@ -33,9 +33,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class AttachmentDownloadJob extends BaseJob implements InjectableType {
|
||||
public class AttachmentDownloadJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "AttachmentDownloadJob";
|
||||
|
||||
|
@ -47,8 +45,6 @@ public class AttachmentDownloadJob extends BaseJob implements InjectableType {
|
|||
private static final String KEY_PAR_UNIQUE_ID = "part_unique_id";
|
||||
private static final String KEY_MANUAL = "part_manual";
|
||||
|
||||
@Inject SignalServiceMessageReceiver messageReceiver;
|
||||
|
||||
private long messageId;
|
||||
private long partRowId;
|
||||
private long partUniqueId;
|
||||
|
@ -164,8 +160,9 @@ public class AttachmentDownloadJob extends BaseJob implements InjectableType {
|
|||
try {
|
||||
attachmentFile = createTempFile();
|
||||
|
||||
SignalServiceAttachmentPointer pointer = createAttachmentPointer(attachment);
|
||||
InputStream stream = messageReceiver.retrieveAttachment(pointer, attachmentFile, MAX_ATTACHMENT_SIZE, (total, progress) -> EventBus.getDefault().postSticky(new PartProgressEvent(attachment, total, progress)));
|
||||
SignalServiceMessageReceiver messageReceiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
SignalServiceAttachmentPointer pointer = createAttachmentPointer(attachment);
|
||||
InputStream stream = messageReceiver.retrieveAttachment(pointer, attachmentFile, MAX_ATTACHMENT_SIZE, (total, progress) -> EventBus.getDefault().postSticky(new PartProgressEvent(attachment, total, progress)));
|
||||
|
||||
database.insertAttachmentsForPlaceholder(messageId, attachmentId, stream);
|
||||
} catch (InvalidPartException | NonSuccessfulResponseCodeException | InvalidMessageException | MmsException e) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
|||
import org.thoughtcrime.securesms.attachments.PointerAttachment;
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.events.PartProgressEvent;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
|
@ -34,9 +34,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class AttachmentUploadJob extends BaseJob implements InjectableType {
|
||||
public class AttachmentUploadJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "AttachmentUploadJob";
|
||||
|
||||
|
@ -50,8 +48,7 @@ public class AttachmentUploadJob extends BaseJob implements InjectableType {
|
|||
*/
|
||||
private static final int FOREGROUND_LIMIT = 10 * 1024 * 1024;
|
||||
|
||||
private AttachmentId attachmentId;
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
private AttachmentId attachmentId;
|
||||
|
||||
public AttachmentUploadJob(AttachmentId attachmentId) {
|
||||
this(new Job.Parameters.Builder()
|
||||
|
@ -81,8 +78,9 @@ public class AttachmentUploadJob extends BaseJob implements InjectableType {
|
|||
|
||||
@Override
|
||||
public void onRun() throws Exception {
|
||||
AttachmentDatabase database = DatabaseFactory.getAttachmentDatabase(context);
|
||||
DatabaseAttachment databaseAttachment = database.getAttachment(attachmentId);
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
AttachmentDatabase database = DatabaseFactory.getAttachmentDatabase(context);
|
||||
DatabaseAttachment databaseAttachment = database.getAttachment(attachmentId);
|
||||
|
||||
if (databaseAttachment == null) {
|
||||
throw new IllegalStateException("Cannot find the specified attachment.");
|
||||
|
|
|
@ -6,7 +6,7 @@ import androidx.annotation.NonNull;
|
|||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -26,9 +26,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class AvatarDownloadJob extends BaseJob implements InjectableType {
|
||||
public class AvatarDownloadJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "AvatarDownloadJob";
|
||||
|
||||
|
@ -38,8 +36,6 @@ public class AvatarDownloadJob extends BaseJob implements InjectableType {
|
|||
|
||||
private static final String KEY_GROUP_ID = "group_id";
|
||||
|
||||
@Inject SignalServiceMessageReceiver receiver;
|
||||
|
||||
private byte[] groupId;
|
||||
|
||||
public AvatarDownloadJob(@NonNull byte[] groupId) {
|
||||
|
@ -92,6 +88,7 @@ public class AvatarDownloadJob extends BaseJob implements InjectableType {
|
|||
attachment = File.createTempFile("avatar", "tmp", context.getCacheDir());
|
||||
attachment.deleteOnExit();
|
||||
|
||||
SignalServiceMessageReceiver receiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
SignalServiceAttachmentPointer pointer = new SignalServiceAttachmentPointer(avatarId, contentType, key, Optional.of(0), Optional.absent(), 0, 0, digest, fileName, false, Optional.absent());
|
||||
InputStream inputStream = receiver.retrieveAttachment(pointer, attachment, MAX_AVATAR_SIZE);
|
||||
Bitmap avatar = BitmapUtil.createScaledBitmap(context, new AttachmentModel(attachment, key, 0, digest), 500, 500);
|
||||
|
|
|
@ -2,16 +2,15 @@ package org.thoughtcrime.securesms.jobs;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.PreKeyUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.whispersystems.libsignal.InvalidKeyIdException;
|
||||
import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
||||
import org.whispersystems.libsignal.state.SignedPreKeyStore;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
||||
|
||||
|
@ -22,11 +21,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.thoughtcrime.securesms.dependencies.AxolotlStorageModule.SignedPreKeyStoreFactory;
|
||||
|
||||
public class CleanPreKeysJob extends BaseJob implements InjectableType {
|
||||
public class CleanPreKeysJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "CleanPreKeysJob";
|
||||
|
||||
|
@ -34,9 +29,6 @@ public class CleanPreKeysJob extends BaseJob implements InjectableType {
|
|||
|
||||
private static final long ARCHIVE_AGE = TimeUnit.DAYS.toMillis(7);
|
||||
|
||||
@Inject SignalServiceAccountManager accountManager;
|
||||
@Inject SignedPreKeyStoreFactory signedPreKeyStoreFactory;
|
||||
|
||||
public CleanPreKeysJob() {
|
||||
this(new Job.Parameters.Builder()
|
||||
.setQueue("CleanPreKeysJob")
|
||||
|
@ -64,7 +56,7 @@ public class CleanPreKeysJob extends BaseJob implements InjectableType {
|
|||
Log.i(TAG, "Cleaning prekeys...");
|
||||
|
||||
int activeSignedPreKeyId = PreKeyUtil.getActiveSignedPreKeyId(context);
|
||||
SignedPreKeyStore signedPreKeyStore = signedPreKeyStoreFactory.create();
|
||||
SignedPreKeyStore signedPreKeyStore = new SignalProtocolStoreImpl(context);
|
||||
|
||||
if (activeSignedPreKeyId < 0) return;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||
import org.thoughtcrime.securesms.crypto.PreKeyUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -18,17 +18,12 @@ import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
||||
public class CreateSignedPreKeyJob extends BaseJob implements InjectableType {
|
||||
public class CreateSignedPreKeyJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "CreateSignedPreKeyJob";
|
||||
|
||||
private static final String TAG = CreateSignedPreKeyJob.class.getSimpleName();
|
||||
|
||||
@Inject SignalServiceAccountManager accountManager;
|
||||
|
||||
public CreateSignedPreKeyJob(Context context) {
|
||||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
|
@ -63,8 +58,9 @@ public class CreateSignedPreKeyJob extends BaseJob implements InjectableType {
|
|||
return;
|
||||
}
|
||||
|
||||
IdentityKeyPair identityKeyPair = IdentityKeyUtil.getIdentityKeyPair(context);
|
||||
SignedPreKeyRecord signedPreKeyRecord = PreKeyUtil.generateSignedPreKey(context, identityKeyPair, true);
|
||||
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
IdentityKeyPair identityKeyPair = IdentityKeyUtil.getIdentityKeyPair(context);
|
||||
SignedPreKeyRecord signedPreKeyRecord = PreKeyUtil.generateSignedPreKey(context, identityKeyPair, true);
|
||||
|
||||
accountManager.setSignedPreKey(signedPreKeyRecord);
|
||||
TextSecurePreferences.setSignedPreKeyRegistered(context, true);
|
||||
|
|
|
@ -27,6 +27,7 @@ import androidx.core.app.NotificationCompat;
|
|||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.gcm.FcmUtil;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
|
@ -35,27 +36,21 @@ import org.thoughtcrime.securesms.logging.Log;
|
|||
|
||||
import org.thoughtcrime.securesms.PlayServicesProblemActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulResponseCodeException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class FcmRefreshJob extends BaseJob implements InjectableType {
|
||||
public class FcmRefreshJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "FcmRefreshJob";
|
||||
|
||||
private static final String TAG = FcmRefreshJob.class.getSimpleName();
|
||||
|
||||
@Inject SignalServiceAccountManager textSecureAccountManager;
|
||||
|
||||
public FcmRefreshJob() {
|
||||
this(new Job.Parameters.Builder()
|
||||
.setQueue("FcmRefreshJob")
|
||||
|
@ -103,7 +98,7 @@ public class FcmRefreshJob extends BaseJob implements InjectableType {
|
|||
Log.i(TAG, "Token didn't change.");
|
||||
}
|
||||
|
||||
textSecureAccountManager.setGcmId(token);
|
||||
ApplicationDependencies.getSignalServiceAccountManager().setGcmId(token);
|
||||
TextSecurePreferences.setFcmToken(context, token.get());
|
||||
TextSecurePreferences.setFcmTokenLastSetTime(context, System.currentTimeMillis());
|
||||
TextSecurePreferences.setWebsocketRegistered(context, true);
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
|||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientReader;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -25,17 +25,13 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class MultiDeviceBlockedUpdateJob extends BaseJob implements InjectableType {
|
||||
public class MultiDeviceBlockedUpdateJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "MultiDeviceBlockedUpdateJob";
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = MultiDeviceBlockedUpdateJob.class.getSimpleName();
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
public MultiDeviceBlockedUpdateJob() {
|
||||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
|
@ -84,6 +80,7 @@ public class MultiDeviceBlockedUpdateJob extends BaseJob implements InjectableTy
|
|||
}
|
||||
}
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(blockedIndividuals, blockedGroups)),
|
||||
UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -19,9 +19,7 @@ import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class MultiDeviceConfigurationUpdateJob extends BaseJob implements InjectableType {
|
||||
public class MultiDeviceConfigurationUpdateJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "MultiDeviceConfigurationUpdateJob";
|
||||
|
||||
|
@ -32,8 +30,6 @@ public class MultiDeviceConfigurationUpdateJob extends BaseJob implements Inject
|
|||
private static final String KEY_UNIDENTIFIED_DELIVERY_INDICATORS_ENABLED = "unidentified_delivery_indicators_enabled";
|
||||
private static final String KEY_LINK_PREVIEWS_ENABLED = "link_previews_enabled";
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
private boolean readReceiptsEnabled;
|
||||
private boolean typingIndicatorsEnabled;
|
||||
private boolean unidentifiedDeliveryIndicatorsEnabled;
|
||||
|
@ -91,6 +87,7 @@ public class MultiDeviceConfigurationUpdateJob extends BaseJob implements Inject
|
|||
return;
|
||||
}
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forConfiguration(new ConfigurationMessage(Optional.of(readReceiptsEnabled),
|
||||
Optional.of(unidentifiedDeliveryIndicatorsEnabled),
|
||||
Optional.of(typingIndicatorsEnabled),
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
|||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.IdentityDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -47,9 +47,7 @@ import java.io.IOException;
|
|||
import java.util.Collection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class MultiDeviceContactUpdateJob extends BaseJob implements InjectableType {
|
||||
public class MultiDeviceContactUpdateJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "MultiDeviceContactUpdateJob";
|
||||
|
||||
|
@ -60,8 +58,6 @@ public class MultiDeviceContactUpdateJob extends BaseJob implements InjectableTy
|
|||
private static final String KEY_ADDRESS = "address";
|
||||
private static final String KEY_FORCE_SYNC = "force_sync";
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
private @Nullable String address;
|
||||
|
||||
private boolean forceSync;
|
||||
|
@ -146,7 +142,7 @@ public class MultiDeviceContactUpdateJob extends BaseJob implements InjectableTy
|
|||
Optional.absent()));
|
||||
|
||||
out.close();
|
||||
sendUpdate(messageSender, contactDataFile, false);
|
||||
sendUpdate(ApplicationDependencies.getSignalServiceMessageSender(), contactDataFile, false);
|
||||
|
||||
} catch(InvalidNumberException e) {
|
||||
Log.w(TAG, e);
|
||||
|
@ -208,7 +204,7 @@ public class MultiDeviceContactUpdateJob extends BaseJob implements InjectableTy
|
|||
}
|
||||
|
||||
out.close();
|
||||
sendUpdate(messageSender, contactDataFile, true);
|
||||
sendUpdate(ApplicationDependencies.getSignalServiceMessageSender(), contactDataFile, true);
|
||||
} catch(InvalidNumberException e) {
|
||||
Log.w(TAG, e);
|
||||
} finally {
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
|||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -34,16 +34,12 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class MultiDeviceGroupUpdateJob extends BaseJob implements InjectableType {
|
||||
public class MultiDeviceGroupUpdateJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "MultiDeviceGroupUpdateJob";
|
||||
|
||||
private static final String TAG = MultiDeviceGroupUpdateJob.class.getSimpleName();
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
public MultiDeviceGroupUpdateJob() {
|
||||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
|
@ -106,7 +102,7 @@ public class MultiDeviceGroupUpdateJob extends BaseJob implements InjectableType
|
|||
out.close();
|
||||
|
||||
if (contactDataFile.exists() && contactDataFile.length() > 0) {
|
||||
sendUpdate(messageSender, contactDataFile);
|
||||
sendUpdate(ApplicationDependencies.getSignalServiceMessageSender(), contactDataFile);
|
||||
} else {
|
||||
Log.w(TAG, "No groups present for sync message...");
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -10,7 +11,6 @@ import org.thoughtcrime.securesms.logging.Log;
|
|||
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
|
@ -28,16 +28,12 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class MultiDeviceProfileKeyUpdateJob extends BaseJob implements InjectableType {
|
||||
public class MultiDeviceProfileKeyUpdateJob extends BaseJob {
|
||||
|
||||
public static String KEY = "MultiDeviceProfileKeyUpdateJob";
|
||||
|
||||
private static final String TAG = MultiDeviceProfileKeyUpdateJob.class.getSimpleName();
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
public MultiDeviceProfileKeyUpdateJob() {
|
||||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
|
@ -81,6 +77,7 @@ public class MultiDeviceProfileKeyUpdateJob extends BaseJob implements Injectabl
|
|||
|
||||
out.close();
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
|
||||
.withStream(new ByteArrayInputStream(baos.toByteArray()))
|
||||
.withContentType("application/octet-stream")
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.annimon.stream.Stream;
|
|||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -13,7 +14,6 @@ import org.thoughtcrime.securesms.logging.Log;
|
|||
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.util.JsonUtils;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
|
@ -28,9 +28,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class MultiDeviceReadUpdateJob extends BaseJob implements InjectableType {
|
||||
public class MultiDeviceReadUpdateJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "MultiDeviceReadUpdateJob";
|
||||
|
||||
|
@ -40,8 +38,6 @@ public class MultiDeviceReadUpdateJob extends BaseJob implements InjectableType
|
|||
|
||||
private List<SerializableSyncMessageId> messageIds;
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
public MultiDeviceReadUpdateJob(List<SyncMessageId> messageIds) {
|
||||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
|
@ -94,6 +90,7 @@ public class MultiDeviceReadUpdateJob extends BaseJob implements InjectableType
|
|||
readMessages.add(new ReadMessage(messageId.sender, messageId.timestamp));
|
||||
}
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forRead(readMessages), UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -18,9 +18,7 @@ import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
|
|||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class MultiDeviceStickerPackOperationJob extends BaseJob implements InjectableType {
|
||||
public class MultiDeviceStickerPackOperationJob extends BaseJob {
|
||||
|
||||
private static final String TAG = Log.tag(MultiDeviceStickerPackOperationJob.class);
|
||||
|
||||
|
@ -34,8 +32,6 @@ public class MultiDeviceStickerPackOperationJob extends BaseJob implements Injec
|
|||
private final String packKey;
|
||||
private final Type type;
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
public MultiDeviceStickerPackOperationJob(@NonNull String packId,
|
||||
@NonNull String packKey,
|
||||
@NonNull Type type)
|
||||
|
@ -92,6 +88,7 @@ public class MultiDeviceStickerPackOperationJob extends BaseJob implements Injec
|
|||
default: throw new AssertionError("No matching type?");
|
||||
}
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
StickerPackOperationMessage stickerPackOperation = new StickerPackOperationMessage(packIdBytes, packKeyBytes, remoteType);
|
||||
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forStickerPackOperations(Collections.singletonList(stickerPackOperation)),
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
|||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.StickerDatabase.StickerPackRecordReader;
|
||||
import org.thoughtcrime.securesms.database.model.StickerPackRecord;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -22,19 +22,15 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Tells a linked desktop about all installed sticker packs.
|
||||
*/
|
||||
public class MultiDeviceStickerPackSyncJob extends BaseJob implements InjectableType {
|
||||
public class MultiDeviceStickerPackSyncJob extends BaseJob {
|
||||
|
||||
private static final String TAG = Log.tag(MultiDeviceStickerPackSyncJob.class);
|
||||
|
||||
public static final String KEY = "MultiDeviceStickerPackSyncJob";
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
public MultiDeviceStickerPackSyncJob() {
|
||||
this(new Parameters.Builder()
|
||||
.setQueue("MultiDeviceStickerPackSyncJob")
|
||||
|
@ -76,6 +72,7 @@ public class MultiDeviceStickerPackSyncJob extends BaseJob implements Injectable
|
|||
}
|
||||
}
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
messageSender.sendMessage(SignalServiceSyncMessage.forStickerPackOperations(operations),
|
||||
UnidentifiedAccessUtil.getAccessForSync(context));
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -11,7 +12,6 @@ import org.thoughtcrime.securesms.logging.Log;
|
|||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.IdentityDatabase.VerifiedStatus;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.util.Base64;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
@ -26,9 +26,7 @@ import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class MultiDeviceVerifiedUpdateJob extends BaseJob implements InjectableType {
|
||||
public class MultiDeviceVerifiedUpdateJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "MultiDeviceVerifiedUpdateJob";
|
||||
|
||||
|
@ -39,8 +37,6 @@ public class MultiDeviceVerifiedUpdateJob extends BaseJob implements InjectableT
|
|||
private static final String KEY_VERIFIED_STATUS = "verified_status";
|
||||
private static final String KEY_TIMESTAMP = "timestamp";
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
private String destination;
|
||||
private byte[] identityKey;
|
||||
private VerifiedStatus verifiedStatus;
|
||||
|
@ -100,6 +96,7 @@ public class MultiDeviceVerifiedUpdateJob extends BaseJob implements InjectableT
|
|||
return;
|
||||
}
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
Address canonicalDestination = Address.fromSerialized(destination);
|
||||
VerifiedMessage.VerifiedState verifiedState = getVerifiedState(verifiedStatus);
|
||||
VerifiedMessage verifiedMessage = new VerifiedMessage(canonicalDestination.toPhoneString(), new IdentityKey(identityKey, 0), verifiedState, timestamp);
|
||||
|
|
|
@ -1360,7 +1360,6 @@ public class PushDecryptJob extends BaseJob {
|
|||
AttachmentDownloadJob downloadJob = new AttachmentDownloadJob(messageId, stickerAttachment.getAttachmentId(), true);
|
||||
|
||||
try {
|
||||
ApplicationContext.getInstance(context).injectDependencies(downloadJob);
|
||||
downloadJob.setContext(context);
|
||||
downloadJob.doWork();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.thoughtcrime.securesms.database.MmsDatabase;
|
|||
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
|
@ -53,16 +53,12 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
public class PushGroupSendJob extends PushSendJob {
|
||||
|
||||
public static final String KEY = "PushGroupSendJob";
|
||||
|
||||
private static final String TAG = PushGroupSendJob.class.getSimpleName();
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
private static final String KEY_MESSAGE_ID = "message_id";
|
||||
private static final String KEY_FILTER_ADDRESS = "filter_address";
|
||||
|
||||
|
@ -227,6 +223,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
|||
throws IOException, UntrustedIdentityException, UndeliverableMessageException {
|
||||
rotateSenderCertificateIfNecessary();
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
String groupId = message.getRecipient().getAddress().toGroupString();
|
||||
Optional<byte[]> profileKey = getProfileKey(message.getRecipient());
|
||||
Optional<Quote> quote = getQuoteFor(message);
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.thoughtcrime.securesms.database.Address;
|
|||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -32,9 +32,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PushGroupUpdateJob extends BaseJob implements InjectableType {
|
||||
public class PushGroupUpdateJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "PushGroupUpdateJob";
|
||||
|
||||
|
@ -43,8 +41,6 @@ public class PushGroupUpdateJob extends BaseJob implements InjectableType {
|
|||
private static final String KEY_SOURCE = "source";
|
||||
private static final String KEY_GROUP_ID = "group_id";
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
private String source;
|
||||
private byte[] groupId;
|
||||
|
||||
|
@ -118,6 +114,7 @@ public class PushGroupUpdateJob extends BaseJob implements InjectableType {
|
|||
.withExpiration(groupRecipient.getExpireMessages())
|
||||
.build();
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
messageSender.sendMessage(new SignalServiceAddress(source),
|
||||
UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, Address.fromSerialized(source), false)),
|
||||
message);
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
|||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
|
@ -46,9 +46,7 @@ import java.io.IOException;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
public class PushMediaSendJob extends PushSendJob {
|
||||
|
||||
public static final String KEY = "PushMediaSendJob";
|
||||
|
||||
|
@ -56,8 +54,6 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
|||
|
||||
private static final String KEY_MESSAGE_ID = "message_id";
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
private long messageId;
|
||||
|
||||
public PushMediaSendJob(long messageId, Address destination) {
|
||||
|
@ -200,6 +196,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
|||
try {
|
||||
rotateSenderCertificateIfNecessary();
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
SignalServiceAddress address = getPushAddress(message.getRecipient().getAddress());
|
||||
List<Attachment> attachments = Stream.of(message.getAttachments()).filterNot(Attachment::isSticker).toList();
|
||||
List<SignalServiceAttachment> serviceAttachments = getAttachmentPointersFor(attachments);
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -15,16 +15,12 @@ import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PushNotificationReceiveJob extends PushReceivedJob implements InjectableType {
|
||||
public class PushNotificationReceiveJob extends PushReceivedJob {
|
||||
|
||||
public static final String KEY = "PushNotificationReceiveJob";
|
||||
|
||||
private static final String TAG = PushNotificationReceiveJob.class.getSimpleName();
|
||||
|
||||
@Inject SignalServiceMessageReceiver receiver;
|
||||
|
||||
public PushNotificationReceiveJob(Context context) {
|
||||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
|
@ -51,7 +47,7 @@ public class PushNotificationReceiveJob extends PushReceivedJob implements Injec
|
|||
|
||||
@Override
|
||||
public void onRun() throws IOException {
|
||||
pullAndProcessMessages(receiver, TAG, System.currentTimeMillis());
|
||||
pullAndProcessMessages(ApplicationDependencies.getSignalServiceMessageReceiver(), TAG, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public void pullAndProcessMessages(SignalServiceMessageReceiver receiver, String tag, long startTime) throws IOException {
|
||||
|
|
|
@ -297,7 +297,6 @@ public abstract class PushSendJob extends SendJob {
|
|||
} catch (InvalidCertificateException e) {
|
||||
Log.w(TAG, "Certificate was invalid at send time. Fetching a new one.", e);
|
||||
RotateCertificateJob certificateJob = new RotateCertificateJob(context);
|
||||
ApplicationContext.getInstance(context).injectDependencies(certificateJob);
|
||||
certificateJob.onRun();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|||
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||
import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
|
@ -32,9 +32,7 @@ import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserExce
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
public class PushTextSendJob extends PushSendJob {
|
||||
|
||||
public static final String KEY = "PushTextSendJob";
|
||||
|
||||
|
@ -42,8 +40,6 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
|||
|
||||
private static final String KEY_MESSAGE_ID = "message_id";
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
private long messageId;
|
||||
|
||||
public PushTextSendJob(long messageId, Address destination) {
|
||||
|
@ -157,6 +153,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
|||
try {
|
||||
rotateSenderCertificateIfNecessary();
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
SignalServiceAddress address = getPushAddress(message.getIndividualRecipient().getAddress());
|
||||
Optional<byte[]> profileKey = getProfileKey(message.getIndividualRecipient());
|
||||
Optional<UnidentifiedAccessPair> unidentifiedAccess = UnidentifiedAccessUtil.getAccessFor(context, message.getIndividualRecipient());
|
||||
|
|
|
@ -3,13 +3,12 @@ package org.thoughtcrime.securesms.jobs;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
|
@ -17,16 +16,12 @@ import org.whispersystems.signalservice.api.push.exceptions.NetworkFailureExcept
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class RefreshAttributesJob extends BaseJob implements InjectableType {
|
||||
public class RefreshAttributesJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "RefreshAttributesJob";
|
||||
|
||||
private static final String TAG = RefreshAttributesJob.class.getSimpleName();
|
||||
|
||||
@Inject SignalServiceAccountManager signalAccountManager;
|
||||
|
||||
public RefreshAttributesJob() {
|
||||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
|
@ -56,6 +51,7 @@ public class RefreshAttributesJob extends BaseJob implements InjectableType {
|
|||
byte[] unidentifiedAccessKey = UnidentifiedAccessUtil.getSelfUnidentifiedAccessKey(context);
|
||||
boolean universalUnidentifiedAccess = TextSecurePreferences.isUniversalUnidentifiedAccess(context);
|
||||
|
||||
SignalServiceAccountManager signalAccountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
signalAccountManager.setAccountAttributes(null, registrationId, fetchesMessages, pin,
|
||||
unidentifiedAccessKey, universalUnidentifiedAccess);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import androidx.annotation.NonNull;
|
|||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||
import org.thoughtcrime.securesms.crypto.PreKeyUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -21,9 +21,7 @@ import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class RefreshPreKeysJob extends BaseJob implements InjectableType {
|
||||
public class RefreshPreKeysJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "RefreshPreKeysJob";
|
||||
|
||||
|
@ -31,8 +29,6 @@ public class RefreshPreKeysJob extends BaseJob implements InjectableType {
|
|||
|
||||
private static final int PREKEY_MINIMUM = 10;
|
||||
|
||||
@Inject SignalServiceAccountManager accountManager;
|
||||
|
||||
public RefreshPreKeysJob() {
|
||||
this(new Job.Parameters.Builder()
|
||||
.setQueue("RefreshPreKeysJob")
|
||||
|
@ -59,6 +55,8 @@ public class RefreshPreKeysJob extends BaseJob implements InjectableType {
|
|||
public void onRun() throws IOException {
|
||||
if (!TextSecurePreferences.isPushRegistered(context)) return;
|
||||
|
||||
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
|
||||
int availableKeys = accountManager.getPreKeysCount();
|
||||
|
||||
if (availableKeys >= PREKEY_MINIMUM && TextSecurePreferences.isSignedPreKeyRegistered(context)) {
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -21,16 +21,12 @@ import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class RefreshUnidentifiedDeliveryAbilityJob extends BaseJob implements InjectableType {
|
||||
public class RefreshUnidentifiedDeliveryAbilityJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "RefreshUnidentifiedDeliveryAbilityJob";
|
||||
|
||||
private static final String TAG = RefreshUnidentifiedDeliveryAbilityJob.class.getSimpleName();
|
||||
|
||||
@Inject SignalServiceMessageReceiver receiver;
|
||||
|
||||
public RefreshUnidentifiedDeliveryAbilityJob() {
|
||||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
|
@ -73,7 +69,8 @@ public class RefreshUnidentifiedDeliveryAbilityJob extends BaseJob implements In
|
|||
}
|
||||
|
||||
private SignalServiceProfile retrieveProfile(@NonNull String number) throws IOException {
|
||||
SignalServiceMessagePipe pipe = IncomingMessageObserver.getPipe();
|
||||
SignalServiceMessageReceiver receiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
SignalServiceMessagePipe pipe = IncomingMessageObserver.getPipe();
|
||||
|
||||
if (pipe != null) {
|
||||
try {
|
||||
|
|
|
@ -4,7 +4,7 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -21,9 +21,7 @@ import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class RequestGroupInfoJob extends BaseJob implements InjectableType {
|
||||
public class RequestGroupInfoJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "RequestGroupInfoJob";
|
||||
|
||||
|
@ -33,8 +31,6 @@ public class RequestGroupInfoJob extends BaseJob implements InjectableType {
|
|||
private static final String KEY_SOURCE = "source";
|
||||
private static final String KEY_GROUP_ID = "group_id";
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
private String source;
|
||||
private byte[] groupId;
|
||||
|
||||
|
@ -79,6 +75,7 @@ public class RequestGroupInfoJob extends BaseJob implements InjectableType {
|
|||
.withTimestamp(System.currentTimeMillis())
|
||||
.build();
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
messageSender.sendMessage(new SignalServiceAddress(source),
|
||||
UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, Address.fromExternal(context, source), false)),
|
||||
message);
|
||||
|
|
|
@ -8,7 +8,7 @@ import android.text.TextUtils;
|
|||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -26,9 +26,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class RetrieveProfileAvatarJob extends BaseJob implements InjectableType {
|
||||
public class RetrieveProfileAvatarJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "RetrieveProfileAvatarJob";
|
||||
|
||||
|
@ -39,8 +37,6 @@ public class RetrieveProfileAvatarJob extends BaseJob implements InjectableType
|
|||
private static final String KEY_PROFILE_AVATAR = "profile_avatar";
|
||||
private static final String KEY_ADDRESS = "address";
|
||||
|
||||
@Inject SignalServiceMessageReceiver receiver;
|
||||
|
||||
private String profileAvatar;
|
||||
private Recipient recipient;
|
||||
|
||||
|
@ -99,8 +95,9 @@ public class RetrieveProfileAvatarJob extends BaseJob implements InjectableType
|
|||
File downloadDestination = File.createTempFile("avatar", "jpg", context.getCacheDir());
|
||||
|
||||
try {
|
||||
InputStream avatarStream = receiver.retrieveProfileAvatar(profileAvatar, downloadDestination, profileKey, MAX_PROFILE_SIZE_BYTES);
|
||||
File decryptDestination = File.createTempFile("avatar", "jpg", context.getCacheDir());
|
||||
SignalServiceMessageReceiver receiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
InputStream avatarStream = receiver.retrieveProfileAvatar(profileAvatar, downloadDestination, profileKey, MAX_PROFILE_SIZE_BYTES);
|
||||
File decryptDestination = File.createTempFile("avatar", "jpg", context.getCacheDir());
|
||||
|
||||
try {
|
||||
Util.copy(avatarStream, new FileOutputStream(decryptDestination));
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.thoughtcrime.securesms.database.Address;
|
|||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -37,9 +37,7 @@ import org.whispersystems.signalservice.api.push.exceptions.NonSuccessfulRespons
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class RetrieveProfileJob extends BaseJob implements InjectableType {
|
||||
public class RetrieveProfileJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "RetrieveProfileJob";
|
||||
|
||||
|
@ -47,8 +45,6 @@ public class RetrieveProfileJob extends BaseJob implements InjectableType {
|
|||
|
||||
private static final String KEY_ADDRESS = "address";
|
||||
|
||||
@Inject SignalServiceMessageReceiver receiver;
|
||||
|
||||
private final Recipient recipient;
|
||||
|
||||
public RetrieveProfileJob(@NonNull Recipient recipient) {
|
||||
|
@ -139,6 +135,7 @@ public class RetrieveProfileJob extends BaseJob implements InjectableType {
|
|||
}
|
||||
}
|
||||
|
||||
SignalServiceMessageReceiver receiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
return receiver.retrieveProfile(new SignalServiceAddress(number), unidentifiedAccess);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -16,17 +16,12 @@ import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class RotateCertificateJob extends BaseJob implements InjectableType {
|
||||
public class RotateCertificateJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "RotateCertificateJob";
|
||||
|
||||
private static final String TAG = RotateCertificateJob.class.getSimpleName();
|
||||
|
||||
@Inject SignalServiceAccountManager accountManager;
|
||||
|
||||
public RotateCertificateJob(Context context) {
|
||||
this(new Job.Parameters.Builder()
|
||||
.setQueue("__ROTATE_SENDER_CERTIFICATE__")
|
||||
|
@ -57,7 +52,9 @@ public class RotateCertificateJob extends BaseJob implements InjectableType {
|
|||
@Override
|
||||
public void onRun() throws IOException {
|
||||
synchronized (RotateCertificateJob.class) {
|
||||
byte[] certificate = accountManager.getSenderCertificate();
|
||||
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
byte[] certificate = accountManager.getSenderCertificate();
|
||||
|
||||
TextSecurePreferences.setUnidentifiedAccessCertificate(context, certificate);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import androidx.annotation.Nullable;
|
|||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -20,14 +20,10 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class RotateProfileKeyJob extends BaseJob implements InjectableType {
|
||||
public class RotateProfileKeyJob extends BaseJob {
|
||||
|
||||
public static String KEY = "RotateProfileKeyJob";
|
||||
|
||||
@Inject SignalServiceAccountManager accountManager;
|
||||
|
||||
public RotateProfileKeyJob() {
|
||||
this(new Job.Parameters.Builder()
|
||||
.setQueue("__ROTATE_PROFILE_KEY__")
|
||||
|
@ -53,7 +49,8 @@ public class RotateProfileKeyJob extends BaseJob implements InjectableType {
|
|||
|
||||
@Override
|
||||
public void onRun() throws Exception {
|
||||
byte[] profileKey = ProfileKeyUtil.rotateProfileKey(context);
|
||||
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
byte[] profileKey = ProfileKeyUtil.rotateProfileKey(context);
|
||||
|
||||
accountManager.setProfileName(profileKey, TextSecurePreferences.getProfileName(context));
|
||||
accountManager.setProfileAvatar(profileKey, getProfileAvatar());
|
||||
|
|
|
@ -6,7 +6,7 @@ import androidx.annotation.NonNull;
|
|||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||
import org.thoughtcrime.securesms.crypto.PreKeyUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -17,16 +17,12 @@ import org.whispersystems.libsignal.state.SignedPreKeyRecord;
|
|||
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class RotateSignedPreKeyJob extends BaseJob implements InjectableType {
|
||||
public class RotateSignedPreKeyJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "RotateSignedPreKeyJob";
|
||||
|
||||
private static final String TAG = RotateSignedPreKeyJob.class.getSimpleName();
|
||||
|
||||
@Inject SignalServiceAccountManager accountManager;
|
||||
|
||||
public RotateSignedPreKeyJob() {
|
||||
this(new Job.Parameters.Builder()
|
||||
.setQueue("RotateSignedPreKeyJob")
|
||||
|
@ -53,8 +49,9 @@ public class RotateSignedPreKeyJob extends BaseJob implements InjectableType {
|
|||
public void onRun() throws Exception {
|
||||
Log.i(TAG, "Rotating signed prekey...");
|
||||
|
||||
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(context);
|
||||
SignedPreKeyRecord signedPreKeyRecord = PreKeyUtil.generateSignedPreKey(context, identityKey, false);
|
||||
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(context);
|
||||
SignedPreKeyRecord signedPreKeyRecord = PreKeyUtil.generateSignedPreKey(context, identityKey, false);
|
||||
|
||||
accountManager.setSignedPreKey(signedPreKeyRecord);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -21,9 +21,7 @@ import java.io.IOException;
|
|||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class SendDeliveryReceiptJob extends BaseJob implements InjectableType {
|
||||
public class SendDeliveryReceiptJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "SendDeliveryReceiptJob";
|
||||
|
||||
|
@ -33,9 +31,6 @@ public class SendDeliveryReceiptJob extends BaseJob implements InjectableType {
|
|||
|
||||
private static final String TAG = SendReadReceiptJob.class.getSimpleName();
|
||||
|
||||
@Inject
|
||||
transient SignalServiceMessageSender messageSender;
|
||||
|
||||
private String address;
|
||||
private long messageId;
|
||||
private long timestamp;
|
||||
|
@ -78,6 +73,7 @@ public class SendDeliveryReceiptJob extends BaseJob implements InjectableType {
|
|||
|
||||
@Override
|
||||
public void onRun() throws IOException, UntrustedIdentityException {
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
SignalServiceAddress remoteAddress = new SignalServiceAddress(address);
|
||||
SignalServiceReceiptMessage receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.DELIVERY,
|
||||
Collections.singletonList(messageId),
|
||||
|
|
|
@ -5,7 +5,7 @@ import androidx.annotation.NonNull;
|
|||
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -23,9 +23,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class SendReadReceiptJob extends BaseJob implements InjectableType {
|
||||
public class SendReadReceiptJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "SendReadReceiptJob";
|
||||
|
||||
|
@ -35,8 +33,6 @@ public class SendReadReceiptJob extends BaseJob implements InjectableType {
|
|||
private static final String KEY_MESSAGE_IDS = "message_ids";
|
||||
private static final String KEY_TIMESTAMP = "timestamp";
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
private String address;
|
||||
private List<Long> messageIds;
|
||||
private long timestamp;
|
||||
|
@ -86,6 +82,7 @@ public class SendReadReceiptJob extends BaseJob implements InjectableType {
|
|||
public void onRun() throws IOException, UntrustedIdentityException {
|
||||
if (!TextSecurePreferences.isReadReceiptsEnabled(context) || messageIds.isEmpty()) return;
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
SignalServiceAddress remoteAddress = new SignalServiceAddress(address);
|
||||
SignalServiceReceiptMessage receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.READ, messageIds, timestamp);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import androidx.annotation.NonNull;
|
|||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.StickerDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.IncomingSticker;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
|
@ -17,9 +17,7 @@ import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException
|
|||
import java.io.InputStream;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class StickerDownloadJob extends BaseJob implements InjectableType {
|
||||
public class StickerDownloadJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "StickerDownloadJob";
|
||||
|
||||
|
@ -36,8 +34,6 @@ public class StickerDownloadJob extends BaseJob implements InjectableType {
|
|||
|
||||
private final IncomingSticker sticker;
|
||||
|
||||
@Inject SignalServiceMessageReceiver receiver;
|
||||
|
||||
public StickerDownloadJob(@NonNull IncomingSticker sticker) {
|
||||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
|
@ -65,9 +61,10 @@ public class StickerDownloadJob extends BaseJob implements InjectableType {
|
|||
return;
|
||||
}
|
||||
|
||||
byte[] packIdBytes = Hex.fromStringCondensed(sticker.getPackId());
|
||||
byte[] packKeyBytes = Hex.fromStringCondensed(sticker.getPackKey());
|
||||
InputStream stream = receiver.retrieveSticker(packIdBytes, packKeyBytes, sticker.getStickerId());
|
||||
SignalServiceMessageReceiver receiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
byte[] packIdBytes = Hex.fromStringCondensed(sticker.getPackId ());
|
||||
byte[] packKeyBytes = Hex.fromStringCondensed(sticker.getPackKey());
|
||||
InputStream stream = receiver.retrieveSticker(packIdBytes, packKeyBytes, sticker.getStickerId());
|
||||
|
||||
db.insertSticker(sticker, stream);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.thoughtcrime.securesms.ApplicationContext;
|
|||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.StickerDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.IncomingSticker;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
|
@ -24,9 +24,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class StickerPackDownloadJob extends BaseJob implements InjectableType {
|
||||
public class StickerPackDownloadJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "StickerPackDownloadJob";
|
||||
|
||||
|
@ -40,8 +38,6 @@ public class StickerPackDownloadJob extends BaseJob implements InjectableType {
|
|||
private final String packKey;
|
||||
private final boolean isReferencePack;
|
||||
|
||||
@Inject SignalServiceMessageReceiver receiver;
|
||||
|
||||
public StickerPackDownloadJob(@NonNull String packId, @NonNull String packKey, boolean isReferencePack)
|
||||
{
|
||||
this(new Parameters.Builder()
|
||||
|
@ -77,6 +73,7 @@ public class StickerPackDownloadJob extends BaseJob implements InjectableType {
|
|||
return;
|
||||
}
|
||||
|
||||
SignalServiceMessageReceiver receiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
|
||||
StickerDatabase stickerDatabase = DatabaseFactory.getStickerDatabase(context);
|
||||
byte[] packIdBytes = Hex.fromStringCondensed(packId);
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.annimon.stream.Stream;
|
|||
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
|
@ -24,9 +24,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class TypingSendJob extends BaseJob implements InjectableType {
|
||||
public class TypingSendJob extends BaseJob {
|
||||
|
||||
public static final String KEY = "TypingSendJob";
|
||||
|
||||
|
@ -38,8 +36,6 @@ public class TypingSendJob extends BaseJob implements InjectableType {
|
|||
private long threadId;
|
||||
private boolean typing;
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
public TypingSendJob(long threadId, boolean typing) {
|
||||
this(new Job.Parameters.Builder()
|
||||
.setQueue("TYPING_" + threadId)
|
||||
|
@ -92,6 +88,7 @@ public class TypingSendJob extends BaseJob implements InjectableType {
|
|||
groupId = Optional.of(GroupUtil.getDecodedId(recipient.getAddress().toGroupString()));
|
||||
}
|
||||
|
||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
List<SignalServiceAddress> addresses = Stream.of(recipients).map(r -> new SignalServiceAddress(r.getAddress().serialize())).toList();
|
||||
List<Optional<UnidentifiedAccessPair>> unidentifiedAccess = Stream.of(recipients).map(r -> UnidentifiedAccessUtil.getAccessFor(context, r)).toList();
|
||||
SignalServiceTypingMessage typingMessage = new SignalServiceTypingMessage(typing ? Action.STARTED : Action.STOPPED, System.currentTimeMillis(), groupId);
|
||||
|
|
|
@ -10,11 +10,10 @@ import android.text.TextUtils;
|
|||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.request.FutureTarget;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.giph.model.ChunkedImageUrl;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
|
@ -43,15 +42,13 @@ import java.util.concurrent.ExecutionException;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import okhttp3.CacheControl;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class LinkPreviewRepository implements InjectableType {
|
||||
public class LinkPreviewRepository {
|
||||
|
||||
private static final String TAG = LinkPreviewRepository.class.getSimpleName();
|
||||
|
||||
|
@ -59,16 +56,12 @@ public class LinkPreviewRepository implements InjectableType {
|
|||
|
||||
private final OkHttpClient client;
|
||||
|
||||
@Inject SignalServiceMessageReceiver messageReceiver;
|
||||
|
||||
public LinkPreviewRepository(@NonNull Context context) {
|
||||
public LinkPreviewRepository() {
|
||||
this.client = new OkHttpClient.Builder()
|
||||
.proxySelector(new ContentProxySelector())
|
||||
.addNetworkInterceptor(new ContentProxySafetyInterceptor())
|
||||
.cache(null)
|
||||
.build();
|
||||
|
||||
ApplicationContext.getInstance(context).injectDependencies(this);
|
||||
}
|
||||
|
||||
RequestController getLinkPreview(@NonNull Context context, @NonNull String url, @NonNull Callback<Optional<LinkPreview>> callback) {
|
||||
|
@ -219,7 +212,8 @@ public class LinkPreviewRepository implements InjectableType {
|
|||
byte[] packIdBytes = Hex.fromStringCondensed(packIdString);
|
||||
byte[] packKeyBytes = Hex.fromStringCondensed(packKeyString);
|
||||
|
||||
SignalServiceStickerManifest manifest = messageReceiver.retrieveStickerManifest(packIdBytes, packKeyBytes);
|
||||
SignalServiceMessageReceiver receiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
SignalServiceStickerManifest manifest = receiver.retrieveStickerManifest(packIdBytes, packKeyBytes);
|
||||
|
||||
String title = manifest.getTitle().or(manifest.getAuthor()).or("");
|
||||
Optional<StickerInfo> firstSticker = Optional.fromNullable(manifest.getStickers().size() > 0 ? manifest.getStickers().get(0) : null);
|
||||
|
|
|
@ -71,7 +71,7 @@ public class SignalGlideModule extends AppGlideModule {
|
|||
registry.append(DecryptableUri.class, InputStream.class, new DecryptableStreamUriLoader.Factory(context));
|
||||
registry.append(AttachmentModel.class, InputStream.class, new AttachmentStreamUriLoader.Factory());
|
||||
registry.append(ChunkedImageUrl.class, InputStream.class, new ChunkedImageUrlLoader.Factory());
|
||||
registry.append(StickerRemoteUri.class, InputStream.class, new StickerRemoteUriLoader.Factory(context));
|
||||
registry.append(StickerRemoteUri.class, InputStream.class, new StickerRemoteUriLoader.Factory());
|
||||
registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.thoughtcrime.securesms.preferences;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -18,7 +17,7 @@ import org.thoughtcrime.securesms.PassphraseChangeActivity;
|
|||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.SwitchPreferenceCompat;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceConfigurationUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob;
|
||||
import org.thoughtcrime.securesms.lock.RegistrationLockDialog;
|
||||
|
@ -30,26 +29,15 @@ import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
|||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import mobi.upod.timedurationpicker.TimeDurationPickerDialog;
|
||||
|
||||
public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment implements InjectableType {
|
||||
public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment {
|
||||
|
||||
private static final String PREFERENCE_CATEGORY_BLOCKED = "preference_category_blocked";
|
||||
private static final String PREFERENCE_UNIDENTIFIED_LEARN_MORE = "pref_unidentified_learn_more";
|
||||
|
||||
private CheckBoxPreference disablePassphrase;
|
||||
|
||||
@Inject
|
||||
SignalServiceAccountManager accountManager;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
ApplicationContext.getInstance(activity).injectDependencies(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle paramBundle) {
|
||||
super.onCreate(paramBundle);
|
||||
|
@ -160,6 +148,8 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
|
|||
private class AccountLockClickListener implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
|
||||
if (((SwitchPreferenceCompat)preference).isChecked()) {
|
||||
RegistrationLockDialog.showRegistrationUnlockPrompt(getContext(), (SwitchPreferenceCompat)preference, accountManager);
|
||||
} else {
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.ConstraintObserver;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraintObserver;
|
||||
|
@ -19,7 +20,6 @@ import org.thoughtcrime.securesms.logging.Log;
|
|||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.jobs.PushContentReceiveJob;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
|
@ -31,9 +31,7 @@ import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class IncomingMessageObserver implements InjectableType, ConstraintObserver.Notifier {
|
||||
public class IncomingMessageObserver implements ConstraintObserver.Notifier {
|
||||
|
||||
private static final String TAG = IncomingMessageObserver.class.getSimpleName();
|
||||
|
||||
|
@ -43,19 +41,19 @@ public class IncomingMessageObserver implements InjectableType, ConstraintObserv
|
|||
private static SignalServiceMessagePipe pipe = null;
|
||||
private static SignalServiceMessagePipe unidentifiedPipe = null;
|
||||
|
||||
private final Context context;
|
||||
private final NetworkConstraint networkConstraint;
|
||||
private final Context context;
|
||||
private final NetworkConstraint networkConstraint;
|
||||
private final SignalServiceMessageReceiver receiver;
|
||||
private final SignalServiceNetworkAccess networkAccess;
|
||||
|
||||
private boolean appVisible;
|
||||
|
||||
@Inject SignalServiceMessageReceiver receiver;
|
||||
@Inject SignalServiceNetworkAccess networkAccess;
|
||||
|
||||
public IncomingMessageObserver(@NonNull Context context) {
|
||||
ApplicationContext.getInstance(context).injectDependencies(this);
|
||||
|
||||
this.context = context;
|
||||
this.context = context;
|
||||
this.networkConstraint = new NetworkConstraint.Factory(ApplicationContext.getInstance(context)).create();
|
||||
this.receiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
this.networkAccess = ApplicationDependencies.getSignalServiceNetworkAccess();
|
||||
|
||||
new NetworkConstraintObserver(ApplicationContext.getInstance(context)).register(this);
|
||||
new MessageRetrievalThread().start();
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
|||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.events.WebRtcViewModel;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
|
@ -102,15 +102,12 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.thoughtcrime.securesms.webrtc.CallNotificationBuilder.TYPE_ESTABLISHED;
|
||||
import static org.thoughtcrime.securesms.webrtc.CallNotificationBuilder.TYPE_INCOMING_CONNECTING;
|
||||
import static org.thoughtcrime.securesms.webrtc.CallNotificationBuilder.TYPE_INCOMING_RINGING;
|
||||
import static org.thoughtcrime.securesms.webrtc.CallNotificationBuilder.TYPE_OUTGOING_RINGING;
|
||||
|
||||
public class WebRtcCallService extends Service implements InjectableType,
|
||||
PeerConnection.Observer,
|
||||
public class WebRtcCallService extends Service implements PeerConnection.Observer,
|
||||
DataChannel.Observer,
|
||||
BluetoothStateManager.BluetoothStateListener,
|
||||
PeerConnectionWrapper.CameraEventListener
|
||||
|
@ -164,8 +161,8 @@ public class WebRtcCallService extends Service implements InjectableType,
|
|||
private boolean remoteVideoEnabled = false;
|
||||
private boolean bluetoothAvailable = false;
|
||||
|
||||
@Inject public SignalServiceMessageSender messageSender;
|
||||
@Inject public SignalServiceAccountManager accountManager;
|
||||
private SignalServiceMessageSender messageSender;
|
||||
private SignalServiceAccountManager accountManager;
|
||||
|
||||
private PeerConnectionFactory peerConnectionFactory;
|
||||
private SignalAudioManager audioManager;
|
||||
|
@ -296,8 +293,8 @@ public class WebRtcCallService extends Service implements InjectableType,
|
|||
// Initializers
|
||||
|
||||
private void initializeResources() {
|
||||
ApplicationContext.getInstance(this).injectDependencies(this);
|
||||
|
||||
this.messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||
this.accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
this.callState = CallState.STATE_IDLE;
|
||||
this.lockManager = new LockManager(this);
|
||||
this.audioManager = new SignalAudioManager(this);
|
||||
|
|
|
@ -8,12 +8,11 @@ import androidx.annotation.WorkerThread;
|
|||
import com.annimon.stream.Stream;
|
||||
import com.google.android.gms.common.util.Hex;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.StickerDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.StickerPackRecord;
|
||||
import org.thoughtcrime.securesms.database.model.StickerRecord;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.util.concurrent.SignalExecutors;
|
||||
import org.whispersystems.libsignal.InvalidMessageException;
|
||||
|
@ -25,18 +24,15 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public final class StickerPackPreviewRepository implements InjectableType {
|
||||
public final class StickerPackPreviewRepository {
|
||||
|
||||
private static final String TAG = Log.tag(StickerPackPreviewRepository.class);
|
||||
|
||||
private final StickerDatabase stickerDatabase;
|
||||
|
||||
@Inject SignalServiceMessageReceiver receiver;
|
||||
private final StickerDatabase stickerDatabase;
|
||||
private final SignalServiceMessageReceiver receiver;
|
||||
|
||||
public StickerPackPreviewRepository(@NonNull Context context) {
|
||||
ApplicationContext.getInstance(context).injectDependencies(this);
|
||||
this.receiver = ApplicationDependencies.getSignalServiceMessageReceiver();
|
||||
this.stickerDatabase = DatabaseFactory.getStickerDatabase(context);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,17 @@
|
|||
package org.thoughtcrime.securesms.stickers;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.load.Options;
|
||||
import com.bumptech.glide.load.model.ModelLoader;
|
||||
import com.bumptech.glide.load.model.ModelLoaderFactory;
|
||||
import com.bumptech.glide.load.model.MultiModelLoaderFactory;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Glide loader to fetch a sticker remotely.
|
||||
*/
|
||||
|
@ -30,7 +25,7 @@ public final class StickerRemoteUriLoader implements ModelLoader<StickerRemoteUr
|
|||
|
||||
|
||||
@Override
|
||||
public @Nullable LoadData<InputStream> buildLoadData(@NonNull StickerRemoteUri sticker, int width, int height, @NonNull Options options) {
|
||||
public @NonNull LoadData<InputStream> buildLoadData(@NonNull StickerRemoteUri sticker, int width, int height, @NonNull Options options) {
|
||||
return new LoadData<>(sticker, new StickerRemoteUriFetcher(receiver, sticker));
|
||||
}
|
||||
|
||||
|
@ -39,17 +34,11 @@ public final class StickerRemoteUriLoader implements ModelLoader<StickerRemoteUr
|
|||
return true;
|
||||
}
|
||||
|
||||
public static class Factory implements ModelLoaderFactory<StickerRemoteUri, InputStream>, InjectableType {
|
||||
|
||||
@Inject SignalServiceMessageReceiver receiver;
|
||||
|
||||
public Factory(@NonNull Context context) {
|
||||
ApplicationContext.getInstance(context).injectDependencies(this);
|
||||
}
|
||||
public static class Factory implements ModelLoaderFactory<StickerRemoteUri, InputStream> {
|
||||
|
||||
@Override
|
||||
public @NonNull ModelLoader<StickerRemoteUri, InputStream> build(@NonNull MultiModelLoaderFactory multiFactory) {
|
||||
return new StickerRemoteUriLoader(receiver);
|
||||
return new StickerRemoteUriLoader(ApplicationDependencies.getSignalServiceMessageReceiver());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue