diff options
author | 2021-09-14 05:34:11 +0000 | |
---|---|---|
committer | 2021-10-11 15:51:58 +0000 | |
commit | 4fe64fb4712a99d5da9c9a0eb8fd5169b252e1e1 (patch) | |
tree | 8a21b30c630f9d7205e658f531e67c64fd13e2da | |
parent | 70e7dd44b422ec4727dce5f6984692bf76a8ca85 (diff) |
Support for OMAPI Vendor stable interface
Changes are made to existing OMAPI inteface to make it as Vendor Stable
Interface.
Bug: b/180639372
Test: Run OMAPI CTS and VTS tests
Change-Id: Ibfd23215ad180d78af843c0d0b394b42ba8e9daa
19 files changed, 311 insertions, 17 deletions
diff --git a/Android.bp b/Android.bp index d976b9172602..794afc8599ef 100644 --- a/Android.bp +++ b/Android.bp @@ -82,6 +82,7 @@ filegroup { ":framework-mca-filterpacks-sources", ":framework-media-sources", ":framework-mms-sources", + ":framework-omapi-sources", ":framework-opengl-sources", ":framework-rs-sources", ":framework-sax-sources", @@ -268,6 +269,7 @@ java_library { "android.hardware.vibrator-V1.2-java", "android.hardware.vibrator-V1.3-java", "android.hardware.vibrator-V2-java", + "android.se.omapi-V1-java", "android.system.suspend.control.internal-java", "devicepolicyprotosnano", diff --git a/omapi/aidl/Android.bp b/omapi/aidl/Android.bp new file mode 100644 index 000000000000..d80317bb8c60 --- /dev/null +++ b/omapi/aidl/Android.bp @@ -0,0 +1,32 @@ +// Copyright 2020, The Android Open Source Project +// +// 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 +// +// 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. + +package { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +aidl_interface { + name: "android.se.omapi", + vendor_available: true, + srcs: ["android/se/omapi/*.aidl"], + stability: "vintf", + backend: { + java: { + sdk_version: "module_current", + }, + rust: { + enabled: true, + }, + }, +} diff --git a/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementChannel.aidl b/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementChannel.aidl new file mode 100644 index 000000000000..725013a35cde --- /dev/null +++ b/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementChannel.aidl @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2021, The Android Open Source Project + * + * 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 + * + * 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. + *//* + * Contributed by: Giesecke & Devrient GmbH. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.se.omapi; +/* @hide */ +@VintfStability +interface ISecureElementChannel { + void close(); + boolean isClosed(); + boolean isBasicChannel(); + byte[] getSelectResponse(); + byte[] transmit(in byte[] command); + boolean selectNext(); +} diff --git a/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementListener.aidl b/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementListener.aidl new file mode 100644 index 000000000000..77e1c53f47ac --- /dev/null +++ b/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementListener.aidl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2017, The Android Open Source Project + * + * 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 + * + * 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. + *//* + * Contributed by: Giesecke & Devrient GmbH. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.se.omapi; +/* @hide */ +@VintfStability +interface ISecureElementListener { +} diff --git a/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementReader.aidl b/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementReader.aidl new file mode 100644 index 000000000000..2b10c473c902 --- /dev/null +++ b/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementReader.aidl @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2017, The Android Open Source Project + * + * 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 + * + * 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. + *//* + * Contributed by: Giesecke & Devrient GmbH. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.se.omapi; +/* @hide */ +@VintfStability +interface ISecureElementReader { + boolean isSecureElementPresent(); + android.se.omapi.ISecureElementSession openSession(); + void closeSessions(); + boolean reset(); +} diff --git a/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementService.aidl b/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementService.aidl new file mode 100644 index 000000000000..ae6346278691 --- /dev/null +++ b/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementService.aidl @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2017, The Android Open Source Project + * + * 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 + * + * 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. + *//* + * Copyright (c) 2015-2017, The Linux Foundation. + *//* + * Contributed by: Giesecke & Devrient GmbH. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.se.omapi; +/* @hide */ +@VintfStability +interface ISecureElementService { + String[] getReaders(); + android.se.omapi.ISecureElementReader getReader(in String reader); + boolean[] isNFCEventAllowed(in String reader, in byte[] aid, in String[] packageNames); +} diff --git a/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementSession.aidl b/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementSession.aidl new file mode 100644 index 000000000000..06287c551f5c --- /dev/null +++ b/omapi/aidl/aidl_api/android.se.omapi/current/android/se/omapi/ISecureElementSession.aidl @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2017, The Android Open Source Project + * + * 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 + * + * 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. + *//* + * Copyright (c) 2015-2017, The Linux Foundation. + *//* + * Contributed by: Giesecke & Devrient GmbH. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m <name>-update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.se.omapi; +/* @hide */ +@VintfStability +interface ISecureElementSession { + byte[] getAtr(); + void close(); + void closeChannels(); + boolean isClosed(); + android.se.omapi.ISecureElementChannel openBasicChannel(in byte[] aid, in byte p2, in android.se.omapi.ISecureElementListener listener); + android.se.omapi.ISecureElementChannel openLogicalChannel(in byte[] aid, in byte p2, in android.se.omapi.ISecureElementListener listener); +} diff --git a/core/java/android/se/omapi/ISecureElementChannel.aidl b/omapi/aidl/android/se/omapi/ISecureElementChannel.aidl index 4ae57ab829cb..bbd3c148caaf 100644 --- a/core/java/android/se/omapi/ISecureElementChannel.aidl +++ b/omapi/aidl/android/se/omapi/ISecureElementChannel.aidl @@ -22,6 +22,7 @@ package android.se.omapi; import android.se.omapi.ISecureElementSession; /** @hide */ +@VintfStability interface ISecureElementChannel { /** @@ -58,6 +59,9 @@ interface ISecureElementChannel { * Transmits the specified command APDU and returns the response APDU. * MANAGE channel commands are not supported. * Selection of applets is not supported in logical channels. + * + * @param command Command APDU, its structure is defined in ISO/IEC 7816-4 + * in Standard byte format */ byte[] transmit(in byte[] command); diff --git a/core/java/android/se/omapi/ISecureElementListener.aidl b/omapi/aidl/android/se/omapi/ISecureElementListener.aidl index e9dd18181c56..479dcd7d5acf 100644 --- a/core/java/android/se/omapi/ISecureElementListener.aidl +++ b/omapi/aidl/android/se/omapi/ISecureElementListener.aidl @@ -23,5 +23,6 @@ package android.se.omapi; * Interface to receive call-backs when the service is connected. * @hide */ +@VintfStability interface ISecureElementListener { } diff --git a/core/java/android/se/omapi/ISecureElementReader.aidl b/omapi/aidl/android/se/omapi/ISecureElementReader.aidl index 41244ab058e0..a6979face61f 100644 --- a/core/java/android/se/omapi/ISecureElementReader.aidl +++ b/omapi/aidl/android/se/omapi/ISecureElementReader.aidl @@ -22,6 +22,7 @@ package android.se.omapi; import android.se.omapi.ISecureElementSession; /** @hide */ +@VintfStability interface ISecureElementReader { /** @@ -34,7 +35,7 @@ interface ISecureElementReader { * Connects to a secure element in this reader. <br> * This method prepares (initialises) the Secure Element for communication * before the Session object is returned (e.g. powers the Secure Element by - * ICC ON if its not already on). There might be multiple sessions opened at + * ICC ON if it is not already on). There might be multiple sessions opened at * the same time on the same reader. The system ensures the interleaving of * APDUs between the respective sessions. * diff --git a/core/java/android/se/omapi/ISecureElementService.aidl b/omapi/aidl/android/se/omapi/ISecureElementService.aidl index 4fa799e78757..61ae4816de82 100644 --- a/core/java/android/se/omapi/ISecureElementService.aidl +++ b/omapi/aidl/android/se/omapi/ISecureElementService.aidl @@ -28,23 +28,31 @@ import android.se.omapi.ISecureElementReader; * SecureElement service interface. * @hide */ +@VintfStability interface ISecureElementService { /** * Returns the friendly names of available Secure Element readers. + * <ul> + * <li>If the reader is a SIM reader, then its name must be "SIM[Slot]".</li> + * <li>If the reader is a SD or micro SD reader, then its name must be "SD[Slot]"</li> + * <li>If the reader is a embedded SE reader, then its name must be "eSE[Slot]"</li> + * </ul> + * Slot is a decimal number without leading zeros. The Numbering must start with 1 + * (e.g. SIM1, SIM2, ... or SD1, SD2, ... or eSE1, eSE2, ...). */ String[] getReaders(); /** * Returns SecureElement Service reader object to the given name. */ - ISecureElementReader getReader(String reader); + ISecureElementReader getReader(in String reader); /** * Checks if the application defined by the package name is allowed to * receive NFC transaction events for the defined AID. */ - boolean[] isNFCEventAllowed(String reader, in byte[] aid, + boolean[] isNFCEventAllowed(in String reader, in byte[] aid, in String[] packageNames); } diff --git a/core/java/android/se/omapi/ISecureElementSession.aidl b/omapi/aidl/android/se/omapi/ISecureElementSession.aidl index 8ea599f2e866..129ecc4ddaa3 100644 --- a/core/java/android/se/omapi/ISecureElementSession.aidl +++ b/omapi/aidl/android/se/omapi/ISecureElementSession.aidl @@ -27,6 +27,7 @@ import android.se.omapi.ISecureElementReader; import android.se.omapi.ISecureElementListener; /** @hide */ +@VintfStability interface ISecureElementSession { /** @@ -45,7 +46,6 @@ interface ISecureElementSession { */ void closeChannels(); - /** * Tells if this session is closed. * @@ -59,15 +59,19 @@ interface ISecureElementSession { * applet if aid != null. * Logical channels cannot be opened with this connection. * Use interface method openLogicalChannel() to open a logical channel. + * Listener is passed to secure element service and used to monitor whether + * the client application that uses OMAPI is still alive or not. */ ISecureElementChannel openBasicChannel(in byte[] aid, in byte p2, - ISecureElementListener listener); + in ISecureElementListener listener); /** * Opens a connection using the next free logical channel of the card in the * specified reader. Selects the specified applet. * Selection of other applets with this connection is not supported. + * Listener is passed to secure element service and used to monitor whether + * the client application that uses OMAPI is still alive or not. */ ISecureElementChannel openLogicalChannel(in byte[] aid, in byte p2, - ISecureElementListener listener); + in ISecureElementListener listener); } diff --git a/omapi/java/Android.bp b/omapi/java/Android.bp new file mode 100644 index 000000000000..8d38da048d9b --- /dev/null +++ b/omapi/java/Android.bp @@ -0,0 +1,17 @@ +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "frameworks_base_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + default_applicable_licenses: ["frameworks_base_license"], +} + +filegroup { + name: "framework-omapi-sources", + srcs: [ + "**/*.java", + "**/*.aidl", + ], + visibility: ["//frameworks/base"], +} diff --git a/core/java/android/se/OWNERS b/omapi/java/android/se/OWNERS index 5682fd3281f4..5682fd3281f4 100644 --- a/core/java/android/se/OWNERS +++ b/omapi/java/android/se/OWNERS diff --git a/core/java/android/se/omapi/Channel.java b/omapi/java/android/se/omapi/Channel.java index 90ce11ae0313..90ce11ae0313 100644 --- a/core/java/android/se/omapi/Channel.java +++ b/omapi/java/android/se/omapi/Channel.java diff --git a/core/java/android/se/omapi/OWNERS b/omapi/java/android/se/omapi/OWNERS index 5682fd3281f4..5682fd3281f4 100644 --- a/core/java/android/se/omapi/OWNERS +++ b/omapi/java/android/se/omapi/OWNERS diff --git a/core/java/android/se/omapi/Reader.java b/omapi/java/android/se/omapi/Reader.java index 90c934d189fa..3c2135d9bc9d 100644 --- a/core/java/android/se/omapi/Reader.java +++ b/omapi/java/android/se/omapi/Reader.java @@ -170,7 +170,9 @@ public final class Reader { try { closeSessions(); return mReader.reset(); - } catch (RemoteException ignore) {return false;} + } catch (RemoteException ignore) { + return false; + } } } } diff --git a/core/java/android/se/omapi/SEService.java b/omapi/java/android/se/omapi/SEService.java index 333af91ac872..f42ca364b6d9 100644 --- a/core/java/android/se/omapi/SEService.java +++ b/omapi/java/android/se/omapi/SEService.java @@ -230,20 +230,20 @@ public final class SEService { * is not exist. * @return A Reader object for this uicc slot. */ - public @NonNull Reader getUiccReader(int slotNumber) { - if (slotNumber < 1) { - throw new IllegalArgumentException("slotNumber should be larger than 0"); - } - loadReaders(); + public @NonNull Reader getUiccReader(int slotNumber) { + if (slotNumber < 1) { + throw new IllegalArgumentException("slotNumber should be larger than 0"); + } + loadReaders(); - String readerName = UICC_TERMINAL + slotNumber; - Reader reader = mReaders.get(readerName); + String readerName = UICC_TERMINAL + slotNumber; + Reader reader = mReaders.get(readerName); - if (reader == null) { + if (reader == null) { throw new IllegalArgumentException("Reader:" + readerName + " doesn't exist"); - } + } - return reader; + return reader; } /** diff --git a/core/java/android/se/omapi/Session.java b/omapi/java/android/se/omapi/Session.java index d5f8c82bf47e..d5f8c82bf47e 100644 --- a/core/java/android/se/omapi/Session.java +++ b/omapi/java/android/se/omapi/Session.java |