add preference controlling whether radio-free short-circuiting is used

for SMS sends when sending and receiving number are the
same. Short-circuiting is faster and tests 99% of the code without
triggering Android's annoying OS-level too-many-sms-sends alerts, but
sometimes you need to test the radio too.
This commit is contained in:
Eric House 2015-02-17 20:16:44 -08:00
parent 1592ac3ede
commit 7e8c30f2ab
5 changed files with 694 additions and 667 deletions

File diff suppressed because it is too large Load diff

View file

@ -116,6 +116,7 @@
<string name="key_na_dicts">key_na_dicts</string>
<string name="key_enable_debug">key_enable_debug</string>
<string name="key_enable_dup_invite">key_enable_dup_invite</string>
<string name="key_enable_nfc_toself">key_enable_nfc_toself</string>
<string name="key_enable_sms_toself">key_enable_sms_toself</string>
<string name="key_nag_intervals">key_nag_intervals</string>
<string name="key_download_path">key_download_path</string>
@ -169,8 +170,10 @@
<string name="xlations_locale">Fake locale for translation</string>
<string name="enable_dupes_summary">Accept invitations more than once</string>
<string name="nag_intervals">Reminder intervals (minutes1,minutes2,...)</string>
<string name="enable_sms_toself_title">Enable NFC to self</string>
<string name="enable_sms_toself_summary">Fake invitation to aid debugging</string>
<string name="enable_nfc_toself_title">Enable NFC to self</string>
<string name="enable_nfc_toself_summary">Fake invitation to aid debugging</string>
<string name="enable_sms_toself_title">Short-circuit SMS to self</string>
<string name="enable_sms_toself_summary">Skip radio when phone numbers same</string>
<string name="force_radio_title">Pretend to have radio</string>
<string name="radio_name_real">Don\'t pretend</string>

View file

@ -331,9 +331,31 @@
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_enable_sms_toself"
android:title="@string/enable_sms_toself_title"
android:summary="@string/enable_sms_toself_summary"
<PreferenceScreen android:title="SMS Stuff"
android:summary="Prefs related to play-via-sms"
>
<CheckBoxPreference android:key="@string/key_enable_sms_toself"
android:title="@string/enable_sms_toself_title"
android:summary="@string/enable_sms_toself_summary"
android:defaultValue="false"
/>
<org.eehouse.android.xw4.XWListPreference
android:key="@string/key_force_radio"
android:title="@string/force_radio_title"
android:entries="@array/force_radio_names"
android:entryValues="@array/force_radio_names"
android:defaultValue="@string/radio_name_real"
/>
<CheckBoxPreference android:key="@string/key_show_sms"
android:title="Show SMS sends, receives"
android:defaultValue="false"
/>
</PreferenceScreen>
<CheckBoxPreference android:key="@string/key_enable_nfc_toself"
android:title="@string/enable_nfc_toself_title"
android:summary="@string/enable_nfc_toself_summary"
android:defaultValue="false"
/>
@ -354,14 +376,6 @@
android:defaultValue="false"
/>
<org.eehouse.android.xw4.XWListPreference
android:key="@string/key_force_radio"
android:title="@string/force_radio_title"
android:entries="@array/force_radio_names"
android:entryValues="@array/force_radio_names"
android:defaultValue="@string/radio_name_real"
/>
<!-- For broken devices like my Blaze 4G that report a download
directory that doesn't exist, allow users to set it. Mine:
/sdcard/external_sd/download
@ -370,10 +384,6 @@
android:key="@string/key_download_path"
android:title="@string/download_path_title"
/>
<CheckBoxPreference android:key="@string/key_show_sms"
android:title="Show SMS sends, receives"
android:defaultValue="false"
/>
<org.eehouse.android.xw4.XWEditTextPreference
android:key="@string/key_relay_host"
android:title="@string/relay_host"

View file

@ -646,13 +646,19 @@ public class SMSService extends XWService {
{
boolean success = false;
if ( XWPrefs.getSMSEnabled( this ) ) {
String myPhone = getPhoneInfo( this ).number;
if ( PhoneNumberUtils.compare( phone, myPhone ) ) {
for ( byte[] fragment : fragments ) {
handleFrom( this, fragment, phone );
// Try send-to-self
if ( XWPrefs.getSMSToSelfEnabled( this ) ) {
String myPhone = getPhoneInfo( this ).number;
if ( PhoneNumberUtils.compare( phone, myPhone ) ) {
for ( byte[] fragment : fragments ) {
handleFrom( this, fragment, phone );
}
success = true;
}
success = true;
} else {
}
if ( !success ) {
short nbsPort = (short)Integer.parseInt( getString( R.string.nbs_port ) );
try {
SmsManager mgr = SmsManager.getDefault();

View file

@ -59,6 +59,11 @@ public class XWPrefs {
}
public static boolean getNFCToSelfEnabled( Context context )
{
return getPrefsBoolean( context, R.string.key_enable_nfc_toself, false );
}
public static boolean getSMSToSelfEnabled( Context context )
{
return getPrefsBoolean( context, R.string.key_enable_sms_toself, false );
}