From 5f4dd46f72f159f9703981b36812c1143f000b3c Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 7 May 2022 18:56:25 -0700 Subject: [PATCH] rip out most devid stuff --- .../java/org/eehouse/android/xw4/DevID.java | 61 ++----------------- .../android/xw4/UpdateCheckReceiver.java | 3 - .../java/org/eehouse/android/xw4/XWPrefs.java | 11 ---- .../eehouse/android/xw4/jni/DUtilCtxt.java | 36 ----------- .../app/src/main/res/values/common_rsrc.xml | 1 - xwords4/android/jni/utilwrapper.c | 6 +- xwords4/common/dutil.h | 4 +- xwords4/linux/lindutil.c | 6 +- 8 files changed, 12 insertions(+), 116 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DevID.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DevID.java index fcc3db4e9..ddccbf650 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DevID.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DevID.java @@ -20,13 +20,8 @@ package org.eehouse.android.xw4; -/* The relay issues an identifier for a registered device. It's a string - * representation of a 32-bit hex number. When devices register, they pass - * what's meant to be a unique identifier of their own. GCM-aware devices (for - * which this was originally conceived) pass their GCM IDs (which can change, - * and require re-registration). Other devices generate an ID however they - * choose, or can pass "", meaning "I'm anonymous; just give me an ID based on - * nothing." +/* This class is left over from the proprietary relay days and doesn't do much + * now. Can go away soon, wihth getNFCDevID() moving elsewhere. */ import android.content.Context; @@ -35,8 +30,6 @@ public class DevID { private static final String TAG = DevID.class.getSimpleName(); private static final String DEVID_KEY = "DevID.devid_key"; - private static final String DEVID_ACK_KEY = "key_relay_regid_ackd2"; - private static final String FCM_REGVERS_KEY = "key_fcmvers_regid"; private static final String NFC_DEVID_KEY = "key_nfc_devid"; private static String s_relayDevID; @@ -53,25 +46,10 @@ public class DevID { return s_asInt; } - public static String getRelayDevID( Context context, boolean insistAckd ) - { - String result = getRelayDevID( context ); - if ( insistAckd && null != result && 0 < result.length() - && ! DBUtils.getBoolFor( context, DEVID_ACK_KEY, false ) ) { - result = null; - } - return result; - } - public static String getRelayDevID( Context context ) { if ( null == s_relayDevID ) { - String asStr = DBUtils.getStringFor( context, DEVID_KEY, "" ); - // TRANSITIONAL: If it's not there, see if it's stored the old way - if ( 0 == asStr.length() ) { - asStr = XWPrefs.getPrefsString( context, R.string.key_relay_regid ); - } - + String asStr = DBUtils.getStringFor( context, DEVID_KEY, "00000000" ); if ( null != asStr && 0 != asStr.length() ) { s_relayDevID = asStr; } @@ -80,37 +58,6 @@ public class DevID { return s_relayDevID; } - public static void setRelayDevID( Context context, String devID ) - { - Log.d( TAG, "setRelayDevID()" ); - if ( BuildConfig.DEBUG ) { - String oldID = getRelayDevID( context ); - if ( null != oldID && 0 < oldID.length() - && ! devID.equals( oldID ) ) { - Log.d( TAG, "devID changing!!!: %s => %s", oldID, devID ); - } - } - DBUtils.setStringFor( context, DEVID_KEY, devID ); - s_relayDevID = devID; - - DBUtils.setBoolFor( context, DEVID_ACK_KEY, true ); - // DbgUtils.printStack(); - } - - public static void clearRelayDevID( Context context ) - { - Log.i( TAG, "clearRelayDevID()" ); - DBUtils.setStringFor( context, DEVID_KEY, "" ); - // DbgUtils.printStack(); - } - - public static void setFCMDevID( Context context, String devID ) - { - int curVers = Utils.getAppVersion( context ); - DBUtils.setIntFor( context, FCM_REGVERS_KEY, curVers ); - DBUtils.setBoolFor( context, DEVID_ACK_KEY, false ); - } - // Just a random number I hang onto as long as possible private static int[] sNFCDevID = {0}; public static int getNFCDevID( Context context ) @@ -124,7 +71,7 @@ public class DevID { } sNFCDevID[0] = devid; } - Log.d( TAG, "getNFCDevID() => %d", sNFCDevID[0] ); + // Log.d( TAG, "getNFCDevID() => %d", sNFCDevID[0] ); return sNFCDevID[0]; } } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java index cd8f57ca5..eccc4d7b2 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/UpdateCheckReceiver.java @@ -70,7 +70,6 @@ public class UpdateCheckReceiver extends BroadcastReceiver { private static final String k_INDEX = "index"; private static final String k_LEN = "len"; private static final String k_URL = "url"; - private static final String k_DEVID = "did"; private static final String k_MQTTDEVID = "devid"; private static final String k_DEBUG = "dbg"; private static final String k_XLATEINFO = "xlatinfo"; @@ -150,7 +149,6 @@ public class UpdateCheckReceiver extends BroadcastReceiver { } appParams.put( k_DEBUG, BuildConfig.DEBUG ); params.put( k_APP, appParams ); - params.put( k_DEVID, XWPrefs.getDevID( context ) ); String devID = XwJNI.dvc_getMQTTDevID( null ); params.put( k_MQTTDEVID, devID ); @@ -168,7 +166,6 @@ public class UpdateCheckReceiver extends BroadcastReceiver { } try { params.put( k_DICTS, dictParams ); - params.put( k_DEVID, XWPrefs.getDevID( context ) ); } catch ( org.json.JSONException jse ) { Log.ex( TAG, jse ); } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java index 36188cc4a..00a6c4e09 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWPrefs.java @@ -335,17 +335,6 @@ public class XWPrefs { return getPrefsStringArray( context, R.string.key_bt_addrs ); } - public static String getDevID( Context context ) - { - String id = getPrefsString( context, R.string.key_dev_id ); - if ( null == id || 0 == id.length() ) { - id = String.format( "%08X-%08X", Utils.nextRandomInt(), - Utils.nextRandomInt() ); - setPrefsString( context, R.string.key_dev_id, id ); - } - return id; - } - public static DictUtils.DictLoc getDefaultLoc( Context context ) { boolean internal = getDefaultLocInternal( context ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java index 220150501..23ca973e4 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/DUtilCtxt.java @@ -52,42 +52,6 @@ public class DUtilCtxt { m_context = XWApp.getContext(); } - // Possible values for typ[0], these must match enum in xwrelay.h - public enum DevIDType { ID_TYPE_NONE - , ID_TYPE_RELAY - , ID_TYPE_LINUX - , ID_TYPE_ANDROID_GCM_UNUSED // 3 - , ID_TYPE_ANDROID_OTHER - , ID_TYPE_ANON - , ID_TYPE_ANDROID_FCM // 6 - } - - public String getDevID( /*out*/ byte[] typa ) - { - DevIDType typ = DevIDType.ID_TYPE_NONE; - String result = DevID.getRelayDevID( m_context ); - if ( null != result ) { - typ = DevIDType.ID_TYPE_RELAY; - } - typa[0] = (byte)typ.ordinal(); - return result; - } - - public void deviceRegistered( DevIDType devIDType, String idRelay ) - { - switch ( devIDType ) { - case ID_TYPE_RELAY: - DevID.setRelayDevID( m_context, idRelay ); - break; - case ID_TYPE_NONE: - DevID.clearRelayDevID( m_context ); - break; - default: - Assert.failDbg(); - break; - } - } - private static final int STRD_ROBOT_TRADED = 1; private static final int STR_ROBOT_MOVED = 2; private static final int STRS_VALUES_HEADER = 3; diff --git a/xwords4/android/app/src/main/res/values/common_rsrc.xml b/xwords4/android/app/src/main/res/values/common_rsrc.xml index e81e1bbbe..94362f562 100644 --- a/xwords4/android/app/src/main/res/values/common_rsrc.xml +++ b/xwords4/android/app/src/main/res/values/common_rsrc.xml @@ -109,7 +109,6 @@ key_sms_phones key_relay_ids key_connstat_data - key_dev_id key_gcmvers_regid key_relay_regid diff --git a/xwords4/android/jni/utilwrapper.c b/xwords4/android/jni/utilwrapper.c index 825a6b880..638a05e1f 100644 --- a/xwords4/android/jni/utilwrapper.c +++ b/xwords4/android/jni/utilwrapper.c @@ -747,7 +747,7 @@ and_util_getInviteeName( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 plyrNum, UTIL_CBK_TAIL(); } -#ifdef XWFEATURE_DEVID +#if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY static const XP_UCHAR* and_dutil_getDevID( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType* typ ) { @@ -794,7 +794,7 @@ and_dutil_deviceRegistered( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType typ, deleteLocalRefs( env, jstr, jtyp, DELETE_NO_REF ); DUTIL_CBK_TAIL(); } -#endif /* XWFEATURE_DEVID */ +#endif /* XWFEATURE_DEVID && XWFEATURE_RELAY */ #endif @@ -1083,7 +1083,7 @@ makeDUtil( MPFORMAL JNIEnv* env, SET_DPROC(remove); # endif -# ifdef XWFEATURE_DEVID +# if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY SET_DPROC(getDevID); SET_DPROC(deviceRegistered); # endif diff --git a/xwords4/common/dutil.h b/xwords4/common/dutil.h index 4ec1d59a7..4eed42e96 100644 --- a/xwords4/common/dutil.h +++ b/xwords4/common/dutil.h @@ -69,7 +69,7 @@ typedef struct _DUtilVtable { const XP_UCHAR* p2 ); #endif -#ifdef XWFEATURE_DEVID +#if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY const XP_UCHAR* (*m_dutil_getDevID)( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType* typ ); void (*m_dutil_deviceRegistered)( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType typ, const XP_UCHAR* idRelay ); @@ -138,7 +138,7 @@ void dutil_super_init( MPFORMAL XW_DUtilCtxt* dutil ); (duc)->vtable.m_dutil_phoneNumbersSame( (duc), (e), (p1), (p2) ) #endif -#ifdef XWFEATURE_DEVID +#if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY # define dutil_getDevID( duc, e, t ) \ (duc)->vtable.m_dutil_getDevID((duc), (e),(t)) # define dutil_deviceRegistered( duc, e, typ, id ) \ diff --git a/xwords4/linux/lindutil.c b/xwords4/linux/lindutil.c index 42dfc773d..21c3866dc 100644 --- a/xwords4/linux/lindutil.c +++ b/xwords4/linux/lindutil.c @@ -52,7 +52,7 @@ static XP_Bool linux_dutil_phoneNumbersSame( XW_DUtilCtxt* duc, XWEnv xwe, const XP_UCHAR* p2 ); #endif -#ifdef XWFEATURE_DEVID +#if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY static const XP_UCHAR* linux_dutil_getDevID( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType* typ ); static void linux_dutil_deviceRegistered( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType typ, const XP_UCHAR* idRelay ); @@ -168,7 +168,7 @@ linux_dutils_init( MPFORMAL VTableMgr* vtMgr, void* closure ) SET_PROC(phoneNumbersSame); #endif -#ifdef XWFEATURE_DEVID +#if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY SET_PROC(getDevID); SET_PROC(deviceRegistered); #endif @@ -380,7 +380,7 @@ linux_dutil_phoneNumbersSame( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe), } #endif -#ifdef XWFEATURE_DEVID +#if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY static const XP_UCHAR* linux_dutil_getDevID( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe), DevIDType* typ ) {