From c39d434ffa1392e13ef8db276743c965d3465069 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 27 Nov 2012 07:22:03 -0800 Subject: [PATCH] add logging giving size and md5sum of downloaded .apk. --- .../android/xw4/DictImportActivity.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportActivity.java index a01e68d43..51e7a1dcb 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictImportActivity.java @@ -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 ? "" + : 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 ) {