寻求换机器人。拒绝连接 ! Android的

时间:2013-05-13 08:51:15

标签: android

我正在使用SEEK-For-Android库来开发相同的应用程序。

当我尝试从https://code.google.com/p/seek-for-android/wiki/UsingSmartCardAPI运行测试应用程序HelloSmartCard时出现错误:“连接被拒绝!!!”

我正在使用Samsung S III和以下代码:

public void onCreate(Bundle savedInstanceState) {    
    super.onCreate(savedInstanceState);

    LinearLayout layout = new LinearLayout(this);
    layout.setLayoutParams(new LayoutParams(
        LayoutParams.WRAP_CONTENT, 
        LayoutParams.WRAP_CONTENT));

    button = new Button(this);
    button.setLayoutParams(new LayoutParams(
        LayoutParams.WRAP_CONTENT, 
        LayoutParams.WRAP_CONTENT));

    button.setText("Click Me");
    button.setEnabled(false);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            try {
                Log.i(LOG_TAG, "Retrieve available readers...");
                Reader[] readers = seService.getReaders();
                if (readers.length < 1)
                    return;

                byte aid[] = new byte[] {(byte)0xA0, 0x00,0x00,0x00,0x03,0x20,0x10};
                SECardIdentifier id = new SECardIdentifier(aid);
                Log.i(LOG_TAG, "Create Session from the first reader...");
                Session session = readers[0].openSession();
                Log.i(LOG_TAG, String.valueOf(session.getReader().getName())+"   "+id.getAid().toString());
                Log.i(LOG_TAG, "Create logical channel within the session...");
                Channel channel = session.openLogicalChannel(aid);

                Log.i(LOG_TAG, "Send HelloWorld APDU command");
                byte[] respApdu = channel.transmit(new byte[] {
                    (byte) 0x90, 0x10, 0x00, 0x00, 0x00 });

                channel.close();

                // Parse response APDU and show text but remove SW1 SW2 first
                byte[] helloStr = new byte[respApdu.length - 2];
                System.arraycopy(respApdu, 0, helloStr, 0, respApdu.length - 2);
                Toast.makeText(MainActivity.this, new String(helloStr), Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                Log.e(LOG_TAG, "Error occured:", e);
                    return;
            }
        }
    });

    layout.addView(button);
    setContentView(layout);

    try {
        Log.i(LOG_TAG, "creating SEService object");
        seService = new SEService(this, this);
    } catch (SecurityException e) {
        Log.e(LOG_TAG, "Binding not allowed, uses-permission org.simalliance.openmobileapi.SMARTCARD?");
    } catch (Exception e) {
        Log.e(LOG_TAG, "Exception: " + e.getMessage());
    }
}

@Override
protected void onDestroy() {
    if (seService != null && seService.isConnected()) {
        seService.shutdown();
    }
    super.onDestroy();
}

public void serviceConnected(SEService service) {
    Log.i(LOG_TAG, "seviceConnected()");
    button.setEnabled(true);
}

然后返回下一个异常:

05-13 11:23:09.979: I/HelloSmartcard(17588): creating SEService object
05-13 11:23:09.984: V/SEService(17588): bindService successful
05-13 11:23:10.054: I/HelloSmartcard(17588): seviceConnected()
05-13 11:23:10.054: V/SEService(17588): Service onServiceConnected
05-13 11:23:11.444: I/HelloSmartcard(17588): Retrieve available readers...
05-13 11:23:11.444: I/HelloSmartcard(17588): Create Session from the first reader...
05-13 11:23:11.444: I/HelloSmartcard(17588): SIM: UICC   A0000000032010
05-13 11:23:11.444: I/HelloSmartcard(17588): Create logical channel within the session...
05-13 11:23:11.634: E/HelloSmartcard(17588): Error occured:
05-13 11:23:11.634: E/HelloSmartcard(17588): java.lang.SecurityException: Connection refused !!!
05-13 11:23:11.634: E/HelloSmartcard(17588):    at org.simalliance.openmobileapi.SEService.checkForException(SEService.java:553)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at org.simalliance.openmobileapi.SEService.openLogicalChannel(SEService.java:365)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at org.simalliance.openmobileapi.Session.openLogicalChannel(Session.java:131)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at com.example.com.pentegy.nfctest.MainActivity$1.onClick(MainActivity.java:65)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at android.view.View.performClick(View.java:4211)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at android.view.View$PerformClick.run(View.java:17267)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at android.os.Handler.handleCallback(Handler.java:615)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at android.os.Handler.dispatchMessage(Handler.java:92)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at android.os.Looper.loop(Looper.java:137)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at android.app.ActivityThread.main(ActivityThread.java:4898)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at java.lang.reflect.Method.invokeNative(Native Method)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at java.lang.reflect.Method.invoke(Method.java:511)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
05-13 11:23:11.634: E/HelloSmartcard(17588):    at dalvik.system.NativeStart.main(Native Method)

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

我遇到了同样的情况,而在我的情况下seSevice.getReader()抛出异常“连接被拒绝”。也就是说,我连一个读者都无法获得。

我从谷歌阅读the following info,希望这有助于解释这种情况。

  

三星仅包含用于SIM卡访问的UiccTerminal.java   并删除了有效和推荐的结果   将SCAPI集成到产品中。

你能告诉我哪个ROM正在运行,所以我可以切换到相同的ROM并获得SIM卡读卡器吗?