implement util_phoneNumbersSame in java and call telephony's number

compare method.  Skip the java call when the numbers are
strcmp-identical.
This commit is contained in:
Eric House 2012-05-18 07:41:46 -07:00
parent 867e9ffc2f
commit 9ba663ab98
3 changed files with 21 additions and 3 deletions

View file

@ -462,9 +462,14 @@ and_util_phoneNumbersSame( XW_UtilCtxt* uc, const XP_UCHAR* p1,
{
XP_Bool same = 0 == strcmp( p1, p2 );
if ( !same ) {
/* If they're same, fine, but if not probably need to call into
platform code for a closer look */
XP_LOGF( "%s(%s,%s)=>%d", __func__, p1, p2, same );
UTIL_CBK_HEADER( "phoneNumbersSame",
"(Ljava/lang/String;Ljava/lang/String;)Z" );
jstring js1 = (*env)->NewStringUTF( env, p1 );
jstring js2 = (*env)->NewStringUTF( env, p2 );
same = (*env)->CallBooleanMethod( env, util->jutil, mid, js1, js2 );
(*env)->DeleteLocalRef( env, js1 );
(*env)->DeleteLocalRef( env, js2 );
UTIL_CBK_TAIL();
}
return same;
}

View file

@ -119,4 +119,6 @@ public interface UtilCtxt {
boolean warnIllegalWord( String[] words, int turn, boolean turnLost );
void showChat( String msg );
boolean phoneNumbersSame( String num1, String num2 );
}

View file

@ -21,8 +21,11 @@
package org.eehouse.android.xw4.jni;
import android.content.Context;
import android.telephony.PhoneNumberUtils;
import junit.framework.Assert;
import org.eehouse.android.xw4.DbgUtils;
import org.eehouse.android.xw4.XWApp;
import org.eehouse.android.xw4.R;
public class UtilCtxtImpl implements UtilCtxt {
@ -238,6 +241,14 @@ public class UtilCtxtImpl implements UtilCtxt {
subclassOverride( "showChat" );
}
public boolean phoneNumbersSame( String num1, String num2 )
{
Assert.assertTrue( XWApp.SMSSUPPORTED );
boolean same = PhoneNumberUtils.compare( m_context, num1, num2 );
DbgUtils.logf( "phoneNumbersSame => %b", same );
return same;
}
private void subclassOverride( String name ) {
// DbgUtils.logf( "%s::%s() called", getClass().getName(), name );
}