mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Remove un-used permissions.
This commit is contained in:
parent
7c89f5ce1a
commit
a57bf0cd98
@ -38,58 +38,36 @@
|
|||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||||
<uses-permission android:name="network.loki.messenger.ACCESS_SECRETS" />
|
<uses-permission android:name="network.loki.messenger.ACCESS_SECRETS" />
|
||||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
|
||||||
<uses-permission android:name="android.permission.WRITE_PROFILE" />
|
|
||||||
<uses-permission
|
|
||||||
android:name="android.permission.BROADCAST_WAP_PUSH"
|
|
||||||
tools:ignore="ProtectedPermissions" />
|
|
||||||
<!--
|
|
||||||
Loki - We don't need these at all
|
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
|
||||||
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_MMS"/>
|
|
||||||
<uses-permission android:name="android.permission.READ_SMS"/>
|
|
||||||
<uses-permission android:name="android.permission.SEND_SMS"/>
|
|
||||||
<uses-permission android:name="android.permission.WRITE_SMS"/>
|
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
|
||||||
-->
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
<!--
|
|
||||||
Loki - Enable again once we have location sharing
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
|
||||||
-->
|
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <!-- <uses-permission android:name="android.permission.READ_CALL_STATE"/> -->
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||||
<!-- For sending/receiving events -->
|
|
||||||
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
|
|
||||||
<uses-permission android:name="android.permission.READ_CALENDAR" /> <!-- Normal -->
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
|
||||||
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- So we can add a TextSecure 'Account' -->
|
|
||||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
|
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
|
<!-- For conversation 'shortcuts' on the desktop -->
|
||||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" /> <!-- For conversation 'shortcuts' on the desktop -->
|
|
||||||
<uses-permission android:name="android.permission.INSTALL_SHORTCUT" />
|
<uses-permission android:name="android.permission.INSTALL_SHORTCUT" />
|
||||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> <!-- For fixing MMS -->
|
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
<!-- Set image as wallpaper -->
|
||||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- Set image as wallpaper -->
|
|
||||||
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
|
||||||
<uses-permission android:name="android.permission.BROADCAST_STICKY" /> <!-- <uses-permission android:name="android.permission.CALL_PHONE" /> -->
|
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
|
||||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
||||||
<uses-permission android:name="android.permission.RAISED_THREAD_PRIORITY" />
|
<uses-permission android:name="android.permission.RAISED_THREAD_PRIORITY" />
|
||||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||||
|
|
||||||
|
<!-- Unused permissions that need to be removed -->
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH" tools:node="remove"/>
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" />
|
||||||
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" tools:node="remove"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="org.thoughtcrime.securesms.ApplicationContext"
|
android:name="org.thoughtcrime.securesms.ApplicationContext"
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
@ -590,20 +568,6 @@
|
|||||||
android:name="android.accounts.AccountAuthenticator"
|
android:name="android.accounts.AccountAuthenticator"
|
||||||
android:resource="@xml/authenticator" />
|
android:resource="@xml/authenticator" />
|
||||||
</service>
|
</service>
|
||||||
<service
|
|
||||||
android:name="org.thoughtcrime.securesms.service.ContactsSyncAdapterService"
|
|
||||||
android:exported="true">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.content.SyncAdapter" />
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<meta-data
|
|
||||||
android:name="android.content.SyncAdapter"
|
|
||||||
android:resource="@xml/syncadapter" />
|
|
||||||
<meta-data
|
|
||||||
android:name="android.provider.CONTACTS_STRUCTURE"
|
|
||||||
android:resource="@xml/contactsformat" />
|
|
||||||
</service>
|
|
||||||
<service
|
<service
|
||||||
android:name="org.thoughtcrime.securesms.service.DirectShareService"
|
android:name="org.thoughtcrime.securesms.service.DirectShareService"
|
||||||
android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE">
|
android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE">
|
||||||
@ -612,11 +576,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
<service android:name="org.thoughtcrime.securesms.service.GenericForegroundService" />
|
<service android:name="org.thoughtcrime.securesms.service.GenericForegroundService" />
|
||||||
<service android:name="org.thoughtcrime.securesms.gcm.FcmService">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="com.google.firebase.MESSAGING_EVENT" />
|
|
||||||
</intent-filter>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name="org.thoughtcrime.securesms.service.SmsListener"
|
android:name="org.thoughtcrime.securesms.service.SmsListener"
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<merge
|
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
@ -39,23 +37,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/footer_sim_info"
|
|
||||||
android:autoLink="none"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="4dp"
|
|
||||||
android:maxWidth="140dp"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:linksClickable="false"
|
|
||||||
style="@style/Signal.Text.Caption.MessageSent"
|
|
||||||
android:layout_gravity="end|bottom"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:visibility="visible"
|
|
||||||
tools:text="to SIM1" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/footer_insecure_indicator"
|
android:id="@+id/footer_insecure_indicator"
|
||||||
android:layout_width="12dp"
|
android:layout_width="12dp"
|
||||||
|
@ -53,7 +53,6 @@ import org.thoughtcrime.securesms.jobmanager.JobManager;
|
|||||||
import org.thoughtcrime.securesms.jobmanager.impl.JsonDataSerializer;
|
import org.thoughtcrime.securesms.jobmanager.impl.JsonDataSerializer;
|
||||||
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
||||||
import org.thoughtcrime.securesms.jobs.FastJobStorage;
|
import org.thoughtcrime.securesms.jobs.FastJobStorage;
|
||||||
import org.thoughtcrime.securesms.jobs.FcmRefreshJob;
|
|
||||||
import org.thoughtcrime.securesms.jobs.JobManagerFactories;
|
import org.thoughtcrime.securesms.jobs.JobManagerFactories;
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob;
|
import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob;
|
||||||
import org.thoughtcrime.securesms.jobs.PushContentReceiveJob;
|
import org.thoughtcrime.securesms.jobs.PushContentReceiveJob;
|
||||||
@ -115,7 +114,6 @@ import java.util.Date;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import dagger.ObjectGraph;
|
import dagger.ObjectGraph;
|
||||||
import kotlin.Unit;
|
import kotlin.Unit;
|
||||||
@ -176,7 +174,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
initializeExpiringMessageManager();
|
initializeExpiringMessageManager();
|
||||||
initializeTypingStatusRepository();
|
initializeTypingStatusRepository();
|
||||||
initializeTypingStatusSender();
|
initializeTypingStatusSender();
|
||||||
initializeGcmCheck();
|
|
||||||
initializeSignedPreKeyCheck();
|
initializeSignedPreKeyCheck();
|
||||||
initializePeriodicTasks();
|
initializePeriodicTasks();
|
||||||
initializeCircumvention();
|
initializeCircumvention();
|
||||||
@ -340,16 +337,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
|||||||
this.objectGraph = ObjectGraph.create(communicationModule, new AxolotlStorageModule(this));
|
this.objectGraph = ObjectGraph.create(communicationModule, new AxolotlStorageModule(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeGcmCheck() {
|
|
||||||
if (TextSecurePreferences.isPushRegistered(this)) {
|
|
||||||
long nextSetTime = TextSecurePreferences.getFcmTokenLastSetTime(this) + TimeUnit.HOURS.toMillis(6);
|
|
||||||
|
|
||||||
if (TextSecurePreferences.getFcmToken(this) == null || nextSetTime <= System.currentTimeMillis()) {
|
|
||||||
this.jobManager.add(new FcmRefreshJob());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeSignedPreKeyCheck() {
|
private void initializeSignedPreKeyCheck() {
|
||||||
if (!TextSecurePreferences.isSignedPreKeyRegistered(this)) {
|
if (!TextSecurePreferences.isSignedPreKeyRegistered(this)) {
|
||||||
jobManager.add(new CreateSignedPreKeyJob(this));
|
jobManager.add(new CreateSignedPreKeyJob(this));
|
||||||
|
@ -62,7 +62,6 @@ import org.thoughtcrime.securesms.database.Address;
|
|||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.IdentityDatabase;
|
import org.thoughtcrime.securesms.database.IdentityDatabase;
|
||||||
import org.thoughtcrime.securesms.database.NoExternalStorageException;
|
import org.thoughtcrime.securesms.database.NoExternalStorageException;
|
||||||
import org.thoughtcrime.securesms.gcm.FcmUtil;
|
|
||||||
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
||||||
import org.thoughtcrime.securesms.jobs.RotateCertificateJob;
|
import org.thoughtcrime.securesms.jobs.RotateCertificateJob;
|
||||||
import org.thoughtcrime.securesms.lock.RegistrationLockReminders;
|
import org.thoughtcrime.securesms.lock.RegistrationLockReminders;
|
||||||
@ -485,13 +484,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements Verif
|
|||||||
|
|
||||||
String password = Util.getSecret(18);
|
String password = Util.getSecret(18);
|
||||||
|
|
||||||
Optional<String> fcmToken;
|
Optional<String> fcmToken = Optional.absent();
|
||||||
|
|
||||||
if (gcmSupported) {
|
|
||||||
fcmToken = FcmUtil.getToken();
|
|
||||||
} else {
|
|
||||||
fcmToken = Optional.absent();
|
|
||||||
}
|
|
||||||
|
|
||||||
accountManager = AccountManagerFactory.createManager(RegistrationActivity.this, e164number, password);
|
accountManager = AccountManagerFactory.createManager(RegistrationActivity.this, e164number, password);
|
||||||
accountManager.requestSmsVerificationCode(smsRetrieverSupported, registrationState.captchaToken);
|
accountManager.requestSmsVerificationCode(smsRetrieverSupported, registrationState.captchaToken);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.thoughtcrime.securesms.components;
|
package org.thoughtcrime.securesms.components;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
@ -14,22 +13,18 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import network.loki.messenger.R;
|
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
|
||||||
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
||||||
import org.thoughtcrime.securesms.util.DateUtils;
|
import org.thoughtcrime.securesms.util.DateUtils;
|
||||||
import org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat;
|
|
||||||
import org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat;
|
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import network.loki.messenger.R;
|
||||||
|
|
||||||
public class ConversationItemFooter extends LinearLayout {
|
public class ConversationItemFooter extends LinearLayout {
|
||||||
|
|
||||||
private TextView dateView;
|
private TextView dateView;
|
||||||
private TextView simView;
|
|
||||||
private ExpirationTimerView timerView;
|
private ExpirationTimerView timerView;
|
||||||
private ImageView insecureIndicatorView;
|
private ImageView insecureIndicatorView;
|
||||||
private DeliveryStatusView deliveryStatusView;
|
private DeliveryStatusView deliveryStatusView;
|
||||||
@ -53,7 +48,6 @@ public class ConversationItemFooter extends LinearLayout {
|
|||||||
inflate(getContext(), R.layout.conversation_item_footer, this);
|
inflate(getContext(), R.layout.conversation_item_footer, this);
|
||||||
|
|
||||||
dateView = findViewById(R.id.footer_date);
|
dateView = findViewById(R.id.footer_date);
|
||||||
simView = findViewById(R.id.footer_sim_info);
|
|
||||||
timerView = findViewById(R.id.footer_expiration_timer);
|
timerView = findViewById(R.id.footer_expiration_timer);
|
||||||
insecureIndicatorView = findViewById(R.id.footer_insecure_indicator);
|
insecureIndicatorView = findViewById(R.id.footer_insecure_indicator);
|
||||||
deliveryStatusView = findViewById(R.id.footer_delivery_status);
|
deliveryStatusView = findViewById(R.id.footer_delivery_status);
|
||||||
@ -74,7 +68,6 @@ public class ConversationItemFooter extends LinearLayout {
|
|||||||
|
|
||||||
public void setMessageRecord(@NonNull MessageRecord messageRecord, @NonNull Locale locale) {
|
public void setMessageRecord(@NonNull MessageRecord messageRecord, @NonNull Locale locale) {
|
||||||
presentDate(messageRecord, locale);
|
presentDate(messageRecord, locale);
|
||||||
presentSimInfo(messageRecord);
|
|
||||||
presentTimer(messageRecord);
|
presentTimer(messageRecord);
|
||||||
presentInsecureIndicator(messageRecord);
|
presentInsecureIndicator(messageRecord);
|
||||||
presentDeliveryStatus(messageRecord);
|
presentDeliveryStatus(messageRecord);
|
||||||
@ -82,7 +75,6 @@ public class ConversationItemFooter extends LinearLayout {
|
|||||||
|
|
||||||
public void setTextColor(int color) {
|
public void setTextColor(int color) {
|
||||||
dateView.setTextColor(color);
|
dateView.setTextColor(color);
|
||||||
simView.setTextColor(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIconColor(int color) {
|
public void setIconColor(int color) {
|
||||||
@ -103,26 +95,6 @@ public class ConversationItemFooter extends LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void presentSimInfo(@NonNull MessageRecord messageRecord) {
|
|
||||||
SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(getContext());
|
|
||||||
|
|
||||||
if (messageRecord.isPush() || messageRecord.getSubscriptionId() == -1 || !Permissions.hasAll(getContext(), Manifest.permission.READ_PHONE_STATE) || !subscriptionManager.isMultiSim()) {
|
|
||||||
simView.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
Optional<SubscriptionInfoCompat> subscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(messageRecord.getSubscriptionId());
|
|
||||||
|
|
||||||
if (subscriptionInfo.isPresent() && messageRecord.isOutgoing()) {
|
|
||||||
simView.setText(getContext().getString(R.string.ConversationItem_from_s, subscriptionInfo.get().getDisplayName()));
|
|
||||||
simView.setVisibility(View.VISIBLE);
|
|
||||||
} else if (subscriptionInfo.isPresent()) {
|
|
||||||
simView.setText(getContext().getString(R.string.ConversationItem_to_s, subscriptionInfo.get().getDisplayName()));
|
|
||||||
simView.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
simView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private void presentTimer(@NonNull final MessageRecord messageRecord) {
|
private void presentTimer(@NonNull final MessageRecord messageRecord) {
|
||||||
if (messageRecord.getExpiresIn() > 0 && !messageRecord.isPending()) {
|
if (messageRecord.getExpiresIn() > 0 && !messageRecord.isPending()) {
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.contacts;
|
|
||||||
|
|
||||||
import android.accounts.Account;
|
|
||||||
import android.content.AbstractThreadedSyncAdapter;
|
|
||||||
import android.content.ContentProviderClient;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SyncResult;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.util.DirectoryHelper;
|
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class ContactsSyncAdapter extends AbstractThreadedSyncAdapter {
|
|
||||||
|
|
||||||
private static final String TAG = ContactsSyncAdapter.class.getSimpleName();
|
|
||||||
|
|
||||||
public ContactsSyncAdapter(Context context, boolean autoInitialize) {
|
|
||||||
super(context, autoInitialize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPerformSync(Account account, Bundle extras, String authority,
|
|
||||||
ContentProviderClient provider, SyncResult syncResult)
|
|
||||||
{
|
|
||||||
Log.i(TAG, "onPerformSync(" + authority +")");
|
|
||||||
|
|
||||||
if (TextSecurePreferences.isPushRegistered(getContext())) {
|
|
||||||
try {
|
|
||||||
DirectoryHelper.refreshDirectory(getContext(), true);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.w(TAG, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSyncCanceled() {
|
|
||||||
Log.w(TAG, "onSyncCanceled()");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSyncCanceled(Thread thread) {
|
|
||||||
Log.w(TAG, "onSyncCanceled(" + thread + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -9,13 +9,11 @@ import org.thoughtcrime.securesms.DeviceListFragment;
|
|||||||
import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl;
|
import org.thoughtcrime.securesms.crypto.storage.SignalProtocolStoreImpl;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.events.ReminderUpdateEvent;
|
import org.thoughtcrime.securesms.events.ReminderUpdateEvent;
|
||||||
import org.thoughtcrime.securesms.gcm.FcmService;
|
|
||||||
import org.thoughtcrime.securesms.jobs.AttachmentDownloadJob;
|
import org.thoughtcrime.securesms.jobs.AttachmentDownloadJob;
|
||||||
import org.thoughtcrime.securesms.jobs.AttachmentUploadJob;
|
import org.thoughtcrime.securesms.jobs.AttachmentUploadJob;
|
||||||
import org.thoughtcrime.securesms.jobs.AvatarDownloadJob;
|
import org.thoughtcrime.securesms.jobs.AvatarDownloadJob;
|
||||||
import org.thoughtcrime.securesms.jobs.CleanPreKeysJob;
|
import org.thoughtcrime.securesms.jobs.CleanPreKeysJob;
|
||||||
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
||||||
import org.thoughtcrime.securesms.jobs.FcmRefreshJob;
|
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob;
|
import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob;
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceConfigurationUpdateJob;
|
import org.thoughtcrime.securesms.jobs.MultiDeviceConfigurationUpdateJob;
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob;
|
import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob;
|
||||||
@ -86,7 +84,6 @@ import network.loki.messenger.BuildConfig;
|
|||||||
MultiDeviceBlockedUpdateJob.class,
|
MultiDeviceBlockedUpdateJob.class,
|
||||||
DeviceListFragment.class,
|
DeviceListFragment.class,
|
||||||
RefreshAttributesJob.class,
|
RefreshAttributesJob.class,
|
||||||
FcmRefreshJob.class,
|
|
||||||
RequestGroupInfoJob.class,
|
RequestGroupInfoJob.class,
|
||||||
PushGroupUpdateJob.class,
|
PushGroupUpdateJob.class,
|
||||||
AvatarDownloadJob.class,
|
AvatarDownloadJob.class,
|
||||||
@ -99,7 +96,6 @@ import network.loki.messenger.BuildConfig;
|
|||||||
MultiDeviceProfileKeyUpdateJob.class,
|
MultiDeviceProfileKeyUpdateJob.class,
|
||||||
SendReadReceiptJob.class,
|
SendReadReceiptJob.class,
|
||||||
AppProtectionPreferenceFragment.class,
|
AppProtectionPreferenceFragment.class,
|
||||||
FcmService.class,
|
|
||||||
RotateCertificateJob.class,
|
RotateCertificateJob.class,
|
||||||
SendDeliveryReceiptJob.class,
|
SendDeliveryReceiptJob.class,
|
||||||
RotateProfileKeyJob.class,
|
RotateProfileKeyJob.class,
|
||||||
|
@ -1,158 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.gcm;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.google.firebase.messaging.FirebaseMessagingService;
|
|
||||||
import com.google.firebase.messaging.RemoteMessage;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
|
||||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
|
||||||
import org.thoughtcrime.securesms.jobs.FcmRefreshJob;
|
|
||||||
import org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob;
|
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
|
||||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
|
||||||
import org.thoughtcrime.securesms.service.GenericForegroundService;
|
|
||||||
import org.thoughtcrime.securesms.util.PowerManagerCompat;
|
|
||||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
||||||
import org.thoughtcrime.securesms.util.WakeLockUtil;
|
|
||||||
import org.thoughtcrime.securesms.util.concurrent.SignalExecutors;
|
|
||||||
import org.whispersystems.signalservice.api.SignalServiceMessageReceiver;
|
|
||||||
import org.whispersystems.signalservice.internal.util.Util;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
public class FcmService extends FirebaseMessagingService implements InjectableType {
|
|
||||||
|
|
||||||
private static final String TAG = FcmService.class.getSimpleName();
|
|
||||||
|
|
||||||
private static final Executor MESSAGE_EXECUTOR = SignalExecutors.newCachedSingleThreadExecutor("FcmMessageProcessing");
|
|
||||||
private static final String WAKE_LOCK_TAG = "FcmMessageProcessing";
|
|
||||||
|
|
||||||
@Inject SignalServiceMessageReceiver messageReceiver;
|
|
||||||
|
|
||||||
private static int activeCount;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMessageReceived(RemoteMessage remoteMessage) {
|
|
||||||
Log.i(TAG, "FCM message... Original Priority: " + remoteMessage.getOriginalPriority() + ", Actual Priority: " + remoteMessage.getPriority());
|
|
||||||
ApplicationContext.getInstance(getApplicationContext()).injectDependencies(this);
|
|
||||||
|
|
||||||
WakeLockUtil.runWithLock(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK, 60000, WAKE_LOCK_TAG, () -> {
|
|
||||||
handleReceivedNotification(getApplicationContext());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNewToken(String token) {
|
|
||||||
Log.i(TAG, "onNewToken()");
|
|
||||||
|
|
||||||
if (!TextSecurePreferences.isPushRegistered(getApplicationContext())) {
|
|
||||||
Log.i(TAG, "Got a new FCM token, but the user isn't registered.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplicationContext.getInstance(getApplicationContext())
|
|
||||||
.getJobManager()
|
|
||||||
.add(new FcmRefreshJob());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleReceivedNotification(Context context) {
|
|
||||||
if (!incrementActiveGcmCount()) {
|
|
||||||
Log.i(TAG, "Skipping FCM processing -- there's already one enqueued.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
final Object foregroundLock = new Object();
|
|
||||||
final AtomicBoolean foregroundRunning = new AtomicBoolean(false);
|
|
||||||
final AtomicBoolean taskCompleted = new AtomicBoolean(false);
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
|
|
||||||
if (doze || !network) {
|
|
||||||
Log.i(TAG, "Starting a foreground task because we may be operating in a constrained environment. Doze: " + doze + " Network: " + network);
|
|
||||||
showForegroundNotification(context);
|
|
||||||
foregroundRunning.set(true);
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
MESSAGE_EXECUTOR.execute(() -> {
|
|
||||||
try {
|
|
||||||
new PushNotificationReceiveJob(context).pullAndProcessMessages(messageReceiver, TAG, startTime);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.i(TAG, "Failed to retrieve the envelope. Scheduling on JobManager.", e);
|
|
||||||
ApplicationContext.getInstance(context)
|
|
||||||
.getJobManager()
|
|
||||||
.add(new PushNotificationReceiveJob(context));
|
|
||||||
} finally {
|
|
||||||
synchronized (foregroundLock) {
|
|
||||||
if (foregroundRunning.getAndSet(false)) {
|
|
||||||
GenericForegroundService.stopForegroundTask(context);
|
|
||||||
} else {
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
taskCompleted.set(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
decrementActiveGcmCount();
|
|
||||||
Log.i(TAG, "Processing complete.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!foregroundRunning.get()) {
|
|
||||||
new Thread("FcmForegroundServiceTimer") {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Util.sleep(7000);
|
|
||||||
synchronized (foregroundLock) {
|
|
||||||
if (!taskCompleted.get() && !foregroundRunning.getAndSet(true)) {
|
|
||||||
Log.i(TAG, "Starting a foreground task because the job is running long.");
|
|
||||||
showForegroundNotification(context);
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
latch.await();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Log.w(TAG, "Latch was interrupted.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showForegroundNotification(@NonNull Context context) {
|
|
||||||
GenericForegroundService.startForegroundTask(context,
|
|
||||||
context.getString(R.string.GcmBroadcastReceiver_retrieving_a_message),
|
|
||||||
NotificationChannels.OTHER,
|
|
||||||
R.drawable.ic_signal_downloading);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static synchronized boolean incrementActiveGcmCount() {
|
|
||||||
if (activeCount < 2) {
|
|
||||||
activeCount++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static synchronized void decrementActiveGcmCount() {
|
|
||||||
activeCount--;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.gcm;
|
|
||||||
|
|
||||||
import android.support.annotation.WorkerThread;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import com.google.firebase.iid.FirebaseInstanceId;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
public final class FcmUtil {
|
|
||||||
|
|
||||||
private static final String TAG = FcmUtil.class.getSimpleName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the current FCM token. If one isn't available, it'll be generated.
|
|
||||||
*/
|
|
||||||
@WorkerThread
|
|
||||||
public static Optional<String> getToken() {
|
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
AtomicReference<String> token = new AtomicReference<>(null);
|
|
||||||
|
|
||||||
FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(task -> {
|
|
||||||
if (task.isSuccessful() && task.getResult() != null && !TextUtils.isEmpty(task.getResult().getToken())) {
|
|
||||||
token.set(task.getResult().getToken());
|
|
||||||
} else {
|
|
||||||
Log.w(TAG, "Failed to get the token.", task.getException());
|
|
||||||
}
|
|
||||||
|
|
||||||
latch.countDown();
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
latch.await();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Log.w(TAG, "Was interrupted while waiting for the token.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.fromNullable(token.get());
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,7 +9,6 @@ import org.thoughtcrime.securesms.jobs.AvatarDownloadJob;
|
|||||||
import org.thoughtcrime.securesms.jobs.CleanPreKeysJob;
|
import org.thoughtcrime.securesms.jobs.CleanPreKeysJob;
|
||||||
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
||||||
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
||||||
import org.thoughtcrime.securesms.jobs.FcmRefreshJob;
|
|
||||||
import org.thoughtcrime.securesms.jobs.LocalBackupJob;
|
import org.thoughtcrime.securesms.jobs.LocalBackupJob;
|
||||||
import org.thoughtcrime.securesms.jobs.MmsDownloadJob;
|
import org.thoughtcrime.securesms.jobs.MmsDownloadJob;
|
||||||
import org.thoughtcrime.securesms.jobs.MmsReceiveJob;
|
import org.thoughtcrime.securesms.jobs.MmsReceiveJob;
|
||||||
@ -59,7 +58,6 @@ public class WorkManagerFactoryMappings {
|
|||||||
put(CleanPreKeysJob.class.getName(), CleanPreKeysJob.KEY);
|
put(CleanPreKeysJob.class.getName(), CleanPreKeysJob.KEY);
|
||||||
put(CreateSignedPreKeyJob.class.getName(), CreateSignedPreKeyJob.KEY);
|
put(CreateSignedPreKeyJob.class.getName(), CreateSignedPreKeyJob.KEY);
|
||||||
put(DirectoryRefreshJob.class.getName(), DirectoryRefreshJob.KEY);
|
put(DirectoryRefreshJob.class.getName(), DirectoryRefreshJob.KEY);
|
||||||
put(FcmRefreshJob.class.getName(), FcmRefreshJob.KEY);
|
|
||||||
put(LocalBackupJob.class.getName(), LocalBackupJob.KEY);
|
put(LocalBackupJob.class.getName(), LocalBackupJob.KEY);
|
||||||
put(MmsDownloadJob.class.getName(), MmsDownloadJob.KEY);
|
put(MmsDownloadJob.class.getName(), MmsDownloadJob.KEY);
|
||||||
put(MmsReceiveJob.class.getName(), MmsReceiveJob.KEY);
|
put(MmsReceiveJob.class.getName(), MmsReceiveJob.KEY);
|
||||||
|
@ -1,151 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (C) 2014 Open Whisper Systems
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.thoughtcrime.securesms.jobs;
|
|
||||||
|
|
||||||
import android.app.NotificationManager;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v4.app.NotificationCompat;
|
|
||||||
|
|
||||||
import com.google.android.gms.common.ConnectionResult;
|
|
||||||
import com.google.android.gms.common.GoogleApiAvailability;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.gcm.FcmUtil;
|
|
||||||
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.PlayServicesProblemActivity;
|
|
||||||
import network.loki.messenger.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 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")
|
|
||||||
.addConstraint(NetworkConstraint.KEY)
|
|
||||||
.setMaxAttempts(1)
|
|
||||||
.setLifespan(TimeUnit.MINUTES.toMillis(5))
|
|
||||||
.setMaxInstances(1)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
private FcmRefreshJob(@NonNull Job.Parameters parameters) {
|
|
||||||
super(parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull Data serialize() {
|
|
||||||
return Data.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull String getFactoryKey() {
|
|
||||||
return KEY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRun() throws Exception {
|
|
||||||
if (TextSecurePreferences.isFcmDisabled(context)) return;
|
|
||||||
|
|
||||||
Log.i(TAG, "Reregistering FCM...");
|
|
||||||
|
|
||||||
int result = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
|
|
||||||
|
|
||||||
if (result != ConnectionResult.SUCCESS) {
|
|
||||||
notifyFcmFailure();
|
|
||||||
} else {
|
|
||||||
Optional<String> token = FcmUtil.getToken();
|
|
||||||
|
|
||||||
if (token.isPresent()) {
|
|
||||||
String oldToken = TextSecurePreferences.getFcmToken(context);
|
|
||||||
|
|
||||||
if (!token.get().equals(oldToken)) {
|
|
||||||
int oldLength = oldToken != null ? oldToken.length() : -1;
|
|
||||||
Log.i(TAG, "Token changed. oldLength: " + oldLength + " newLength: " + token.get().length());
|
|
||||||
} else {
|
|
||||||
Log.i(TAG, "Token didn't change.");
|
|
||||||
}
|
|
||||||
|
|
||||||
textSecureAccountManager.setGcmId(token);
|
|
||||||
TextSecurePreferences.setFcmToken(context, token.get());
|
|
||||||
TextSecurePreferences.setFcmTokenLastSetTime(context, System.currentTimeMillis());
|
|
||||||
TextSecurePreferences.setWebsocketRegistered(context, true);
|
|
||||||
} else {
|
|
||||||
throw new RetryLaterException(new IOException("Failed to retrieve a token."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCanceled() {
|
|
||||||
Log.w(TAG, "GCM reregistration failed after retry attempt exhaustion!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onShouldRetry(@NonNull Exception throwable) {
|
|
||||||
if (throwable instanceof NonSuccessfulResponseCodeException) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyFcmFailure() {
|
|
||||||
Intent intent = new Intent(context, PlayServicesProblemActivity.class);
|
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 1122, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationChannels.FAILURES);
|
|
||||||
|
|
||||||
builder.setSmallIcon(R.drawable.ic_notification);
|
|
||||||
builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
|
|
||||||
R.drawable.ic_action_warning_red));
|
|
||||||
builder.setContentTitle(context.getString(R.string.GcmRefreshJob_Permanent_Signal_communication_failure));
|
|
||||||
builder.setContentText(context.getString(R.string.GcmRefreshJob_Signal_was_unable_to_register_with_Google_Play_Services));
|
|
||||||
builder.setTicker(context.getString(R.string.GcmRefreshJob_Permanent_Signal_communication_failure));
|
|
||||||
builder.setVibrate(new long[] {0, 1000});
|
|
||||||
builder.setContentIntent(pendingIntent);
|
|
||||||
|
|
||||||
((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE))
|
|
||||||
.notify(12, builder.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class Factory implements Job.Factory<FcmRefreshJob> {
|
|
||||||
@Override
|
|
||||||
public @NonNull FcmRefreshJob create(@NonNull Parameters parameters, @NonNull Data data) {
|
|
||||||
return new FcmRefreshJob(parameters);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -31,7 +31,6 @@ public final class JobManagerFactories {
|
|||||||
put(CleanPreKeysJob.KEY, new CleanPreKeysJob.Factory());
|
put(CleanPreKeysJob.KEY, new CleanPreKeysJob.Factory());
|
||||||
put(CreateSignedPreKeyJob.KEY, new CreateSignedPreKeyJob.Factory());
|
put(CreateSignedPreKeyJob.KEY, new CreateSignedPreKeyJob.Factory());
|
||||||
put(DirectoryRefreshJob.KEY, new DirectoryRefreshJob.Factory(application));
|
put(DirectoryRefreshJob.KEY, new DirectoryRefreshJob.Factory(application));
|
||||||
put(FcmRefreshJob.KEY, new FcmRefreshJob.Factory());
|
|
||||||
put(LocalBackupJob.KEY, new LocalBackupJob.Factory());
|
put(LocalBackupJob.KEY, new LocalBackupJob.Factory());
|
||||||
put(MmsDownloadJob.KEY, new MmsDownloadJob.Factory());
|
put(MmsDownloadJob.KEY, new MmsDownloadJob.Factory());
|
||||||
put(MmsReceiveJob.KEY, new MmsReceiveJob.Factory());
|
put(MmsReceiveJob.KEY, new MmsReceiveJob.Factory());
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.service;
|
|
||||||
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.contacts.ContactsSyncAdapter;
|
|
||||||
|
|
||||||
public class ContactsSyncAdapterService extends Service {
|
|
||||||
|
|
||||||
private static ContactsSyncAdapter syncAdapter;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void onCreate() {
|
|
||||||
if (syncAdapter == null) {
|
|
||||||
syncAdapter = new ContactsSyncAdapter(this, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
return syncAdapter.getSyncAdapterBinder();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user