mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
go back to android-7 SDK version to support 2.1, and to make that work
remove use of java base64 encoding in favor of the C version I'd already written (and that was probably compiled into the library anyway unless the strip step catched unused code.)
This commit is contained in:
parent
0fd9e6c30f
commit
1e22a33d55
4 changed files with 57 additions and 15 deletions
|
@ -37,7 +37,7 @@
|
|||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
|
||||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />
|
||||
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="7" />
|
||||
|
||||
<application android:icon="@drawable/icon48x48"
|
||||
android:label="@string/app_name"
|
||||
|
|
|
@ -1547,4 +1547,45 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getStartsWith
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifdef XWFEATURE_SMS
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_base64Encode
|
||||
( JNIEnv* env, jclass C, jbyteArray jbytes )
|
||||
{
|
||||
int inlen = (*env)->GetArrayLength( env, jbytes );
|
||||
jbyte* elems = (*env)->GetByteArrayElements( env, jbytes, NULL );
|
||||
XP_ASSERT( !!elems );
|
||||
|
||||
XP_UCHAR out[4+(inlen*4/3)];
|
||||
XP_U16 outlen = VSIZE( out );
|
||||
binToSms( out, &outlen, (const XP_U8*)elems, inlen );
|
||||
|
||||
(*env)->ReleaseByteArrayElements( env, jbytes, elems, 0 );
|
||||
|
||||
jstring result = (*env)->NewStringUTF( env, out );
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_base64Decode
|
||||
( JNIEnv* env, jclass C, jstring jstr )
|
||||
{
|
||||
jbyteArray result = NULL;
|
||||
const char* instr = (*env)->GetStringUTFChars( env, jstr, NULL );
|
||||
XP_U16 inlen = (*env)->GetStringUTFLength( env, jstr );
|
||||
XP_U8 out[inlen];
|
||||
XP_U16 outlen = VSIZE(out);
|
||||
if ( smsToBin( out, &outlen, instr, inlen ) ) {
|
||||
result = (*env)->NewByteArray( env, outlen );
|
||||
jbyte* jelems = (*env)->GetByteArrayElements( env, result, NULL );
|
||||
XP_MEMCPY( jelems, out, outlen );
|
||||
(*env)->ReleaseByteArrayElements( env, result, jelems, 0 );
|
||||
} else {
|
||||
XP_ASSERT(0);
|
||||
}
|
||||
(*env)->ReleaseStringUTFChars( env, jstr, instr );
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* XWFEATURE_BOARDWORDS */
|
||||
|
|
|
@ -28,7 +28,6 @@ import android.os.Bundle;
|
|||
import android.os.IBinder;
|
||||
import android.telephony.SmsManager;
|
||||
import android.telephony.SmsMessage;
|
||||
import android.util.Base64;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
|
@ -40,6 +39,7 @@ import java.lang.System;
|
|||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
||||
import org.eehouse.android.xw4.jni.XwJNI;
|
||||
|
||||
public class SMSService extends Service {
|
||||
|
||||
|
@ -233,7 +233,7 @@ public class SMSService extends Service {
|
|||
das.write( bytes, 0, bytes.length );
|
||||
das.flush();
|
||||
|
||||
String as64 = Base64.encodeToString( bas.toByteArray(), Base64.NO_WRAP );
|
||||
String as64 = XwJNI.base64Encode( bas.toByteArray() );
|
||||
String[] msgs = breakAndEncode( as64 );
|
||||
return sendBuffers( msgs, phone );
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ public class SMSService extends Service {
|
|||
int count, String msg )
|
||||
{
|
||||
if ( index == 0 && count == 1 ) {
|
||||
disAssemble( senderPhone, msg.getBytes() );
|
||||
disAssemble( senderPhone, msg );
|
||||
} else {
|
||||
synchronized( s_partialMsgs ) {
|
||||
HashMap <Integer, MsgStore> perPhone =
|
||||
|
@ -343,7 +343,7 @@ public class SMSService extends Service {
|
|||
|
||||
if ( store.isComplete() ) {
|
||||
s_partialMsgs.remove( id );
|
||||
byte[] fullMsg = store.message();
|
||||
String fullMsg = store.message();
|
||||
perPhone.remove( id );
|
||||
disAssemble( senderPhone, fullMsg );
|
||||
}
|
||||
|
@ -351,10 +351,10 @@ public class SMSService extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
private void disAssemble( String senderPhone, byte[] fullMsg )
|
||||
private void disAssemble( String senderPhone, String fullMsg )
|
||||
{
|
||||
DbgUtils.logf( "disAssemble()" );
|
||||
byte[] data = Base64.decode( fullMsg, Base64.NO_WRAP );
|
||||
byte[] data = XwJNI.base64Decode( fullMsg );
|
||||
DataInputStream dis =
|
||||
new DataInputStream( new ByteArrayInputStream(data) );
|
||||
try {
|
||||
|
@ -487,16 +487,13 @@ public class SMSService extends Service {
|
|||
return complete;
|
||||
}
|
||||
|
||||
public byte[] message()
|
||||
public String message()
|
||||
{
|
||||
byte[] result = new byte[m_fullLength];
|
||||
int offset = 0;
|
||||
for ( int ii = 0; ii < m_msgs.length; ++ii ) {
|
||||
byte[] src = m_msgs[ii].getBytes();
|
||||
System.arraycopy( src, 0, result, offset, src.length );
|
||||
offset += src.length;
|
||||
StringBuffer sb = new StringBuffer(m_fullLength);
|
||||
for ( String msg : m_msgs ) {
|
||||
sb.append( msg );
|
||||
}
|
||||
return result;
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -255,4 +255,8 @@ public class XwJNI {
|
|||
public static native int[] dict_iter_getIndices( int closure );
|
||||
public static native int dict_iter_getStartsWith( int closure,
|
||||
String prefix );
|
||||
|
||||
// base64 stuff since 2.1 doesn't support it in java
|
||||
public static native String base64Encode( byte[] in );
|
||||
public static native byte[] base64Decode( String in );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue