Merge "Add an Executor for the onConnectedListener" am: 0d1f7933a3
am: a6c7187242
Change-Id: I99338270ac10c27b68bd851a844259441145c186
This commit is contained in:
@@ -38414,7 +38414,7 @@ package android.se.omapi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class SEService {
|
public final class SEService {
|
||||||
ctor public SEService(android.content.Context, android.se.omapi.SEService.OnConnectedListener);
|
ctor public SEService(android.content.Context, java.util.concurrent.Executor, android.se.omapi.SEService.OnConnectedListener);
|
||||||
method public android.se.omapi.Reader[] getReaders();
|
method public android.se.omapi.Reader[] getReaders();
|
||||||
method public java.lang.String getVersion();
|
method public java.lang.String getVersion();
|
||||||
method public boolean isConnected();
|
method public boolean isConnected();
|
||||||
@@ -38422,7 +38422,7 @@ package android.se.omapi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static abstract interface SEService.OnConnectedListener {
|
public static abstract interface SEService.OnConnectedListener {
|
||||||
method public abstract void onServiceConnected();
|
method public abstract void onConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class Session {
|
public final class Session {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import android.os.RemoteException;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SEService realises the communication to available Secure Elements on the
|
* The SEService realises the communication to available Secure Elements on the
|
||||||
@@ -66,7 +67,7 @@ public final class SEService {
|
|||||||
/**
|
/**
|
||||||
* Called by the framework when the service is connected.
|
* Called by the framework when the service is connected.
|
||||||
*/
|
*/
|
||||||
void onServiceConnected();
|
void onConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,15 +76,21 @@ public final class SEService {
|
|||||||
*/
|
*/
|
||||||
private class SEListener extends ISecureElementListener.Stub {
|
private class SEListener extends ISecureElementListener.Stub {
|
||||||
public OnConnectedListener mListener = null;
|
public OnConnectedListener mListener = null;
|
||||||
|
public Executor mExecutor = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder asBinder() {
|
public IBinder asBinder() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServiceConnected() {
|
public void onConnected() {
|
||||||
if (mListener != null) {
|
if (mListener != null && mExecutor != null) {
|
||||||
mListener.onServiceConnected();
|
mExecutor.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mListener.onConnected();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,22 +123,26 @@ public final 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
|
||||||
* onServiceConnected() method called when the connection actually happen.
|
* onConnected() 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 OnConnectedListener object.
|
* a OnConnectedListener object.
|
||||||
|
* @param executor
|
||||||
|
* an Executor which will be used when invoking the callback.
|
||||||
*/
|
*/
|
||||||
public SEService(@NonNull Context context, @NonNull OnConnectedListener listener) {
|
public SEService(@NonNull Context context, @NonNull Executor executor,
|
||||||
|
@NonNull OnConnectedListener listener) {
|
||||||
|
|
||||||
if (context == null) {
|
if (context == null || listener == null || executor == null) {
|
||||||
throw new NullPointerException("context must not be null");
|
throw new NullPointerException("Arguments must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSEListener.mListener = listener;
|
mSEListener.mListener = listener;
|
||||||
|
mSEListener.mExecutor = executor;
|
||||||
|
|
||||||
mConnection = new ServiceConnection() {
|
mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
@@ -140,7 +151,7 @@ public final class SEService {
|
|||||||
|
|
||||||
mSecureElementService = ISecureElementService.Stub.asInterface(service);
|
mSecureElementService = ISecureElementService.Stub.asInterface(service);
|
||||||
if (mSEListener != null) {
|
if (mSEListener != null) {
|
||||||
mSEListener.onServiceConnected();
|
mSEListener.onConnected();
|
||||||
}
|
}
|
||||||
Log.i(TAG, "Service onServiceConnected");
|
Log.i(TAG, "Service onServiceConnected");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user