Monday, May 16, 2011


Looting Android's log files

Hello, my faithful droogsreaders. Been awhile since I've posted here, because I've been super-busy, mostly writing code. But I'm off travelling for a couple of months shortly (Ethiopia, France, Ladakh) so I thought I'd leave you with a little Android/Bluetooth tidbit before I go:

In theory, any Android 2.1-or-later device can open serial port protocols to any Bluetooth device. In practice, though, a bunch of handset manufacturers have, for reasons known to them alone, crippled their Bluetooth stack so that they can't Discover (a word with a loaded meaning in Bluetooth) any device with a generic (ie set to 0) Bluetooth class.

How annoying, no? However, it turns out that - even on those devices - you can pair with and connect to those devices, if you know their address. "But Jon," you say, "how can I get their address, if the Discovery process has been crippled?"

Well. It turns out that the Qualcomm drivers in question, when they ignore the generic Bluetooth devices, do write to the Android log file the fact that they are ignoring it. So all you need to do is mine your log files for the address. How do you do that? So glad you asked.

First, add to your AndroidManifest:

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

Second, use this method:

private Set checkLogs() {
HashSet devices = new HashSet();
if (mAdapter==null)
return devices;

//check the logs
Log.i(""+this, "Log check...");
try {
Process process = Runtime.getRuntime().exec("logcat -d *:e");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
String deviceAddress=null;
while ((line = bufferedReader.readLine()) != null) {
if (line.indexOf("0x00 - skip it") > 0) {
int end = line.indexOf("] class");
int start = line.indexOf("Device [");
if (start>=0)
start=start+"Device [".length();
deviceAddress = line.substring(start, end);
Log.i(""+this, "Found "+deviceAddress+" in log");
BluetoothDevice device = mAdapter.getRemoteDevice(deviceAddress) ;
//String deviceName = device.getName()==null ? device.getAddress() : device.getName();
//Util.DoToast(Main.this, "Discovered device "+deviceName);
return devices;
catch(IOException ex) {
Log.e(""+this, "Error checking logs - "+ex);
return null;

...and finally, just connect to the device explicitly:

btSocket = device.createRfcommSocketToServiceRecord(GatewayManagerConversation.uuid);

...and that should trigger the pairing process, and after pairing, you can connect to the device (which will be in your local cache of paired devices, as normal.)

Hope that helps!

Labels: , ,

I took the same log file approach, but I have written an AsyncTask that kicks of discovery, and they retrieves just those devices that were 'skipped' during that discovery. This will avoid finding multiple devices, and won't require the user to kick of a discovery in the phone settings first :)

You can find it here.

anks for sharing this informative content.,
Leanpitch provides online training in Agile team facilitation during this lockdown period everyone can use it wisely.

Agile team facilitation

Thanks for sharing this informative content.,
Leanpitch provides online training in Agile team facilitation during this lockdown period everyone can use it wisely.
Team facilitator Agile

Agile facilitator
Thanks for sharing this informative content.,
Leanpitch provides online training in Agile team facilitation during this lockdown period everyone can use it wisely.
Team facilitator in Agile


Excellent content ,Thanks for sharing this .,
Scrum master certification online
CSM certification online

Your easiest option, and Apple’s first recommendation, is to back up your iPhone to iCloud. APPIC Directory | how to add Apple gift card to wallet | how to reset PS4 | Windows 10 password reset | how to backup iPhone to iCloud | how to load money on cash app card | How to Reset Apple Id Password if Forgotten | activate | TotalAV Account login |

Nice Blog. Thanks for sharing with us. Such amazing information.

Main causes for failure in digital marketing strategy
I never heard about this method. I will try this but first I have to complete some projects of Hrm Dissertation Editing Services Uk. Then I will definitely give it a try and give my opinion on this method.
Well, you shared outstanding information about the android log files. I never heard anything about android log files, but I am sure this information might be helpful for Android users. I will share this post with my younger brother, and he will try this method of looting android log files.
Best Assignment Writing Services

This really is such a awesome write-up. I’ve been looking for this information for quite a while now and then finally stumbled upon your internet site. Thanks so much for posting this, this has helped me out tremendously. By the way I love the style of the blog, looks good, did you create it all by yourself?


Wow! After all I got a web site from where I can actually get valuable information regarding my study and knowledge.|
Such a very nice post. Top assignment help

Great Blog! I have go through all the content of this blog.This is really helpful and informative for me and all the readers.We are offering an online business management research topics ideas for those students,who have interested to avail this service at a cheap price.

This is very nice guys! I would love to recommend you a beautiful service for homework! If you need some help, just text to them personal statement professional and be ready for help! They rally know how to it!
Thank you for this informational post. I really like your content. Keep Posting. If your Roadrunner Email Not Working with Outlook and looking for technical help. Please contact us.
Most students who only have one lesson at a time use research paper writers to free up their time by writing any kind of written paper on it for a small fee.I am glad that I found a site where I can easily order various essays.
Want to make best assignment in civil engineering assignment help get it done with help of our professional who provide you best content also provide your assignment on time with best price.
The bedroom is a place for intimacy and privacy. One of the best ways to ensure both is by using a Queen Size Bed instead of sharing one with your partner. The designer full-size beds at Grayson Living are an elegant way to keep up the romance in your life, but also maintain that private space where you can retreat when you need it most.
Our business is dedicated to introducing companies to potential partners and helping them grow. We consult with our clients on their business SBLC discounting in Dubai and challenges, and we think that client collaboration and co-development is the best way to achieve successful and long-lasting outcomes.
interactive SPAs, we ensure responsivenessWeb Development dubai and cross-browser compatibility, as well as live up to users’ high expectations in agility and performance.
Grayson Luxury offers a wide selection of Modern Accent Chairs that can bring elegance to any living room. Whether you are looking for a traditional style or something more contemporary, our luxury furnishings have the perfect option for your needs.
Most of the top martial arts schools are successful in instructing children, adults, and individuals of all ages and ability levels, from beginners to black belts.

You explained it nicely and the best part is providing the code. Thanks sharing the code. It is much helpful. Keep sharing more tech tidbits like this and update us also. Halifax DUI VA
Thank you for sharing this helpful content with us.Adobe Photoshop is one of the world's best and most versatile image editing tools. With it, you can do anything from retouching to creating a new image or illustration. In addition, you can Buy Adobe Photoshop from PI Software to animate your images with layered content that moves independently. Buy-Adobe-Photoshop
Emirate Coffee Coffee Beans Dubai the unique taste of beans makes your day happy

Post a Comment

Subscribe to Post Comments [Atom]

<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]