Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b012b876 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix toString in RILUtils" into tm-dev

parents f06705f9 20a7b688
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -349,6 +349,7 @@ import com.android.telephony.Rlog;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -5183,10 +5184,17 @@ public class RILUtils {
            // Special handling for arrays
            StringBuilder sb = new StringBuilder("[");
            boolean added = false;
            if (isPrimitiveOrWrapper(o.getClass().getComponentType())) {
                for (int i = 0; i < Array.getLength(o); i++) {
                    sb.append(convertToString(Array.get(o, i))).append(", ");
                    added = true;
                }
            } else {
                for (Object element : (Object[]) o) {
                    sb.append(convertToString(element)).append(", ");
                    added = true;
                }
            }
            if (added) {
                // Remove extra ,
                sb.delete(sb.length() - 2, sb.length());
@@ -5200,8 +5208,10 @@ public class RILUtils {
        int tag = -1;
        try {
            tag = (int) o.getClass().getDeclaredMethod("getTag").invoke(o);
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            loge(e.getMessage());
        } catch (IllegalAccessException | InvocationTargetException e) {
            loge(e.toString());
        } catch (NoSuchMethodException ignored) {
            // Ignored since only unions have the getTag method
        }
        if (tag != -1) {
            // Special handling for unions
@@ -5211,7 +5221,7 @@ public class RILUtils {
                method.setAccessible(true);
                tagName = (String) method.invoke(o, tag);
            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
                loge(e.getMessage());
                loge(e.toString());
            }
            if (tagName != null) {
                sb.append(tagName);
@@ -5224,7 +5234,7 @@ public class RILUtils {
                    val = o.getClass().getDeclaredMethod(getTagMethod).invoke(o);
                } catch (NoSuchMethodException | IllegalAccessException
                        | InvocationTargetException e) {
                    loge(e.getMessage());
                    loge(e.toString());
                }
                if (val != null) {
                    sb.append(convertToString(val));
@@ -5240,7 +5250,7 @@ public class RILUtils {
                try {
                    val = field.get(o);
                } catch (IllegalAccessException e) {
                    loge(e.getMessage());
                    loge(e.toString());
                }
                if (val == null) continue;
                sb.append(convertToString(val)).append(", ");