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

Commit fb69da32 authored by Chris Wren's avatar Chris Wren
Browse files

Reduce logspam by catching unexpected types ourselves.

Also fix a bug in the conversion of ArrayLists to String[].

Change-Id: I839c80d0b571be298062d511dd3c83cc1e263f54
parent 6940b361
Loading
Loading
Loading
Loading
+44 −36
Original line number Original line Diff line number Diff line
@@ -139,56 +139,64 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor {
    }
    }


    private String[] getExtraPeople(Bundle extras) {
    private String[] getExtraPeople(Bundle extras) {
        String[] people = extras.getStringArray(Notification.EXTRA_PEOPLE);
        Object people = extras.get(Notification.EXTRA_PEOPLE);
        if (people != null) {
        if (people instanceof String[]) {
            return people;
            return (String[]) people;
        }
        }


        ArrayList<String> stringArray = extras.getStringArrayList(Notification.EXTRA_PEOPLE);
        if (people instanceof ArrayList) {
        if (stringArray != null) {
            ArrayList arrayList = (ArrayList) people;
            return (String[]) stringArray.toArray();

            if (arrayList.isEmpty()) {
                return null;
            }

            if (arrayList.get(0) instanceof String) {
                ArrayList<String> stringArray = (ArrayList<String>) arrayList;
                return stringArray.toArray(new String[stringArray.size()]);
            }
            }


        String string = extras.getString(Notification.EXTRA_PEOPLE);
            if (arrayList.get(0) instanceof CharSequence) {
        if (string != null) {
                ArrayList<CharSequence> charSeqList = (ArrayList<CharSequence>) arrayList;
            people = new String[1];
                final int N = charSeqList.size();
            people[0] = string;
                String[] array = new String[N];
            return people;
                for (int i = 0; i < N; i++) {
                    array[i] = charSeqList.get(i).toString();
                }
                }
        char[] charArray = extras.getCharArray(Notification.EXTRA_PEOPLE);
                return array;
        if (charArray != null) {
            people = new String[1];
            people[0] = new String(charArray);
            return people;
            }
            }


        CharSequence charSeq = extras.getCharSequence(Notification.EXTRA_PEOPLE);
            return null;
        if (charSeq != null) {
            people = new String[1];
            people[0] = charSeq.toString();
            return people;
        }
        }


        CharSequence[] charSeqArray = extras.getCharSequenceArray(Notification.EXTRA_PEOPLE);
        if (people instanceof String) {
        if (charSeqArray != null) {
            String[] array = new String[1];
            final int N = charSeqArray.length;
            array[0] = (String) people;
            people = new String[N];
            return array;
            for (int i = 0; i < N; i++) {
                people[i] = charSeqArray[i].toString();
        }
        }
            return people;

        if (people instanceof char[]) {
            String[] array = new String[1];
            array[0] = new String((char[]) people);
            return array;
        }
        }


        ArrayList<CharSequence> charSeqList =
        if (people instanceof CharSequence) {
                extras.getCharSequenceArrayList(Notification.EXTRA_PEOPLE);
            String[] array = new String[1];
        if (charSeqList != null) {
            array[0] = ((CharSequence) people).toString();
            final int N = charSeqList.size();
            return array;
            people = new String[N];
        }

        if (people instanceof CharSequence[]) {
            CharSequence[] charSeqArray = (CharSequence[]) people;
            final int N = charSeqArray.length;
            String[] array = new String[N];
            for (int i = 0; i < N; i++) {
            for (int i = 0; i < N; i++) {
                people[i] = charSeqList.get(i).toString();
                array[i] = charSeqArray[i].toString();
            }
            }
            return people;
            return array;
        }
        }

        return null;
        return null;
    }
    }