我使用示例蓝牙聊天应用程序(https://android.googlesource.com/platform/development/+/eclair-passion-release/samples/BluetoothChat)与facebook的隐藏库(希望)加密设备之间的通信。我更改了ConnectedThread构造函数:
public ConnectedThread(BluetoothSocket socket, String socketType) {
Log.d(TAG, "create ConnectedThread: " + socketType);
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
InputStream cryptIn = null;
OutputStream cryptOut = null;
// Get the BluetoothSocket input and output streams
try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
>> cryptIn = crypto.getCipherInputStream(tmpIn,entity); << gets stuck on this line
cryptOut = crypto.getCipherOutputStream(tmpOut,entity);
} catch (IOException e) {
Log.e(TAG, "temp sockets not created", e);
}
catch (CryptoInitializationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (KeyChainException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mmInStream = cryptIn;
mmOutStream = cryptOut;
}
它会卡在该行上,但不会返回任何类型的错误或堆栈跟踪(它只是冻结)。我还要通过beam在设备之间传递钥匙串名称,以便在调用ConnectedThread之前创建加密对象。
显然,我对android和隐藏起来很新。谢谢你的意见。