summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Yu <jackcwyu@google.com>2020-01-22 19:19:23 -0800
committerandroid-build-merger <android-build-merger@google.com>2020-01-22 19:19:23 -0800
commit463b69661946fb195322d30fc7c40092dc7de558 (patch)
treeabb8d999f3eb60c93f83f087cfc7bc89134c4f71
parentedcdd54ffa398bc7a93bb39424c5f0a60d6c6206 (diff)
parent138fac9fd11baf6401b1c6407cbd721bc964363d (diff)
downloadSecureElement-463b69661946fb195322d30fc7c40092dc7de558.tar.gz
Merge "Add support for secure_element HAL 1.2"
am: 138fac9fd1 Change-Id: I71b2faf5fbb8ad26b9aed7cbfd93691c3b2bfd37
-rw-r--r--Android.bp3
-rw-r--r--src/com/android/se/Terminal.java61
2 files changed, 52 insertions, 12 deletions
diff --git a/Android.bp b/Android.bp
index 9649f23..00b6871 100644
--- a/Android.bp
+++ b/Android.bp
@@ -4,7 +4,8 @@ android_app {
platform_apis: true,
certificate: "platform",
static_libs: ["android.hardware.secure_element-V1.0-java",
- "android.hardware.secure_element-V1.1-java"],
+ "android.hardware.secure_element-V1.1-java",
+ "android.hardware.secure_element-V1.2-java"],
optimize: {
enabled: false,
},
diff --git a/src/com/android/se/Terminal.java b/src/com/android/se/Terminal.java
index d7d9d99..2f03cf2 100644
--- a/src/com/android/se/Terminal.java
+++ b/src/com/android/se/Terminal.java
@@ -77,6 +77,7 @@ public class Terminal {
private static final int EVENT_GET_HAL = 1;
private ISecureElement mSEHal;
+ private android.hardware.secure_element.V1_2.ISecureElement mSEHal12;
/** For each Terminal there will be one AccessController object. */
private AccessControlEnforcer mAccessControlEnforcer;
@@ -191,25 +192,33 @@ public class Terminal {
* @throws RemoteException if there is a failure communicating with the remote
*/
public void initialize(boolean retryOnFail) throws NoSuchElementException, RemoteException {
+ android.hardware.secure_element.V1_1.ISecureElement mSEHal11 = null;
synchronized (mLock) {
- android.hardware.secure_element.V1_1.ISecureElement seHal11 = null;
try {
- seHal11 =
- android.hardware.secure_element.V1_1.ISecureElement.getService(mName,
+ mSEHal = mSEHal11 = mSEHal12 =
+ android.hardware.secure_element.V1_2.ISecureElement.getService(mName,
retryOnFail);
} catch (Exception e) {
- Log.d(mTag, "SE Hal V1.1 is not supported");
+ Log.d(mTag, "SE Hal V1.2 is not supported");
}
+ if (mSEHal12 == null) {
+ try {
+ mSEHal = mSEHal11 =
+ android.hardware.secure_element.V1_1.ISecureElement.getService(mName,
+ retryOnFail);
+ } catch (Exception e) {
+ Log.d(mTag, "SE Hal V1.1 is not supported");
+ }
- if (seHal11 == null) {
- mSEHal = ISecureElement.getService(mName, retryOnFail);
- if (mSEHal == null) {
- throw new NoSuchElementException("No HAL is provided for " + mName);
+ if (mSEHal11 == null) {
+ mSEHal = ISecureElement.getService(mName, retryOnFail);
+ if (mSEHal == null) {
+ throw new NoSuchElementException("No HAL is provided for " + mName);
+ }
}
}
- if (seHal11 != null) {
- mSEHal = seHal11;
- seHal11.init_1_1(mHalCallback11);
+ if (mSEHal11 != null || mSEHal12 != null) {
+ mSEHal11.init_1_1(mHalCallback11);
} else {
mSEHal.init(mHalCallback);
}
@@ -664,6 +673,31 @@ public class Terminal {
}
/**
+ * Reset the Secure Element. Return true if success, false otherwise.
+ */
+ public boolean reset() {
+ if (mSEHal12 == null) {
+ return false;
+ }
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.SECURE_ELEMENT_PRIVILEGED,
+ "Need SECURE_ELEMENT_PRIVILEGED permission");
+
+ try {
+ byte status = mSEHal12.reset();
+ // Successfully trigger reset. HAL service should send onStateChange
+ // after secure element reset and initialization process complete
+ if (status == SecureElementStatus.SUCCESS) {
+ return true;
+ }
+ Log.e(mTag, "Error reseting terminal " + mName);
+ } catch (RemoteException e) {
+ Log.e(mTag, "Exception in reset()" + e);
+ }
+ return false;
+ }
+
+ /**
* Initialize the Access Control and set up the channel access.
*/
private ChannelAccess setUpChannelAccess(byte[] aid, String packageName, int pid)
@@ -874,5 +908,10 @@ public class Terminal {
Terminal getTerminal() {
return Terminal.this;
}
+
+ @Override
+ public boolean reset() {
+ return Terminal.this.reset();
+ }
}
}