[DO NOT MERGE] Eliminate duplicate layers in A11yService#getWindows()

Fixes: 73904014
Test: using TestBack, ensure the attached bug is fixed
Change-Id: I097ca47563420d658cea083a3b6f8d5e7d02991c
(cherry picked from commit 8f0124190a)
This commit is contained in:
Eugene Susla
2018-03-16 14:35:31 -07:00
parent cfa8591779
commit 18e7fc1114
2 changed files with 19 additions and 13 deletions

View File

@@ -219,7 +219,7 @@ public class DebugUtils {
&& field.getType().equals(int.class) && field.getName().startsWith(prefix)) {
try {
if (value == field.getInt(null)) {
return field.getName().substring(prefix.length());
return constNameWithoutPrefix(prefix, field);
}
} catch (IllegalAccessException ignored) {
}
@@ -236,6 +236,7 @@ public class DebugUtils {
*/
public static String flagsToString(Class<?> clazz, String prefix, int flags) {
final StringBuilder res = new StringBuilder();
boolean flagsWasZero = flags == 0;
for (Field field : clazz.getDeclaredFields()) {
final int modifiers = field.getModifiers();
@@ -243,9 +244,12 @@ public class DebugUtils {
&& field.getType().equals(int.class) && field.getName().startsWith(prefix)) {
try {
final int value = field.getInt(null);
if (value == 0 && flagsWasZero) {
return constNameWithoutPrefix(prefix, field);
}
if ((flags & value) != 0) {
flags &= ~value;
res.append(field.getName().substring(prefix.length())).append('|');
res.append(constNameWithoutPrefix(prefix, field)).append('|');
}
} catch (IllegalAccessException ignored) {
}
@@ -258,4 +262,8 @@ public class DebugUtils {
}
return res.toString();
}
private static String constNameWithoutPrefix(String prefix, Field field) {
return field.getName().substring(prefix.length());
}
}