mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 12:08:26 +00:00
Proper SMS support for KitKat.
This commit is contained in:
parent
f9c7687ce2
commit
e81756f443
@ -5,7 +5,7 @@
|
||||
android:versionCode="58"
|
||||
android:versionName="1.0.2">
|
||||
|
||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>
|
||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19"/>
|
||||
|
||||
<permission android:name="org.thoughtcrime.securesms.ACCESS_SECRETS"
|
||||
android:label="Access to TextSecure Secrets"
|
||||
@ -60,6 +60,8 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="sms" />
|
||||
<data android:scheme="smsto" />
|
||||
<data android:scheme="mms" />
|
||||
<data android:scheme="mmsto" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
@ -192,6 +194,9 @@
|
||||
<intent-filter android:priority="1001">
|
||||
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.provider.Telephony.SMS_DELIVER"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="org.thoughtcrime.securesms.services.MESSAGE_SENT"/>
|
||||
</intent-filter>
|
||||
@ -205,6 +210,10 @@
|
||||
<action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED"/>
|
||||
<data android:mimeType="application/vnd.wap.mms-message" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER"/>
|
||||
<data android:mimeType="application/vnd.wap.mms-message" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".service.SystemStateListener"
|
||||
|
@ -28,12 +28,12 @@ dependencies {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 17
|
||||
buildToolsVersion '17.0.0'
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion '19.0.0'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 17
|
||||
targetSdkVersion 19
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -48,6 +48,7 @@ import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@ -103,6 +104,10 @@ public class MessageNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Util.isDefaultSmsProvider(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateNotification(context, masterSecret, false);
|
||||
}
|
||||
|
||||
@ -113,6 +118,10 @@ public class MessageNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Util.isDefaultSmsProvider(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (visibleThread == threadId) {
|
||||
DatabaseFactory.getThreadDatabase(context).setRead(threadId);
|
||||
sendInThreadNotification(context);
|
||||
|
@ -25,6 +25,7 @@ import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||
import org.thoughtcrime.securesms.protocol.WirePrefix;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import ws.com.google.android.mms.pdu.GenericPdu;
|
||||
import ws.com.google.android.mms.pdu.NotificationInd;
|
||||
@ -33,6 +34,8 @@ import ws.com.google.android.mms.pdu.PduParser;
|
||||
|
||||
public class MmsListener extends BroadcastReceiver {
|
||||
|
||||
private static final String WAP_PUSH_RECEIVE_ACTION = "android.provider.Telephony.WAP_PUSH_RECEIVE";
|
||||
|
||||
private boolean isRelevent(Context context, Intent intent) {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT)
|
||||
return false;
|
||||
@ -40,6 +43,10 @@ public class MmsListener extends BroadcastReceiver {
|
||||
if (!ApplicationMigrationService.isDatabaseImported(context))
|
||||
return false;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
|
||||
intent.getAction().equals(WAP_PUSH_RECEIVE_ACTION) && Util.isDefaultSmsProvider(context))
|
||||
return false;
|
||||
|
||||
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(ApplicationPreferencesActivity.ALL_MMS_PERF, true))
|
||||
return true;
|
||||
|
||||
|
@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.telephony.SmsMessage;
|
||||
import android.util.Log;
|
||||
@ -28,12 +29,14 @@ import android.util.Log;
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||
import org.thoughtcrime.securesms.protocol.WirePrefix;
|
||||
import org.thoughtcrime.securesms.sms.IncomingTextMessage;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SmsListener extends BroadcastReceiver {
|
||||
|
||||
private static final String SMS_RECEIVED_ACTION = "android.provider.Telephony.SMS_RECEIVED";
|
||||
private static final String SMS_DELIVERED_ACTION = "android.provider.Telephony.SMS_DELIVER";
|
||||
|
||||
private boolean isExemption(SmsMessage message, String messageBody) {
|
||||
|
||||
@ -99,6 +102,10 @@ public class SmsListener extends BroadcastReceiver {
|
||||
if (!ApplicationMigrationService.isDatabaseImported(context))
|
||||
return false;
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
|
||||
intent.getAction().equals(SMS_RECEIVED_ACTION) && Util.isDefaultSmsProvider(context))
|
||||
return false;
|
||||
|
||||
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("pref_all_sms", true))
|
||||
return true;
|
||||
|
||||
@ -140,7 +147,9 @@ public class SmsListener extends BroadcastReceiver {
|
||||
context.sendBroadcast(challengeIntent);
|
||||
|
||||
abortBroadcast();
|
||||
} else if (intent.getAction().equals(SMS_RECEIVED_ACTION) && isRelevant(context, intent)) {
|
||||
} else if ((intent.getAction().equals(SMS_RECEIVED_ACTION) ||
|
||||
intent.getAction().equals(SMS_DELIVERED_ACTION)) &&
|
||||
isRelevant(context, intent)) {
|
||||
Intent receivedIntent = new Intent(context, SendReceiveService.class);
|
||||
receivedIntent.setAction(SendReceiveService.RECEIVE_SMS_ACTION);
|
||||
receivedIntent.putExtra("ResultCode", this.getResultCode());
|
||||
|
@ -24,6 +24,8 @@ import android.text.SpannableString;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.Log;
|
||||
import android.widget.EditText;
|
||||
import android.os.Build;
|
||||
import android.provider.Telephony;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -184,6 +186,11 @@ public class Util {
|
||||
return new String(bout.toByteArray());
|
||||
}
|
||||
|
||||
public static boolean isDefaultSmsProvider(Context context){
|
||||
return (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) ||
|
||||
(Telephony.Sms.getDefaultSmsPackage(context) == context.getPackageName());
|
||||
}
|
||||
|
||||
// public static Bitmap loadScaledBitmap(InputStream src, int targetWidth, int targetHeight) {
|
||||
// return BitmapFactory.decodeStream(src);
|
||||
//// BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
|
Loading…
x
Reference in New Issue
Block a user