summaryrefslogtreecommitdiffstats
path: root/services/core
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2014-05-15 18:03:11 -0400
committerChris Wren <cwren@android.com>2014-05-27 10:19:07 -0400
commitfb69da323b97ae4712054d37fb2f7d54cddb7dbd (patch)
treea7ae7505705a4bb41dea77af2ae15f4e59505ab6 /services/core
parent6940b361e54d083be38c24bfaa4f168462640d03 (diff)
downloadframeworks_base-fb69da323b97ae4712054d37fb2f7d54cddb7dbd.zip
frameworks_base-fb69da323b97ae4712054d37fb2f7d54cddb7dbd.tar.gz
frameworks_base-fb69da323b97ae4712054d37fb2f7d54cddb7dbd.tar.bz2
Reduce logspam by catching unexpected types ourselves.
Also fix a bug in the conversion of ArrayLists to String[]. Change-Id: I839c80d0b571be298062d511dd3c83cc1e263f54
Diffstat (limited to 'services/core')
-rw-r--r--services/core/java/com/android/server/notification/ValidateNotificationPeople.java80
1 files changed, 44 insertions, 36 deletions
diff --git a/services/core/java/com/android/server/notification/ValidateNotificationPeople.java b/services/core/java/com/android/server/notification/ValidateNotificationPeople.java
index 157d749..a629a5f 100644
--- a/services/core/java/com/android/server/notification/ValidateNotificationPeople.java
+++ b/services/core/java/com/android/server/notification/ValidateNotificationPeople.java
@@ -139,56 +139,64 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor {
}
private String[] getExtraPeople(Bundle extras) {
- String[] people = extras.getStringArray(Notification.EXTRA_PEOPLE);
- if (people != null) {
- return people;
+ Object people = extras.get(Notification.EXTRA_PEOPLE);
+ if (people instanceof String[]) {
+ return (String[]) people;
}
- ArrayList<String> stringArray = extras.getStringArrayList(Notification.EXTRA_PEOPLE);
- if (stringArray != null) {
- return (String[]) stringArray.toArray();
+ if (people instanceof ArrayList) {
+ ArrayList arrayList = (ArrayList) people;
+
+ if (arrayList.isEmpty()) {
+ return null;
+ }
+
+ if (arrayList.get(0) instanceof String) {
+ ArrayList<String> stringArray = (ArrayList<String>) arrayList;
+ return stringArray.toArray(new String[stringArray.size()]);
+ }
+
+ if (arrayList.get(0) instanceof CharSequence) {
+ ArrayList<CharSequence> charSeqList = (ArrayList<CharSequence>) arrayList;
+ final int N = charSeqList.size();
+ String[] array = new String[N];
+ for (int i = 0; i < N; i++) {
+ array[i] = charSeqList.get(i).toString();
+ }
+ return array;
+ }
+
+ return null;
}
- String string = extras.getString(Notification.EXTRA_PEOPLE);
- if (string != null) {
- people = new String[1];
- people[0] = string;
- return people;
+ if (people instanceof String) {
+ String[] array = new String[1];
+ array[0] = (String) people;
+ return array;
}
- char[] charArray = extras.getCharArray(Notification.EXTRA_PEOPLE);
- if (charArray != null) {
- people = new String[1];
- people[0] = new String(charArray);
- return people;
+
+ if (people instanceof char[]) {
+ String[] array = new String[1];
+ array[0] = new String((char[]) people);
+ return array;
}
- CharSequence charSeq = extras.getCharSequence(Notification.EXTRA_PEOPLE);
- if (charSeq != null) {
- people = new String[1];
- people[0] = charSeq.toString();
- return people;
+ if (people instanceof CharSequence) {
+ String[] array = new String[1];
+ array[0] = ((CharSequence) people).toString();
+ return array;
}
- CharSequence[] charSeqArray = extras.getCharSequenceArray(Notification.EXTRA_PEOPLE);
- if (charSeqArray != null) {
+ if (people instanceof CharSequence[]) {
+ CharSequence[] charSeqArray = (CharSequence[]) people;
final int N = charSeqArray.length;
- people = new String[N];
+ String[] array = new String[N];
for (int i = 0; i < N; i++) {
- people[i] = charSeqArray[i].toString();
+ array[i] = charSeqArray[i].toString();
}
- return people;
+ return array;
}
- ArrayList<CharSequence> charSeqList =
- extras.getCharSequenceArrayList(Notification.EXTRA_PEOPLE);
- if (charSeqList != null) {
- final int N = charSeqList.size();
- people = new String[N];
- for (int i = 0; i < N; i++) {
- people[i] = charSeqList.get(i).toString();
- }
- return people;
- }
return null;
}