DEBUG构建指纹崩溃!

时间:2011-05-20 08:10:43

标签: android sockets fingerprint

当我尝试启动蓝牙套接字时,我收到此消息,并且我的Android应用程序崩溃而没有错误日志:

05-20 09:59:07.790 E/BluetoothConnectionService  (3162): socket connect failed

05-20 09:59:07.790 I/BluetoothConnectionService  (3162): close socket

05-20 09:59:07.800 I/DEBUG   ( 1064): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

05-20 09:59:07.800 I/DEBUG   ( 1064): Build fingerprint: 'SEMC/X10i_1237-0688/X10i/es209ra:2.1-update1/2.1.A.0.435/TP7d:user/release-keys'

05-20 09:59:07.800 I/DEBUG   ( 1064): pid: 3605, tid: 3605  >>> com.secu4.s4b <<<

05-20 09:59:07.800 I/DEBUG   ( 1064): signal 11 (SIGSEGV), fault addr deadbaad

05-20 09:59:07.800 I/DEBUG   ( 1064):  r0 00000000  r1 afe13359  r2 00000027  r3 00000054

05-20 09:59:07.800 I/DEBUG   ( 1064):  r4 afe3ae08  r5 00000000  r6 00000000  r7 0000a000

05-20 09:59:07.800 I/DEBUG   ( 1064):  r8 beb8c998  r9 41873cf8  10 41873ce0  fp 00000000

05-20 09:59:07.800 I/DEBUG   ( 1064):  ip 00002ee0  sp beb8c928  lr deadbaad  pc afe10a14  cpsr 68000030

05-20 09:59:07.830 D/GpsLocationProvider( 1143): updateNetworkState available info: NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true

05-20 09:59:07.850 V/AutoSyncService( 1595): onCreate()

05-20 09:59:07.920 I/GTalkService( 1286): [ServiceAutoStarter] --- start GTalk service ---

05-20 09:59:07.950 I/MediaUploader( 1446): No need to wake up

05-20 09:59:08.000 V/AutoSyncService( 1595): onStart(): action_auto_sync_event[3]

05-20 09:59:08.010 V/AutoSyncService( 1595): onDestroy()

05-20 09:59:08.150 I/DEBUG   ( 1064):          #00  pc 00010a14  /system/lib/libc.so

05-20 09:59:08.150 I/DEBUG   ( 1064):          #01  pc 0000b342  /system/lib/libc.so

05-20 09:59:08.160 I/DEBUG   ( 1064):          #02  pc 000060ba  /system/lib/libcutils.so

05-20 09:59:08.180 I/DEBUG   ( 1064):          #03  pc 00051a0a  /system/lib/libandroid_runtime.so

05-20 09:59:08.190 I/DEBUG   ( 1064):          #04  pc 0000edb4  /system/lib/libdvm.so

05-20 09:59:08.190 I/DEBUG   ( 1064):          #05  pc 00038938  /system/lib/libdvm.so

05-20 09:59:08.190 I/DEBUG   ( 1064):          #06  pc 00013ab8  /system/lib/libdvm.so

05-20 09:59:08.190 I/DEBUG   ( 1064):          #07  pc 00019438  /system/lib/libdvm.so

05-20 09:59:08.200 I/DEBUG   ( 1064):          #08  pc 00018904  /system/lib/libdvm.so

05-20 09:59:08.200 I/DEBUG   ( 1064):          #09  pc 0004f0c2  /system/lib/libdvm.so

05-20 09:59:08.200 I/DEBUG   ( 1064):          #10  pc 000572f0  /system/lib/libdvm.so

05-20 09:59:08.200 I/DEBUG   ( 1064):          #11  pc 00013ab8  /system/lib/libdvm.so

05-20 09:59:08.200 I/DEBUG   ( 1064):          #12  pc 00019438  /system/lib/libdvm.so

05-20 09:59:08.200 I/DEBUG   ( 1064):          #13  pc 00018904  /system/lib/libdvm.so

05-20 09:59:08.200 I/DEBUG   ( 1064):          #14  pc 0004f3ec  /system/lib/libdvm.so

05-20 09:59:08.200 I/DEBUG   ( 1064):          #15  pc 0003b0be  /system/lib/libdvm.so

05-20 09:59:08.200 I/DEBUG   ( 1064):          #16  pc 00028b68  /system/lib/libandroid_runtime.so

05-20 09:59:08.210 I/DEBUG   ( 1064):          #17  pc 000298d4  /system/lib/libandroid_runtime.so

05-20 09:59:08.210 I/DEBUG   ( 1064):          #18  pc 00008cd8  /system/bin/app_process

05-20 09:59:08.210 I/DEBUG   ( 1064):          #19  pc 0000c238  /system/lib/libc.so

05-20 09:59:08.210 I/DEBUG   ( 1064): 

05-20 09:59:08.210 I/DEBUG   ( 1064): code around pc:

05-20 09:59:08.210 I/DEBUG   ( 1064): afe10a04 f8442001 4798000c e054f8df 26002227 

05-20 09:59:08.210 I/DEBUG   ( 1064): afe10a14 2000f88e ef3af7fb f7fd2106 f04fe818 

05-20 09:59:08.210 I/DEBUG   ( 1064): 

05-20 09:59:08.210 I/DEBUG   ( 1064): code around lr:

05-20 09:59:08.210 I/DEBUG   ( 1064): deadba9c ffffffff ffffffff ffffffff ffffffff 

05-20 09:59:08.210 I/DEBUG   ( 1064): deadbaac ffffffff ffffffff ffffffff ffffffff 

05-20 09:59:08.210 I/DEBUG   ( 1064): deadbabc ffffffff ffffffff ffffffff ffffffff 

05-20 09:59:08.210 I/DEBUG   ( 1064): 

05-20 09:59:08.210 I/DEBUG   ( 1064): stack:

05-20 09:59:08.210 I/DEBUG   ( 1064):     beb8c8e8  00000015  

05-20 09:59:08.210 I/DEBUG   ( 1064):     beb8c8ec  afe13389  /system/lib/libc.so

05-20 09:59:08.210 I/DEBUG   ( 1064):     beb8c8f0  afe3b02c  /system/lib/libc.so

05-20 09:59:08.210 I/DEBUG   ( 1064):     beb8c8f4  afe3afd8  /system/lib/libc.so

05-20 09:59:08.210 I/DEBUG   ( 1064):     beb8c8f8  00000000  

05-20 09:59:08.210 I/DEBUG   ( 1064):     beb8c8fc  afe143a3  /system/lib/libc.so

05-20 09:59:08.260 D/dalvikvm( 1416): GC freed 1639 objects / 375144 bytes in 290ms

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c900  afe13359  /system/lib/libc.so

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c904  afe13359  /system/lib/libc.so

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c908  00000054  

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c90c  afe3ae08  /system/lib/libc.so

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c910  00000000  

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c914  beb8c93c  [stack]

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c918  0000a000  [heap]

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c91c  afe135fb  /system/lib/libc.so

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c920  df002777  

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c924  e3a070ad  

05-20 09:59:08.260 I/DEBUG   ( 1064): #00 beb8c928  afe3db7c  

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c92c  afe0f130  /system/lib/libc.so

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c930  afe3ae08  /system/lib/libc.so

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c934  00000000  

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c938  00126968  [heap]

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c93c  fffffbdf  

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c940  afe3ae08  /system/lib/libc.so

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c944  afe3d9c4  

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c948  00126968  [heap]

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c94c  afe0b347  /system/lib/libc.so

05-20 09:59:08.260 I/DEBUG   ( 1064): #01 beb8c950  beb8c967  [stack]

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c954  afe1fcb7  /system/lib/libc.so

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c958  00002bbc  

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c95c  afb06077  /system/lib/libcutils.so

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c960  beb8c97c  [stack]

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c964  00126968  [heap]

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c968  00000000  

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c96c  41873cf4  

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c970  41873d00  

05-20 09:59:08.260 I/DEBUG   ( 1064):     beb8c974  afb060bd  /system/lib/libcutils.so

05-20 09:59:08.490 D/dalvikvm( 3460): GC freed 14516 objects / 523568 bytes in 75ms

05-20 09:59:08.870 W/GTalkService( 1286): [GTalkConnection.15] doConnect: caught Could not connect to mtalk.google.com:5228.: (404)

05-20 09:59:08.870 W/GTalkService( 1286):   -- caused by: java.net.UnknownHostException: mtalk.google.com

05-20 09:59:08.960 D/Zygote  ( 1066): Process 3605 terminated by signal (11)

05-20 09:59:09.080 D/dalvikvm( 1143): GC freed 41717 objects / 2111424 bytes in 117ms

05-20 09:59:09.080 I/WindowManager( 1143): WIN DEATH: Window{45f45758 com.secu4.s4b/com.secu4.s4b.Welcome paused=false}

05-20 09:59:09.110 I/ActivityManager( 1143): Process com.secu4.s4b (pid 3605) has died.

05-20 09:59:09.110 W/ActivityManager( 1143): Scheduling restart of crashed service com.secu4.s4b/.provider.ProtectionService in 5000ms

05-20 09:59:09.110 I/UsageStats( 1143): Unexpected resume of com.fede.launcher while already resumed in com.secu4.s4b

05-20 09:59:09.150 D/ViewFlipper( 1316): updateRunning() mVisible=true, mStarted=true, mUserPresent=true, mRunning=true

05-20 09:59:09.160 W/InputManagerService( 1143): Got RemoteException sending setActive(false) notification to pid 3605 uid 10019

05-20 09:59:09.230 I/global  ( 1248): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.

05-20 09:59:09.310 D/dalvikvm( 1623): GC freed 3025 objects / 334128 bytes in 117ms

05-20 09:59:09.370 D/dalvikvm( 1623): GC freed 2848 objects / 343280 bytes in 30ms

05-20 09:59:09.370 I/dalvikvm-heap( 1623): Grow heap (frag case) to 4.684MB for 236626-byte allocation

05-20 09:59:09.410 D/dalvikvm( 1623): GC freed 0 objects / 0 bytes in 39ms

05-20 09:59:09.460 D/dalvikvm( 1623): GC freed 2219 objects / 290192 bytes in 30ms

有什么想法吗?

提前致谢!

编辑:

在我的清单中我有:

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

对于蓝牙连接,我首先搜索设备:

private void searchBWD() {
    Log.w(TAG,"SEARCH : "+search);
    if(search > Globals.MAX_SEARCH){
        stop = true;
        showCloseDialog(true);
        pwrOnLabel.setText(R.string.lbl_power_on2);
        isSearching = false;
    }else if(!stop){
        if(!controller.isDeviceStored()) {
            search++;
            if(D) Log.d(TAG, "start search BWD devices");

            showProgressDialog();
            pwrOnLabel.setText(R.string.msg_scanning_bwd);

            mNewDevices = new ArrayList<String>();

            try{
                // If we're already discovering, stop it
                if (mBluetoothAdapter.isDiscovering()) {
                    mBluetoothAdapter.cancelDiscovery();
                }
                // Request discover from BluetoothAdapter
                mBluetoothAdapter.startDiscovery();
            }catch (Exception e) {
                e.printStackTrace();
            }
        }else connectionStart();
    }
}

并且比较它是否是我正在寻找的设备,如果是我停止搜索并开始连接:

private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent){
        String action = intent.getAction();

        if(D) Log.v(TAG, "onReceive action:"+action);

        // When discovery finds a device
        if (BluetoothDevice.ACTION_FOUND.equals(action)){
            // Get the BluetoothDevice object from the Intent
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            if (D) Log.d(TAG, "deviceFound :" + device.getName() + "[" + device.getAddress() + "]");
            mNewDevices.add(device.getAddress());
            // If the founded device is the BWD, stop discovering
            if (device.getName() != null){
                if(device.getName().toUpperCase().startsWith(Globals.REMOTEBTNAME.toUpperCase()) 
                        | device.getName().toUpperCase().startsWith(Globals.REMOTEBTNAME2.toUpperCase())) {
                    mBluetoothAdapter.cancelDiscovery();
                }
            }

            // When discovery is finished, change the Activity title
        } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
            if (D) Log.i(TAG, "scanCompleted:" + mNewDevices.size());
            hideProgressDialog();

            // Look for the bluetooth address of the S4B(s)
            int nbBWGDiscovered = 0;
            BluetoothDevice device;
            String bBWDAddress = "";
            for (int i = 0; i < mNewDevices.size(); i++) {
                device = mBluetoothAdapter.getRemoteDevice(mNewDevices.get(i));
                try {
                    if (D) Log.d(TAG, "Found device name:" + device.getName() + ", address:" + device.getAddress());

                    if (device.getName() != null){
                        if(device.getName().toUpperCase().startsWith(Globals.REMOTEBTNAME.toUpperCase()) 
                                | device.getName().toUpperCase().startsWith(Globals.REMOTEBTNAME2.toUpperCase())) {
                            nbBWGDiscovered++;
                            bBWDAddress = device.getAddress();
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (D) Log.d(TAG, "nbBWGDiscovered =" + nbBWGDiscovered);

            switch (nbBWGDiscovered) {
            case 0:
                // error, 0 bwg found
                searchBWD();
                break;

            case 1:                 
                storeBWGDevice(bBWDAddress, true);
                connectionStart();
                break;

            default:
                // to many bwg found to localize yours
                searchBWD();
                break;
            }
        } else if(ACTION_CONNECTED.equals(action)) {   ........

以下是连接过程:

public void connectionStart() {
    if(!stop){
        if(D) Log.d(TAG, " X===> connectionStart to:"+ controller.getDeviceAddress());
        showProgressDialog();
        pwrOnLabel.setText(R.string.alert_device_found);

        Runnable reConnect = new Runnable() {
            public void run() {
                Utils.pause(200);

                protectionService.putExtra(DEVICE_ADDRESS, controller.getDeviceAddress());
                Welcome.this.startService(protectionService);
            }
        };
        Thread thread = new Thread(null, reConnect, "ConnectToBWD");
        thread.start();     
    }
}

这是'ConnectThread'过程,我尝试用我的设备打开蓝牙插座:

private class ConnectThread extends Thread {        
    private final BluetoothSocket mmSocket;
    private final BluetoothDevice mmDevice;

    public ConnectThread(BluetoothDevice device) {
        if(D) Log.d(TAG, "start connectThread ");
        mmDevice = device;
        BluetoothSocket connection = null;


        // Get a BluetoothSocket for a connection with the
        // given BluetoothDevice
        try {
             //connection = device.createRfcommSocketToServiceRecord(MY_UUID);
            if(D) Log.i(TAG,"Create RF Socket");
            Method m = device.getClass().getMethod("createRfcommSocket", new Class[] { int.class });
            connection = (BluetoothSocket) m.invoke(device, 1);
            Utils.pause(100);
        } catch (Exception e) {
            Log.e(TAG, "create() failed", e);
        }
        mmSocket = connection;
        if(D) Log.i(TAG,"Socket initialized");
    }

    public void run() {
        if(D) Log.i(TAG, "BEGIN mConnectThread");
        setName("ConnectThread");

        if (mmSocket != null) {
            // Always cancel discovery because it will slow down a connection
            if (mAdapter.isDiscovering()){
                mAdapter.cancelDiscovery();
                if(D) Log.i(TAG,"cancel discovering before connect");
            }

            // Make a connection to the BluetoothSocket
            try {
                // This is a blocking call and will only return on a
                // successful connection or an exception
                if(D) Log.i(TAG,"Start socket connection");
                mmSocket.connect();
                if(D) Log.i(TAG,"End of socket connection");
            } catch (Exception e) {
                Log.e(TAG, "socket connect failed", e);
                // Close the socket
                try {
                    mmSocket.close();
                    if(D) Log.i(TAG,"close socket");

                } catch (IOException e2) {
                    Log.e(TAG,"unable to close() socket during connection failure",e2);
                }
                // Start the service over to restart listening mode
                BluetoothConnectionService.this.start();
                connectionFailed();
                return;
            }

            // Reset the ConnectThread because we're done
            synchronized (BluetoothConnectionService.this) {
                mConnectThread = null;
            }

            // Start the connected thread
            connected(mmSocket, mmDevice);
        } else {
            connectionFailed();
            BluetoothConnectionService.this.start();
        }
    }

    public void cancel() {
        try {
            if (mmSocket != null) {
                mmSocket.close();
            }
        } catch (IOException e) {
            Log.e(TAG, "close() of connect socket failed", e);
        }
    }
}

就在这里,当打开套接字失败时,我在关闭套接字后收到DEBUG消息。

1 个答案:

答案 0 :(得分:1)

好的,那么没有代码,你必须记住,必须通过添加以下内容在Manifest中声明蓝牙访问:

<uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission>

然后执行以下操作:

BluetoothAdapter bt_adapter = BluetoothAdapter.getDefaultAdapter();
Set<BluetoothDevice> pairedDevices =  bt_adapter.getBondedDevices();
if (pairedDevices.size() > 0) {
  // Loop through paired devices
  for (BluetoothDevice device : pairedDevices) {
    // Add the name and address to an array adapter to show in a ListView
    String name = device.getName();
    //BT2IR
    if (name.contains("K01-Blue")) {
       GlobalVars.bluetooth.bt_device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(device.getAddress());
      break;
    }
  }
}