Support dual SE am: 68546a4f4d

Original change: https://android-review.googlesource.com/c/platform/hardware/st/secure_element2/+/1436834

Change-Id: If9e8c6650806faf7b09b265cac497b4a71627cf5
diff --git a/secure_element/1.0/GtoService.cpp b/secure_element/1.0/GtoService.cpp
index 623cb16..1d1cd1b 100644
--- a/secure_element/1.0/GtoService.cpp
+++ b/secure_element/1.0/GtoService.cpp
@@ -26,8 +26,8 @@
 using android::status_t;
 
 int main() {
-  ALOGD("Gemalto Secure Element HAL Service 1.0.1 is starting. libse-gto v1.12");
-  sp<ISecureElement> se_service = new SecureElement();
+  ALOGD("Gemalto Secure Element HAL for eSE1 Service 1.3.0 is starting. libse-gto v1.12");
+  sp<ISecureElement> se_service = new SecureElement("/vendor/etc/libse-gto-hal.conf");
   configureRpcThreadpool(1, true);
   status_t status = se_service->registerAsService("eSE1");
   if (status != OK) {
diff --git a/secure_element/1.0/GtoService_ese2.cpp b/secure_element/1.0/GtoService_ese2.cpp
new file mode 100644
index 0000000..803fab4
--- /dev/null
+++ b/secure_element/1.0/GtoService_ese2.cpp
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * Copyright ©2017-2019 Gemalto – a Thales Company. All rights Reserved.
+ *
+ * This copy is licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *     http://www.apache.org/licenses/LICENSE-2.0 or https://www.apache.org/licenses/LICENSE-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+
+ ****************************************************************************/
+#include <android/hardware/secure_element/1.0/ISecureElement.h>
+#include <hidl/LegacySupport.h>
+#include <log/log.h>
+
+#include "SecureElement.h"
+
+// Generated HIDL files
+using android::hardware::secure_element::V1_0::ISecureElement;
+using android::hardware::secure_element::V1_0::implementation::SecureElement;
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+using android::OK;
+using android::sp;
+using android::status_t;
+
+int main() {
+  ALOGD("Gemalto Secure Element HAL for eSE2 Service 1.3.0 is starting. libse-gto v1.12");
+  sp<ISecureElement> se_service = new SecureElement("/vendor/etc/libse-gto-hal2.conf");
+  configureRpcThreadpool(1, true);
+  status_t status = se_service->registerAsService("eSE2");
+  if (status != OK) {
+    LOG_ALWAYS_FATAL(
+        "registerAsService (%d).",
+        status);
+    return -1;
+  }
+
+  ALOGD("Gemalto Secure Element Service is ready");
+  joinRpcThreadpool();
+  return 1;
+}
diff --git a/secure_element/1.0/SecureElement.cpp b/secure_element/1.0/SecureElement.cpp
index f4e7a5f..e610ecd 100644
--- a/secure_element/1.0/SecureElement.cpp
+++ b/secure_element/1.0/SecureElement.cpp
@@ -49,9 +49,10 @@
 
 static struct se_gto_ctx *ctx;
 
-SecureElement::SecureElement(){
+SecureElement::SecureElement(const char* configFile_name){
     nbrOpenChannel = 0;
     ctx = NULL;
+    strcpy( config_filename, configFile_name);
 }
 
 int SecureElement::resetSE(){
@@ -581,24 +582,24 @@
 {
     int   r;
     FILE *f;
-    char filename[] = "/vendor/etc/libse-gto-hal.conf";
+
 
     /* filename is not NULL */
-    ALOGD("SecureElement:%s Open Config file : %s", __func__, filename);
-    f = fopen(filename, "r");
+    ALOGD("SecureElement:%s Open Config file : %s", __func__, config_filename);
+    f = fopen(config_filename, "r");
     if (f) {
         r = parseConfigFile(f, verbose);
         if (r == -1) {
-            perror(filename);
-            ALOGE("SecureElement:%s Error parse %s Failed", __func__, filename);
+            perror(config_filename);
+            ALOGE("SecureElement:%s Error parse %s Failed", __func__, config_filename);
         }
         if (fclose(f) != 0) {
             r = -1;
-            ALOGE("SecureElement:%s Error close %s Failed", __func__, filename);
+            ALOGE("SecureElement:%s Error close %s Failed", __func__, config_filename);
         }
     } else {
         r = -1;
-        ALOGE("SecureElement:%s Error open %s Failed", __func__, filename);
+        ALOGE("SecureElement:%s Error open %s Failed", __func__, config_filename);
     }
     return r;
 }
diff --git a/secure_element/1.0/SecureElement.h b/secure_element/1.0/SecureElement.h
index a7ff072..a87830e 100644
--- a/secure_element/1.0/SecureElement.h
+++ b/secure_element/1.0/SecureElement.h
@@ -34,7 +34,7 @@
 
 struct SecureElement : public ISecureElement , public hidl_death_recipient {
     // Methods from ::android::hardware::secure_element::V1_0::ISecureElement follow.
-    SecureElement();
+    SecureElement(const char* configFile_name);
     Return<void> init(const sp<V1_0::ISecureElementHalCallback>& clientCallback) override;
     Return<void> openLogicalChannel(const hidl_vec<uint8_t>& aid, uint8_t p2, openLogicalChannel_cb _hidl_cb) override;
     Return<void> openBasicChannel(const hidl_vec<uint8_t>& aid, uint8_t p2, openBasicChannel_cb _hidl_cb) override;
@@ -52,6 +52,7 @@
     bool turnOffSE = true;
     uint8_t atr[32];
     uint8_t atr_size;
+    char config_filename[100];
     static sp<V1_0::ISecureElementHalCallback> internalClientCallback;
     int initializeSE();
     Return<::android::hardware::secure_element::V1_0::SecureElementStatus> deinitializeSE();
diff --git a/secure_element/1.0/android.hardware.secure_element@1.0-service-gto-ese2.rc b/secure_element/1.0/android.hardware.secure_element@1.0-service-gto-ese2.rc
new file mode 100644
index 0000000..c03d935
--- /dev/null
+++ b/secure_element/1.0/android.hardware.secure_element@1.0-service-gto-ese2.rc
@@ -0,0 +1,4 @@
+service gto_secure_element_hal_service_ese2 /vendor/bin/hw/android.hardware.secure_element@1.0-service-gto-ese2
+    class hal
+    user secure_element
+    group secure_element
diff --git a/secure_element/1.1/GtoService.cpp b/secure_element/1.1/GtoService.cpp
index 263d9e1..ba95755 100644
--- a/secure_element/1.1/GtoService.cpp
+++ b/secure_element/1.1/GtoService.cpp
@@ -28,7 +28,7 @@
 int main() {
   ALOGD("android::hardware::secure_element::V1_1 is starting.");
   ALOGD("Thales Secure Element HAL Service Release 1.1.1 ==> libse-gto v1.12");
-  sp<ISecureElement> se_service = new SecureElement();
+  sp<ISecureElement> se_service = new SecureElement("/vendor/etc/libse-gto-hal.conf");
   configureRpcThreadpool(1, true);
   status_t status = se_service->registerAsService("eSE1");
   if (status != OK) {
diff --git a/secure_element/1.1/GtoService_ese2.cpp b/secure_element/1.1/GtoService_ese2.cpp
new file mode 100644
index 0000000..4c9cd10
--- /dev/null
+++ b/secure_element/1.1/GtoService_ese2.cpp
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * Copyright ©2017-2019 Gemalto – a Thales Company. All rights Reserved.
+ *
+ * This copy is licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *     http://www.apache.org/licenses/LICENSE-2.0 or https://www.apache.org/licenses/LICENSE-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+
+ ****************************************************************************/
+#include <android/hardware/secure_element/1.1/ISecureElement.h>
+#include <hidl/LegacySupport.h>
+#include <log/log.h>
+
+#include "SecureElement.h"
+
+// Generated HIDL files
+using android::hardware::secure_element::V1_1::ISecureElement;
+using android::hardware::secure_element::V1_1::implementation::SecureElement;
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+using android::OK;
+using android::sp;
+using android::status_t;
+
+int main() {
+  ALOGD("Gemalto Secure Element HAL for eSE2 Service 1.3.0 is starting. libse-gto v1.12");
+  sp<ISecureElement> se_service = new SecureElement("/vendor/etc/libse-gto-hal2.conf");
+  configureRpcThreadpool(1, true);
+  status_t status = se_service->registerAsService("eSE2");
+  if (status != OK) {
+    LOG_ALWAYS_FATAL(
+        "registerAsService (%d).",
+        status);
+    return -1;
+  }
+
+  ALOGD("Gemalto Secure Element Service is ready");
+  joinRpcThreadpool();
+  return 1;
+}
diff --git a/secure_element/1.1/SecureElement.cpp b/secure_element/1.1/SecureElement.cpp
index fb3d4c5..7f34672 100644
--- a/secure_element/1.1/SecureElement.cpp
+++ b/secure_element/1.1/SecureElement.cpp
@@ -49,9 +49,10 @@
 
 static struct se_gto_ctx *ctx;
 
-SecureElement::SecureElement(){
+SecureElement::SecureElement(const char* configFile_name){
     nbrOpenChannel = 0;
     ctx = NULL;
+    strcpy( config_filename, configFile_name);
 }
 
 int SecureElement::resetSE(){
@@ -612,24 +613,24 @@
 {
     int   r;
     FILE *f;
-    char filename[] = "/vendor/etc/libse-gto-hal.conf";
+
 
     /* filename is not NULL */
-    ALOGD("SecureElement:%s Open Config file : %s", __func__, filename);
-    f = fopen(filename, "r");
+    ALOGD("SecureElement:%s Open Config file : %s", __func__, config_filename);
+    f = fopen(config_filename, "r");
     if (f) {
         r = parseConfigFile(f, verbose);
         if (r == -1) {
-            perror(filename);
-            ALOGE("SecureElement:%s Error parse %s Failed", __func__, filename);
+            perror(config_filename);
+            ALOGE("SecureElement:%s Error parse %s Failed", __func__, config_filename);
         }
         if (fclose(f) != 0) {
             r = -1;
-            ALOGE("SecureElement:%s Error close %s Failed", __func__, filename);
+            ALOGE("SecureElement:%s Error close %s Failed", __func__, config_filename);
         }
     } else {
         r = -1;
-        ALOGE("SecureElement:%s Error open %s Failed", __func__, filename);
+        ALOGE("SecureElement:%s Error open %s Failed", __func__, config_filename);
     }
     return r;
 }
@@ -667,6 +668,7 @@
         }
         checkSeUp = false;
         turnOffSE = false;
+
     }else{
         ALOGD("SecureElement:%s No need to deinitialize SE", __func__);
         mSecureElementStatus = SecureElementStatus::SUCCESS;
diff --git a/secure_element/1.1/SecureElement.h b/secure_element/1.1/SecureElement.h
index ddeef79..852aca9 100644
--- a/secure_element/1.1/SecureElement.h
+++ b/secure_element/1.1/SecureElement.h
@@ -37,7 +37,7 @@
 
 
 struct SecureElement : public ISecureElement , public hidl_death_recipient {
-    SecureElement();
+    SecureElement(const char* configFile_name);
     Return<void> init(const sp<V1_0::ISecureElementHalCallback>& clientCallback) override;
     Return<void> init_1_1(const sp<V1_1::ISecureElementHalCallback>& clientCallback) override;
     Return<void> openLogicalChannel(const hidl_vec<uint8_t>& aid, uint8_t p2, openLogicalChannel_cb _hidl_cb) override;
@@ -55,6 +55,7 @@
     bool turnOffSE = true;
     uint8_t atr[32];
     uint8_t atr_size;
+    char config_filename[100];
     static sp<V1_0::ISecureElementHalCallback> internalClientCallback;
     static sp<V1_1::ISecureElementHalCallback> internalClientCallback_v1_1;
     int initializeSE();
diff --git a/secure_element/1.1/android.hardware.secure_element@1.1-service-gto-ese2.rc b/secure_element/1.1/android.hardware.secure_element@1.1-service-gto-ese2.rc
new file mode 100644
index 0000000..7c94429
--- /dev/null
+++ b/secure_element/1.1/android.hardware.secure_element@1.1-service-gto-ese2.rc
@@ -0,0 +1,4 @@
+service gto_secure_element_hal_service_ese2_1_1 /vendor/bin/hw/android.hardware.secure_element@1.1-service-gto-ese2
+    class hal
+    user secure_element
+    group secure_element
diff --git a/secure_element/1.2/GtoService.cpp b/secure_element/1.2/GtoService.cpp
index 72f6542..8bc9d59 100644
--- a/secure_element/1.2/GtoService.cpp
+++ b/secure_element/1.2/GtoService.cpp
@@ -28,7 +28,7 @@
 int main() {
   ALOGD("android::hardware::secure_element::V1_2 is starting.");
   ALOGD("Thales Secure Element HAL Service Release 1.2.2 ==> libse-gto v1.12");
-  sp<ISecureElement> se_service = new SecureElement();
+  sp<ISecureElement> se_service = new SecureElement("/vendor/etc/libse-gto-hal.conf");
   //sp<ISecureElement> se_service2 = new SecureElement();
   configureRpcThreadpool(1, true);
   status_t status = se_service->registerAsService("eSE1");
diff --git a/secure_element/1.2/GtoService_ese2.cpp b/secure_element/1.2/GtoService_ese2.cpp
new file mode 100644
index 0000000..a6042df
--- /dev/null
+++ b/secure_element/1.2/GtoService_ese2.cpp
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * Copyright ©2017-2019 Gemalto – a Thales Company. All rights Reserved.
+ *
+ * This copy is licensed under the Apache License, Version 2.0 (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *     http://www.apache.org/licenses/LICENSE-2.0 or https://www.apache.org/licenses/LICENSE-2.0.html
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations under the License.
+
+ ****************************************************************************/
+#include <android/hardware/secure_element/1.2/ISecureElement.h>
+#include <hidl/LegacySupport.h>
+#include <log/log.h>
+
+#include "SecureElement.h"
+
+// Generated HIDL files
+using android::hardware::secure_element::V1_2::ISecureElement;
+using android::hardware::secure_element::V1_2::implementation::SecureElement;
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+using android::OK;
+using android::sp;
+using android::status_t;
+
+int main() {
+  ALOGD("Gemalto Secure Element HAL for eSE2 Service 1.3.0 is starting. libse-gto v1.12");
+  sp<ISecureElement> se_service = new SecureElement("/vendor/etc/libse-gto-hal2.conf");
+  configureRpcThreadpool(1, true);
+  status_t status = se_service->registerAsService("eSE2");
+  if (status != OK) {
+    LOG_ALWAYS_FATAL(
+        "registerAsService (%d).",
+        status);
+    return -1;
+  }
+
+  ALOGD("Gemalto Secure Element Service is ready");
+  joinRpcThreadpool();
+  return 1;
+}
diff --git a/secure_element/1.2/SecureElement.cpp b/secure_element/1.2/SecureElement.cpp
index 4d459e8..0fcaa0d 100644
--- a/secure_element/1.2/SecureElement.cpp
+++ b/secure_element/1.2/SecureElement.cpp
@@ -49,9 +49,10 @@
 
 static struct se_gto_ctx *ctx;
 
-SecureElement::SecureElement(){
+SecureElement::SecureElement(const char* configFile_name){
     nbrOpenChannel = 0;
     ctx = NULL;
+    strcpy( config_filename, configFile_name);
 }
 
 int SecureElement::resetSE(){
@@ -612,24 +613,24 @@
 {
     int   r;
     FILE *f;
-    char filename[] = "/vendor/etc/libse-gto-hal.conf";
+
 
     /* filename is not NULL */
-    ALOGD("SecureElement:%s Open Config file : %s", __func__, filename);
-    f = fopen(filename, "r");
+    ALOGD("SecureElement:%s Open Config file : %s", __func__, config_filename);
+    f = fopen(config_filename, "r");
     if (f) {
         r = parseConfigFile(f, verbose);
         if (r == -1) {
-            perror(filename);
-            ALOGE("SecureElement:%s Error parse %s Failed", __func__, filename);
+            perror(config_filename);
+            ALOGE("SecureElement:%s Error parse %s Failed", __func__, config_filename);
         }
         if (fclose(f) != 0) {
             r = -1;
-            ALOGE("SecureElement:%s Error close %s Failed", __func__, filename);
+            ALOGE("SecureElement:%s Error close %s Failed", __func__, config_filename);
         }
     } else {
         r = -1;
-        ALOGE("SecureElement:%s Error open %s Failed", __func__, filename);
+        ALOGE("SecureElement:%s Error open %s Failed", __func__, config_filename);
     }
     return r;
 }
diff --git a/secure_element/1.2/SecureElement.h b/secure_element/1.2/SecureElement.h
index 71630c7..a2015ea 100644
--- a/secure_element/1.2/SecureElement.h
+++ b/secure_element/1.2/SecureElement.h
@@ -37,7 +37,7 @@
 
 
 struct SecureElement : public ISecureElement , public hidl_death_recipient {
-    SecureElement();
+    SecureElement(const char* configFile_name);
     Return<void> init(const sp<V1_0::ISecureElementHalCallback>& clientCallback) override;
     Return<void> init_1_1(const sp<V1_1::ISecureElementHalCallback>& clientCallback) override;
     Return<void> openLogicalChannel(const hidl_vec<uint8_t>& aid, uint8_t p2, openLogicalChannel_cb _hidl_cb) override;
@@ -56,6 +56,7 @@
     bool turnOffSE = true;
     uint8_t atr[32];
     uint8_t atr_size;
+    char config_filename[100];
     static sp<V1_0::ISecureElementHalCallback> internalClientCallback;
     static sp<V1_1::ISecureElementHalCallback> internalClientCallback_v1_1;
     int initializeSE();
diff --git a/secure_element/1.2/android.hardware.secure_element@1.1-service-gto-ese2.rc b/secure_element/1.2/android.hardware.secure_element@1.1-service-gto-ese2.rc
new file mode 100644
index 0000000..7c94429
--- /dev/null
+++ b/secure_element/1.2/android.hardware.secure_element@1.1-service-gto-ese2.rc
@@ -0,0 +1,4 @@
+service gto_secure_element_hal_service_ese2_1_1 /vendor/bin/hw/android.hardware.secure_element@1.1-service-gto-ese2
+    class hal
+    user secure_element
+    group secure_element
diff --git a/secure_element/1.2/android.hardware.secure_element@1.2-service-gto-ese2.rc b/secure_element/1.2/android.hardware.secure_element@1.2-service-gto-ese2.rc
new file mode 100644
index 0000000..165f308
--- /dev/null
+++ b/secure_element/1.2/android.hardware.secure_element@1.2-service-gto-ese2.rc
@@ -0,0 +1,4 @@
+service gto_secure_element_hal_service_ese2_1_2 /vendor/bin/hw/android.hardware.secure_element@1.2-service-gto-ese2
+    class hal
+    user secure_element
+    group secure_element
diff --git a/secure_element/Android.bp b/secure_element/Android.bp
index 3270488..a30615b 100644
--- a/secure_element/Android.bp
+++ b/secure_element/Android.bp
@@ -231,3 +231,239 @@
         "libutils",
     ],
 }
+
+// --------------------------------------------------------------------------------
+
+cc_library_shared {
+    // FIXME: this should only be -impl for a passthrough hal.
+    // In most cases, to convert this to a binderized implementation, you should:
+    // - change '-impl' to '-service' here and make it a cc_binary instead of a
+    //   cc_library_shared.
+    // - add a *.rc file for this module.
+    // - delete HIDL_FETCH_I* functions.
+    // - call configureRpcThreadpool and registerAsService on the instance.
+    // You may also want to append '-impl/-service' with a specific identifier like
+    // '-vendor' or '-<hardware identifier>' etc to distinguish it.
+    name: "android.hardware.secure_element@1.0-impl-gto-ese2",
+    //relative_install_path: "hw",
+    // FIXME: this should be 'vendor: true' for modules that will eventually be
+    // on AOSP.
+    vendor: true,
+    srcs: [
+        "1.0/esehal/src/checksum.c",
+        "1.0/esehal/src/iso7816_t1.c",
+        "1.0/esehal/src/libse-gto.c",
+        "1.0/esehal/src/spi.c",
+        "1.0/esehal/src/transport.c",
+        "1.0/esehal/src/log.c",
+        "1.0/SecureElement.cpp",
+    ],
+
+    local_include_dirs: [
+        "1.0/esehal/src",
+    ],
+
+    cflags: [
+        "-DANDROID",
+        "-DENABLE_LOGGING=1",
+        "-DENABLE_DEBUG=1",
+        "-DBUILDCFG=1",
+        "-DNXP_EXTNS=TRUE",
+        "-Wno-unused-parameter",
+        "-Wno-unused-private-field",
+        "-Wno-error",
+        "-Wreturn-type",
+    ],
+
+    shared_libs: [
+        "libbase",
+        "libcutils",
+        "libhardware",
+        "libhidlbase",
+        "liblog",
+        "libutils",
+        "android.hardware.secure_element@1.0",
+    ],
+
+}
+
+cc_binary {
+    name: "android.hardware.secure_element@1.0-service-gto-ese2",
+    relative_install_path: "hw",
+    init_rc: ["1.0/android.hardware.secure_element@1.0-service-gto-ese2.rc"],
+    vendor: true,
+    defaults: ["hidl_defaults"],
+    srcs: [
+        "1.0/GtoService_ese2.cpp",
+    ],
+
+    shared_libs: [
+        "android.hardware.secure_element@1.0",
+        "android.hardware.secure_element@1.0-impl-gto-ese2",
+        "libbase",
+        "libcutils",
+        "libhardware",
+        "libhidlbase",
+        "liblog",
+        "libutils",
+    ],
+}
+
+cc_library_shared {
+    // FIXME: this should only be -impl for a passthrough hal.
+    // In most cases, to convert this to a binderized implementation, you should:
+    // - change '-impl' to '-service' here and make it a cc_binary instead of a
+    //   cc_library_shared.
+    // - add a *.rc file for this module.
+    // - delete HIDL_FETCH_I* functions.
+    // - call configureRpcThreadpool and registerAsService on the instance.
+    // You may also want to append '-impl/-service' with a specific identifier like
+    // '-vendor' or '-<hardware identifier>' etc to distinguish it.
+    name: "android.hardware.secure_element@1.1-impl-gto-ese2",
+    //relative_install_path: "hw",
+    // FIXME: this should be 'vendor: true' for modules that will eventually be
+    // on AOSP.
+    vendor: true,
+    srcs: [
+        "1.0/esehal/src/checksum.c",
+        "1.0/esehal/src/iso7816_t1.c",
+        "1.0/esehal/src/libse-gto.c",
+        "1.0/esehal/src/spi.c",
+        "1.0/esehal/src/transport.c",
+        "1.0/esehal/src/log.c",
+        "1.1/SecureElement.cpp",
+    ],
+
+    local_include_dirs: [
+        "1.0/esehal/src",
+    ],
+
+    cflags: [
+        "-DANDROID",
+        "-DENABLE_LOGGING=1",
+        "-DENABLE_DEBUG=1",
+        "-DBUILDCFG=1",
+        "-DNXP_EXTNS=TRUE",
+        "-Wno-unused-parameter",
+        "-Wno-unused-private-field",
+        "-Wno-error",
+        "-Wreturn-type",
+    ],
+
+    shared_libs: [
+        "libbase",
+        "libcutils",
+        "libhardware",
+        "libhidlbase",
+        "liblog",
+        "libutils",
+        "android.hardware.secure_element@1.0",
+	"android.hardware.secure_element@1.1",
+    ],
+
+}
+
+cc_binary {
+    name: "android.hardware.secure_element@1.1-service-gto-ese2",
+    relative_install_path: "hw",
+    init_rc: ["1.1/android.hardware.secure_element@1.1-service-gto-ese2.rc"],
+    vendor: true,
+    defaults: ["hidl_defaults"],
+    srcs: [
+        "1.1/GtoService_ese2.cpp",
+    ],
+
+    shared_libs: [
+        "android.hardware.secure_element@1.0",
+        "android.hardware.secure_element@1.0-impl-gto-ese2",
+	"android.hardware.secure_element@1.1",
+        "android.hardware.secure_element@1.1-impl-gto-ese2",
+        "libbase",
+        "libcutils",
+        "libhardware",
+        "libhidlbase",
+        "liblog",
+        "libutils",
+    ],
+}
+
+cc_library_shared {
+    // FIXME: this should only be -impl for a passthrough hal.
+    // In most cases, to convert this to a binderized implementation, you should:
+    // - change '-impl' to '-service' here and make it a cc_binary instead of a
+    //   cc_library_shared.
+    // - add a *.rc file for this module.
+    // - delete HIDL_FETCH_I* functions.
+    // - call configureRpcThreadpool and registerAsService on the instance.
+    // You may also want to append '-impl/-service' with a specific identifier like
+    // '-vendor' or '-<hardware identifier>' etc to distinguish it.
+    name: "android.hardware.secure_element@1.2-impl-gto-ese2",
+    //relative_install_path: "hw",
+    // FIXME: this should be 'vendor: true' for modules that will eventually be
+    // on AOSP.
+    vendor: true,
+    srcs: [
+        "1.0/esehal/src/checksum.c",
+        "1.0/esehal/src/iso7816_t1.c",
+        "1.0/esehal/src/libse-gto.c",
+        "1.0/esehal/src/spi.c",
+        "1.0/esehal/src/transport.c",
+        "1.0/esehal/src/log.c",
+        "1.2/SecureElement.cpp",
+    ],
+
+    local_include_dirs: [
+        "1.0/esehal/src",
+    ],
+
+    cflags: [
+        "-DANDROID",
+        "-DENABLE_LOGGING=1",
+        "-DENABLE_DEBUG=1",
+        "-DBUILDCFG=1",
+        "-DNXP_EXTNS=TRUE",
+        "-Wno-unused-parameter",
+        "-Wno-unused-private-field",
+        "-Wno-error",
+        "-Wreturn-type",
+    ],
+
+    shared_libs: [
+        "libbase",
+        "libcutils",
+        "libhardware",
+        "libhidlbase",
+        "liblog",
+        "libutils",
+        "android.hardware.secure_element@1.0",
+	"android.hardware.secure_element@1.1",
+	"android.hardware.secure_element@1.2",
+    ],
+
+}
+
+cc_binary {
+    name: "android.hardware.secure_element@1.2-service-gto-ese2",
+    relative_install_path: "hw",
+    init_rc: ["1.2/android.hardware.secure_element@1.2-service-gto-ese2.rc"],
+    vendor: true,
+    defaults: ["hidl_defaults"],
+    srcs: [
+        "1.2/GtoService_ese2.cpp",
+    ],
+
+    shared_libs: [
+        "android.hardware.secure_element@1.0",
+        "android.hardware.secure_element@1.0-impl-gto-ese2",
+	"android.hardware.secure_element@1.1",
+        "android.hardware.secure_element@1.1-impl-gto-ese2",
+        "android.hardware.secure_element@1.2",
+        "android.hardware.secure_element@1.2-impl-gto-ese2",
+        "libbase",
+        "libcutils",
+        "libhardware",
+        "libhidlbase",
+        "liblog",
+        "libutils",
+    ],
+}