mirror of
				https://github.com/oxen-io/session-android.git
				synced 2025-10-30 23:09:20 +00:00 
			
		
		
		
	Update behavior for incoming SMS path.
1) On KitKat, unencrypted SMS messages are never stored in TextSecure unless it is set as the system-wide default. 2) On KitKat, if TextSecure is set as the system-wide default, provide an option to change the default to a different app. 3) Don't store the TextSecure challenge on KitKat+ devices.
This commit is contained in:
		| @@ -27,6 +27,10 @@ | ||||
|     <string name="ApplicationPreferencesActivity_you_are_not_registered_with_the_push_service">You are not registered with the push service...</string> | ||||
|     <string name="ApplicationPreferencesActivity_updating_directory">Updating directory</string> | ||||
|     <string name="ApplicationPreferencesActivity_updating_push_directory">Updating push directory...</string> | ||||
|     <string name="ApplicationPreferencesActivity_sms_enabled">SMS Enabled</string> | ||||
|     <string name="ApplicationPreferencesActivity_touch_to_change_your_default_sms_app">Touch to change your default SMS app</string> | ||||
|     <string name="ApplicationPreferencesActivity_sms_disabled">SMS Disabled</string> | ||||
|     <string name="ApplicationPreferencesActivity_touch_to_make_textsecure_your_default_sms_app">Touch to make TextSecure your default SMS app</string> | ||||
|  | ||||
|     <!-- AttachmentTypeSelectorAdapter --> | ||||
|  | ||||
|   | ||||
| @@ -38,6 +38,7 @@ import android.preference.PreferenceManager; | ||||
| import android.preference.PreferenceScreen; | ||||
| import android.preference.RingtonePreference; | ||||
| import android.provider.ContactsContract; | ||||
| import android.provider.Settings; | ||||
| import android.provider.Telephony; | ||||
| import android.text.TextUtils; | ||||
| import android.util.Log; | ||||
| @@ -101,7 +102,6 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr | ||||
|     addPreferencesFromResource(R.xml.preferences); | ||||
|  | ||||
|     initializeIdentitySelection(); | ||||
|     initializePlatformSpecificOptions(); | ||||
|     initializeSmsFallbackOption(); | ||||
|     initializePushMessagingToggle(); | ||||
|  | ||||
| @@ -142,6 +142,8 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr | ||||
|     super.onResume(); | ||||
|     dynamicTheme.onResume(this); | ||||
|     dynamicLanguage.onResume(this); | ||||
|  | ||||
|     initializePlatformSpecificOptions(); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
| @@ -187,21 +189,26 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredSherlockPr | ||||
|   private void initializePlatformSpecificOptions() { | ||||
|     PreferenceGroup    generalCategory    = (PreferenceGroup) findPreference("general_category"); | ||||
|     Preference         defaultPreference  = findPreference(KITKAT_DEFAULT_PREF); | ||||
|     Preference         allSmsPreference   = findPreference(TextSecurePreferences.ALL_SMS_PREF); | ||||
|     Preference         allMmsPreference   = findPreference(TextSecurePreferences.ALL_MMS_PREF); | ||||
|  | ||||
|     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | ||||
|       generalCategory.removePreference(findPreference(TextSecurePreferences.ALL_SMS_PREF)); | ||||
|       generalCategory.removePreference(findPreference(TextSecurePreferences.ALL_MMS_PREF)); | ||||
|       if (allSmsPreference != null) generalCategory.removePreference(allSmsPreference); | ||||
|       if (allMmsPreference != null) generalCategory.removePreference(allMmsPreference); | ||||
|  | ||||
|       if (Util.isDefaultSmsProvider(this)) { | ||||
|         generalCategory.removePreference(defaultPreference); | ||||
|         defaultPreference.setIntent(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); | ||||
|         defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_enabled)); | ||||
|         defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_change_your_default_sms_app)); | ||||
|       } else { | ||||
|         Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT); | ||||
|         intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getPackageName()); | ||||
|  | ||||
|         defaultPreference.setIntent(intent); | ||||
|         defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_disabled)); | ||||
|         defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_make_textsecure_your_default_sms_app)); | ||||
|       } | ||||
|     } else { | ||||
|       generalCategory.removePreference(defaultPreference); | ||||
|       if (defaultPreference != null) generalCategory.removePreference(defaultPreference); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -50,8 +50,7 @@ public class MmsListener extends BroadcastReceiver { | ||||
|       return false; | ||||
|     } | ||||
|  | ||||
|     if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && | ||||
|          TextSecurePreferences.isSmsFallbackEnabled(context)) || | ||||
|     if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT && | ||||
|         TextSecurePreferences.isInterceptAllMmsEnabled(context)) | ||||
|     { | ||||
|       return true; | ||||
| @@ -76,7 +75,10 @@ public class MmsListener extends BroadcastReceiver { | ||||
|     public void onReceive(Context context, Intent intent) { | ||||
|     Log.w("MmsListener", "Got MMS broadcast..." + intent.getAction()); | ||||
|  | ||||
|     if (isRelevant(context, intent)) { | ||||
|     if (Telephony.Sms.Intents.WAP_PUSH_DELIVER_ACTION.equals(intent.getAction()) || | ||||
|         (Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction()) && | ||||
|          isRelevant(context, intent))) | ||||
|     { | ||||
|       Log.w("MmsListener", "Relevant!"); | ||||
|       intent.setAction(SendReceiveService.RECEIVE_MMS_ACTION); | ||||
|       intent.putExtra("ResultCode", this.getResultCode()); | ||||
|   | ||||
| @@ -19,25 +19,23 @@ package org.thoughtcrime.securesms.service; | ||||
| import android.content.BroadcastReceiver; | ||||
| 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.os.Bundle; | ||||
| import android.provider.Telephony; | ||||
| import android.telephony.SmsMessage; | ||||
| 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 org.thoughtcrime.securesms.util.TextSecurePreferences; | ||||
| 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 static final String SMS_RECEIVED_ACTION  = Telephony.Sms.Intents.SMS_RECEIVED_ACTION; | ||||
|   private static final String SMS_DELIVERED_ACTION = Telephony.Sms.Intents.SMS_DELIVER_ACTION; | ||||
|  | ||||
|   private boolean isExemption(SmsMessage message, String messageBody) { | ||||
|  | ||||
| @@ -103,6 +101,9 @@ public class SmsListener extends BroadcastReceiver { | ||||
|     if (!ApplicationMigrationService.isDatabaseImported(context)) | ||||
|       return false; | ||||
|  | ||||
|     if (isChallenge(context, intent)) | ||||
|       return false; | ||||
|  | ||||
|     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && | ||||
|         SMS_RECEIVED_ACTION.equals(intent.getAction()) && | ||||
|         Util.isDefaultSmsProvider(context)) | ||||
| @@ -110,8 +111,7 @@ public class SmsListener extends BroadcastReceiver { | ||||
|       return false; | ||||
|     } | ||||
|  | ||||
|     if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && | ||||
|          TextSecurePreferences.isSmsFallbackEnabled(context)) || | ||||
|     if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT && | ||||
|         TextSecurePreferences.isInterceptAllSmsEnabled(context)) | ||||
|     { | ||||
|       return true; | ||||
| @@ -154,9 +154,8 @@ public class SmsListener extends BroadcastReceiver { | ||||
|       context.sendBroadcast(challengeIntent); | ||||
|  | ||||
|       abortBroadcast(); | ||||
|     } else if ((intent.getAction().equals(SMS_RECEIVED_ACTION) ||  | ||||
|                 intent.getAction().equals(SMS_DELIVERED_ACTION)) && | ||||
|                 isRelevant(context, intent)) | ||||
|     } else if ((intent.getAction().equals(SMS_DELIVERED_ACTION)) || | ||||
|                (intent.getAction().equals(SMS_RECEIVED_ACTION)) && isRelevant(context, intent)) | ||||
|     { | ||||
|       Intent receivedIntent = new Intent(context, SendReceiveService.class); | ||||
|       receivedIntent.setAction(SendReceiveService.RECEIVE_SMS_ACTION); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Moxie Marlinspike
					Moxie Marlinspike