From e9435930356f49685c0224c84b227419dc7bef34 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 29 Oct 2019 07:57:39 +0100 Subject: [PATCH] Prevent crash --- app/src/main/java/eu/faircode/email/Log.java | 44 +++++++++++--------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Log.java b/app/src/main/java/eu/faircode/email/Log.java index 078accba7f..18e1cdd4a3 100644 --- a/app/src/main/java/eu/faircode/email/Log.java +++ b/app/src/main/java/eu/faircode/email/Log.java @@ -30,6 +30,7 @@ import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkInfo; +import android.os.BadParcelableException; import android.os.Build; import android.os.Bundle; import android.os.DeadObjectException; @@ -320,28 +321,33 @@ public class Log { if (data == null) return result; - Set keys = data.keySet(); - for (String key : keys) { - Object v = data.get(key); + try { + Set keys = data.keySet(); + for (String key : keys) { + Object v = data.get(key); - Object value = v; - if (v != null && v.getClass().isArray()) { - int length = Array.getLength(v); - if (length <= 10) { - String[] elements = new String[length]; - for (int i = 0; i < length; i++) { - Object element = Array.get(v, i); - if (element instanceof Long) - elements[i] = "0x" + Long.toHexString((Long) element); - else - elements[i] = (element == null ? null : element.toString()); + Object value = v; + if (v != null && v.getClass().isArray()) { + int length = Array.getLength(v); + if (length <= 10) { + String[] elements = new String[length]; + for (int i = 0; i < length; i++) { + Object element = Array.get(v, i); + if (element instanceof Long) + elements[i] = "0x" + Long.toHexString((Long) element); + else + elements[i] = (element == null ? null : element.toString()); + } + value = TextUtils.join(",", elements); } - value = TextUtils.join(",", elements); - } - } else if (v instanceof Long) - value = "0x" + Long.toHexString((Long) v); + } else if (v instanceof Long) + value = "0x" + Long.toHexString((Long) v); - result.add(key + "=" + value + (value == null ? "" : " (" + v.getClass().getSimpleName() + ")")); + result.add(key + "=" + value + (value == null ? "" : " (" + v.getClass().getSimpleName() + ")")); + } + } catch (BadParcelableException ex) { + // android.os.BadParcelableException: ClassNotFoundException when unmarshalling: ... + Log.e(ex); } return result;