I am trying to find a way to have a tablet basically auto-accept/give permission to accept an incoming Bluetooth Share file transferred from a laptop to my Nexus Android device. Since the Android bluetooth system itself does not support this feature, I was wondering if this could be done programmatically using an Android application that listened for the notification and accepted it for me.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
MUCH EASIER WAY
If you have a rooted device and use XPosed Framework, your goal can be achieved much easier.
You Need not implement your own bluetooth server nor kill the original BT service, which are very bothering!!!
xposed tutorial link.
Try this code.
I tested and it works fine:)
Links
Dropbox link of the auto accepting app
Dropbox link of the project files (zip)
Xposed apk site
Towelroot site to root your phone
Background(Original answer)
As I commented above, you bay be able to, and I tried and succeeded in blocking (though not receiving) with this code.
The code above hooks the method
startListenerSocket()
ofcom.android.bluetooth.BluetoothOppService
and prevents the original method from being called by the lineparam.setResult(null);
Refer to here to see the full code of
com.android.bluetooth.BluetoothOppService.java
and you will understand the operation.And the code you can start from is shown below.
This code hooks the
onPut
method ofcom.android.bluetooth. BluetoothOppObexServerSession
linked here. I either am newbie to xposed framework but I hope my answer helped.I had the same issues you asked and partially solved the problem by implementing my custom OBEX server and manually / programmatically(with
ps|grep
andsu kill pid
) killing the native BluetoothOppService. But I will either try the idea of hooking and directly executing my code.And to help you customize OBEX server session I post my implementation below.
I just removed some rejecting codes from the original one.
Also to look at my full code please refer to my git repository.
I also thank the contributors to the android project!