Merge "Modify Open Mobile API to follow Android API guidelines"
am: ee63876ed4
Change-Id: I29c43bcdccb3ba263c0a6a7e106c3c9180910c75
This commit is contained in:
@@ -37037,10 +37037,8 @@ package android.se.omapi {
|
|||||||
method public void shutdown();
|
method public void shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class SEService.SecureElementListener extends android.os.Binder {
|
public static abstract interface SEService.SecureElementListener {
|
||||||
ctor public SEService.SecureElementListener();
|
method public abstract void onServiceConnected();
|
||||||
method public android.os.IBinder asBinder();
|
|
||||||
method public void serviceConnected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Session {
|
public class Session {
|
||||||
@@ -37050,9 +37048,7 @@ package android.se.omapi {
|
|||||||
method public android.se.omapi.Reader getReader();
|
method public android.se.omapi.Reader getReader();
|
||||||
method public boolean isClosed();
|
method public boolean isClosed();
|
||||||
method public android.se.omapi.Channel openBasicChannel(byte[], byte) throws java.io.IOException;
|
method public android.se.omapi.Channel openBasicChannel(byte[], byte) throws java.io.IOException;
|
||||||
method public android.se.omapi.Channel openBasicChannel(byte[]) throws java.io.IOException;
|
|
||||||
method public android.se.omapi.Channel openLogicalChannel(byte[], byte) throws java.io.IOException;
|
method public android.se.omapi.Channel openLogicalChannel(byte[], byte) throws java.io.IOException;
|
||||||
method public android.se.omapi.Channel openLogicalChannel(byte[]) throws java.io.IOException;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ public class Channel {
|
|||||||
private final SEService mService;
|
private final SEService mService;
|
||||||
private final Object mLock = new Object();
|
private final Object mLock = new Object();
|
||||||
|
|
||||||
Channel(SEService service, Session session, ISecureElementChannel channel) {
|
Channel(@NonNull SEService service, @NonNull Session session,
|
||||||
|
@NonNull ISecureElementChannel channel) {
|
||||||
if (service == null || session == null || channel == null) {
|
if (service == null || session == null || channel == null) {
|
||||||
throw new IllegalArgumentException("Parameters cannot be null");
|
throw new IllegalArgumentException("Parameters cannot be null");
|
||||||
}
|
}
|
||||||
@@ -158,7 +159,7 @@ public class Channel {
|
|||||||
* @throws SecurityException if the command is filtered by the security policy.
|
* @throws SecurityException if the command is filtered by the security policy.
|
||||||
* @throws NullPointerException if command is NULL.
|
* @throws NullPointerException if command is NULL.
|
||||||
*/
|
*/
|
||||||
public @NonNull byte[] transmit(byte[] command) throws IOException {
|
public @NonNull byte[] transmit(@NonNull byte[] command) throws IOException {
|
||||||
if (!mService.isConnected()) {
|
if (!mService.isConnected()) {
|
||||||
throw new IllegalStateException("service not connected to system");
|
throw new IllegalStateException("service not connected to system");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,4 @@ package android.se.omapi;
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
interface ISecureElementListener {
|
interface ISecureElementListener {
|
||||||
/**
|
|
||||||
* Called by the framework when the service is connected.
|
|
||||||
*/
|
|
||||||
void serviceConnected();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class Reader {
|
|||||||
private final Object mLock = new Object();
|
private final Object mLock = new Object();
|
||||||
|
|
||||||
|
|
||||||
Reader(SEService service, String name, ISecureElementReader reader) {
|
Reader(@NonNull SEService service, @NonNull String name, @NonNull ISecureElementReader reader) {
|
||||||
if (reader == null || service == null || name == null) {
|
if (reader == null || service == null || name == null) {
|
||||||
throw new IllegalArgumentException("Parameters cannot be null");
|
throw new IllegalArgumentException("Parameters cannot be null");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,17 +62,32 @@ public class SEService {
|
|||||||
/**
|
/**
|
||||||
* Interface to send call-backs to the application when the service is connected.
|
* Interface to send call-backs to the application when the service is connected.
|
||||||
*/
|
*/
|
||||||
public abstract static class SecureElementListener extends ISecureElementListener.Stub {
|
public interface SecureElementListener {
|
||||||
|
/**
|
||||||
|
* Called by the framework when the service is connected.
|
||||||
|
*/
|
||||||
|
void onServiceConnected();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener object that allows the notification of the caller if this
|
||||||
|
* SEService could be bound to the backend.
|
||||||
|
*/
|
||||||
|
private class SEListener extends ISecureElementListener.Stub {
|
||||||
|
public SecureElementListener mListener = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder asBinder() {
|
public IBinder asBinder() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void onServiceConnected() {
|
||||||
* Called by the framework when the service is connected.
|
if (mListener != null) {
|
||||||
*/
|
mListener.onServiceConnected();
|
||||||
public void serviceConnected() {};
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
private SEListener mSEListener = new SEListener();
|
||||||
|
|
||||||
private static final String TAG = "OMAPI.SEService";
|
private static final String TAG = "OMAPI.SEService";
|
||||||
|
|
||||||
@@ -94,12 +109,6 @@ public class SEService {
|
|||||||
*/
|
*/
|
||||||
private final HashMap<String, Reader> mReaders = new HashMap<String, Reader>();
|
private final HashMap<String, Reader> mReaders = new HashMap<String, Reader>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Listener object that allows the notification of the caller if this
|
|
||||||
* SEService could be bound to the backend.
|
|
||||||
*/
|
|
||||||
private ISecureElementListener mSEListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Establishes a new connection that can be used to connect to all the
|
* Establishes a new connection that can be used to connect to all the
|
||||||
* Secure Elements available in the system. The connection process can be
|
* Secure Elements available in the system. The connection process can be
|
||||||
@@ -107,22 +116,22 @@ public class SEService {
|
|||||||
* the specified listener is called or if isConnected() returns
|
* the specified listener is called or if isConnected() returns
|
||||||
* <code>true</code>. <br>
|
* <code>true</code>. <br>
|
||||||
* The call-back object passed as a parameter will have its
|
* The call-back object passed as a parameter will have its
|
||||||
* serviceConnected() method called when the connection actually happen.
|
* onServiceConnected() method called when the connection actually happen.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* the context of the calling application. Cannot be
|
* the context of the calling application. Cannot be
|
||||||
* <code>null</code>.
|
* <code>null</code>.
|
||||||
* @param listener
|
* @param listener
|
||||||
* a SecureElementListener object. Can be <code>null</code>.
|
* a SecureElementListener object.
|
||||||
*/
|
*/
|
||||||
public SEService(Context context, SecureElementListener listener) {
|
public SEService(@NonNull Context context, @NonNull SecureElementListener listener) {
|
||||||
|
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
throw new NullPointerException("context must not be null");
|
throw new NullPointerException("context must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSEListener = listener;
|
mSEListener.mListener = listener;
|
||||||
|
|
||||||
mConnection = new ServiceConnection() {
|
mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
@@ -131,9 +140,7 @@ public class SEService {
|
|||||||
|
|
||||||
mSecureElementService = ISecureElementService.Stub.asInterface(service);
|
mSecureElementService = ISecureElementService.Stub.asInterface(service);
|
||||||
if (mSEListener != null) {
|
if (mSEListener != null) {
|
||||||
try {
|
mSEListener.onServiceConnected();
|
||||||
mSEListener.serviceConnected();
|
|
||||||
} catch (RemoteException ignore) { }
|
|
||||||
}
|
}
|
||||||
Log.i(TAG, "Service onServiceConnected");
|
Log.i(TAG, "Service onServiceConnected");
|
||||||
}
|
}
|
||||||
@@ -233,7 +240,7 @@ public class SEService {
|
|||||||
*
|
*
|
||||||
* @return String containing the OpenMobile API version (e.g. "3.0").
|
* @return String containing the OpenMobile API version (e.g. "3.0").
|
||||||
*/
|
*/
|
||||||
public String getVersion() {
|
public @NonNull String getVersion() {
|
||||||
return "3.2";
|
return "3.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ public class Session {
|
|||||||
private final ISecureElementSession mSession;
|
private final ISecureElementSession mSession;
|
||||||
private static final String TAG = "OMAPI.Session";
|
private static final String TAG = "OMAPI.Session";
|
||||||
|
|
||||||
Session(SEService service, ISecureElementSession session, Reader reader) {
|
Session(@NonNull SEService service, @NonNull ISecureElementSession session,
|
||||||
|
@NonNull Reader reader) {
|
||||||
if (service == null || reader == null || session == null) {
|
if (service == null || reader == null || session == null) {
|
||||||
throw new IllegalArgumentException("Parameters cannot be null");
|
throw new IllegalArgumentException("Parameters cannot be null");
|
||||||
}
|
}
|
||||||
@@ -195,7 +196,8 @@ public class Session {
|
|||||||
* supported by the device
|
* supported by the device
|
||||||
* @return an instance of Channel if available or null.
|
* @return an instance of Channel if available or null.
|
||||||
*/
|
*/
|
||||||
public @Nullable Channel openBasicChannel(byte[] aid, byte p2) throws IOException {
|
public @Nullable Channel openBasicChannel(@Nullable byte[] aid, @Nullable byte p2)
|
||||||
|
throws IOException {
|
||||||
if (!mService.isConnected()) {
|
if (!mService.isConnected()) {
|
||||||
throw new IllegalStateException("service not connected to system");
|
throw new IllegalStateException("service not connected to system");
|
||||||
}
|
}
|
||||||
@@ -222,32 +224,6 @@ public class Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is provided to ease the development of mobile application and for compliancy
|
|
||||||
* with existing applications.
|
|
||||||
* This method is equivalent to openBasicChannel(aid, P2=0x00)
|
|
||||||
*
|
|
||||||
* @param aid the AID of the Applet to be selected on this channel, as a
|
|
||||||
* byte array, or null if no Applet is to be selected.
|
|
||||||
* @throws IOException if there is a communication problem to the reader or
|
|
||||||
* the Secure Element.
|
|
||||||
* @throws IllegalStateException if the Secure Element session is used after
|
|
||||||
* being closed.
|
|
||||||
* @throws IllegalArgumentException if the aid's length is not within 5 to
|
|
||||||
* 16 (inclusive).
|
|
||||||
* @throws SecurityException if the calling application cannot be granted
|
|
||||||
* access to this AID or the default Applet on this
|
|
||||||
* session.
|
|
||||||
* @throws NoSuchElementException if the AID on the Secure Element is not available or cannot be
|
|
||||||
* selected.
|
|
||||||
* @throws UnsupportedOperationException if the given P2 parameter is not
|
|
||||||
* supported by the device
|
|
||||||
* @return an instance of Channel if available or null.
|
|
||||||
*/
|
|
||||||
public @Nullable Channel openBasicChannel(byte[] aid) throws IOException {
|
|
||||||
return openBasicChannel(aid, (byte) 0x00);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a logical channel with the Secure Element, selecting the Applet represented by
|
* Open a logical channel with the Secure Element, selecting the Applet represented by
|
||||||
* the given AID. If the AID is null, which means no Applet is to be selected on this
|
* the given AID. If the AID is null, which means no Applet is to be selected on this
|
||||||
@@ -300,7 +276,8 @@ public class Session {
|
|||||||
* @return an instance of Channel. Null if the Secure Element is unable to
|
* @return an instance of Channel. Null if the Secure Element is unable to
|
||||||
* provide a new logical channel.
|
* provide a new logical channel.
|
||||||
*/
|
*/
|
||||||
public @Nullable Channel openLogicalChannel(byte[] aid, byte p2) throws IOException {
|
public @Nullable Channel openLogicalChannel(@Nullable byte[] aid, @Nullable byte p2)
|
||||||
|
throws IOException {
|
||||||
if (!mService.isConnected()) {
|
if (!mService.isConnected()) {
|
||||||
throw new IllegalStateException("service not connected to system");
|
throw new IllegalStateException("service not connected to system");
|
||||||
}
|
}
|
||||||
@@ -327,32 +304,4 @@ public class Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is provided to ease the development of mobile application and for compliancy
|
|
||||||
* with existing applications.
|
|
||||||
* This method is equivalent to openLogicalChannel(aid, P2=0x00)
|
|
||||||
*
|
|
||||||
* @param aid the AID of the Applet to be selected on this channel, as a
|
|
||||||
* byte array.
|
|
||||||
* @throws IOException if there is a communication problem to the reader or
|
|
||||||
* the Secure Element.
|
|
||||||
* @throws IllegalStateException if the Secure Element is used after being
|
|
||||||
* closed.
|
|
||||||
* @throws IllegalArgumentException if the aid's length is not within 5 to
|
|
||||||
* 16 (inclusive).
|
|
||||||
* @throws SecurityException if the calling application cannot be granted
|
|
||||||
* access to this AID or the default Applet on this
|
|
||||||
* session.
|
|
||||||
* @throws NoSuchElementException if the AID on the Secure Element is not
|
|
||||||
* available or cannot be selected or a logical channel is already
|
|
||||||
* open to a non-multiselectable Applet.
|
|
||||||
* @throws UnsupportedOperationException if the given P2 parameter is not
|
|
||||||
* supported by the device.
|
|
||||||
* @return an instance of Channel. Null if the Secure Element is unable to
|
|
||||||
* provide a new logical channel.
|
|
||||||
*/
|
|
||||||
public @Nullable Channel openLogicalChannel(byte[] aid) throws IOException {
|
|
||||||
return openLogicalChannel(aid, (byte) 0x00);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user