mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-22 07:57:30 +00:00
Pass on incoming messages until DB is imported.
This commit is contained in:
parent
5eb04328d3
commit
1ff4fd842c
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2011 Whisper Systems
|
* Copyright (C) 2011 Whisper Systems
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
@ -10,12 +10,19 @@
|
|||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.thoughtcrime.securesms.service;
|
package org.thoughtcrime.securesms.service;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||||
import org.thoughtcrime.securesms.protocol.WirePrefix;
|
import org.thoughtcrime.securesms.protocol.WirePrefix;
|
||||||
|
|
||||||
@ -23,51 +30,48 @@ import ws.com.google.android.mms.pdu.GenericPdu;
|
|||||||
import ws.com.google.android.mms.pdu.NotificationInd;
|
import ws.com.google.android.mms.pdu.NotificationInd;
|
||||||
import ws.com.google.android.mms.pdu.PduHeaders;
|
import ws.com.google.android.mms.pdu.PduHeaders;
|
||||||
import ws.com.google.android.mms.pdu.PduParser;
|
import ws.com.google.android.mms.pdu.PduParser;
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class MmsListener extends BroadcastReceiver {
|
public class MmsListener extends BroadcastReceiver {
|
||||||
|
|
||||||
private boolean isRelevent(Context context, Intent intent) {
|
private boolean isRelevent(Context context, Intent intent) {
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT)
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!ApplicationMigrationService.isDatabaseImported(context))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ApplicationPreferencesActivity.ALL_MMS_PERF, true))
|
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ApplicationPreferencesActivity.ALL_MMS_PERF, true))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
byte[] mmsData = intent.getByteArrayExtra("data");
|
byte[] mmsData = intent.getByteArrayExtra("data");
|
||||||
PduParser parser = new PduParser(mmsData);
|
PduParser parser = new PduParser(mmsData);
|
||||||
GenericPdu pdu = parser.parse();
|
GenericPdu pdu = parser.parse();
|
||||||
|
|
||||||
if (pdu.getMessageType() != PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND)
|
if (pdu.getMessageType() != PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
NotificationInd notificationPdu = (NotificationInd)pdu;
|
NotificationInd notificationPdu = (NotificationInd)pdu;
|
||||||
|
|
||||||
if (notificationPdu.getSubject() == null)
|
if (notificationPdu.getSubject() == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return WirePrefix.isEncryptedMmsSubject(notificationPdu.getSubject().getString());
|
return WirePrefix.isEncryptedMmsSubject(notificationPdu.getSubject().getString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
Log.w("MmsListener", "Got MMS broadcast...");
|
Log.w("MmsListener", "Got MMS broadcast...");
|
||||||
|
|
||||||
if (isRelevent(context, intent)) {
|
if (isRelevent(context, intent)) {
|
||||||
intent.setAction(SendReceiveService.RECEIVE_MMS_ACTION);
|
intent.setAction(SendReceiveService.RECEIVE_MMS_ACTION);
|
||||||
intent.putExtra("ResultCode", this.getResultCode());
|
intent.putExtra("ResultCode", this.getResultCode());
|
||||||
intent.setClass(context, SendReceiveService.class);
|
intent.setClass(context, SendReceiveService.class);
|
||||||
|
|
||||||
context.startService(intent);
|
context.startService(intent);
|
||||||
abortBroadcast();
|
abortBroadcast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,9 @@ public class SmsListener extends BroadcastReceiver {
|
|||||||
if (isExemption(message, messageBody))
|
if (isExemption(message, messageBody))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!ApplicationMigrationService.isDatabaseImported(context))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("pref_all_sms", true))
|
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("pref_all_sms", true))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user