Merge "Support KM_LONG_REP"
This commit is contained in:
@@ -42,6 +42,7 @@ abstract class KeymasterArgument implements Parcelable {
|
||||
case KeymasterDefs.KM_INT_REP:
|
||||
return new KeymasterIntArgument(tag, in);
|
||||
case KeymasterDefs.KM_LONG:
|
||||
case KeymasterDefs.KM_LONG_REP:
|
||||
return new KeymasterLongArgument(tag, in);
|
||||
case KeymasterDefs.KM_DATE:
|
||||
return new KeymasterDateArgument(tag, in);
|
||||
|
||||
@@ -63,6 +63,12 @@ public class KeymasterArguments implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
public void addLongs(int tag, long... values) {
|
||||
for (long value : values) {
|
||||
addLong(tag, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void addBoolean(int tag) {
|
||||
mArguments.add(new KeymasterBooleanArgument(tag));
|
||||
}
|
||||
@@ -111,8 +117,13 @@ public class KeymasterArguments implements Parcelable {
|
||||
}
|
||||
|
||||
public long getLong(int tag, long defaultValue) {
|
||||
if (KeymasterDefs.getTagType(tag) != KeymasterDefs.KM_LONG) {
|
||||
throw new IllegalArgumentException("Tag is not a long type: " + tag);
|
||||
switch (KeymasterDefs.getTagType(tag)) {
|
||||
case KeymasterDefs.KM_LONG:
|
||||
break; // Accepted type
|
||||
case KeymasterDefs.KM_LONG_REP:
|
||||
throw new IllegalArgumentException("Repeatable tags must use getLongs: " + tag);
|
||||
default:
|
||||
throw new IllegalArgumentException("Tag is not a long type: " + tag);
|
||||
}
|
||||
KeymasterArgument arg = getArgumentByTag(tag);
|
||||
if (arg == null) {
|
||||
@@ -175,6 +186,19 @@ public class KeymasterArguments implements Parcelable {
|
||||
return values;
|
||||
}
|
||||
|
||||
public List<Long> getLongs(int tag) {
|
||||
if (KeymasterDefs.getTagType(tag) != KeymasterDefs.KM_LONG_REP) {
|
||||
throw new IllegalArgumentException("Tag is not a repeating long: " + tag);
|
||||
}
|
||||
List<Long> values = new ArrayList<Long>();
|
||||
for (KeymasterArgument arg : mArguments) {
|
||||
if (arg.tag == tag) {
|
||||
values.add(((KeymasterLongArgument) arg).value);
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return mArguments.size();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class KeymasterLongArgument extends KeymasterArgument {
|
||||
super(tag);
|
||||
switch (KeymasterDefs.getTagType(tag)) {
|
||||
case KeymasterDefs.KM_LONG:
|
||||
case KeymasterDefs.KM_LONG_REP:
|
||||
break; // OK.
|
||||
default:
|
||||
throw new IllegalArgumentException("Bad long tag " + tag);
|
||||
|
||||
Reference in New Issue
Block a user