[Sony Xperia XZ Guides, News, & Discussion] Corgism:
Hi I got an Xperia XZ and have been experiencing similar annoyances in regards to battery life (20% drain overnight). I did an extensive study on my XZ over the course of 2 weeks and have found it's wifi related, could be hardware or software, but never got about finding a solution that fixed it (aside from keeping wifi off and the phone on mobile data all the time).

Background: Bought the phone brand new in the US, but being used in Europe. Phone was manufactured Week 37, 2017. Rooted on Day 1 and upgraded to Nougat (41.2.A.7.76), so the gap in my testing is that I don't have 'control' numbers from XZ on Marshmallow. I did, however, have a 3 year old Xperia Z3 loaded with a nearly identical setup (root, Xposed, same apps) on Lollipop for reference.

Every day of testing started out with the phone charged to 100% by 6pm. I recorded battery percentages at:

9pm: Phone stops being used and physically sits on the table (there's 1 or 2 times when I use the phone to check the time during the night)

6am: Morning usage of the phone involves light checking of email and social media, playing some music for 15 mins via loudspeaker, that's it.

9am: Phone disconnected from wifi network (but Wifi still enabled) and on mobile data until 3pm. Normal usage of phone: Regular texting, web browsing for about 1.5 hours, music via headphone jack for 1.5 hours.

3pm: Phone is plugged into charger and charged to 100%, unplugged at 6pm

The disturbing part is the XZ's overnight battery drain (9pm to 6am, 9 hours of doing nothing) was typically 20% while regular daytime usage (9am to 3pm, 6 hours of regular use) averaged 15-20%. In comparison, the Z3 with its original 3 year old battery and fully loaded with apps had overnight drain (9pm to 6am) of 8%!

My XZ setup is as follows: stock Nougat ROM, "useless" apps included in stock OS removed via System App Remover, rooted, Magisk (latest version), Viper4Android, Whatsapp & Telegram, Instagram, web browsers, Trello, email accounts with push notifications, other productivity apps. OS tap to wake enabled, wifi always on, LTE enabled. NO Facebook, FB messenger, Snapchat or any games installed, so we can rule those out for excessive battery drain. With the phone "fully loaded" by my definition, my storage usage is only 42% so that should give an idea how few apps I have installed.

I did the following tests on the XZ and did not see any change:

Uninstalled Trello and Fenix apps

Uninstalled Instagram, VLC, Steam mobile, MyFitnessPal

Uninstalled Skype, Speedtest

Reset app preferences

Uninstalled Google Play Services updates

Restrict Google Play Services on Force Doze

Disable Smart Cleaner

Disable tap to wake

Disable keep awake for multiple apps

Factory reset with only Magisk installed

Factory reset, removed useless stock apps, nothing installed

Installed Duality ROM (Build 41.2.A.7.53)

Installed Existenz ROM (Forgot which build, the 'latest' from early November)

The following items made a difference to overnight battery drain:

8% overnight drain after rebooting and clearing cache with fully loaded phone. This was an oddity because I was never able to reproduce this.

9-10% overnight drain. Reboot phone in safe mode. Consistently reproducible.

8% overnight drain with mobile data ENABLED, but wifi DISABLED! Consistently reproducible. This did not make a difference during normal daytime 9am-3pm since the phone never was connected to any wifi networks anyway.

This is where the Z3's testing helped because it helped rule out my wireless router as the troublemaker (Z3's overnight battery drain was constantly 8% with or without Wifi).

My results conclude that the battery drain issue (at least for my XZ) is caused by the phone BEING CONNECTED to a wifi network (battery life is OK with Wifi enabled on the phone, but not connected to any specific Wifi network). The issue occurred regardless of apps, disable keep awake, Doze settings and ROMs on Android Nougat.

I hope this helps and that more people will come forward with similarly scientific studies. I may retest once more Android Oreo ROMs come out, I may also abandon testing if DRM backup/root becomes available for the XZ1 or 2018 Xperia flagship.