From 75b976449ffcc4747341601e2288ee4e4101cfe1 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 23 Nov 2013 19:02:57 -0800 Subject: [PATCH 01/10] turn SMS back on, and modify to send/receive "data" SMS rather than text. This works between two t-mobile devices without filling the kitkat one's message box. TBD: does it work on CDMA? --- xwords4/android/XWords4/AndroidManifest.xml | 8 + .../org/eehouse/android/xw4/SMSReceiver.java | 33 +-- .../org/eehouse/android/xw4/SMSService.java | 200 ++++++++++++++++-- .../src/org/eehouse/android/xw4/Utils.java | 13 +- 4 files changed, 219 insertions(+), 35 deletions(-) diff --git a/xwords4/android/XWords4/AndroidManifest.xml b/xwords4/android/XWords4/AndroidManifest.xml index 429b022a3..963a7c7f8 100644 --- a/xwords4/android/XWords4/AndroidManifest.xml +++ b/xwords4/android/XWords4/AndroidManifest.xml @@ -206,6 +206,14 @@ + + + + + + + + diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSReceiver.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSReceiver.java index 32161091d..009ec6246 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSReceiver.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSReceiver.java @@ -33,28 +33,37 @@ public class SMSReceiver extends BroadcastReceiver { @Override public void onReceive( Context context, Intent intent ) { + String action = intent.getAction(); Bundle bundle = intent.getExtras(); + DbgUtils.logf( "onReceive: action=%s", action ); if ( null != bundle ) { + boolean isData = + action.equals("android.intent.action.DATA_SMS_RECEIVED"); boolean isMine = false; Object[] pdus = (Object[])bundle.get( "pdus" ); SmsMessage[] smses = new SmsMessage[pdus.length]; for ( int ii = 0; ii < pdus.length; ++ii ) { SmsMessage sms = SmsMessage.createFromPdu((byte[])pdus[ii]); - String body = sms.getMessageBody(); - String postDetectable = SMSService.fromPublicFmt( body ); - isMine = null != postDetectable; - if ( isMine ) { - String phone = sms.getOriginatingAddress(); - DbgUtils.logf( "SMSReceiver: \"%s\" from %s", - body, phone ); - SMSService.handleFrom( context, postDetectable, phone ); + String phone = sms.getOriginatingAddress(); + if ( isData ) { + byte[] body = sms.getUserData(); + SMSService.handleFrom( context, body, phone ); + } else { + String body = sms.getMessageBody(); + String postDetectable = SMSService.fromPublicFmt( body ); + isMine = null != postDetectable; + if ( isMine ) { + DbgUtils.logf( "SMSReceiver: \"%s\" from %s", + body, phone ); + SMSService.handleFrom( context, postDetectable, phone ); + } } - } - if ( isMine ) { - DbgUtils.logf( "SMSReceiver: CONSUMING message" ); - abortBroadcast(); + if ( isMine ) { + DbgUtils.logf( "SMSReceiver: CONSUMING message" ); + abortBroadcast(); + } } } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java index 773291d39..55be5587b 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java @@ -55,12 +55,14 @@ public class SMSService extends XWService { private static final String INSTALL_URL = "http://eehouse.org/_/a.py/a "; private static final int MAX_SMS_LEN = 140; // ??? differs by network + private static final boolean s_asData = true; private static final String MSG_SENT = "MSG_SENT"; private static final String MSG_DELIVERED = "MSG_DELIVERED"; private static final int SMS_PROTO_VERSION = 0; private static final int MAX_LEN_TEXT = 100; + private static final int MAX_LEN_BINARY = 100; private static final int HANDLE = 1; private static final int INVITE = 2; private static final int SEND = 3; @@ -69,6 +71,7 @@ public class SMSService extends XWService { private static final int CHECK_MSGDB = 6; private static final int ADDED_MISSING = 7; private static final int STOP_SELF = 8; + private static final int HANDLEDATA = 9; private static final String CMD_STR = "CMD"; private static final String BUFFER = "BUFFER"; @@ -118,6 +121,15 @@ public class SMSService extends XWService { context.startService( intent ); } + public static void handleFrom( Context context, byte[] buffer, + String phone ) + { + Intent intent = getIntentTo( context, HANDLEDATA ); + intent.putExtra( BUFFER, buffer ); + intent.putExtra( PHONE, phone ); + context.startService( intent ); + } + public static void inviteRemote( Context context, String phone, int gameID, String gameName, int lang, String dict, @@ -256,6 +268,7 @@ public class SMSService extends XWService { } break; case HANDLE: + case HANDLEDATA: ++m_nReceived; ConnStatusHandler. updateStatusIn( this, null, @@ -263,9 +276,14 @@ public class SMSService extends XWService { if ( s_showToasts ) { DbgUtils.showf( this, "got %dth msg", m_nReceived ); } - String buffer = intent.getStringExtra( BUFFER ); String phone = intent.getStringExtra( PHONE ); - receiveBuffer( buffer, phone ); + if ( HANDLE == cmd ) { + String buffer = intent.getStringExtra( BUFFER ); + receiveBuffer( buffer, phone ); + } else { + byte[] buffer = intent.getByteArrayExtra( BUFFER ); + receiveBuffer( buffer, phone ); + } break; case INVITE: case ADDED_MISSING: @@ -387,9 +405,16 @@ public class SMSService extends XWService { das.write( bytes, 0, bytes.length ); das.flush(); - String as64 = XwJNI.base64Encode( bas.toByteArray() ); - String[] msgs = breakAndEncode( as64 ); - return sendBuffers( msgs, phone ); + byte[] data = bas.toByteArray(); + boolean result; + if ( s_asData ) { + byte[][] msgs = breakAndEncode( data ); + result = sendBuffers( msgs, phone ); + } else { + String[] msgs = breakAndEncode( XwJNI.base64Encode( data ) ); + result = sendBuffers( msgs, phone ); + } + return result; } private String[] breakAndEncode( String msg ) @@ -417,6 +442,33 @@ public class SMSService extends XWService { return result; } + private byte[][] breakAndEncode( byte msg[] ) throws java.io.IOException + { + int count = (msg.length + (MAX_LEN_BINARY-1)) / MAX_LEN_BINARY; + byte[][] result = new byte[count][]; + int msgID = ++s_nSent % 0x000000FF; + + int start = 0; + int end = 0; + for ( int ii = 0; ii < count; ++ii ) { + int len = msg.length - end; + if ( len > MAX_LEN_BINARY ) { + len = MAX_LEN_BINARY; + } + end += len; + byte[] part = new byte[4 + len]; + part[0] = (byte)0; // proto + part[1] = (byte)msgID; + part[2] = (byte)ii; + part[3] = (byte)count; + System.arraycopy( msg, start, part, 4, len ); + + result[ii] = part; + start = end; + } + return result; + } + private void receive( SMS_CMD cmd, byte[] data, String phone ) { DataInputStream dis = @@ -472,6 +524,19 @@ public class SMSService extends XWService { } } + private void receiveBuffer( byte[] buffer, String senderPhone ) + { + byte proto = buffer[0]; + int id = buffer[1]; + int index = buffer[2]; + int count = buffer[3]; + byte[] rest = new byte[buffer.length - 4]; + System.arraycopy( buffer, 4, rest, 0, rest.length ); + tryAssemble( senderPhone, id, index, count, rest ); + + sendResult( MultiEvent.SMS_RECEIVE_OK ); + } + private void receiveBuffer( String as64, String senderPhone ) { String[] parts = as64.split( ":" ); @@ -487,6 +552,34 @@ public class SMSService extends XWService { } } + private void tryAssemble( String senderPhone, int id, int index, + int count, byte[] msg ) + { + if ( index == 0 && count == 1 ) { + disAssemble( senderPhone, msg ); + } else { + // required? Should always be in main thread. + synchronized( s_partialMsgs ) { + HashMap perPhone = + s_partialMsgs.get( senderPhone ); + if ( null == perPhone ) { + perPhone = new HashMap (); + s_partialMsgs.put( senderPhone, perPhone ); + } + MsgStore store = perPhone.get( id ); + if ( null == store ) { + store = new MsgStore( id, count, false ); + perPhone.put( id, store ); + } + + if ( store.add( index, msg ).isComplete() ) { + disAssemble( senderPhone, store.messageData() ); + perPhone.remove( id ); + } + } + } + } + private void tryAssemble( String senderPhone, int id, int index, int count, String msg ) { @@ -503,18 +596,41 @@ public class SMSService extends XWService { } MsgStore store = perPhone.get( id ); if ( null == store ) { - store = new MsgStore( id, count ); + store = new MsgStore( id, count, true ); perPhone.put( id, store ); } if ( store.add( index, msg ).isComplete() ) { - disAssemble( senderPhone, store.message() ); + disAssemble( senderPhone, store.messageText() ); perPhone.remove( id ); } } } } + private void disAssemble( String senderPhone, byte[] fullMsg ) + { + DataInputStream dis = + new DataInputStream( new ByteArrayInputStream(fullMsg) ); + try { + byte proto = dis.readByte(); + if ( SMS_PROTO_VERSION != proto ) { + DbgUtils.logf( "SMSService.disAssemble: bad proto %d; dropping", + proto ); + } else { + SMS_CMD cmd = SMS_CMD.values()[dis.readByte()]; + byte[] rest = new byte[dis.available()]; + dis.read( rest ); + receive( cmd, rest, senderPhone ); + } + } catch ( java.io.IOException ioe ) { + DbgUtils.loge( ioe ); + } catch ( ArrayIndexOutOfBoundsException oob ) { + // enum this older code doesn't know about; drop it + DbgUtils.logf( "disAssemble: dropping message with too-new enum" ); + } + } + private void disAssemble( String senderPhone, String fullMsg ) { byte[] data = XwJNI.base64Decode( fullMsg ); @@ -592,6 +708,33 @@ public class SMSService extends XWService { return success; } + private boolean sendBuffers( byte[][] fragments, String phone ) + { + boolean success = false; + try { + SmsManager mgr = SmsManager.getDefault(); + PendingIntent sent = makeStatusIntent( MSG_SENT ); + PendingIntent delivery = makeStatusIntent( MSG_DELIVERED ); + for ( byte[] fragment : fragments ) { + mgr.sendDataMessage( phone, null, (short)3344, fragment, + sent, delivery ); + } + if ( s_showToasts ) { + DbgUtils.showf( this, "sent %dth msg", s_nSent ); + } + success = true; + } catch ( IllegalArgumentException iae ) { + DbgUtils.logf( "sendBuffers(%s): %s", phone, iae.toString() ); + } catch ( Exception ee ) { + DbgUtils.loge( ee ); + } + + ConnStatusHandler.updateStatusOut( this, null, + CommsConnType.COMMS_CONN_SMS, + success ); + return success; + } + private static void fillInviteIntent( Intent intent, String phone, int gameID, String gameName, int lang, String dict, @@ -728,41 +871,68 @@ public class SMSService extends XWService { } private class MsgStore { - String[] m_msgs; + String[] m_msgsText; + byte[][] m_msgsData; int m_msgID; int m_haveCount; int m_fullLength; - public MsgStore( int id, int count ) + public MsgStore( int id, int count, boolean usingStrings ) { m_msgID = id; - m_msgs = new String[count]; + if ( usingStrings ) { + m_msgsText = new String[count]; + } else { + m_msgsData = new byte[count][]; + } m_fullLength = 0; } public MsgStore add( int index, String msg ) { - if ( null == m_msgs[index] ) { + if ( null == m_msgsText[index] ) { ++m_haveCount; m_fullLength += msg.length(); } - m_msgs[index] = msg; + m_msgsText[index] = msg; + return this; + } + + public MsgStore add( int index, byte[] msg ) + { + if ( null == m_msgsData[index] ) { + ++m_haveCount; + m_fullLength += msg.length; + } + m_msgsData[index] = msg; return this; } public boolean isComplete() { - boolean complete = m_msgs.length == m_haveCount; + int count = null != m_msgsText ? m_msgsText.length : m_msgsData.length; + boolean complete = count == m_haveCount; return complete; } - public String message() + public String messageText() { StringBuffer sb = new StringBuffer(m_fullLength); - for ( String msg : m_msgs ) { + for ( String msg : m_msgsText ) { sb.append( msg ); } return sb.toString(); } + + public byte[] messageData() + { + byte[] result = new byte[m_fullLength]; + int indx = 0; + for ( byte[] msg : m_msgsData ) { + System.arraycopy( msg, 0, result, indx, msg.length ); + indx += msg.length; + } + return result; + } } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java index 1832493f0..3816f18f1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java @@ -100,14 +100,11 @@ public class Utils { { if ( null == s_deviceSupportSMS ) { boolean doesSMS = false; - // TEMPORARY: disable SMS on KITKAT - if ( 19 > Integer.valueOf( android.os.Build.VERSION.SDK ) ) { - TelephonyManager tm = (TelephonyManager) - context.getSystemService(Context.TELEPHONY_SERVICE); - if ( null != tm ) { - int type = tm.getPhoneType(); - doesSMS = TelephonyManager.PHONE_TYPE_NONE != type; - } + TelephonyManager tm = (TelephonyManager) + context.getSystemService(Context.TELEPHONY_SERVICE); + if ( null != tm ) { + int type = tm.getPhoneType(); + doesSMS = TelephonyManager.PHONE_TYPE_NONE != type; } s_deviceSupportSMS = new Boolean( doesSMS ); } From eab12200af8e0bc1fe687157637c9abc3c4b4ad7 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 26 Nov 2013 07:11:22 -0800 Subject: [PATCH 02/10] add debug preference to determine whether to use sendDataMessage() --- xwords4/android/XWords4/res/values/common_rsrc.xml | 3 +++ xwords4/android/XWords4/res/xml/xwprefs.xml | 5 +++++ .../XWords4/src/org/eehouse/android/xw4/SMSService.java | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml index 72aa19275..d824161e9 100644 --- a/xwords4/android/XWords4/res/values/common_rsrc.xml +++ b/xwords4/android/XWords4/res/values/common_rsrc.xml @@ -39,6 +39,7 @@ key_dict_host3 key_logging_on key_show_sms + key_send_data_sms key_init_hintsallowed key_init_nethintsallowed key_init_autojuggle @@ -137,6 +138,8 @@ Enable debug features Menuitems etc. (release builds only) + Send SMS as data + (fails on CDMA phones) Source version id Relay game port diff --git a/xwords4/android/XWords4/res/xml/xwprefs.xml b/xwords4/android/XWords4/res/xml/xwprefs.xml index e6ad3a3e9..2b8a061d5 100644 --- a/xwords4/android/XWords4/res/xml/xwprefs.xml +++ b/xwords4/android/XWords4/res/xml/xwprefs.xml @@ -328,6 +328,11 @@ android:title="Show SMS sends, receives" android:defaultValue="false" /> + Date: Wed, 27 Nov 2013 07:06:14 -0800 Subject: [PATCH 03/10] fix crash: make thumbnail BEFORE closing game --- .../XWords4/src/org/eehouse/android/xw4/GameUtils.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index 536c8bc42..ac9d08e6c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -746,14 +746,15 @@ public class GameUtils { // update gi to reflect changes due to messages XwJNI.game_getGi( gamePtr, gi ); - saveGame( context, gamePtr, gi, lock, false ); - summarizeAndClose( context, lock, gamePtr, gi, feedImpl ); if ( draw && XWPrefs.getThumbEnabled( context ) ) { Bitmap bitmap = takeSnapshot( context, gamePtr, gi ); DBUtils.saveThumbnail( context, lock, bitmap ); } + saveGame( context, gamePtr, gi, lock, false ); + summarizeAndClose( context, lock, gamePtr, gi, feedImpl ); + int flags = setFromFeedImpl( feedImpl ); if ( GameSummary.MSG_FLAGS_NONE != flags ) { draw = true; From 605b45f6a069342aa6acc8e93f33a4c00ed40cb7 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 27 Nov 2013 07:06:27 -0800 Subject: [PATCH 04/10] remove logging --- xwords4/android/XWords4/jni/utilwrapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/jni/utilwrapper.c b/xwords4/android/XWords4/jni/utilwrapper.c index 1da05d0c9..d406ab7ba 100644 --- a/xwords4/android/XWords4/jni/utilwrapper.c +++ b/xwords4/android/XWords4/jni/utilwrapper.c @@ -536,7 +536,7 @@ static void and_util_addrChange( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr, const CommsAddrRec* newAddr ) { - LOG_FUNC(); + // LOG_FUNC(); } static void From 72341a085a0b654377d3d4b62514f6e3f71f06cf Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 27 Nov 2013 07:08:58 -0800 Subject: [PATCH 05/10] start out sending as data, but on first NPE, the symptom of CDMAness, set the pref to send as text and do that from then on (unless the pref is reset manually) --- xwords4/android/XWords4/res/xml/xwprefs.xml | 2 +- .../org/eehouse/android/xw4/SMSService.java | 42 ++++++++++++++----- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/xwords4/android/XWords4/res/xml/xwprefs.xml b/xwords4/android/XWords4/res/xml/xwprefs.xml index 2b8a061d5..a3a8b9cea 100644 --- a/xwords4/android/XWords4/res/xml/xwprefs.xml +++ b/xwords4/android/XWords4/res/xml/xwprefs.xml @@ -331,7 +331,7 @@ Date: Mon, 2 Dec 2013 07:01:04 -0800 Subject: [PATCH 06/10] register for sms prefs changes so they can take effect immediately --- .../org/eehouse/android/xw4/SMSService.java | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java index adb5e7891..b6a654bb2 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java @@ -29,6 +29,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; @@ -86,6 +87,7 @@ public class SMSService extends XWService { private BroadcastReceiver m_sentReceiver; private BroadcastReceiver m_receiveReceiver; + private OnSharedPreferenceChangeListener m_prefsListener; private int m_nReceived = 0; private static int s_nSent = 0; @@ -212,10 +214,8 @@ public class SMSService extends XWService { private static Intent getIntentTo( Context context, int cmd ) { if ( null == s_showToasts ) { - SharedPreferences sp - = PreferenceManager.getDefaultSharedPreferences( context ); - String key = context.getString( R.string.key_show_sms ); - s_showToasts = sp.getBoolean( key, false ); + s_showToasts = + XWPrefs.getPrefsBoolean( context, R.string.key_show_sms, false ); } Intent intent = new Intent( context, SMSService.class ); @@ -244,6 +244,13 @@ public class SMSService extends XWService { unregisterReceiver( m_receiveReceiver ); m_receiveReceiver = null; } + if ( null != m_prefsListener ) { + SharedPreferences sp + = PreferenceManager.getDefaultSharedPreferences( this ); + sp.unregisterOnSharedPreferenceChangeListener( m_prefsListener ); + m_prefsListener = null; + } + super.onDestroy(); } @@ -843,14 +850,27 @@ public class SMSService extends XWService { @Override public void onReceive(Context arg0, Intent arg1) { - if ( Activity.RESULT_OK == getResultCode() ) { - DbgUtils.logf( "SUCCESS!!!" ); - } else { - DbgUtils.logf( "FAILURE!!!" ); - } + DbgUtils.logf( "SMS delivery result: %s", + Activity.RESULT_OK == getResultCode() + ? "SUCCESS" : "FAILURE" ); } }; registerReceiver( m_receiveReceiver, new IntentFilter(MSG_DELIVERED) ); + + m_prefsListener = new OnSharedPreferenceChangeListener() { + public void onSharedPreferenceChanged( SharedPreferences sp, + String key ) { + if ( key.equals( getString( R.string.key_show_sms ) ) ) { + s_showToasts = null; + } else if ( key.equals( getString( R.string + .key_send_data_sms ))) { + s_asData = null; + } + } + }; + SharedPreferences sp + = PreferenceManager.getDefaultSharedPreferences( this ); + sp.registerOnSharedPreferenceChangeListener( m_prefsListener ); } private boolean sendAsText( byte[] data, String phone ) From 6402ae56d22298d209844a6b856351673889b6de Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 2 Dec 2013 07:08:43 -0800 Subject: [PATCH 07/10] remove now-redundant response to prefs change --- .../XWords4/src/org/eehouse/android/xw4/PrefsActivity.java | 5 ----- .../XWords4/src/org/eehouse/android/xw4/SMSService.java | 5 ----- 2 files changed, 10 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java index b2a830a11..d30015767 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java @@ -42,13 +42,11 @@ public class PrefsActivity extends PreferenceActivity public static final int EXPLAIN_TITLE = 4; private String m_keyLogging; - private String m_smsToasting; private String m_smsEnable; private String m_downloadPath; private String m_thumbSize; private String m_hideTitle; - @Override protected Dialog onCreateDialog( int id ) { @@ -133,7 +131,6 @@ public class PrefsActivity extends PreferenceActivity setContentView( R.layout.prefs_w_buttons ); m_keyLogging = getString( R.string.key_logging_on ); - m_smsToasting = getString( R.string.key_show_sms ); m_smsEnable = getString( R.string.key_enable_sms ); m_downloadPath = getString( R.string.key_download_path ); m_thumbSize = getString( R.string.key_thumbsize ); @@ -174,8 +171,6 @@ public class PrefsActivity extends PreferenceActivity { if ( key.equals( m_keyLogging ) ) { DbgUtils.logEnable( sp.getBoolean( key, false ) ); - } else if ( key.equals( m_smsToasting ) ) { - SMSService.smsToastEnable( sp.getBoolean( key, false ) ); } else if ( key.equals( m_smsEnable ) ) { if ( sp.getBoolean( key, true ) ) { SMSService.checkForInvites( this ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java index b6a654bb2..55cc147dc 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java @@ -95,11 +95,6 @@ public class SMSService extends XWService { = new HashMap>(); private static HashSet s_sentDied = new HashSet(); - public static void smsToastEnable( boolean newVal ) - { - s_showToasts = newVal; - } - public static void checkForInvites( Context context ) { if ( XWApp.SMSSUPPORTED && Utils.deviceSupportsSMS( context ) ) { From ad60fcc61019a8f134ee6830c36504d20e8a5ac3 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 6 Dec 2013 07:37:56 -0800 Subject: [PATCH 08/10] uninstall based on where called from --- xwords4/android/scripts/adb_uninstall.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/xwords4/android/scripts/adb_uninstall.sh b/xwords4/android/scripts/adb_uninstall.sh index a20cbeb92..9f7e63434 100755 --- a/xwords4/android/scripts/adb_uninstall.sh +++ b/xwords4/android/scripts/adb_uninstall.sh @@ -10,6 +10,23 @@ usage() { exit 0 } +if [ ! -e build.xml ]; then + usage "No build.xml; please run me from the top android directory" +fi + +DIRNAME=$(basename $(pwd)) +case $DIRNAME in + XWords4-bt) + PKG=xw4bt + ;; + XWords4) + PKG=xw4 + ;; + *) + usage "running in unexpected directory $DIRNAME" + ;; +esac + while [ $# -ge 1 ]; do case $1 in -n) @@ -24,4 +41,4 @@ done SERIAL="$(adb devices | grep 'device$' | sed -n "$((1+INDEX)) p" | awk '{print $1}')" -adb -s $SERIAL uninstall org.eehouse.android.xw4 +adb -s $SERIAL uninstall org.eehouse.android.${PKG} From fa5649501ebe81162c0daa6a863b25cb5cd7c8d1 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 6 Dec 2013 07:39:16 -0800 Subject: [PATCH 09/10] update send success status --- .../src/org/eehouse/android/xw4/BTService.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java index 5bc5988de..efa932caa 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTService.java @@ -43,11 +43,12 @@ import java.util.Set; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; -import junit.framework.Assert; - import org.eehouse.android.xw4.MultiService.MultiEvent; +import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType; import org.eehouse.android.xw4.jni.CommsAddrRec; +import junit.framework.Assert; + public class BTService extends XWService { private static final long RESEND_TIMEOUT = 5; // seconds @@ -357,6 +358,9 @@ public class BTService extends XWService { DbgUtils.logf( "unexpected msg %d", msg ); break; } + ConnStatusHandler. + updateStatusIn( BTService.this, null, + CommsConnType.COMMS_CONN_BT, true ); } } catch ( java.io.IOException ioe ) { DbgUtils.loge( ioe ); @@ -618,9 +622,15 @@ public class BTService extends XWService { sendInvite( elem ); break; case MESG_SEND: - if ( !doAnyResends( elem.m_addr ) || ! sendMsg( elem ) ) { + boolean success = doAnyResends( elem.m_addr ) + && sendMsg( elem ); + if ( !success ) { addToResends( elem ); } + ConnStatusHandler + .updateStatusOut( BTService.this, null, + CommsConnType.COMMS_CONN_BT, + success ); break; default: Assert.fail(); From c82c59d985d9c566447a50ad5f0d7fd004c228a6 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 26 Apr 2014 20:04:55 -0700 Subject: [PATCH 10/10] experimental: enable SMS on KitKat if debug setting to use Data SMS is on --- .../src/org/eehouse/android/xw4/Utils.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java index 858192f0d..2860986f4 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java @@ -100,11 +100,16 @@ public class Utils { { if ( null == s_deviceSupportSMS ) { boolean doesSMS = false; - TelephonyManager tm = (TelephonyManager) - context.getSystemService(Context.TELEPHONY_SERVICE); - if ( null != tm ) { - int type = tm.getPhoneType(); - doesSMS = TelephonyManager.PHONE_TYPE_NONE != type; + // TEMPORARY: disable SMS on KITKAT UNLESS use-text turned on + if ( 19 > Integer.valueOf( android.os.Build.VERSION.SDK ) + || XWPrefs.getPrefsBoolean( context, R.string.key_send_data_sms, + false ) ) { + TelephonyManager tm = (TelephonyManager) + context.getSystemService(Context.TELEPHONY_SERVICE); + if ( null != tm ) { + int type = tm.getPhoneType(); + doesSMS = TelephonyManager.PHONE_TYPE_NONE != type; + } } s_deviceSupportSMS = new Boolean( doesSMS ); }