FORUMS
Remove All Ads from XDA

Permanent fix for Bluetooth battery drain on stock 7.1 N108

277 posts
Thanks Meter: 96
 
By boxes, Senior Member on 13th May 2018, 09:41 PM
Post Reply Email Thread
I found a permanent fix for the Bluetooth battery drain bug on stock 7.1, the last n108 release.

Root is required for this fix.


First, go to developer settings and enable Bluetooth hci Snoop log. Reboot. Then disable the Bluetooth hci log. Reboot.

Next, using a root file explorer (I used ES file explorer), navigate to /system/etc/Bluetooth/
Open bt_stack.conf

Near the top is "BtSnoopConfigFromFile=false"
Change it to true, then make sure the following two lines are set to false.
BtSnoopLogOutput=false
BtSnoopExtDump=false

Save the file and reboot.

After some browsing on the nextbit forums, someone had identified that the Bluetooth Snoop hci log was being written to the root directory of /sdcard/, causing significant battery drain. Their solution was to toggle the Bluetooth log on in developer settings, reboot, turn it off, then reboot again. It would always turn itself back on though. This prevents that.
(Bluetooth hci log is a file where android literally records all Bluetooth traffic information, which as you might imagine is CPU and I/o intensive. Normally used by devs for troubleshooting).

I decided to go back to stock due to constant bugs and freezes with the lineage 14.1 builds. Battery life has even been a little better on stock, with rock solid stability.

This prevents the battery drain aspect, but the battery settings still has a reporting error that attributes much more drain to Bluetooth than it should. I'm still getting 3-4hrs screen on time with lots of Bluetooth use after this fix. Better battery stats will provide accurate drain stats.
The Following 7 Users Say Thank You to boxes For This Useful Post: [ View ] Gift boxes Ad-Free
 
 
21st June 2018, 09:41 PM |#2  
Junior Member
Thanks Meter: 2
 
More
This is excellent information - thanks for posting - however, I get stuck when trying to save the proposed changes to bt_stack.conf; the file is read-only and I cannot figure out how to change it to allow me to save the changes. How did you do that on the stock ROM?
22nd June 2018, 05:38 PM |#3  
OP Senior Member
Thanks Meter: 96
 
More
Quote:
Originally Posted by Bleser

This is excellent information - thanks for posting - however, I get stuck when trying to save the proposed changes to bt_stack.conf; the file is read-only and I cannot figure out how to change it to allow me to save the changes. How did you do that on the stock ROM?

Is your phone rooted? I used ES File explorer with "root mode" enabled. You can only make changes to the file with a root elevated program. There is also solid file explorer and root file explorer as other options that may work. I should have mentioned root is required.

I believe ES file explorer changes the permission automatically when in root mode, to allow changes. Other apps may require manually changing the permissions of the BT config file.

I did also run 'hide magisk manager" in the magisk settings.
22nd June 2018, 07:41 PM |#4  
Junior Member
Thanks Meter: 2
 
More
Quote:
Originally Posted by boxes

Is your phone rooted? I used ES File explorer with "root mode" enabled. You can only make changes to the file with a root elevated program. There is also solid file explorer and root file explorer as other options that may work. I should have mentioned root is required.

I believe ES file explorer changes the permission automatically when in root mode, to allow changes. Other apps may require manually changing the permissions of the BT config file.

Hi @boxes,

No, it is not rooted. I will try ES File explorer. Thanks!
22nd June 2018, 08:07 PM |#5  
OP Senior Member
Thanks Meter: 96
 
More
Quote:
Originally Posted by Bleser

Hi @boxes,

No, it is not rooted. I will try ES File explorer. Thanks!

You will need to be rooted to do this. If you root with magisk, then you can still pass the safetynet check.

Rooting the robin is very easy luckily.

Follow these steps to unlock the bootloader and flash TWRP.
https://forum.xda-developers.com/nex...robin-t3334171
(Use this TWRP rather than the one on that thread-)
https://forum.xda-developers.com/nex...overy-t3334152

Then download magisk from here-
https://forum.xda-developers.com/app...mless-t3473445

Also download the magisk manager APK. Flash magisk from TWRP then install magisk manger in android.
26th June 2018, 08:39 PM |#6  
Junior Member
Thanks Meter: 2
 
More
Quote:
Originally Posted by boxes

Is your phone rooted? I used ES File explorer with "root mode" enabled. You can only make changes to the file with a root elevated program. There is also solid file explorer and root file explorer as other options that may work. I should have mentioned root is required.

I believe ES file explorer changes the permission automatically when in root mode, to allow changes. Other apps may require manually changing the permissions of the BT config file.

Quote:
Originally Posted by boxes

You will need to be rooted to do this. If you root with magisk, then you can still pass the safetynet check.

Rooting the robin is very easy luckily.

Follow these steps to unlock the bootloader and flash TWRP.
https://forum.xda-developers.com/nex...robin-t3334171
(Use this TWRP rather than the one on that thread-)
https://forum.xda-developers.com/nex...overy-t3334152

Then download magisk from here-
https://forum.xda-developers.com/app...mless-t3473445

Also download the magisk manager APK. Flash magisk from TWRP then install magisk manger in android.

Thanks again for your help!
3rd July 2018, 12:00 AM |#7  
Member
Thanks Meter: 15
 
More
Quote:
Originally Posted by boxes

I found a permanent fix for the Bluetooth battery drain bug on stock 7.1, the last n108 release.

Root is required for this fix.


First, go to developer settings and enable Bluetooth hci Snoop log. Reboot. Then disable the Bluetooth hci log. Reboot.

Next, using a root file explorer (I used ES file explorer), navigate to /system/etc/Bluetooth/
Open bt_stack.conf

Near the top is "BtSnoopConfigFromFile=false"
Change it to true, then make sure the following two lines are set to false.
BtSnoopLogOutput=false
BtSnoopExtDump=false

Save the file and reboot.

After some browsing on the nextbit forums, someone had identified that the Bluetooth Snoop hci log was being written to the root directory of /sdcard/, causing significant battery drain. Their solution was to toggle the Bluetooth log on in developer settings, reboot, turn it off, then reboot again. It would always turn itself back on though. This prevents that.
(Bluetooth hci log is a file where android literally records all Bluetooth traffic information, which as you might imagine is CPU and I/o intensive. Normally used by devs for troubleshooting).

I decided to go back to stock due to constant bugs and freezes with the lineage 14.1 builds. Battery life has even been a little better on stock, with rock solid stability.

This prevents the battery drain aspect, but the battery settings still has a reporting error that attributes much more drain to Bluetooth than it should. I'm still getting 3-4hrs screen on time with lots of Bluetooth use after this fix. Better battery stats will provide accurate drain stats.

For extra security you can change the permissions of the .conf file to read only for all groups.

Bless you! I should have looked into this earlier but never got around to it, having just left Bluetooth off except when charging. Will see if I can do a bind mount over the file with Magisk so I can leave the system image read-only.

---------- Post added 3rd July 2018 at 12:00 AM ---------- Previous post was 2nd July 2018 at 11:57 PM ----------

In the process of looking this up, I discovered a Magisk module to fix the Bluetooth config problem already exists:
https://forum.xda-developers.com/app...p-log-t3680223
You do not need to edit your system image, just install Magisk and then use Magisk Manager to install this module.
3rd July 2018, 06:08 PM |#8  
OP Senior Member
Thanks Meter: 96
 
More
Quote:
Originally Posted by iscaela

Bless you! I should have looked into this earlier but never got around to it, having just left Bluetooth off except when charging. Will see if I can do a bind mount over the file with Magisk so I can leave the system image read-only.

---------- Post added 3rd July 2018 at 12:00 AM ---------- Previous post was 2nd July 2018 at 11:57 PM ----------

In the process of looking this up, I discovered a Magisk module to fix the Bluetooth config problem already exists:
https://forum.xda-developers.com/app...p-log-t3680223
You do not need to edit your system image, just install Magisk and then use Magisk Manager to install this module.

I tried that and it didn't work for me, I replied to the thread a while back. At least with magisk v16.

Are you concerned about passing the safetynet check? I ran the check in magisk manager and passed, both ctsProfile:true and basicIntegrity:true

I'm still able to download apps from the play store that block rooted/modified devices. Magisk is masking the changes perhaps.

edit: I tinkered with magisk, enabling "hide magisk manager" and now it wont pass safetynet check. So I reinstalled magisk manager. This time I didnt "hide magisk manager", but I enabled "magisk core only mode" and checked the box for "Magisk Hide" and "Systemless Hosts" (I use adaway), now it passes the safetynet check again.
3rd July 2018, 10:39 PM |#9  
Member
Thanks Meter: 15
 
More
Quote:
Originally Posted by boxes

I tried that and it didn't work for me, I replied to the thread a while back. At least with magisk v16.

Are you concerned about passing the safetynet check? I ran the check in magisk manager and passed, both ctsProfile:true and basicIntegrity:true

I'm still able to download apps from the play store that block rooted/modified devices. Magisk is masking the changes perhaps.

After installing the module, I had to turn "Enable Bluetooth HCI snoop log" on in "Developer options", reboot, and turn it back off again, but it seems to have worked and /sdcard/btsnoop_hci.log stopped growing in size.
The file was also not recreated after I deleted it and rebooted one more time. So I think the extra steps are necessary whether using the module or editing the original file in the system image (there's lingering config data which could in theory be handled in the module as well if ).

Quote:
Originally Posted by boxes

edit: I tinkered with magisk, enabling "hide magisk manager" and now it wont pass safetynet check. So I reinstalled magisk manager. This time I didnt "hide magisk manager", but I enabled "magisk core only mode" and checked the box for "Magisk Hide" and "Systemless Hosts" (I use adaway), now it passes the safetynet check again.

I've had Magisk installed since I first got the phone and except for a brief period in mid 2017, SafetyNet checks have been passing with "Magisk Hide" alone, without selecting "core only mode" (which disables modules). I'm also using "Systemless hosts" for AdAway.
3rd July 2018, 10:51 PM |#10  
OP Senior Member
Thanks Meter: 96
 
More
@iscaela
How long has it been since you did that? Just the process of enabling/disabling in dev options would fix it for a day or two in my experience.
4th July 2018, 03:01 AM |#11  
Member
Thanks Meter: 15
 
More
Quote:
Originally Posted by boxes

@iscaela
How long has it been since you did that? Just the process of enabling/disabling in dev options would fix it for a day or two in my experience.

Just over 12 hours today. I've rebooted twice recently and it's stayed the same. I doubt there's a time component to it reverting, the config loading is pretty simple.

Interestingly, bluedroid is still listening on port 8872 as documented at https://android.googlesource.com/pla...btsnoop_net.md but isn't producing any traces.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes