use full sum to fix fake dict upgrade offers

Needed to be incorporating the fullfile md5sum that was added recently
This commit is contained in:
Eric House 2022-05-13 19:42:12 -07:00
parent f4c36f8c81
commit 78b5e280cd
5 changed files with 19 additions and 32 deletions

View file

@ -2032,8 +2032,8 @@ public class BoardDelegate extends DelegateBase
// different name, offer to install.
String msg = null;
if ( oldName.equals( newName ) ) {
String oldSum = DictLangCache.getDictMD5Sum( m_activity,
oldName );
String oldSum = DictLangCache
.getDictMD5Sums( m_activity, oldName )[0];
if ( !oldSum.equals( newSum ) ) {
// Same dict, different versions
msg = getString( R.string.inform_dict_diffversion_fmt,

View file

@ -283,8 +283,8 @@ public class DictBrowseDelegate extends DelegateBase
if ( BuildConfig.NON_RELEASE ) {
TextView tv = (TextView)findViewById( R.id.md5sum_summary );
tv.setVisibility( View.VISIBLE );
String sum = DictLangCache.getDictMD5Sum( m_activity, m_name );
tv.setText( "md5: " + sum );
String[] sums = DictLangCache.getDictMD5Sums( m_activity, m_name );
tv.setText( "md5: " + sums[0] );
}
setShowConfig();

View file

@ -300,22 +300,13 @@ public class DictLangCache {
return s_langCodeStrs.get( code );
}
public static String getDictMD5Sum( Context context, String dict )
public static String[] getDictMD5Sums( Context context, String dict )
{
String result = null;
String[] result = {null, null};
DictInfo info = getInfo( context, dict );
if ( null != info ) {
result = info.md5Sum;
}
return result;
}
public static String getDictFullSum( Context context, String dict )
{
String result = null;
DictInfo info = getInfo( context, dict );
if ( null != info ) {
result = info.fullSum;
result[0] = info.md5Sum;
result[1] = info.fullSum;
}
return result;
}

View file

@ -1434,7 +1434,7 @@ public class DictsDelegate extends ListDelegateBase
// DictLangCache hits the DB hundreds of times below. Fix!
Log.w( TAG, "Fix me I'm stupid" );
try {
// Log.d( TAG, "data: %s", jsonData );
// Log.d( TAG, "digestData(%s)", jsonData );
JSONObject obj = new JSONObject( jsonData );
langs = obj.optJSONArray( "langs" );
@ -1483,15 +1483,12 @@ public class DictsDelegate extends ListDelegateBase
if ( DictLangCache.haveDict( m_activity,
localLangName, name )){
boolean matches = true;
String curSum = DictLangCache
.getDictMD5Sum( m_activity, name );
if ( null != curSum ) {
JSONArray sums =
dict.getJSONArray("md5sums");
if ( null != sums ) {
matches = false;
for ( int kk = 0;
!matches && kk < sums.length();
JSONArray sums = dict.getJSONArray("md5sums");
if ( null != sums ) {
matches = false;
String[] curSums = DictLangCache.getDictMD5Sums( m_activity, name );
for ( String curSum : curSums ) {
for ( int kk = 0; !matches && kk < sums.length();
++kk ) {
String sum = sums.getString( kk );
matches = sum.equals( curSum );

View file

@ -218,16 +218,15 @@ public class UpdateCheckReceiver extends BroadcastReceiver {
int lang = DictLangCache.getDictLangCode( context, dal );
String langCode = DictLangCache.getLangCodeStr( context, lang );
String langStr = DictLangCache.getLangName( context, lang );
String sum = DictLangCache.getDictMD5Sum( context, dal.name );
String fullSum = DictLangCache.getDictFullSum( context, dal.name );
Assert.assertTrueNR( null != fullSum );
String[] sums = DictLangCache.getDictMD5Sums( context, dal.name );
Assert.assertTrueNR( null != sums[1] );
long len = DictLangCache.getFileLen( context, dal );
try {
params.put( k_NAME, dal.name );
params.put( k_LANG, langStr );
params.put( k_LANGCODE, langCode );
params.put( k_MD5SUM, sum );
params.put( k_FULLSUM, fullSum );
params.put( k_MD5SUM, sums[0] );
params.put( k_FULLSUM, sums[1] );
params.put( k_INDEX, index );
params.put( k_LEN, len );
} catch( org.json.JSONException jse ) {