2016-12-20 17:55:52 +00:00
|
|
|
package org.thoughtcrime.securesms.push;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2017-01-11 23:37:51 +00:00
|
|
|
import android.os.AsyncTask;
|
2018-08-01 15:09:24 +00:00
|
|
|
import org.thoughtcrime.securesms.logging.Log;
|
2017-01-11 23:37:51 +00:00
|
|
|
|
|
|
|
import com.google.android.gms.security.ProviderInstaller;
|
2016-12-20 17:55:52 +00:00
|
|
|
|
2019-07-24 02:30:23 +00:00
|
|
|
import network.loki.messenger.BuildConfig;
|
2016-12-20 17:55:52 +00:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
|
|
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
|
|
|
|
|
|
|
|
public class AccountManagerFactory {
|
|
|
|
|
2018-12-06 20:14:20 +00:00
|
|
|
private static final String TAG = AccountManagerFactory.class.getSimpleName();
|
2017-01-11 23:37:51 +00:00
|
|
|
|
2016-12-20 17:55:52 +00:00
|
|
|
public static SignalServiceAccountManager createManager(Context context) {
|
2016-12-30 04:54:05 +00:00
|
|
|
return new SignalServiceAccountManager(new SignalServiceNetworkAccess(context).getConfiguration(context),
|
2016-12-20 17:55:52 +00:00
|
|
|
TextSecurePreferences.getLocalNumber(context),
|
|
|
|
TextSecurePreferences.getPushServerPassword(context),
|
|
|
|
BuildConfig.USER_AGENT);
|
|
|
|
}
|
|
|
|
|
2017-01-11 23:37:51 +00:00
|
|
|
public static SignalServiceAccountManager createManager(final Context context, String number, String password) {
|
|
|
|
if (new SignalServiceNetworkAccess(context).isCensored(number)) {
|
|
|
|
new AsyncTask<Void, Void, Void>() {
|
|
|
|
@Override
|
|
|
|
protected Void doInBackground(Void... params) {
|
|
|
|
try {
|
|
|
|
ProviderInstaller.installIfNeeded(context);
|
|
|
|
} catch (Throwable t) {
|
|
|
|
Log.w(TAG, t);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2017-10-23 20:03:32 +00:00
|
|
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
2017-01-11 23:37:51 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 04:54:05 +00:00
|
|
|
return new SignalServiceAccountManager(new SignalServiceNetworkAccess(context).getConfiguration(number),
|
2016-12-20 17:55:52 +00:00
|
|
|
number, password, BuildConfig.USER_AGENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|