mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-17 18:12:01 +01:00
rip out most devid stuff
This commit is contained in:
parent
58cba766d3
commit
5f4dd46f72
8 changed files with 12 additions and 116 deletions
|
@ -20,13 +20,8 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
package org.eehouse.android.xw4;
|
||||||
|
|
||||||
/* The relay issues an identifier for a registered device. It's a string
|
/* This class is left over from the proprietary relay days and doesn't do much
|
||||||
* representation of a 32-bit hex number. When devices register, they pass
|
* now. Can go away soon, wihth getNFCDevID() moving elsewhere.
|
||||||
* 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."
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -35,8 +30,6 @@ public class DevID {
|
||||||
private static final String TAG = DevID.class.getSimpleName();
|
private static final String TAG = DevID.class.getSimpleName();
|
||||||
|
|
||||||
private static final String DEVID_KEY = "DevID.devid_key";
|
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 final String NFC_DEVID_KEY = "key_nfc_devid";
|
||||||
|
|
||||||
private static String s_relayDevID;
|
private static String s_relayDevID;
|
||||||
|
@ -53,25 +46,10 @@ public class DevID {
|
||||||
return s_asInt;
|
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 )
|
public static String getRelayDevID( Context context )
|
||||||
{
|
{
|
||||||
if ( null == s_relayDevID ) {
|
if ( null == s_relayDevID ) {
|
||||||
String asStr = DBUtils.getStringFor( context, DEVID_KEY, "" );
|
String asStr = DBUtils.getStringFor( context, DEVID_KEY, "00000000" );
|
||||||
// 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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( null != asStr && 0 != asStr.length() ) {
|
if ( null != asStr && 0 != asStr.length() ) {
|
||||||
s_relayDevID = asStr;
|
s_relayDevID = asStr;
|
||||||
}
|
}
|
||||||
|
@ -80,37 +58,6 @@ public class DevID {
|
||||||
return s_relayDevID;
|
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
|
// Just a random number I hang onto as long as possible
|
||||||
private static int[] sNFCDevID = {0};
|
private static int[] sNFCDevID = {0};
|
||||||
public static int getNFCDevID( Context context )
|
public static int getNFCDevID( Context context )
|
||||||
|
@ -124,7 +71,7 @@ public class DevID {
|
||||||
}
|
}
|
||||||
sNFCDevID[0] = devid;
|
sNFCDevID[0] = devid;
|
||||||
}
|
}
|
||||||
Log.d( TAG, "getNFCDevID() => %d", sNFCDevID[0] );
|
// Log.d( TAG, "getNFCDevID() => %d", sNFCDevID[0] );
|
||||||
return sNFCDevID[0];
|
return sNFCDevID[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,6 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
private static final String k_INDEX = "index";
|
private static final String k_INDEX = "index";
|
||||||
private static final String k_LEN = "len";
|
private static final String k_LEN = "len";
|
||||||
private static final String k_URL = "url";
|
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_MQTTDEVID = "devid";
|
||||||
private static final String k_DEBUG = "dbg";
|
private static final String k_DEBUG = "dbg";
|
||||||
private static final String k_XLATEINFO = "xlatinfo";
|
private static final String k_XLATEINFO = "xlatinfo";
|
||||||
|
@ -150,7 +149,6 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
appParams.put( k_DEBUG, BuildConfig.DEBUG );
|
appParams.put( k_DEBUG, BuildConfig.DEBUG );
|
||||||
params.put( k_APP, appParams );
|
params.put( k_APP, appParams );
|
||||||
params.put( k_DEVID, XWPrefs.getDevID( context ) );
|
|
||||||
|
|
||||||
String devID = XwJNI.dvc_getMQTTDevID( null );
|
String devID = XwJNI.dvc_getMQTTDevID( null );
|
||||||
params.put( k_MQTTDEVID, devID );
|
params.put( k_MQTTDEVID, devID );
|
||||||
|
@ -168,7 +166,6 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
params.put( k_DICTS, dictParams );
|
params.put( k_DICTS, dictParams );
|
||||||
params.put( k_DEVID, XWPrefs.getDevID( context ) );
|
|
||||||
} catch ( org.json.JSONException jse ) {
|
} catch ( org.json.JSONException jse ) {
|
||||||
Log.ex( TAG, jse );
|
Log.ex( TAG, jse );
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,17 +335,6 @@ public class XWPrefs {
|
||||||
return getPrefsStringArray( context, R.string.key_bt_addrs );
|
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 )
|
public static DictUtils.DictLoc getDefaultLoc( Context context )
|
||||||
{
|
{
|
||||||
boolean internal = getDefaultLocInternal( context );
|
boolean internal = getDefaultLocInternal( context );
|
||||||
|
|
|
@ -52,42 +52,6 @@ public class DUtilCtxt {
|
||||||
m_context = XWApp.getContext();
|
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 STRD_ROBOT_TRADED = 1;
|
||||||
private static final int STR_ROBOT_MOVED = 2;
|
private static final int STR_ROBOT_MOVED = 2;
|
||||||
private static final int STRS_VALUES_HEADER = 3;
|
private static final int STRS_VALUES_HEADER = 3;
|
||||||
|
|
|
@ -109,7 +109,6 @@
|
||||||
<string name="key_sms_phones">key_sms_phones</string>
|
<string name="key_sms_phones">key_sms_phones</string>
|
||||||
<string name="key_relay_ids">key_relay_ids</string>
|
<string name="key_relay_ids">key_relay_ids</string>
|
||||||
<string name="key_connstat_data">key_connstat_data</string>
|
<string name="key_connstat_data">key_connstat_data</string>
|
||||||
<string name="key_dev_id">key_dev_id</string>
|
|
||||||
|
|
||||||
<string name="key_gcmvers_regid">key_gcmvers_regid</string>
|
<string name="key_gcmvers_regid">key_gcmvers_regid</string>
|
||||||
<string name="key_relay_regid">key_relay_regid</string>
|
<string name="key_relay_regid">key_relay_regid</string>
|
||||||
|
|
|
@ -747,7 +747,7 @@ and_util_getInviteeName( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 plyrNum,
|
||||||
UTIL_CBK_TAIL();
|
UTIL_CBK_TAIL();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XWFEATURE_DEVID
|
#if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY
|
||||||
static const XP_UCHAR*
|
static const XP_UCHAR*
|
||||||
and_dutil_getDevID( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType* typ )
|
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 );
|
deleteLocalRefs( env, jstr, jtyp, DELETE_NO_REF );
|
||||||
DUTIL_CBK_TAIL();
|
DUTIL_CBK_TAIL();
|
||||||
}
|
}
|
||||||
#endif /* XWFEATURE_DEVID */
|
#endif /* XWFEATURE_DEVID && XWFEATURE_RELAY */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1083,7 +1083,7 @@ makeDUtil( MPFORMAL JNIEnv* env,
|
||||||
SET_DPROC(remove);
|
SET_DPROC(remove);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XWFEATURE_DEVID
|
# if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY
|
||||||
SET_DPROC(getDevID);
|
SET_DPROC(getDevID);
|
||||||
SET_DPROC(deviceRegistered);
|
SET_DPROC(deviceRegistered);
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -69,7 +69,7 @@ typedef struct _DUtilVtable {
|
||||||
const XP_UCHAR* p2 );
|
const XP_UCHAR* p2 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XWFEATURE_DEVID
|
#if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY
|
||||||
const XP_UCHAR* (*m_dutil_getDevID)( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType* typ );
|
const XP_UCHAR* (*m_dutil_getDevID)( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType* typ );
|
||||||
void (*m_dutil_deviceRegistered)( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType typ,
|
void (*m_dutil_deviceRegistered)( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType typ,
|
||||||
const XP_UCHAR* idRelay );
|
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) )
|
(duc)->vtable.m_dutil_phoneNumbersSame( (duc), (e), (p1), (p2) )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XWFEATURE_DEVID
|
#if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY
|
||||||
# define dutil_getDevID( duc, e, t ) \
|
# define dutil_getDevID( duc, e, t ) \
|
||||||
(duc)->vtable.m_dutil_getDevID((duc), (e),(t))
|
(duc)->vtable.m_dutil_getDevID((duc), (e),(t))
|
||||||
# define dutil_deviceRegistered( duc, e, typ, id ) \
|
# define dutil_deviceRegistered( duc, e, typ, id ) \
|
||||||
|
|
|
@ -52,7 +52,7 @@ static XP_Bool linux_dutil_phoneNumbersSame( XW_DUtilCtxt* duc, XWEnv xwe,
|
||||||
const XP_UCHAR* p2 );
|
const XP_UCHAR* p2 );
|
||||||
#endif
|
#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 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,
|
static void linux_dutil_deviceRegistered( XW_DUtilCtxt* duc, XWEnv xwe, DevIDType typ,
|
||||||
const XP_UCHAR* idRelay );
|
const XP_UCHAR* idRelay );
|
||||||
|
@ -168,7 +168,7 @@ linux_dutils_init( MPFORMAL VTableMgr* vtMgr, void* closure )
|
||||||
SET_PROC(phoneNumbersSame);
|
SET_PROC(phoneNumbersSame);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XWFEATURE_DEVID
|
#if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY
|
||||||
SET_PROC(getDevID);
|
SET_PROC(getDevID);
|
||||||
SET_PROC(deviceRegistered);
|
SET_PROC(deviceRegistered);
|
||||||
#endif
|
#endif
|
||||||
|
@ -380,7 +380,7 @@ linux_dutil_phoneNumbersSame( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe),
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XWFEATURE_DEVID
|
#if defined XWFEATURE_DEVID && defined XWFEATURE_RELAY
|
||||||
static const XP_UCHAR*
|
static const XP_UCHAR*
|
||||||
linux_dutil_getDevID( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe), DevIDType* typ )
|
linux_dutil_getDevID( XW_DUtilCtxt* duc, XWEnv XP_UNUSED(xwe), DevIDType* typ )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue