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
This commit is contained in:
Rajesh Nyamagoud
2021-09-14 05:34:11 +00:00
parent 70e7dd44b4
commit 4fe64fb471
19 changed files with 311 additions and 17 deletions

View File

@@ -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",

32
omapi/aidl/Android.bp Normal file
View File

@@ -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,
},
},
}

View File

@@ -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();
}

View File

@@ -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 {
}

View File

@@ -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();
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -23,5 +23,6 @@ package android.se.omapi;
* Interface to receive call-backs when the service is connected.
* @hide
*/
@VintfStability
interface ISecureElementListener {
}

View File

@@ -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.
*

View File

@@ -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);
}

View File

@@ -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);
}

17
omapi/java/Android.bp Normal file
View File

@@ -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"],
}

View File

@@ -170,7 +170,9 @@ public final class Reader {
try {
closeSessions();
return mReader.reset();
} catch (RemoteException ignore) {return false;}
} catch (RemoteException ignore) {
return false;
}
}
}
}

View File

@@ -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;
}
/**