Prevent crash

This commit is contained in:
M66B 2019-10-29 07:57:39 +01:00
parent 62a4fba00d
commit e943593035
1 changed files with 25 additions and 19 deletions

View File

@ -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<String> keys = data.keySet();
for (String key : keys) {
Object v = data.get(key);
try {
Set<String> 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;