mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
+4
-6
@@ -339,6 +339,8 @@
|
||||
<service android:enabled="true" android:exported="false" android:name=".service.KeyCachingService"/>
|
||||
<service android:enabled="true" android:name=".service.MessageRetrievalService"/>
|
||||
|
||||
<service android:name=".connect.KeepAliveService" android:enabled="true"/>
|
||||
|
||||
<service android:name=".service.AccountAuthenticatorService" android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.AccountAuthenticator" />
|
||||
@@ -363,6 +365,8 @@
|
||||
|
||||
<service android:name=".service.GenericForegroundService"/>
|
||||
|
||||
<receiver android:name=".connect.TimerReceiver" android:enabled="true"/>
|
||||
|
||||
<receiver android:name=".gcm.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
|
||||
<intent-filter>
|
||||
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
|
||||
@@ -449,12 +453,6 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".service.PersistentConnectionBootListener">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".notifications.MessageNotifier$ReminderReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="org.thoughtcrime.securesms.MessageNotifier.REMINDER_ACTION"/>
|
||||
|
||||
+5
-11
@@ -238,25 +238,19 @@ JNIEXPORT jint Java_com_b44t_messenger_DcContext_isConfigured(JNIEnv *env, jobje
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcContext_performJobs(JNIEnv *env, jobject obj)
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcContext_performImapJobs(JNIEnv *env, jobject obj)
|
||||
{
|
||||
dc_perform_imap_jobs(get_dc_context(env, obj));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcContext_idle(JNIEnv *env, jobject obj)
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcContext_performImapIdle(JNIEnv *env, jobject obj)
|
||||
{
|
||||
dc_perform_imap_idle(get_dc_context(env, obj));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcContext_interruptIdle(JNIEnv *env, jobject obj)
|
||||
{
|
||||
dc_interrupt_imap_idle(get_dc_context(env, obj));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcContext_fetch(JNIEnv *env, jobject obj)
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcContext_performImapFetch(JNIEnv *env, jobject obj)
|
||||
{
|
||||
dc_perform_imap_fetch(get_dc_context(env, obj));
|
||||
}
|
||||
@@ -274,9 +268,9 @@ JNIEXPORT void Java_com_b44t_messenger_DcContext_performSmtpIdle(JNIEnv *env, jo
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcContext_interruptSmtpIdle(JNIEnv *env, jobject obj)
|
||||
JNIEXPORT void Java_com_b44t_messenger_DcContext_maybeNetwork(JNIEnv *env, jobject obj)
|
||||
{
|
||||
dc_interrupt_smtp_idle(get_dc_context(env, obj));
|
||||
dc_maybe_network(get_dc_context(env, obj));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 799 B After Width: | Height: | Size: 750 B |
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB |
@@ -1534,5 +1534,6 @@
|
||||
<string name="conversation__menu_unarchive_chat">Unarchive chat</string>
|
||||
<string name="conversation__menu_delete_chat">Delete chat</string>
|
||||
<string name="conversation__no_messages">No messages.</string>
|
||||
<string name="permanent_notification_subtitle">Tap to open.</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -86,13 +86,12 @@ public class DcContext {
|
||||
public native void configure ();
|
||||
public native void stopOngoingProcess ();
|
||||
public native int isConfigured ();
|
||||
public native void performJobs ();
|
||||
public native void fetch ();
|
||||
public native void idle ();
|
||||
public native void interruptIdle ();
|
||||
public native void performImapJobs ();
|
||||
public native void performImapFetch ();
|
||||
public native void performImapIdle ();
|
||||
public native void performSmtpJobs ();
|
||||
public native void performSmtpIdle ();
|
||||
public native void interruptSmtpIdle ();
|
||||
public native void maybeNetwork ();
|
||||
public native void setConfig (String key, String value);
|
||||
public void setConfigInt (String key, int value) { setConfig(key, Integer.toString(value)); }
|
||||
public native String getConfig (String key, String def);
|
||||
|
||||
@@ -32,20 +32,16 @@ import com.b44t.messenger.DcEventCenter;
|
||||
|
||||
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
|
||||
import org.thoughtcrime.securesms.crypto.PRNGFixes;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.AxolotlStorageModule;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.dependencies.SignalCommunicationModule;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
import org.thoughtcrime.securesms.jobmanager.dependencies.DependencyInjector;
|
||||
import org.thoughtcrime.securesms.jobmanager.persistence.JavaJobSerializer;
|
||||
import org.thoughtcrime.securesms.jobmanager.requirements.NetworkRequirementProvider;
|
||||
import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirementProvider;
|
||||
import org.thoughtcrime.securesms.jobs.requirements.SqlCipherMigrationRequirementProvider;
|
||||
import org.thoughtcrime.securesms.notifications.MarkReadReceiver;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
||||
@@ -171,7 +167,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
.withDependencyInjector(this)
|
||||
.withJobSerializer(new JavaJobSerializer())
|
||||
.withRequirementProviders(new MasterSecretRequirementProvider(this),
|
||||
new NetworkRequirementProvider(this),
|
||||
new SqlCipherMigrationRequirementProvider())
|
||||
.withConsumerThreads(5)
|
||||
.build();
|
||||
|
||||
@@ -1,23 +1,9 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Delta Chat contributors
|
||||
*
|
||||
* 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.connect;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
@@ -69,6 +55,7 @@ public class ApplicationDcContext extends DcContext {
|
||||
public static final int RECIPIENT_TYPE_CONTACT = 1;
|
||||
|
||||
public Context context;
|
||||
public volatile boolean isScreenOn = false;
|
||||
|
||||
public ApplicationDcContext(Context context) {
|
||||
super("android-dev");
|
||||
@@ -96,6 +83,27 @@ public class ApplicationDcContext extends DcContext {
|
||||
|
||||
new ForegroundDetector(ApplicationContext.getInstance(context));
|
||||
startThreads();
|
||||
|
||||
TimerReceiver.scheduleNextAlarm(context);
|
||||
|
||||
BroadcastReceiver networkStateReceiver = new NetworkStateReceiver();
|
||||
context.registerReceiver(networkStateReceiver, new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION));
|
||||
|
||||
IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
|
||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
BroadcastReceiver screenReceiver = new ScreenReceiver();
|
||||
context.registerReceiver(screenReceiver, filter);
|
||||
|
||||
try {
|
||||
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
|
||||
isScreenOn = pm.isScreenOn();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
if( !isScreenOn ) {
|
||||
context.startService(new Intent(context, KeepAliveService.class));
|
||||
}
|
||||
}
|
||||
|
||||
public File getImexDir()
|
||||
@@ -259,28 +267,25 @@ public class ApplicationDcContext extends DcContext {
|
||||
imapThreadStartedVal = false;
|
||||
}
|
||||
|
||||
imapThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// raise the starting condition
|
||||
// after acquiring a wakelock so that the process is not terminated.
|
||||
// as imapWakeLock is not reference counted that would result in a wakelock-gap is not needed here.
|
||||
imapThread = new Thread(() -> {
|
||||
// raise the starting condition
|
||||
// after acquiring a wakelock so that the process is not terminated.
|
||||
// as imapWakeLock is not reference counted that would result in a wakelock-gap is not needed here.
|
||||
imapWakeLock.acquire();
|
||||
synchronized (imapThreadStartedCond) {
|
||||
imapThreadStartedVal = true;
|
||||
imapThreadStartedCond.notifyAll();
|
||||
}
|
||||
|
||||
Log.i("DeltaChat", "###################### IMAP-Thread started. ######################");
|
||||
|
||||
|
||||
while (true) {
|
||||
imapWakeLock.acquire();
|
||||
synchronized (imapThreadStartedCond) {
|
||||
imapThreadStartedVal = true;
|
||||
imapThreadStartedCond.notifyAll();
|
||||
}
|
||||
|
||||
Log.i("DeltaChat", "###################### IMAP-Thread started. ######################");
|
||||
|
||||
|
||||
while (true) {
|
||||
imapWakeLock.acquire();
|
||||
performJobs();
|
||||
fetch();
|
||||
imapWakeLock.release();
|
||||
idle();
|
||||
}
|
||||
performImapJobs();
|
||||
performImapFetch();
|
||||
imapWakeLock.release();
|
||||
performImapIdle();
|
||||
}
|
||||
}, "imapThread");
|
||||
imapThread.setPriority(Thread.NORM_PRIORITY);
|
||||
@@ -293,24 +298,21 @@ public class ApplicationDcContext extends DcContext {
|
||||
smtpThreadStartedVal = false;
|
||||
}
|
||||
|
||||
smtpThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
smtpThread = new Thread(() -> {
|
||||
smtpWakeLock.acquire();
|
||||
synchronized (smtpThreadStartedCond) {
|
||||
smtpThreadStartedVal = true;
|
||||
smtpThreadStartedCond.notifyAll();
|
||||
}
|
||||
|
||||
Log.i("DeltaChat", "###################### SMTP-Thread started. ######################");
|
||||
|
||||
|
||||
while (true) {
|
||||
smtpWakeLock.acquire();
|
||||
synchronized (smtpThreadStartedCond) {
|
||||
smtpThreadStartedVal = true;
|
||||
smtpThreadStartedCond.notifyAll();
|
||||
}
|
||||
|
||||
Log.i("DeltaChat", "###################### SMTP-Thread started. ######################");
|
||||
|
||||
|
||||
while (true) {
|
||||
smtpWakeLock.acquire();
|
||||
performSmtpJobs();
|
||||
smtpWakeLock.release();
|
||||
performSmtpIdle();
|
||||
}
|
||||
performSmtpJobs();
|
||||
smtpWakeLock.release();
|
||||
performSmtpIdle();
|
||||
}
|
||||
}, "smtpThread");
|
||||
smtpThread.setPriority(Thread.MAX_PRIORITY);
|
||||
|
||||
@@ -1,25 +1,3 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Delta Chat Android
|
||||
* (C) 2017 Björn Petersen
|
||||
* Contact: r10s@b44t.com, http://b44t.com
|
||||
*
|
||||
* 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.connect;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
|
||||
@@ -1,24 +1,9 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Delta Chat contributors
|
||||
*
|
||||
* 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.connect;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
@@ -53,7 +38,7 @@ public class ForegroundDetector implements Application.ActivityLifecycleCallback
|
||||
public void onActivityStarted(Activity activity) {
|
||||
refs++;
|
||||
|
||||
//applicationContext.stopService(new Intent(applicationContext, KeepAliveService.class));
|
||||
activity.stopService(new Intent(activity, KeepAliveService.class));
|
||||
application.dcContext.startThreads(); // we call this without checking getPermanentPush() to have a simple guarantee that push is always active when the app is in foregroud (startIdleThread makes sure the thread is not started twice)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package org.thoughtcrime.securesms.connect;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.ConversationListActivity;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class KeepAliveService extends Service {
|
||||
|
||||
static KeepAliveService s_this = null;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Log.i("DeltaChat", "*** KeepAliveService.onCreate()");
|
||||
// there's nothing more to do here as all initialisation stuff is already done in
|
||||
// ApplicationLoader.onCreate() which is called before this broadcast is sended.
|
||||
s_this = this;
|
||||
setSelfAsForeground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
// START_STICKY ensured, the service is recreated as soon it is terminated for any reasons.
|
||||
// as ApplicationLoader.onCreate() is called before a service starts, there is no more to do here,
|
||||
// the app is just running fine.
|
||||
Log.i("DeltaChat", "*** KeepAliveService.onStartCommand()");
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
Log.i("DeltaChat", "*** KeepAliveService.onDestroy()");
|
||||
// the service will be restarted due to START_STICKY automatically, there's nothing more to do.
|
||||
}
|
||||
|
||||
private void setSelfAsForeground() {
|
||||
stopForeground(true);
|
||||
startForeground(FG_NOTIFICATION_ID, createNotification()); // TODO: if we target Android O, we should use startServiceInForeground()
|
||||
}
|
||||
|
||||
static public KeepAliveService getInstance()
|
||||
{
|
||||
return s_this; // may be null
|
||||
}
|
||||
|
||||
/* The notification
|
||||
* A notification is required for a foreground service; and without a foreground service,
|
||||
* Delta Chat won't get new messages reliable
|
||||
**********************************************************************************************/
|
||||
|
||||
public static final int FG_NOTIFICATION_ID = 4142;
|
||||
private Notification createNotification()
|
||||
{
|
||||
ApplicationDcContext dcContext = DcHelper.getContext(this);
|
||||
|
||||
Intent intent = new Intent(this, ConversationListActivity.class);
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
// a notification _must_ contain a small icon, a title and a text, see https://developer.android.com/guide/topics/ui/notifiers/notifications.html#Required
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
|
||||
|
||||
builder.setContentTitle(getString(R.string.app_name));
|
||||
builder.setContentText(getString(R.string.permanent_notification_subtitle));
|
||||
|
||||
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN ) {
|
||||
builder.setPriority(NotificationCompat.PRIORITY_MIN);
|
||||
}
|
||||
builder.setWhen(0);
|
||||
builder.setContentIntent(contentIntent);
|
||||
builder.setSmallIcon(R.drawable.icon_notification);
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.thoughtcrime.securesms.connect;
|
||||
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
|
||||
|
||||
public class NetworkStateReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
try {
|
||||
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo ni = manager.getActiveNetworkInfo();
|
||||
|
||||
if (ni != null && ni.getState() == NetworkInfo.State.CONNECTED) {
|
||||
Log.i("DeltaChat", "++++++++++++++++++ Connected ++++++++++++++++++");
|
||||
ApplicationDcContext dcContext = DcHelper.getContext(context);
|
||||
dcContext.startThreads();
|
||||
dcContext.waitForThreadsRunning();
|
||||
dcContext.maybeNetwork();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.thoughtcrime.securesms.connect;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
public class ScreenReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
ApplicationDcContext dcContext = DcHelper.getContext(context);
|
||||
|
||||
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
|
||||
Log.i("DeltaChat", "-------------------- Screen off --------------------");
|
||||
dcContext.isScreenOn = false;
|
||||
context.startService(new Intent(context, KeepAliveService.class));
|
||||
}
|
||||
else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
|
||||
Log.i("DeltaChat", "-------------------- Screen on --------------------");
|
||||
dcContext.isScreenOn = true;
|
||||
context.stopService(new Intent(context, KeepAliveService.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// restart the smtp and imap threads every 60 seconds if they were killed by the os
|
||||
|
||||
package org.thoughtcrime.securesms.connect;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
|
||||
public class TimerReceiver extends BroadcastReceiver {
|
||||
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
Log.i("DeltaChat", "-------------------- on receive timer --------------------");
|
||||
|
||||
scheduleNextAlarm(context);
|
||||
|
||||
ApplicationDcContext dcContext = DcHelper.getContext(context);
|
||||
dcContext.startThreads();
|
||||
dcContext.waitForThreadsRunning();
|
||||
}
|
||||
|
||||
public static void scheduleNextAlarm(Context context)
|
||||
{
|
||||
try {
|
||||
Intent intent = new Intent(context, TimerReceiver.class);
|
||||
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
|
||||
|
||||
long triggerAtMillis = System.currentTimeMillis() + 60 * 1000;
|
||||
|
||||
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Activity.ALARM_SERVICE);
|
||||
if( Build.VERSION.SDK_INT >= 23 ) {
|
||||
// a simple AlarmManager.set() is no longer send in the new DOZE mode
|
||||
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, triggerAtMillis, alarmIntent);
|
||||
}
|
||||
else {
|
||||
alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, alarmIntent);
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.e("DeltaChat", "Cannot create alarm.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,8 @@ import org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceReadReceiptUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob;
|
||||
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.RequestGroupInfoJob;
|
||||
@@ -49,9 +46,6 @@ import dagger.Provides;
|
||||
|
||||
@Module(complete = false, injects = {CleanPreKeysJob.class,
|
||||
CreateSignedPreKeyJob.class,
|
||||
PushGroupSendJob.class,
|
||||
PushTextSendJob.class,
|
||||
PushMediaSendJob.class,
|
||||
AttachmentDownloadJob.class,
|
||||
RefreshPreKeysJob.class,
|
||||
MessageRetrievalService.class,
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.requirements;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.dependencies.ContextDependent;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Uses exponential backoff to re-schedule network jobs to be retried in the future.
|
||||
*/
|
||||
public class NetworkBackoffRequirement implements Requirement, ContextDependent {
|
||||
|
||||
private static final long MAX_WAIT = TimeUnit.SECONDS.toMillis(30);
|
||||
|
||||
private transient Context context;
|
||||
|
||||
public NetworkBackoffRequirement(@NonNull Context context) {
|
||||
this.context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPresent(@NonNull Job job) {
|
||||
return new NetworkRequirement(context).isPresent() && System.currentTimeMillis() >= calculateNextRunTime(job);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRetry(@NonNull Job job) {
|
||||
if (!(new NetworkRequirement(context).isPresent())) {
|
||||
job.resetRunStats();
|
||||
return;
|
||||
}
|
||||
|
||||
BackoffReceiver.setUniqueAlarm(context, NetworkBackoffRequirement.calculateNextRunTime(job));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContext(Context context) {
|
||||
this.context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
private static long calculateNextRunTime(@NonNull Job job) {
|
||||
long targetTime = job.getLastRunTime() + (long) (Math.pow(2, job.getRunIteration() - 1) * 1000);
|
||||
long furthestTime = System.currentTimeMillis() + MAX_WAIT;
|
||||
|
||||
return Math.min(targetTime, Math.min(furthestTime, job.getRetryUntil()));
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2014 Open Whisper Systems
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.thoughtcrime.securesms.jobmanager.requirements;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
|
||||
public class NetworkRequirementProvider implements RequirementProvider {
|
||||
|
||||
private RequirementListener listener;
|
||||
|
||||
private final NetworkRequirement requirement;
|
||||
|
||||
public NetworkRequirementProvider(Context context) {
|
||||
this.requirement = new NetworkRequirement(context);
|
||||
|
||||
context.getApplicationContext().registerReceiver(new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (listener == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (requirement.isPresent()) {
|
||||
listener.onRequirementStatusChanged();
|
||||
}
|
||||
}
|
||||
}, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListener(RequirementListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.GroupReceiptDatabase.GroupReceiptInfo;
|
||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobParameters;
|
||||
import org.thoughtcrime.securesms.jobmanager.requirements.NetworkBackoffRequirement;
|
||||
import org.thoughtcrime.securesms.jobmanager.requirements.NetworkRequirement;
|
||||
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
|
||||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||
import org.thoughtcrime.securesms.mms.MmsException;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
||||
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Quote;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
||||
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.EncapsulatedExceptions;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.NetworkFailureException;
|
||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final String TAG = PushGroupSendJob.class.getSimpleName();
|
||||
|
||||
@Inject transient SignalServiceMessageSender messageSender;
|
||||
|
||||
private final long messageId;
|
||||
private final long filterRecipientId; // Deprecated
|
||||
private final String filterAddress;
|
||||
|
||||
public PushGroupSendJob(Context context, long messageId, @NonNull Address destination, @Nullable Address filterAddress) {
|
||||
super(context, JobParameters.newBuilder()
|
||||
.withPersistence()
|
||||
.withGroupId(destination.toGroupString())
|
||||
.withRequirement(new MasterSecretRequirement(context))
|
||||
.withRequirement(new NetworkBackoffRequirement(context))
|
||||
.withRetryDuration(TimeUnit.DAYS.toMillis(1))
|
||||
.create());
|
||||
|
||||
this.messageId = messageId;
|
||||
this.filterAddress = filterAddress == null ? null :filterAddress.toPhoneString();
|
||||
this.filterRecipientId = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPushSend()
|
||||
throws MmsException, IOException, NoSuchMessageException
|
||||
{
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
|
||||
try {
|
||||
deliver(message, filterAddress == null ? null : Address.fromSerialized(filterAddress));
|
||||
|
||||
database.markAsSent(messageId, true);
|
||||
markAttachmentsUploaded(messageId, message.getAttachments());
|
||||
|
||||
if (message.getExpiresIn() > 0 && !message.isExpirationUpdate()) {
|
||||
database.markExpireStarted(messageId);
|
||||
ApplicationContext.getInstance(context)
|
||||
.getExpiringMessageManager()
|
||||
.scheduleDeletion(messageId, true, message.getExpiresIn());
|
||||
}
|
||||
} catch (InvalidNumberException | RecipientFormattingException | UndeliverableMessageException e) {
|
||||
Log.w(TAG, e);
|
||||
database.markAsSentFailed(messageId);
|
||||
notifyMediaMessageDeliveryFailed(context, messageId);
|
||||
} catch (EncapsulatedExceptions e) {
|
||||
Log.w(TAG, e);
|
||||
List<NetworkFailure> failures = new LinkedList<>();
|
||||
|
||||
for (NetworkFailureException nfe : e.getNetworkExceptions()) {
|
||||
failures.add(new NetworkFailure(Address.fromSerialized(nfe.getE164number())));
|
||||
}
|
||||
|
||||
for (UntrustedIdentityException uie : e.getUntrustedIdentityExceptions()) {
|
||||
database.addMismatchedIdentity(messageId, Address.fromSerialized(uie.getE164Number()), uie.getIdentityKey());
|
||||
}
|
||||
|
||||
database.addFailures(messageId, failures);
|
||||
|
||||
if (e.getNetworkExceptions().isEmpty() && e.getUntrustedIdentityExceptions().isEmpty()) {
|
||||
database.markAsSent(messageId, true);
|
||||
markAttachmentsUploaded(messageId, message.getAttachments());
|
||||
|
||||
if (message.getExpiresIn() > 0 && !message.isExpirationUpdate()) {
|
||||
database.markExpireStarted(messageId);
|
||||
ApplicationContext.getInstance(context)
|
||||
.getExpiringMessageManager()
|
||||
.scheduleDeletion(messageId, true, message.getExpiresIn());
|
||||
}
|
||||
} else {
|
||||
database.markAsSentFailed(messageId);
|
||||
notifyMediaMessageDeliveryFailed(context, messageId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
if (exception instanceof IOException) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled() {
|
||||
DatabaseFactory.getMmsDatabase(context).markAsSentFailed(messageId);
|
||||
}
|
||||
|
||||
private void deliver(OutgoingMediaMessage message, @Nullable Address filterAddress)
|
||||
throws IOException, RecipientFormattingException, InvalidNumberException,
|
||||
EncapsulatedExceptions, UndeliverableMessageException
|
||||
{
|
||||
String groupId = message.getRecipient().getAddress().toGroupString();
|
||||
Optional<byte[]> profileKey = getProfileKey(message.getRecipient());
|
||||
List<Address> recipients = getGroupMessageRecipients(groupId, messageId);
|
||||
MediaConstraints mediaConstraints = MediaConstraints.getPushMediaConstraints();
|
||||
List<Attachment> scaledAttachments = scaleAndStripExifFromAttachments(mediaConstraints, message.getAttachments());
|
||||
List<SignalServiceAttachment> attachmentStreams = getAttachmentsFor(scaledAttachments);
|
||||
Optional<Quote> quote = getQuoteFor(message);
|
||||
List<SharedContact> sharedContacts = getSharedContactsFor(message);
|
||||
|
||||
List<SignalServiceAddress> addresses;
|
||||
|
||||
if (filterAddress != null) addresses = getPushAddresses(filterAddress);
|
||||
else addresses = getPushAddresses(recipients);
|
||||
|
||||
if (message.isGroup()) {
|
||||
OutgoingGroupMediaMessage groupMessage = (OutgoingGroupMediaMessage) message;
|
||||
GroupContext groupContext = groupMessage.getGroupContext();
|
||||
SignalServiceAttachment avatar = attachmentStreams.isEmpty() ? null : attachmentStreams.get(0);
|
||||
SignalServiceGroup.Type type = groupMessage.isGroupQuit() ? SignalServiceGroup.Type.QUIT : SignalServiceGroup.Type.UPDATE;
|
||||
SignalServiceGroup group = new SignalServiceGroup(type, GroupUtil.getDecodedId(groupId), groupContext.getName(), groupContext.getMembersList(), avatar);
|
||||
SignalServiceDataMessage groupDataMessage = SignalServiceDataMessage.newBuilder()
|
||||
.withTimestamp(message.getSentTimeMillis())
|
||||
.withExpiration(message.getRecipient().getExpireMessages())
|
||||
.asGroupMessage(group)
|
||||
.build();
|
||||
|
||||
messageSender.sendMessage(addresses, groupDataMessage);
|
||||
} else {
|
||||
SignalServiceGroup group = new SignalServiceGroup(GroupUtil.getDecodedId(groupId));
|
||||
SignalServiceDataMessage groupMessage = SignalServiceDataMessage.newBuilder()
|
||||
.withTimestamp(message.getSentTimeMillis())
|
||||
.asGroupMessage(group)
|
||||
.withAttachments(attachmentStreams)
|
||||
.withBody(message.getBody())
|
||||
.withExpiration((int)(message.getExpiresIn() / 1000))
|
||||
.asExpirationUpdate(message.isExpirationUpdate())
|
||||
.withProfileKey(profileKey.orNull())
|
||||
.withQuote(quote.orNull())
|
||||
.withSharedContacts(sharedContacts)
|
||||
.build();
|
||||
|
||||
messageSender.sendMessage(addresses, groupMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private List<SignalServiceAddress> getPushAddresses(Address address) {
|
||||
List<SignalServiceAddress> addresses = new LinkedList<>();
|
||||
addresses.add(getPushAddress(address));
|
||||
return addresses;
|
||||
}
|
||||
|
||||
private List<SignalServiceAddress> getPushAddresses(List<Address> addresses) {
|
||||
return Stream.of(addresses).map(this::getPushAddress).toList();
|
||||
}
|
||||
|
||||
private @NonNull List<Address> getGroupMessageRecipients(String groupId, long messageId) {
|
||||
List<GroupReceiptInfo> destinations = DatabaseFactory.getGroupReceiptDatabase(context).getGroupReceiptInfo(messageId);
|
||||
if (!destinations.isEmpty()) return Stream.of(destinations).map(GroupReceiptInfo::getAddress).toList();
|
||||
|
||||
List<Recipient> members = DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupId, false);
|
||||
return Stream.of(members).map(Recipient::getAddress).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||
import org.thoughtcrime.securesms.mms.MmsException;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
||||
import org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException;
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final String TAG = PushMediaSendJob.class.getSimpleName();
|
||||
|
||||
@Inject transient SignalServiceMessageSender messageSender;
|
||||
|
||||
private final long messageId;
|
||||
|
||||
public PushMediaSendJob(Context context, long messageId, Address destination) {
|
||||
super(context, constructParameters(context, destination));
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPushSend()
|
||||
throws RetryLaterException, MmsException, NoSuchMessageException,
|
||||
UndeliverableMessageException
|
||||
{
|
||||
ExpiringMessageManager expirationManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
|
||||
try {
|
||||
deliver(message);
|
||||
database.markAsSent(messageId, true);
|
||||
markAttachmentsUploaded(messageId, message.getAttachments());
|
||||
|
||||
if (message.getExpiresIn() > 0 && !message.isExpirationUpdate()) {
|
||||
database.markExpireStarted(messageId);
|
||||
expirationManager.scheduleDeletion(messageId, true, message.getExpiresIn());
|
||||
}
|
||||
|
||||
} catch (InsecureFallbackApprovalException ifae) {
|
||||
Log.w(TAG, ifae);
|
||||
database.markAsPendingInsecureSmsFallback(messageId);
|
||||
notifyMediaMessageDeliveryFailed(context, messageId);
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, false));
|
||||
} catch (UntrustedIdentityException uie) {
|
||||
Log.w(TAG, uie);
|
||||
database.addMismatchedIdentity(messageId, Address.fromSerialized(uie.getE164Number()), uie.getIdentityKey());
|
||||
database.markAsSentFailed(messageId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
if (exception instanceof RequirementNotMetException) return true;
|
||||
if (exception instanceof RetryLaterException) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled() {
|
||||
DatabaseFactory.getMmsDatabase(context).markAsSentFailed(messageId);
|
||||
notifyMediaMessageDeliveryFailed(context, messageId);
|
||||
}
|
||||
|
||||
private void deliver(OutgoingMediaMessage message)
|
||||
throws RetryLaterException, InsecureFallbackApprovalException, UntrustedIdentityException,
|
||||
UndeliverableMessageException
|
||||
{
|
||||
if (message.getRecipient() == null) {
|
||||
throw new UndeliverableMessageException("No destination address.");
|
||||
}
|
||||
|
||||
try {
|
||||
SignalServiceAddress address = getPushAddress(message.getRecipient().getAddress());
|
||||
MediaConstraints mediaConstraints = MediaConstraints.getPushMediaConstraints();
|
||||
List<Attachment> scaledAttachments = scaleAndStripExifFromAttachments(mediaConstraints, message.getAttachments());
|
||||
List<SignalServiceAttachment> attachmentStreams = getAttachmentsFor(scaledAttachments);
|
||||
Optional<byte[]> profileKey = getProfileKey(message.getRecipient());
|
||||
Optional<SignalServiceDataMessage.Quote> quote = getQuoteFor(message);
|
||||
List<SharedContact> sharedContacts = getSharedContactsFor(message);
|
||||
SignalServiceDataMessage mediaMessage = SignalServiceDataMessage.newBuilder()
|
||||
.withBody(message.getBody())
|
||||
.withAttachments(attachmentStreams)
|
||||
.withTimestamp(message.getSentTimeMillis())
|
||||
.withExpiration((int)(message.getExpiresIn() / 1000))
|
||||
.withProfileKey(profileKey.orNull())
|
||||
.withQuote(quote.orNull())
|
||||
.withSharedContacts(sharedContacts)
|
||||
.asExpirationUpdate(message.isExpirationUpdate())
|
||||
.build();
|
||||
|
||||
messageSender.sendMessage(address, mediaMessage);
|
||||
} catch (UnregisteredUserException e) {
|
||||
Log.w(TAG, e);
|
||||
throw new InsecureFallbackApprovalException(e);
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.w(TAG, e);
|
||||
throw new UndeliverableMessageException(e);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
throw new RetryLaterException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.TextSecureExpiredException;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
||||
import org.thoughtcrime.securesms.contactshare.ContactModelMapper;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.events.PartProgressEvent;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobParameters;
|
||||
import org.thoughtcrime.securesms.jobmanager.requirements.NetworkBackoffRequirement;
|
||||
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
|
||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority;
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.messages.shared.SharedContact;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public abstract class PushSendJob extends SendJob {
|
||||
|
||||
private static final long serialVersionUID = 5906098204770900739L;
|
||||
private static final String TAG = PushSendJob.class.getSimpleName();
|
||||
|
||||
protected PushSendJob(Context context, JobParameters parameters) {
|
||||
super(context, parameters);
|
||||
}
|
||||
|
||||
protected static JobParameters constructParameters(Context context, Address destination) {
|
||||
JobParameters.Builder builder = JobParameters.newBuilder();
|
||||
builder.withPersistence();
|
||||
builder.withGroupId(destination.serialize());
|
||||
builder.withRequirement(new MasterSecretRequirement(context));
|
||||
builder.withRequirement(new NetworkBackoffRequirement(context));
|
||||
builder.withRetryDuration(TimeUnit.DAYS.toMillis(1));
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onSend(MasterSecret masterSecret) throws Exception {
|
||||
if (TextSecurePreferences.getSignedPreKeyFailureCount(context) > 5) {
|
||||
ApplicationContext.getInstance(context)
|
||||
.getJobManager()
|
||||
.add(new RotateSignedPreKeyJob(context));
|
||||
|
||||
throw new TextSecureExpiredException("Too many signed prekey rotation failures");
|
||||
}
|
||||
|
||||
onPushSend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRetry() {
|
||||
super.onRetry();
|
||||
|
||||
if (getRunIteration() > 1) {
|
||||
// ApplicationContext.getInstance(context).getJobManager().add(new ServiceOutageDetectionJob(context));
|
||||
}
|
||||
}
|
||||
|
||||
protected Optional<byte[]> getProfileKey(@NonNull Recipient recipient) {
|
||||
if (!recipient.resolve().isSystemContact() && !recipient.resolve().isProfileSharing()) {
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
return Optional.of(ProfileKeyUtil.getProfileKey(context));
|
||||
}
|
||||
|
||||
protected SignalServiceAddress getPushAddress(Address address) {
|
||||
// String relay = TextSecureDirectory.getInstance(context).getRelay(address.toPhoneString());
|
||||
String relay = null;
|
||||
return new SignalServiceAddress(address.toPhoneString(), Optional.fromNullable(relay));
|
||||
}
|
||||
|
||||
protected List<SignalServiceAttachment> getAttachmentsFor(List<Attachment> parts) {
|
||||
List<SignalServiceAttachment> attachments = new LinkedList<>();
|
||||
|
||||
for (final Attachment attachment : parts) {
|
||||
SignalServiceAttachment converted = getAttachmentFor(attachment);
|
||||
if (converted != null) {
|
||||
attachments.add(converted);
|
||||
}
|
||||
}
|
||||
|
||||
return attachments;
|
||||
}
|
||||
|
||||
protected SignalServiceAttachment getAttachmentFor(Attachment attachment) {
|
||||
try {
|
||||
if (attachment.getDataUri() == null || attachment.getSize() == 0) throw new IOException("Assertion failed, outgoing attachment has no data!");
|
||||
InputStream is = PartAuthority.getAttachmentStream(context, attachment.getDataUri());
|
||||
return SignalServiceAttachment.newStreamBuilder()
|
||||
.withStream(is)
|
||||
.withContentType(attachment.getContentType())
|
||||
.withLength(attachment.getSize())
|
||||
.withFileName(attachment.getFileName())
|
||||
.withVoiceNote(attachment.isVoiceNote())
|
||||
.withWidth(attachment.getWidth())
|
||||
.withHeight(attachment.getHeight())
|
||||
.withListener((total, progress) -> EventBus.getDefault().postSticky(new PartProgressEvent(attachment, total, progress)))
|
||||
.build();
|
||||
} catch (IOException ioe) {
|
||||
Log.w(TAG, "Couldn't open attachment", ioe);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void notifyMediaMessageDeliveryFailed(Context context, long messageId) {
|
||||
long threadId = DatabaseFactory.getMmsDatabase(context).getThreadIdForMessage(messageId);
|
||||
Recipient recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId);
|
||||
|
||||
if (threadId != -1 && recipient != null) {
|
||||
// todo the following line will not work for the signal code because of the cast, as soon as it is converted to dc code, remove the cast.
|
||||
MessageNotifier.notifyMessageDeliveryFailed(context, recipient, (int)threadId);
|
||||
}
|
||||
}
|
||||
|
||||
protected Optional<SignalServiceDataMessage.Quote> getQuoteFor(OutgoingMediaMessage message) {
|
||||
if (message.getOutgoingQuote() == null) return Optional.absent();
|
||||
|
||||
long quoteId = message.getOutgoingQuote().getId();
|
||||
String quoteBody = message.getOutgoingQuote().getText();
|
||||
Address quoteAuthor = message.getOutgoingQuote().getAuthor();
|
||||
List<SignalServiceDataMessage.Quote.QuotedAttachment> quoteAttachments = new LinkedList<>();
|
||||
|
||||
for (Attachment attachment : message.getOutgoingQuote().getAttachments()) {
|
||||
BitmapUtil.ScaleResult thumbnailData = null;
|
||||
SignalServiceAttachment thumbnail = null;
|
||||
|
||||
try {
|
||||
if (MediaUtil.isImageType(attachment.getContentType()) && attachment.getDataUri() != null) {
|
||||
thumbnailData = BitmapUtil.createScaledBytes(context, new DecryptableStreamUriLoader.DecryptableUri(attachment.getDataUri()), 100, 100, 500 * 1024);
|
||||
} else if (MediaUtil.isVideoType(attachment.getContentType()) && attachment.getThumbnailUri() != null) {
|
||||
thumbnailData = BitmapUtil.createScaledBytes(context, new DecryptableStreamUriLoader.DecryptableUri(attachment.getThumbnailUri()), 100, 100, 500 * 1024);
|
||||
}
|
||||
|
||||
if (thumbnailData != null) {
|
||||
thumbnail = SignalServiceAttachment.newStreamBuilder()
|
||||
.withContentType("image/jpeg")
|
||||
.withWidth(thumbnailData.getWidth())
|
||||
.withHeight(thumbnailData.getHeight())
|
||||
.withLength(thumbnailData.getBitmap().length)
|
||||
.withStream(new ByteArrayInputStream(thumbnailData.getBitmap()))
|
||||
.build();
|
||||
}
|
||||
|
||||
quoteAttachments.add(new SignalServiceDataMessage.Quote.QuotedAttachment(attachment.getContentType(),
|
||||
attachment.getFileName(),
|
||||
thumbnail));
|
||||
} catch (BitmapDecodingException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.of(new SignalServiceDataMessage.Quote(quoteId, new SignalServiceAddress(quoteAuthor.serialize()), quoteBody, quoteAttachments));
|
||||
}
|
||||
|
||||
List<SharedContact> getSharedContactsFor(OutgoingMediaMessage mediaMessage) {
|
||||
List<SharedContact> sharedContacts = new LinkedList<>();
|
||||
|
||||
for (Contact contact : mediaMessage.getSharedContacts()) {
|
||||
SharedContact.Builder builder = ContactModelMapper.localToRemoteBuilder(contact);
|
||||
SharedContact.Avatar avatar = null;
|
||||
|
||||
if (contact.getAvatar() != null && contact.getAvatar().getAttachment() != null) {
|
||||
avatar = SharedContact.Avatar.newBuilder().withAttachment(getAttachmentFor(contact.getAvatarAttachment()))
|
||||
.withProfileFlag(contact.getAvatar().isProfile())
|
||||
.build();
|
||||
}
|
||||
|
||||
builder.setAvatar(avatar);
|
||||
sharedContacts.add(builder.build());
|
||||
}
|
||||
|
||||
return sharedContacts;
|
||||
}
|
||||
|
||||
protected abstract void onPushSend() throws Exception;
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
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.notifications.MessageNotifier;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.service.ExpiringMessageManager;
|
||||
import org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException;
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final String TAG = PushTextSendJob.class.getSimpleName();
|
||||
|
||||
@Inject transient SignalServiceMessageSender messageSender;
|
||||
|
||||
private final long messageId;
|
||||
|
||||
public PushTextSendJob(Context context, long messageId, Address destination) {
|
||||
super(context, constructParameters(context, destination));
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {}
|
||||
|
||||
@Override
|
||||
public void onPushSend() throws NoSuchMessageException, RetryLaterException {
|
||||
ExpiringMessageManager expirationManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
|
||||
SmsDatabase database = DatabaseFactory.getSmsDatabase(context);
|
||||
SmsMessageRecord record = database.getMessage(messageId);
|
||||
|
||||
try {
|
||||
Log.w(TAG, "Sending message: " + messageId);
|
||||
|
||||
deliver(record);
|
||||
database.markAsSent(messageId, true);
|
||||
|
||||
if (record.getExpiresIn() > 0) {
|
||||
database.markExpireStarted(messageId);
|
||||
expirationManager.scheduleDeletion(record.getId(), record.isMms(), record.getExpiresIn());
|
||||
}
|
||||
|
||||
} catch (InsecureFallbackApprovalException e) {
|
||||
Log.w(TAG, e);
|
||||
database.markAsPendingInsecureSmsFallback(record.getId());
|
||||
// todo the following line will not work for signal because of the cast, remove the cast as soon as it is reworked to dc code.
|
||||
MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipient(), (int)record.getThreadId());
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, false));
|
||||
} catch (UntrustedIdentityException e) {
|
||||
Log.w(TAG, e);
|
||||
database.addMismatchedIdentity(record.getId(), Address.fromSerialized(e.getE164Number()), e.getIdentityKey());
|
||||
database.markAsSentFailed(record.getId());
|
||||
database.markAsPush(record.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetryThrowable(Exception exception) {
|
||||
if (exception instanceof RetryLaterException) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled() {
|
||||
DatabaseFactory.getSmsDatabase(context).markAsSentFailed(messageId);
|
||||
|
||||
long threadId = DatabaseFactory.getSmsDatabase(context).getThreadIdForMessage(messageId);
|
||||
Recipient recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId);
|
||||
|
||||
if (threadId != -1 && recipient != null) {
|
||||
// todo the following line will not work for the signal code because of the cast, when its converted to dc code, remove the cast.
|
||||
MessageNotifier.notifyMessageDeliveryFailed(context, recipient, (int)threadId);
|
||||
}
|
||||
}
|
||||
|
||||
private void deliver(SmsMessageRecord message)
|
||||
throws UntrustedIdentityException, InsecureFallbackApprovalException, RetryLaterException
|
||||
{
|
||||
try {
|
||||
SignalServiceAddress address = getPushAddress(message.getIndividualRecipient().getAddress());
|
||||
Optional<byte[]> profileKey = getProfileKey(message.getIndividualRecipient());
|
||||
SignalServiceDataMessage textSecureMessage = SignalServiceDataMessage.newBuilder()
|
||||
.withTimestamp(message.getDateSent())
|
||||
.withBody(message.getBody())
|
||||
.withExpiration((int)(message.getExpiresIn() / 1000))
|
||||
.withProfileKey(profileKey.orNull())
|
||||
.asEndSessionMessage(message.isEndSession())
|
||||
.build();
|
||||
|
||||
|
||||
messageSender.sendMessage(address, textSecureMessage);
|
||||
} catch (UnregisteredUserException e) {
|
||||
Log.w(TAG, e);
|
||||
throw new InsecureFallbackApprovalException(e);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
throw new RetryLaterException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,15 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent != null && Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||
Intent messageRetrievalService = new Intent(context, MessageRetrievalService.class);
|
||||
context.startService(messageRetrievalService);
|
||||
}
|
||||
Log.i("DeltaChat", "*** BootReceiver.onReceive()");
|
||||
// there's nothing more to do here as all initialisation stuff is already done in
|
||||
// ApplicationDcContext() which is called before this broadcast is sent.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.gcm.GcmBroadcastReceiver;
|
||||
import org.thoughtcrime.securesms.jobmanager.requirements.NetworkRequirement;
|
||||
import org.thoughtcrime.securesms.jobmanager.requirements.NetworkRequirementProvider;
|
||||
import org.thoughtcrime.securesms.jobmanager.requirements.RequirementListener;
|
||||
import org.thoughtcrime.securesms.jobs.PushContentReceiveJob;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
@@ -42,7 +41,6 @@ public class MessageRetrievalService extends Service implements InjectableType,
|
||||
private static final long REQUEST_TIMEOUT_MINUTES = 1;
|
||||
|
||||
private NetworkRequirement networkRequirement;
|
||||
private NetworkRequirementProvider networkRequirementProvider;
|
||||
|
||||
@Inject
|
||||
public SignalServiceMessageReceiver receiver;
|
||||
@@ -59,9 +57,6 @@ public class MessageRetrievalService extends Service implements InjectableType,
|
||||
ApplicationContext.getInstance(this).injectDependencies(this);
|
||||
|
||||
networkRequirement = new NetworkRequirement(this);
|
||||
networkRequirementProvider = new NetworkRequirementProvider(this);
|
||||
|
||||
networkRequirementProvider.setListener(this);
|
||||
|
||||
retrievalThread = new MessageRetrievalThread();
|
||||
retrievalThread.start();
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.thoughtcrime.securesms.service;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
|
||||
public class PersistentConnectionBootListener extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent != null && Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||
if (TextSecurePreferences.isGcmDisabled(context)) {
|
||||
Intent serviceIntent = new Intent(context, MessageRetrievalService.class);
|
||||
serviceIntent.setAction(MessageRetrievalService.ACTION_INITIALIZE);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) context.startForegroundService(serviceIntent);
|
||||
else context.startService(serviceIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,10 +32,6 @@ import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager;
|
||||
import org.thoughtcrime.securesms.jobs.PushGroupSendJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushMediaSendJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushTextSendJob;
|
||||
import org.thoughtcrime.securesms.mms.MmsException;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.push.AccountManagerFactory;
|
||||
@@ -108,29 +104,6 @@ public class MessageSender {
|
||||
}
|
||||
}
|
||||
|
||||
public static void resendGroupMessage(Context context, MessageRecord messageRecord, Address filterAddress) {
|
||||
if (!messageRecord.isMms()) throw new AssertionError("Not Group");
|
||||
sendGroupPush(context, messageRecord.getRecipient(), messageRecord.getId(), filterAddress);
|
||||
}
|
||||
|
||||
public static void resend(Context context, MessageRecord messageRecord) {
|
||||
try {
|
||||
long messageId = messageRecord.getId();
|
||||
boolean forceSms = messageRecord.isForcedSms();
|
||||
boolean keyExchange = messageRecord.isKeyExchange();
|
||||
long expiresIn = messageRecord.getExpiresIn();
|
||||
Recipient recipient = messageRecord.getRecipient();
|
||||
|
||||
if (messageRecord.isMms()) {
|
||||
sendMediaMessage(context, recipient, forceSms, messageId, expiresIn);
|
||||
} else {
|
||||
sendTextMessage(context, recipient, forceSms, keyExchange, messageId, expiresIn);
|
||||
}
|
||||
} catch (MmsException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendMediaMessage(Context context, Recipient recipient, boolean forceSms, long messageId, long expiresIn)
|
||||
throws MmsException
|
||||
{
|
||||
@@ -191,18 +164,18 @@ public class MessageSender {
|
||||
}
|
||||
|
||||
private static void sendTextPush(Context context, Recipient recipient, long messageId) {
|
||||
JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
|
||||
jobManager.add(new PushTextSendJob(context, messageId, recipient.getAddress()));
|
||||
// JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
|
||||
// jobManager.add(new PushTextSendJob(context, messageId, recipient.getAddress()));
|
||||
}
|
||||
|
||||
private static void sendMediaPush(Context context, Recipient recipient, long messageId) {
|
||||
JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
|
||||
jobManager.add(new PushMediaSendJob(context, messageId, recipient.getAddress()));
|
||||
// JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
|
||||
// jobManager.add(new PushMediaSendJob(context, messageId, recipient.getAddress()));
|
||||
}
|
||||
|
||||
private static void sendGroupPush(Context context, Recipient recipient, long messageId, Address filterAddress) {
|
||||
JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
|
||||
jobManager.add(new PushGroupSendJob(context, messageId, recipient.getAddress(), filterAddress));
|
||||
// JobManager jobManager = ApplicationContext.getInstance(context).getJobManager();
|
||||
// jobManager.add(new PushGroupSendJob(context, messageId, recipient.getAddress(), filterAddress));
|
||||
}
|
||||
|
||||
private static void sendSms(Context context, Recipient recipient, long messageId) {
|
||||
|
||||
Reference in New Issue
Block a user