mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-01 06:19:57 +01:00
add logging giving size and md5sum of downloaded .apk.
This commit is contained in:
parent
441cc53740
commit
c39d434ffa
1 changed files with 20 additions and 1 deletions
|
@ -33,6 +33,7 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.HashMap;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
@ -183,16 +184,34 @@ public class DictImportActivity extends XWActivity {
|
|||
boolean success = false;
|
||||
File appFile = new File( DictUtils.getDownloadDir( this ), name );
|
||||
Assert.assertNotNull( appFile );
|
||||
|
||||
|
||||
// Get rid of this after debugging download/install problems
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("MD5");
|
||||
} catch( Exception ex ) {
|
||||
md = null;
|
||||
}
|
||||
|
||||
byte[] buf = new byte[1024*4];
|
||||
try {
|
||||
int nTotal = 0;
|
||||
FileOutputStream fos = new FileOutputStream( appFile );
|
||||
int nRead;
|
||||
while ( 0 <= (nRead = is.read( buf, 0, buf.length )) ) {
|
||||
fos.write( buf, 0, nRead );
|
||||
if ( null != md ) {
|
||||
md.update( buf, 0, nRead );
|
||||
}
|
||||
nTotal += nRead;
|
||||
}
|
||||
fos.close();
|
||||
success = true;
|
||||
|
||||
String sum = null == md ? "<failed>"
|
||||
: Utils.digestToString( md.digest() );
|
||||
DbgUtils.logf( "saveToDownloads: saved %d bytes to %s, md5sum=%s",
|
||||
nTotal, appFile.getPath(), sum );
|
||||
} catch ( java.io.FileNotFoundException fnf ) {
|
||||
DbgUtils.loge( fnf );
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
|
|
Loading…
Reference in a new issue