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

Commit 3df47e18 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix toString in RILUtils"

parents 47650fb4 12ef6537
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;
@@ -5174,10 +5175,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());
@@ -5191,8 +5199,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
@@ -5202,7 +5212,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);
@@ -5215,7 +5225,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));
@@ -5231,7 +5241,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(", ");