summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-01-24 07:57:27 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-01-24 07:57:27 +0000
commit276bf2cb4c8444db66e5bd81821d2943cc77e0a6 (patch)
treeabb8d999f3eb60c93f83f087cfc7bc89134c4f71
parent1c9b2734e4a11e54987bab3ce5fa2f27db5e72bd (diff)
parent5199b8777fdf74660a8c692e963cc4f580418d03 (diff)
downloadSecureElement-276bf2cb4c8444db66e5bd81821d2943cc77e0a6.tar.gz
Merge "Add support for secure_element HAL 1.2" am: 138fac9fd1 am: 463b696619 am: 5199b8777f
Change-Id: I825ebd3f5664543b774fe07090ab336e097df572
-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();
+ }
}
}