yashsingh1/xdaforums huggingface dataset:
[HTC 10 Guides, News, & Discussion] gekkehenkie11:
[MENTION=1416236]devsk[/MENTION] I think I must have misunderstood you. You're not implying that the fingerprint scanner is somehow causing a wifi interrupt, you're simply saying that it was a wakeup cause. It wouldnt make any sense at all if the fingerprint scanner would somehow signal the wifi subsystem to wakeup, but you weren't implying that.

Anyway I still dont get it though, i was looking at my log for the disconnected wifi (but wifi on). I was again looking at those wifi wakeups and not sure how I missed it but most of them are:

+5s885ms (2) 069 +running [B]-wifi_scan[/B] wifi_suppl=disconn wake_reason=0:"506:msm_pcie_wake:200:qcom,smd-rpm:203:fc4281d0.qcom,mpm:240:fd510000.pinctrl"

wifi_scan, that's just the wifi adapator checking if there's a wifi network available. That makes sense of course (although I'd rather not have it do that, why wake up my phone to see if there's a wifi network available when it's supposed to sleep). But what doesnt make sense to me at all is that I'm also seeing:

+7m45s427ms (2) 069 +running wake_reason=0:"506:msm_pcie_wake:200:qcom,smd-rpm:203:fc4281d0.qcom,mpm:240:fd510000.pinctrl"

That seems just a general wifi wakeup. I think it must somehow also be involved in scanning for a wifi network but why isnt it called 'wifi scan' then, it makes no sense to me ... I don't think we can find out though, this is something inside the wifi chip's firmware. Maybe it's documented somewhere but I highly doubt it.
[HTC 10 Guides, News, & Discussion] devsk:
GIC is Generic Interrupt Controller. You can give a quick read if you are interested: http://www.cl.cam.ac.uk/research/srg/han/ACS-P35/zynq/arm_gic_architecture_specification.pdf (Warning: Its fairly involved and I didn't really read/comprehend all of it, but just the general idea of what we are dealing with...:))

These GICs have numbers, pretty much like IRQs. The numbers you saw most often (200, 203, 240) are also the ones I see and mentioned above. I have not seen 506 though. I have seen 365 and 481 also a lot. Its good you have provided some strings to hunt through the code and see where those wakelocks are being used in the kernel.

I am sort of going through a busy spell at work, with long weekend coming. I will not have much time to spend on researching this further in near future.
[HTC 10 Guides, News, & Discussion] gekkehenkie11:
Thanks ! I skimmed through the document briefly. But I'm pretty sure what what you call GIC in fact just ARE irq's. At least that's what they state here:

https://github.com/google/battery-historian/blob/master/wakeupreason/wakeup_reason.go

So that 200$qcom,smd-rpm would just mean IRQ 200, with name "qcom,smd-rpm". I'm not sure how it exactly works though, but as there's a pincontroller involved and that 506$msm_pcie_wake corresponds with "wifi interrupt", I guess would should read it that it all starts with that pincontroller and then ends up with a wifi interrupt. So basically the hardware sets a pin, based on some event (network packet arriving, or some other event) and then the interrupt is released. So it's basically a pin for 'wake up', which the hardware sets on certain events, I *guess*, because honestly I haven't done any work in this area before neither.
[HTC 10 Guides, News, & Discussion] masi0:
Folks, not sure if this is the same issue, but in my case wireless seems not turning off after 15 minutes when phone is not being used. it is not a conctant case, it mostly happens in the morning (after 24hr DHCP lease from my home router) - i had to reboot my router to fix this.
[HTC 10 Guides, News, & Discussion] masi0:
I have exact same RT-AC68U with stock firmware. Is this router may cause issues with the wireless on HTC 10?
[HTC 10 Guides, News, & Discussion] MNoisy:
I never had a chance to test out the stock firmware with this. I did tweak some broadcast settings slightly on the router but I did not notice a huge difference on the phone.

I finally am getting great battery life with:

On the newest firmware (1.91.617)

Increasing the wlan dividers in elementalX (3/2)

Ice Rom w/ ghostpepper v2

Slightly decreased amount of broadcasts on Asus router

I hope that helps!
[HTC 10 Guides, News, & Discussion] tonnytech:
found with latest fw and rom this issue has gone for me , i can leave wlan on now when phone sleeps and thankfully it does not keep phone awake :)
[HTC 10 Guides, News, & Discussion] Cro Cop:
Judging by the picture below, my wifi stayed on all night, even when I set the "keep wifi on during sleep" option to

never

. I see you use Viper Rom.

Stock rom, exkernel v16, pnp balanced tweak here

So custom roms like Viper, LeeDroid fix this issue, right ??
[HTC 10 Guides, News, & Discussion] DeeZZ_NuuZZ:
seems like you have older firmware when using ex kernel 0.16?

i'm on latest viper and latest firmware running with ex kernel 0.18 and i set keep wifi on only when connected and it sleeps when not connected.
[HTC 10 Guides, News, & Discussion] Cro Cop:
No, I have the newest firmware for my WWE device (1.90.401.5), I use the older ex v16 because the newer versions have a feature called analog gain which introduces static noise for me.

Anyway, seems like I have to flash a custom rom so that my wifi can "sleep" when the phone sleeps.
[HTC 10 Guides, News, & Discussion] DeeZZ_NuuZZ:
newest is 1.95.401.3, this is the one i have installed.

you mean the static noise on speakers or headphones?

on headphones i don't notice it, but installed acoustix and use only PAP

and on speakers when music mode enabled, sometimes i can hear static noise, but barely and with theatre mode there isn't really any static noise

but yea, not everyone has the same ears :D
[HTC 10 Guides, News, & Discussion] Cro Cop:
1.95 is not available for me yes, I`m stock.

-On headphones. There was an obvious static noise issue, me and three more people had it, just as described here (http://xdaforums.com/htc-10/help/static-sound-headphone-output-speaker-t3450465).

but on topic, on the picture tonnytech posted up there, it says "Wifi Active - 28:58 (1d and 4h)" , if his wifi is not active while the phone is in deepsleep, why is it like that, is that normal ?
[HTC 10 Guides, News, & Discussion] DeeZZ_NuuZZ:
i just noticed, in 7 hours your phone was just 3 minutes awake. so why do you think it's bad? wifi normally doesn't drain much, except you have really really bad and slow connection or your router fails.

maybe he meant keep awake with that the kernel will show wlan_rx wakelock and will always keep phone awake when connected to wifi. maybe just maybe [MENTION=2748936]tonnytech[/MENTION] tell us what exactly you mean
[HTC 10 Guides, News, & Discussion] tonnytech:
With 1.95.401.3 and latest rom in my case viper , my wi fi remains active yes but now the phone enters deep sleep.

Where as prior to 1.95.401.3 whilst wi fi was active the phone would not enter deep sleep and drained way more battery.

The only work around this prior to above for me was to disable wi fi when sleeping in settings and using data. I have posted pictures in this thread detailing issues prior.
[HTC 10 Guides, News, & Discussion] andybones:
That is very good Wi-Fi drain.

It seems you either have Wi-Fi connected the entire 7 hours, or more likely you babe Wi-Fi scanning on, which Eben when Wi-Fi is turned off or is set to turn off when in deep sleep it stays active. Rom has nothing to do with this, during the rom setup is when this is initially chosen.

http://www.howtogeek.com/211186/how-to-disable-google-location-wi-fi-scanning-on-android/
[HTC 10 Guides, News, & Discussion] Cro Cop:
I have wifi scanning + Google Location service turned off for good.

I have now flashed Leedroid + exkernel + PnP tweak (no xposed), and wifi active time looks much better during sleep when wifi is left enabled.

God knows how it will be when Nougat comes (I`ll go stock when it does).
[HTC 10 Guides, News, & Discussion] EtherealRemnant:
I'm at my wit's end with this phone. I switched to T-Mobile's unlimited plan just so I could be on 4G all the time and WiFi is still on even though I have WiFi disabled and location enhancement off. The icon goes away but WiFi is still on... The steep drain was when the phone was asleep!
[HTC 10 Guides, News, & Discussion] Cro Cop:
This is just plain weird. Maybe you can try reseting the network settings in Backup settings. Also you can try wipe cache.
[HTC 10 Guides, News, & Discussion] Igor6661:
nope, same thing here, even if you turn wifi OFF, it always shows it's ON. although it drains less battery when it's OFF. i really hope Nougat will change something for better...
[HTC 10 Guides, News, & Discussion] INDIAN-MAfIA:
Even with wi-fi scanning off?

Settings?Locations?Three dots?Scanning
[HTC 10 Guides, News, & Discussion] Igor6661:
yep.

but since wifi is OFF that option is not relevant in my opinion.
[HTC 10 Guides, News, & Discussion] racingmatt1:
Can anyone recommend a good app that turns Wi-Fi on and off automatically when leaving/entering location without root and doesn't use much battery
[HTC 10 Guides, News, & Discussion] gekkehenkie11:
*DISCLAIMER* I'm on a 6p running Nougat, yet I think we're experiencing the exact same issue.

[MENTION=1416236]devsk[/MENTION] (and others) So I've made some very interesting progress on the wifi drain. What I noticed before is that the wifi wakeups as logged in Android's batterystats didn't correlate to any TCP traffic as I was logging with the network log app. So it would only make sense that it wouldn't be TCP traffic but wifi management messages that would wake up the device, but I didn't have any means to verify that, untill [MENTION=4533695]rchtk[/MENTION] brought up (in a 6p thread) the nice idea of running wireshark in monitor mode. This "monitor mode" can only be activated on certain wifi chipsets, luckily I had one of the correct chipsets in my old notebook. What it does is that it captures ALL wifi traffic going through the air, including the wifi management messages. So what I did was I reset the batterystats in Android at the same time I started the wireshark sniffer, so the timestamps would roughly correlate. So I did this various time to see if it was a specific message that would always be there when the device would wake up. And there was ! It's an "ICMPv6" protocol message with name "Router advertisement",which would ALWAYS be there when I saw this in the batterystats:

+59s482ms (2) 041 +running wake_reason=0:"506:msm_pcie_wake:200:qcom,smd-rpm:203:fc4281d0.qcom,mpm:240:fd510000.pinctrl"
+1m00s202ms (2) 041 -running wake_reason=0:"Abort:Last active Wakeup Source: wlan_wake"

(which is the device being woken up by the wifi subsystem as discussed earlier). Now the interesting thing is that this message is being broadcasted by my old router (on which my device drains) every 3 seconds. BUT the device is not being woken up every 3 seconds: it will wake up on some of these messages, but not on every single one of them. BUT every single time you see the above in the batterystats, that message is there.

So in short, I feel it's pretty safe now to say that I've finally found the culprit, being this "Router advertisement" message waking up the device. Next step would be to research into this message
[HTC 10 Guides, News, & Discussion] devsk:
Someone else had reported on this earlier. Yes, there are multiple reasons for the wakeup. And RAs (Router Advertisements) for IPv6 are part of the this problem. If you disable IPv6 on your router for testing purposes, you can take this specific element out of the picture. But the wakeups and drain seen for other reasons will still be there....:) Its a complex problem. Android just does not pay attention to battery life aspect of the wifi wakeup.
[HTC 10 Guides, News, & Discussion] gekkehenkie11:
Unfortunately I can't disable IPv6 on my old router so I can't verify it but I think it indeed might fix it. Of course there are other wakeups but these will be from within Android itself (apps waking up the device like google sync services). But the main drain here is this Router advertisement on Ipv6, I'm sure of it after my analysis.

I've done analysis of wakeups on my new router (that doesn't cause wakeups) and I could trace back pretty much all remaining wakeups to apps/services waking up the device (mainly google sync services). So at least the mystery of the source behind the wakeups is solved now.

My main question right now is though: why the hell is this 'router advertisement' message waking up the device ?!?! I wonder if there's even a way to find out since this will be happening in the wifi firmware I guess ? Which makes me think, did anyone try flashing the old wifi firmware ? I think a wifi FW update is included in every android release, if I remember correctly, will look into that. Cause this didnt happen on the LP version of our 6p ROM's .
[HTC 10 Guides, News, & Discussion] donibrasco:
Guys, give you some light, if you use viber you must choose settings-general- wifi sleep policy-use device's settings (see the screenshot) instead even wifi turned off this app will keep it always on! Make sure you check other apps.
[HTC 10 Guides, News, & Discussion] grega_slo:
Errr yes, I figured that out ages ago and reported it here but some ppl claim that they have disabled ipv6 on phones completley. But radio firmware still registers ra from network even if phone has disabled ipv6. If you disable ipv6 on router however, this stops ra flood completely.

Nougat won't do any better, this one needs radio firmware update to correct behaviour...

And btw, since I reconfigured my router my drain is 0.4% per hour during night...
[HTC 10 Guides, News, & Discussion] gekkehenkie11:
I just searched your name through the thread and you indeed came to the same conclusion and indeed got your phone to sleep by disabling ipv6. LOL, not sure why people were still discussing this issue, your posts should be sticky in first post, would have saved me quite some trouble inventing the same wheel as you did :)

Anyway it does kinda suck, since it turns out to be a WIFI firmware issue, fixing it would be hard for us. I could take a look at the WIFI firmware (it's in the vendor partition and seems to be loaded dynamically on each boot). It might be signed though. But if not, in theory we could see if we could find the handler for router advertisement messages and just kill the IRQ wake-up request it sends. But this would be a hell of a job anyway I'm afraid. I might take a look though. Otherwise the work around would indeed be changing the router/settings

BTW, I just flashed back 6.0.1 to my 6p (i was running Nougat) and it had the same issue, weird, not sure why I never noticed it on 6.0.1 before, but then again, I never did too much work on the 6p.

BTW2, on Nougat on my 6p my phone is now losing 0.25% per hour with wifi on, I think that's the best wifi battery usage I've seen on any of my phones/firmwares :)
[HTC 10 Guides, News, & Discussion] Haldi4803:
Welll glad it works for you. Let's see if it still does tomorrow or the day afer tomorrow.

I currently have WiFI Disabled in Sleep mode. So no actual stats. Can't do them tonight, but i'll try again on Monday night.
[HTC 10 Guides, News, & Discussion] devsk:
Like I said before its not the only source of wakeups. I have completely disabled IPv6 on both router and on the phone, I continue to get "external" wakeups, not created by the apps. Its a complex problem guys! You are affected by one aspect, does not mean all are affected by that aspect of it alone.

For example, I found another source of wakeups is DTIM related packets that arrive from router. Another one was ARP requests coming from the router. There are several wakeups I can't attribute to anything.
[HTC 10 Guides, News, & Discussion] Haldi4803:
In short... We're ****ed!

btw, [MENTION=3296134]gekkehenkie11[/MENTION] you're using the "dumpsys batterystats --reset" command for resetting Battery Stats?

That's what i used on 1.80 ROM, but now on 1.92.709.1 it doesn't work anymore on my HTC10 -.-

"Error dumping service info: (Unknown error -2147483646)"
[HTC 10 Guides, News, & Discussion] grega_slo:
It works for me since then...

So for sure a month or so...
[HTC 10 Guides, News, & Discussion] gekkehenkie11:
I haven't seen any 'external' wakeups apart other than those Router advertisements myself. Well there are also wifi scanning wakeups (you should disable wifi scanning), they mostly occur though when you're not connected to a wifi network.

What I did, is I used my new router (on which IPv6 is disabled) and ran a tcpdump and compared this to the wakeups as depicted in the batterystats. The remaining wakeups were ALL corresponding to the TCP messages in the tcpdump, 95% of the time it was an IP from the Google network. Disabling pretty much all syncing cut down heavily on that and now my phone sleeps better than any device I've ever owned, on Nougat that is.
[HTC 10 Guides, News, & Discussion] gekkehenkie11:
Yep, been on my new router for about a week (which has ipv6 disabled), and my phone has been sleeping like a baby too :) No more issue's here.
[HTC 10 Guides, News, & Discussion] gekkehenkie11:
yes, not sure why it's not working for you, haven't seen that error myself.
[HTC 10 Guides, News, & Discussion] racingmatt1:
So what app do you recommend I'm not rooted
[HTC 10 Guides, News, & Discussion] donibrasco:
Don't use third party apps for that. Just found what keeps my wifi aweken even with turned wifi off, so it was viber and changed setting like on the screenshot (did you check it). No need root e.t.c.
[HTC 10 Guides, News, & Discussion] racingmatt1:
So you want me to keep the Wi-Fi on all the time ?
[HTC 10 Guides, News, & Discussion] Haldi4803:
Btw, in the dumpsys of WiFi i found this line here...

*** firmware logging disabled, no debug data ****

set config_wifi_enable_wifi_firmware_debugging to enable

anyone tried?
[HTC 10 Guides, News, & Discussion] donibrasco:
That's what I'm trying to explain you is wifi working just fine. If you don't have some app which keeps wifi aweken and default wifi settings are settled correct, wifi automatically goes off when there is unavailable net, and automatically goes on when some wifi coverage pops up.
[HTC 10 Guides, News, & Discussion] racingmatt1:
My device settings are to leave on always when sleeping
[HTC 10 Guides, News, & Discussion] mcwups1:
Wow. I can't believe I haven't seen this. I'm on Sprint and have this issue constantly even with the new base.
[HTC 10 Guides, News, & Discussion] EtherealRemnant:
Well I did double check and location scanning was indeed on even though I thought I disabled it. Turned that off so let's see what happens now.

I have an ASUS AC-68U (technically it's the T-Mobile rebranded TM-1900) with IPv6 turned off and I still get massive wifi drain.

Also, if you use ES File Explorer to scan app permissions, look for ones that have access to changing the wifi state. When I first switched to the unlimited plan with T-Mobile, I'd turn wifi off and come back a few minutes later to find it was back on so I went in and ran the scan. Forgot I had the Xfinity WiFi helper. Took it off the phone and WiFi stayed off after that (other than the scanning apparently).

I don't recommend keeping ES on your device - disable it or freeze it in Titanium Backup - because it has some rather obnoxious adware behavior but it's an effective permission scanner and it's thorough and free.
[HTC 10 Guides, News, & Discussion] EtherealRemnant:
Such a ridiculous difference. I mean seriously. Wifi scanning off. 1 hr SoT, 17hr standby.

HTC really needs to fix this...
[HTC 10 Guides, News, & Discussion] Haldi4803:
I can top that ;) with WiFi on.

Formated Data and on Stock 1.92.709.1 No root, No xposed nothing.

Lets See when the WiFi drain Beginns...
[HTC 10 Guides, News, & Discussion] racingmatt1:
If no root how are you able to use BBS?
[HTC 10 Guides, News, & Discussion] Haldi4803:
You can use the basic Features without Root ;)

And guess whats back?

The Battery drain!

And as always i fail to spot any difference...

(except from the obvious "phone state" which was probably Log full and couldn' save more, like "activity manager proc")
[HTC 10 Guides, News, & Discussion] devsk:
Haldi: have you tried CM13 yet? It may not be tuned but possibly rules out the userspace involvement.
[HTC 10 Guides, News, & Discussion] Haldi4803:
Last time i tried there was no deepsleep xD

As soon as Multirom works I'll run some CM.
[HTC 10 Guides, News, & Discussion] Ivanovic:
Charged the phone to 100%, left it unplugged the whole night and I lost 20% while using only data I am losing just 2-4% overnight. Didn't have the change to try it so far coz I was charging my phone when I was sleeping but yesterday I want to see if my phone suffers from the same "bug"

Στάλθηκε από το HTC 10 μου χρησιμοποιώντας Tapatalk
[HTC 10 Guides, News, & Discussion] Haldi4803:
Beanstalk.

0.2%/hour

But well, that's an unfair comparison as I don't have GAPPs installed yet.

And I have to try multiple times, there were also some good runs on stock... Once.... Whyever...

Trying to get the SRA script running. 20min screen off + script somewhen this evening.
[HTC 10 Guides, News, & Discussion] devsk:
Can you pls screenshot the 'System' in BBS? I think userspace being different between AOSP and Sense will be create interesting dynamics for battery usage.

Your suspend abort action is very minimal. This is what causes the major damage to the battery life.
[HTC 10 Guides, News, & Discussion] Haldi4803:
System?

http://cloud.tapatalk.com/s/57e41b227ee7f/BetterBatteryStats-2016-09-22_120644686.txt
[HTC 10 Guides, News, & Discussion] devsk:
darn! I meant 'Process' and have a look inside that for "system". The system is very chatty on Sense ROM compared to CM.
[HTC 10 Guides, News, & Discussion] gekkehenkie11:
This has nothing to do with the kernel or userspace. This is a problem in the broadcom wifi firmware. This firmware is actually dynamically being loaded to the WIFI chipset RAM at each boot (it's located in /vendor/firmware in my nexus, not sure what the location is for the htc 10 but you can easily see it in the ramdisk config files). I've been reverse engineering the firmware for my 6p (almost the same broadcom chipset as you guys have, we have BCM4358, you have BCM4359). The architecture is ARM and you can analyse it in IDA pro if you know assembler of course (make sure to load it to the correct loading address, in the 6p it's 0x180000 but you can find out via the kernel log). I've actually managed to locate the ipv6 router advertisement handler in the code (by searching for a cmp with #0x86, which is the ipv6 router advertisement message type, and confirmed it was correct because that code was also checking 0x3A at the correct offset, which should be there in those ipv6 headers).

Simply cutting that out unfortunately doesn't solve it, the wakeup is handled by code after that. The problem though that makes the analysis quite difficult is that the API part of the code is not in that FW file, but is in ROM and I don't know how to dump that (it's the memory region below that 0x180000). So it's really hard to find out what an API call does when you don't have code for it :( I'm still messsing around with it for the fun of it but I'm not really optimistic this will lead to a fix, since it's really hard without API code.