Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit df369da8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Modify Open Mobile API to follow Android API guidelines" into pi-dev

parents 2fc8197b 1d0b1551
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -38342,10 +38342,8 @@ package android.se.omapi {
    method public void shutdown();
  }
  public static abstract class SEService.SecureElementListener extends android.os.Binder {
    ctor public SEService.SecureElementListener();
    method public android.os.IBinder asBinder();
    method public void serviceConnected();
  public static abstract interface SEService.SecureElementListener {
    method public abstract void onServiceConnected();
  }
  public class Session {
@@ -38355,9 +38353,7 @@ package android.se.omapi {
    method public android.se.omapi.Reader getReader();
    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[]) 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;
  }
}
+3 −2
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ public class Channel {
    private final SEService mService;
    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) {
            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 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()) {
            throw new IllegalStateException("service not connected to system");
        }
+0 −4
Original line number Diff line number Diff line
@@ -24,8 +24,4 @@ package android.se.omapi;
 * @hide
 */
interface ISecureElementListener {
  /**
   * Called by the framework when the service is connected.
   */
  void serviceConnected();
}
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ public class Reader {
    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) {
            throw new IllegalArgumentException("Parameters cannot be null");
        }
+26 −19
Original line number Diff line number Diff line
@@ -62,17 +62,32 @@ public class SEService {
    /**
     * 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
        public IBinder asBinder() {
            return this;
        }

        /**
         * Called by the framework when the service is connected.
         */
        public void serviceConnected() {};
        public void onServiceConnected() {
            if (mListener != null) {
                mListener.onServiceConnected();
            }
        }
    }
    private SEListener mSEListener = new SEListener();

    private static final String TAG = "OMAPI.SEService";

@@ -94,12 +109,6 @@ public class SEService {
     */
    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
     * 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
     * <code>true</code>. <br>
     * 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
     *            the context of the calling application. Cannot be
     *            <code>null</code>.
     * @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) {
            throw new NullPointerException("context must not be null");
        }

        mContext = context;
        mSEListener = listener;
        mSEListener.mListener = listener;

        mConnection = new ServiceConnection() {

@@ -131,9 +140,7 @@ public class SEService {

                mSecureElementService = ISecureElementService.Stub.asInterface(service);
                if (mSEListener != null) {
                    try {
                        mSEListener.serviceConnected();
                    } catch (RemoteException ignore) { }
                    mSEListener.onServiceConnected();
                }
                Log.i(TAG, "Service onServiceConnected");
            }
@@ -233,7 +240,7 @@ public class SEService {
     *
     * @return String containing the OpenMobile API version (e.g. "3.0").
     */
    public String getVersion() {
    public @NonNull String getVersion() {
        return "3.2";
    }

Loading