summaryrefslogtreecommitdiffstats
path: root/core/java/android/security
diff options
context:
space:
mode:
authorChad Brubaker <cbrubaker@google.com>2015-04-16 14:30:30 -0700
committerChad Brubaker <cbrubaker@google.com>2015-04-16 14:39:51 -0700
commitb543b393549ccb2f1aa2cf3a198811fafbc309eb (patch)
tree3924af018aef38a4212f941e077e5e986c2012d6 /core/java/android/security
parentd1af38a4783c1c0d1a5b7c76a7583beb02a88462 (diff)
downloadframeworks_base-b543b393549ccb2f1aa2cf3a198811fafbc309eb.zip
frameworks_base-b543b393549ccb2f1aa2cf3a198811fafbc309eb.tar.gz
frameworks_base-b543b393549ccb2f1aa2cf3a198811fafbc309eb.tar.bz2
Support KM_LONG_REP
Change-Id: I37814bcb03dc8918e27226ec43230fa4218723d0
Diffstat (limited to 'core/java/android/security')
-rw-r--r--core/java/android/security/keymaster/KeymasterArgument.java1
-rw-r--r--core/java/android/security/keymaster/KeymasterArguments.java28
-rw-r--r--core/java/android/security/keymaster/KeymasterLongArgument.java1
3 files changed, 28 insertions, 2 deletions
diff --git a/core/java/android/security/keymaster/KeymasterArgument.java b/core/java/android/security/keymaster/KeymasterArgument.java
index 9a1c894..9adde35 100644
--- a/core/java/android/security/keymaster/KeymasterArgument.java
+++ b/core/java/android/security/keymaster/KeymasterArgument.java
@@ -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);
diff --git a/core/java/android/security/keymaster/KeymasterArguments.java b/core/java/android/security/keymaster/KeymasterArguments.java
index 8ed288c..82f65c7 100644
--- a/core/java/android/security/keymaster/KeymasterArguments.java
+++ b/core/java/android/security/keymaster/KeymasterArguments.java
@@ -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();
}
diff --git a/core/java/android/security/keymaster/KeymasterLongArgument.java b/core/java/android/security/keymaster/KeymasterLongArgument.java
index d51d7e6..e04ce5d 100644
--- a/core/java/android/security/keymaster/KeymasterLongArgument.java
+++ b/core/java/android/security/keymaster/KeymasterLongArgument.java
@@ -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);