Tron logging - Fix isValidValue to match its name, allow nulls.

Test: runtest --path frameworks/base/core/tests/coretests/src/android/metrics/LogMakerTest.java
Change-Id: I92567e1873c5178606ac88135b5934d760b4ec24
This commit is contained in:
Alison Cichowlas
2017-01-25 08:51:45 -05:00
parent 07e29ad1ea
commit 2d89c243da
2 changed files with 8 additions and 3 deletions

View File

@@ -106,7 +106,7 @@ public class LogMaker {
* @return
*/
public LogMaker addTaggedData(int tag, Object value) {
if (isValidValue(value)) {
if (!isValidValue(value)) {
throw new IllegalArgumentException(
"Value must be loggable type - int, long, float, String");
}
@@ -119,10 +119,14 @@ public class LogMaker {
}
public boolean isValidValue(Object value) {
return !(value instanceof Integer ||
if (value == null) {
Log.i("LogBuilder", "Logging a null value.");
return true;
}
return value instanceof Integer ||
value instanceof String ||
value instanceof Long ||
value instanceof Float);
value instanceof Float;
}
public Object getTaggedData(int tag) {

View File

@@ -100,6 +100,7 @@ public class LogMakerTest extends TestCase {
builder.addTaggedData(2, 123);
builder.addTaggedData(3, 123L);
builder.addTaggedData(4, 123.0F);
builder.addTaggedData(5, null);
Object[] out = builder.serialize();
assertEquals("onetwothree", out[1]);
assertEquals(123, out[3]);