I have device which sends data via Bluetooth using OBEX Object Push Profile (OPP).
Using adb logcat i see that my android device receives a connection (but abort this connection?)
08-22 11:14:37.939: I/BtOppRfcommListener(22586): Accepted connectoin from 00:07:CF:5F:52:A0
08-22 11:14:37.939: I/BtOpp Service(22586): Start Obex Server
08-22 11:14:38.109: D/Obex ServerSession(22586): java.io.IOException: Software caused connection abort
08-22 11:14:38.109: D/PowerManagerService(180): @PowerManagement: 'BtOppObexServer' releaseWakeLock when screen locked
08-22 11:14:39.219: D/BluetoothEventLoop(180): Device property changed: 00:07:CF:5F:52:A0 property: Connected value: false
When I install Bluetooth File Transfer (Free application from market) then i'm able to receive files. But I wouldn't like to install other application.
I believe I have (at least a partial) solution which should then allow files to be intercepted via OPP and custom code added. The first step is to go to settings > apps > running > Bluetooth Share and kill the
BluetoothOppService
Then I used reflection to access a method on
BluetoothAdapter
(code below) which allows listening on a specific port. After which we can intercept the incoming OPP communication and interact with the input and output streams. This SO thread will help with the OPP communication part, but as an initial step I read the data stream and reponded with an OPP 'OK' message ieos.writeByte(ObexSession.OBEX_SUCCESS | ObexSession.OBEX_FINAL_BIT);
Usage: initialise using
After which, use the following from a separate
Thread
(to prevent blocking) and remote devices can connect viasocket = serverSocket.accept();