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

Commit bb328e91 authored by Ruchi Kandoi's avatar Ruchi Kandoi Committed by android-build-merger
Browse files

Merge "Add ServiceSpecificExceptions for SecureElementService." am: 73e7a1a7 am: e09ba38a

am: 4a007408

Change-Id: I860518723941e56fec03dab2298931a5fe00450f
parents 18fb6316 4a007408
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ package android.se.omapi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
import android.util.Log;

import java.io.IOException;
@@ -168,8 +169,10 @@ public class Channel {
                    throw new IOException("Error in communicating with Secure Element");
                }
                return response;
            } catch (RemoteException e) {
            } catch (ServiceSpecificException e) {
                throw new IOException(e.getMessage());
            } catch (RemoteException e) {
                throw new IllegalStateException(e.getMessage());
            }
        }
    }
@@ -244,8 +247,10 @@ public class Channel {
            synchronized (mLock) {
                return mChannel.selectNext();
            }
        } catch (RemoteException e) {
        } catch (ServiceSpecificException e) {
            throw new IOException(e.getMessage());
        } catch (RemoteException e) {
            throw new IllegalStateException(e.getMessage());
        }
    }
}
+5 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ package android.se.omapi;

import android.annotation.NonNull;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
import android.util.Log;

import java.io.IOException;
@@ -45,8 +46,7 @@ public class Reader {
    private final Object mLock = new Object();


    Reader(SEService service, String name, ISecureElementReader reader) throws
            IOException {
    Reader(SEService service, String name, ISecureElementReader reader) {
        if (reader == null || service == null || name == null) {
            throw new IllegalArgumentException("Parameters cannot be null");
        }
@@ -96,8 +96,10 @@ public class Reader {
            ISecureElementSession session;
            try {
                session = mReader.openSession();
            } catch (RemoteException e) {
            } catch (ServiceSpecificException e) {
                throw new IOException(e.getMessage());
            } catch (RemoteException e) {
                throw new IllegalStateException(e.getMessage());
            }
            if (session == null) {
                throw new IOException("service session is null.");
+17 −0
Original line number Diff line number Diff line
@@ -42,6 +42,23 @@ import java.util.HashMap;
 */
public class SEService {

    /**
     * Error code used with ServiceSpecificException.
     * Thrown if there was an error communicating with the Secure Element.
     *
     * @hide
     */
    public static final int IO_ERROR = 1;

    /**
     * Error code used with ServiceSpecificException.
     * Thrown if AID cannot be selected or is not available when opening
     * a logical channel.
     *
     * @hide
     */
    public static final int NO_SUCH_ELEMENT_ERROR = 2;

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

    private final Object mLock = new Object();
+19 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ package android.se.omapi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
import android.util.Log;

import java.io.IOException;
@@ -207,8 +208,16 @@ public class Session {
                    return null;
                }
                return new Channel(mService, this, channel);
            } catch (RemoteException e) {
            } catch (ServiceSpecificException e) {
                if (e.errorCode == SEService.IO_ERROR) {
                    throw new IOException(e.getMessage());
                } else if (e.errorCode == SEService.NO_SUCH_ELEMENT_ERROR) {
                    throw new NoSuchElementException(e.getMessage());
                } else {
                    throw new IllegalStateException(e.getMessage());
                }
            } catch (RemoteException e) {
                throw new IllegalStateException(e.getMessage());
            }
        }
    }
@@ -311,8 +320,16 @@ public class Session {
                    return null;
                }
                return new Channel(mService, this, channel);
            } catch (RemoteException e) {
            } catch (ServiceSpecificException e) {
                if (e.errorCode == SEService.IO_ERROR) {
                    throw new IOException(e.getMessage());
                } else if (e.errorCode == SEService.NO_SUCH_ELEMENT_ERROR) {
                    throw new NoSuchElementException(e.getMessage());
                } else {
                    throw new IllegalStateException(e.getMessage());
                }
            } catch (RemoteException e) {
                throw new IllegalStateException(e.getMessage());
            }
        }
    }