Add support for secure_element HAL 1.1
Test: manual
Bug: 122590188
Change-Id: I28d2bec166cf786fedd0444778583073492de804
diff --git a/Android.bp b/Android.bp
index 4175047..9649f23 100644
--- a/Android.bp
+++ b/Android.bp
@@ -3,7 +3,8 @@
srcs: ["src/**/*.java"],
platform_apis: true,
certificate: "platform",
- static_libs: ["android.hardware.secure_element-V1.0-java"],
+ static_libs: ["android.hardware.secure_element-V1.0-java",
+ "android.hardware.secure_element-V1.1-java"],
optimize: {
enabled: false,
},
diff --git a/src/com/android/se/Terminal.java b/src/com/android/se/Terminal.java
index efdb2b3..00382ef 100644
--- a/src/com/android/se/Terminal.java
+++ b/src/com/android/se/Terminal.java
@@ -81,30 +81,46 @@
private ISecureElementHalCallback.Stub mHalCallback = new ISecureElementHalCallback.Stub() {
@Override
public void onStateChange(boolean state) {
- synchronized (mLock) {
- Log.i(mTag, "OnStateChange:" + state);
- mIsConnected = state;
- if (!state) {
- if (mAccessControlEnforcer != null) {
- mAccessControlEnforcer.reset();
- }
- } else {
- // If any logical channel in use is in the channel list, it should be closed
- // because the access control enfocer allowed to open it by checking the access
- // rules retrieved before. Now we are going to retrieve the rules again and
- // the new rules can be different from the previous ones.
- closeChannels();
- try {
- initializeAccessControl();
- } catch (Exception e) {
- // ignore
- }
- mDefaultApplicationSelectedOnBasicChannel = true;
- }
- }
+ stateChange(state, "");
}
};
+ private android.hardware.secure_element.V1_1.ISecureElementHalCallback.Stub mHalCallback11 =
+ new android.hardware.secure_element.V1_1.ISecureElementHalCallback.Stub() {
+ @Override
+ public void onStateChange_1_1(boolean state, String reason) {
+ stateChange(state, reason);
+ }
+
+ public void onStateChange(boolean state) {
+ return;
+ }
+ };
+
+ private void stateChange(boolean state, String reason) {
+ synchronized (mLock) {
+ Log.i(mTag, "OnStateChange:" + state + " reason:" + reason);
+ mIsConnected = state;
+ if (!state) {
+ if (mAccessControlEnforcer != null) {
+ mAccessControlEnforcer.reset();
+ }
+ } else {
+ // If any logical channel in use is in the channel list, it should be closed
+ // because the access control enfocer allowed to open it by checking the access
+ // rules retrieved before. Now we are going to retrieve the rules again and
+ // the new rules can be different from the previous ones.
+ closeChannels();
+ try {
+ initializeAccessControl();
+ } catch (Exception e) {
+ // ignore
+ }
+ mDefaultApplicationSelectedOnBasicChannel = true;
+ }
+ }
+ }
+
class SecureElementDeathRecipient implements HwBinder.DeathRecipient {
@Override
public void serviceDied(long cookie) {
@@ -155,11 +171,20 @@
*/
public void initialize() throws NoSuchElementException, RemoteException {
synchronized (mLock) {
- mSEHal = ISecureElement.getService(mName, true);
- if (mSEHal == null) {
- throw new NoSuchElementException("No HAL is provided for " + mName);
+ android.hardware.secure_element.V1_1.ISecureElement seHal11 =
+ android.hardware.secure_element.V1_1.ISecureElement.getService(mName, true);
+ if (seHal11 == null) {
+ mSEHal = ISecureElement.getService(mName, true);
+ if (mSEHal == null) {
+ throw new NoSuchElementException("No HAL is provided for " + mName);
+ }
}
- mSEHal.init(mHalCallback);
+ if (seHal11 != null) {
+ seHal11.init_1_1(mHalCallback11);
+ mSEHal = seHal11;
+ } else {
+ mSEHal.init(mHalCallback);
+ }
mSEHal.linkToDeath(mDeathRecipient, 0);
}
Log.i(mTag, mName + " was initialized");