Merge "Do not throw exception when there is no omapi reader supported"
This commit is contained in:
@@ -22,14 +22,11 @@
|
|||||||
|
|
||||||
package android.se.omapi;
|
package android.se.omapi;
|
||||||
|
|
||||||
import android.app.ActivityThread;
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
import android.content.pm.IPackageManager;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -143,10 +140,6 @@ public final class SEService {
|
|||||||
throw new NullPointerException("Arguments must not be null");
|
throw new NullPointerException("Arguments must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasOMAPIReaders()) {
|
|
||||||
throw new UnsupportedOperationException("Device does not support any OMAPI reader");
|
|
||||||
}
|
|
||||||
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSEListener.mListener = listener;
|
mSEListener.mListener = listener;
|
||||||
mSEListener.mExecutor = executor;
|
mSEListener.mExecutor = executor;
|
||||||
@@ -277,23 +270,4 @@ public final class SEService {
|
|||||||
throw new IllegalStateException(e.getMessage());
|
throw new IllegalStateException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper to check if this device support any OMAPI readers
|
|
||||||
*/
|
|
||||||
private static boolean hasOMAPIReaders() {
|
|
||||||
IPackageManager pm = ActivityThread.getPackageManager();
|
|
||||||
if (pm == null) {
|
|
||||||
Log.e(TAG, "Cannot get package manager, assuming OMAPI readers supported");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return pm.hasSystemFeature(PackageManager.FEATURE_SE_OMAPI_UICC, 0)
|
|
||||||
|| pm.hasSystemFeature(PackageManager.FEATURE_SE_OMAPI_ESE, 0)
|
|
||||||
|| pm.hasSystemFeature(PackageManager.FEATURE_SE_OMAPI_SD, 0);
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log.e(TAG, "Package manager query failed, assuming OMAPI readers supported", e);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user