debugging

This commit is contained in:
Dominik 2012-06-20 20:54:31 +03:00
parent 72718d7fbc
commit ea2bc75f8c
2 changed files with 35 additions and 1 deletions

View File

@ -21,7 +21,14 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.Iterator;
import java.util.Set;
import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.util.Log;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
public class OtherHelper { public class OtherHelper {
@ -71,4 +78,26 @@ public class OtherHelper {
return numDays; return numDays;
} }
/**
* Logs bundle content to debug for inspecting the content
*
* @param bundle
* @param bundleName
*/
public static void logDebugBundle(Bundle bundle, String bundleName) {
if (Constants.DEBUG) {
Set<String> ks = bundle.keySet();
Iterator<String> iterator = ks.iterator();
Log.d(Constants.TAG, "Bundle " + bundleName + ":");
Log.d(Constants.TAG, "------------------------------");
while (iterator.hasNext()) {
String key = iterator.next();
Object value = bundle.get(key);
Log.d(Constants.TAG, key + " : " + value.toString());
}
Log.d(Constants.TAG, "------------------------------");
}
}
} }

View File

@ -33,6 +33,7 @@ import org.thialfihar.android.apg.Constants;
import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.Id;
import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.R;
import org.thialfihar.android.apg.helper.FileHelper; import org.thialfihar.android.apg.helper.FileHelper;
import org.thialfihar.android.apg.helper.OtherHelper;
import org.thialfihar.android.apg.helper.PGPMain; import org.thialfihar.android.apg.helper.PGPMain;
import org.thialfihar.android.apg.helper.Preferences; import org.thialfihar.android.apg.helper.Preferences;
import org.thialfihar.android.apg.helper.PGPMain.GeneralException; import org.thialfihar.android.apg.helper.PGPMain.GeneralException;
@ -168,6 +169,9 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
mMessenger = (Messenger) extras.get(EXTRA_MESSENGER); mMessenger = (Messenger) extras.get(EXTRA_MESSENGER);
Bundle data = extras.getBundle(EXTRA_DATA); Bundle data = extras.getBundle(EXTRA_DATA);
OtherHelper.logDebugBundle(data, "EXTRA_DATA");
int action = extras.getInt(EXTRA_ACTION); int action = extras.getInt(EXTRA_ACTION);
// execute action from extra bundle // execute action from extra bundle
@ -606,7 +610,8 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
* Set progress of ProgressDialog by sending message to handler on UI thread * Set progress of ProgressDialog by sending message to handler on UI thread
*/ */
public void setProgress(String message, int progress, int max) { public void setProgress(String message, int progress, int max) {
Log.d(Constants.TAG, "Send message by setProgress"); Log.d(Constants.TAG, "Send message by setProgress with progress=" + progress + ", max="
+ max);
Bundle data = new Bundle(); Bundle data = new Bundle();
if (message != null) { if (message != null) {