How to clear the cached bluetooth devices from cache???

5,448 views
Skip to first unread message

aviral gupta

unread,
Sep 24, 2010, 5:48:35 AM9/24/10
to android-platform
i m facing a weird problem that whenever i m launching my app (which
scans the bluetooth devices) it does not always show the devices in
range(sometimes a blank list appears). this is due the fact that the
bluetooth devices are getting cached and on launching the app again it
does not finds any new device.


kindly help me to clear the cached bluetooth devices.


Regards
Aviral

Suresh Chandra Pal

unread,
Sep 25, 2010, 1:00:00 AM9/25/10
to android-...@googlegroups.com
Aviral,
In my understanding caching devices is a useful feature. so I am not exactly sure why do you want to clear the cached devices.
If I understand correctly then you want to scan for devices without displaying cached devices.

Anyways, the BluetoothSettings.java is the file, where it adds cached devices - by calling addDevices inside onResume().

If you can clear which of the following tasks you want to do, I might help you more:
1. Do you want it to be a feature to clear the cached devices?
2. Do you want only that - when it starts scanning, it never shows the cached devices (I wonder, in this case what will be the use of Cached Devices :) ). Also this is tricky coz when it scans new devices, it always compares the new device with the old device, and hence in this case you need to make a number of changes at different places.

Best Wishes,
Suresh Pal


--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.


Arun Kumar

unread,
Sep 25, 2010, 6:16:21 AM9/25/10
to android-...@googlegroups.com
Hi,


>i m facing a weird problem that whenever i m launching my app (which scans the bluetooth devices) it does not always show the devices in
>range(sometimes a blank list appears).

It appears that you do see the bt devices inrange occasionally but not always. There are multiple options you can explore starting with hci-tool. Results to this tool in bluez are thrown directly from the controller via a raw hci socket.

If these are on expected lines, you may focus debugging Dbus/JNI layers next. Try tapping the Bluez signals going upwards during and after a scan via dbus/eventloop.cpp in jni.



>this is due the fact that the bluetooth devices are getting cached and on launching the app again it
>does not finds any new device.

Your app will always get the delta between cache and latest scan results, whether its positive or otherwise. Caches rarely conflict with actual scan results as its also done at controller[LMP] and Bluez kernel layers. It would be premature to doubt cache philosophy and very difficult to get rid of, if you eventually decide to.


>kindly help me to clear the cached bluetooth devices.
Good luck for yr debugging ..logcat may help debugging above jni and dbus-monitor across Dbus.

--
Best Regards,
Arun Kumar Singh
www.crazydaks.com
 



Suresh Chandra Pal

unread,
Sep 25, 2010, 6:51:37 AM9/25/10
to android-...@googlegroups.com
Arun,
As I have started on Bluetooth recently and worked mainly above the jni layers. Can you tell me how to debug DBus/Jni layers.
Also. I understand that the Settings app did some kind of Caching of device at the application side.
If you see CachedBluetoothDevice.java and BluetoothSettings.java classes in settings application.
I thought that is the point Aviral might be referring to.
You mentioned that device caching happens below jni layer too. Since I have not looked below that layer yet, so I am too interested to get the idea for it. Please share your knowledge.

Regards,

Suresh Pal

Arun Kumar

unread,
Sep 26, 2010, 5:26:55 AM9/26/10
to android-...@googlegroups.com
Hi Suresh,

Even I am new to Bluetooth and learning Bluez and Android myself. The folder external\bluetooth\bluez in Android has the userspace
parts of Bluez and would be a good place to start playing with.

Also Bluez-linux forum would be the best place to check for latest updates and more info on Bluez. Happy Bluezing!


--
Best Regards,
Arun Kumar Singh
www.crazydaks.com


Naveen Jain

unread,
Sep 27, 2010, 11:53:33 PM9/27/10
to android-...@googlegroups.com

Hi Arival,

 

It is useful behavior to display cached devices (previously scanned, paired or connected) devices while we scan for new devices. I agree that some of the phones may do it differently as below -- They have a paired devices menu where all the previously paired/connected devices are listed and when you scan, it lists only newly scanned devices.

 

As Android does not have any separate menu "for paired/previously-connected" devices, there is no other way but list all previous paired/connected devices and new scanned devices together.

 

BTW: We should not forget our old friends (with whom we have paired/bonded and connected earlier) when we are looking for new friends.

 

BTW what is your exact issue?

1) The BT menu shows both cached and newly scanned devices OR 2) the BT menu does not find any new device.

 

If it is second (BT neu does not display any new devices) problem, it might be due to the fact that devices in the vicinities are not discoverable. In such you can use hci-tools to first validate if the hci-tool can scan the new devices also make sure the devices are discoverable. You might also use any other BT phone to just check if that phone can discover the devices while you scan from Android.

 

Regards,

Naveen

Suresh Chandra Pal

unread,
Sep 28, 2010, 1:31:24 AM9/28/10
to android-...@googlegroups.com
Naveen,

Can u share information about using hci-tool?

Regards,

Suresh Pal

Naveen Jain

unread,
Sep 28, 2010, 2:11:14 AM9/28/10
to android-...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages