• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[Mod] wifi-service framework (eliminates wakelock) (Updated)

Search This thread

shbang

Member
Jul 25, 2015
27
67
So I was wondering why my battery kept draining overnight when the phone was supposed to be asleep. I opened up BetterBatteryStats and found this goddamn WifiOffDelayIfNotUsed wakelock keeping my phone awake all the time. I didn't have 1 min of deep sleep time unless I turned wifi off. I looked up some information on this and finally found a post by @metalboy94 detailing a simple framework modification to get rid of this. I went through all the steps here and the other page with a few modifications. I installed the new wifi-service.jar framework, and my phone has had hours of deep sleep now. My battery level stays the same for hours now when the screen is off.

I'm not sure if other people are suffering from this battery draining wakelock, but if your battery is draining with the screen off, I'd go ahead and check BetterBatteryStats or GSam Battery Monitor to see if you have this wakelock. In android's battery monitor, it gets blended in with Android System or Android OS, pushing one of them up to 20-30% in battery consumption.

This new wifi-service framework is made from a Verizon VS986 11a phone, but the process I went through should work on all G4s and other phones as well, and I'm willing to make a modded framework for other G4s if necessary and desired. I only need two files: /system/framework/arm/boot.oat and /system/framework/arm/wifi-service.odex.

I didn't bundle this in a nice installer since the VS986 doesn't have TWRP yet, but the installation is just one file along with the backup and removal of a few files (I'll make a twrp installer for H815 folks who are interested and supply the two files I need). I attached a zip containing the framework. I'll go through all the steps you need to do after downloading it. This should really be installed using adb. Use terminal emulator if you must and definitely not a slow and dangerous file manager. (If something goes wrong and you get into a bootloop, you'll want to be in adb since the terminal doesn't close. While in a hypothetical bootloop, you can use adb to undo the installation. I've done this a lot testing out stuff; it's pretty reliable. You can also reflash the rooted system.img in download mode assuming it's on your phone. That's a worst case scenario.) If you don't have busybox, skip the unzip step, and use a file manager to extract the framework to /sdcard/Download. So after you download the attached zip file, follow these steps in adb. You can copy the whole thing and paste it in with terminal emulator or via adb on Linux. Window's excuse for a terminal might throw a fit. Just don't enter the last command unless all others were successful.

Code:
su
cd /sdcard/Download
unzip wifi-service.zip
mount -o remount,rw /system
cp wifi-service.jar /system
cd /system
chown 0:0 wifi-service.jar
chmod 0644 wifi-service.jar
cp framework/wifi-service.jar framework/wifi-service.jar.bak
cp framework/arm/wifi-service.odex framework/arm/wifi-service.odex.bak
cp framework/arm64/wifi-service.odex framework/arm64/wifi-service.odex.bak
mount -o remount,rw /system
cp -f wifi-service.jar framework; rm framework/arm/wifi-service.odex; rm framework/arm64/wifi-service.odex

At this point, your phone may hot reboot or not. Reboot it if it doesn't(or execute "svc power reboot" in adb if you're lazy). The phone needs to reboot to odex the new framework. That's it. You can check to see if the WifiOffDelayIfNotUsed wakelock is still plaguing your phone. It isn't, so enjoy some better battery life.


:EDIT:
I uploaded a TWRP flash installer and uninstaller for the H815. Thanks for posting those files @stuliv12. Let me know if this works. I tested the installation and uninstallation on my Nexus 4 just to make sure they worked in TWRP. (The files are named, so I didn't include a "ro.product.model" check in the update-binary.)

That's great @mawells787 found a solution that I suggest trying first before flashing this. For me though, I was getting the wakelock when my wifi connection was great (full wifi bars, 4 meters from router), and it just wouldn't go away even when I turned on "Avoid bad Wi-Fi connections."
 

Attachments

  • wifi-service-fix-vzw.zip
    465.4 KB · Views: 577
  • wifi-service-fix-H815_TWRP.zip
    470.5 KB · Views: 945
  • wifi-service-fix-uninstaller_TWRP.zip
    4.7 KB · Views: 397
Last edited:

AhsanU

Senior Member
Sep 27, 2013
720
251
NYC
While my phone does sleep, I see this same service eating up some battery life according to wakelock detector. I have twrp on this H815, can I just flash the zip you provided?

Thanks.

Sent from my LG-H815 using Tapatalk
 

pen²

Senior Member
Oct 6, 2008
283
45
While my phone does sleep, I see this same service eating up some battery life according to wakelock detector. I have twrp on this H815, can I just flash the zip you provided?

Thanks.

Sent from my LG-H815 using Tapatalk

No, as the poster of the op has a special Verizon model. But as said in the op, you can provide him your .oat/.odex files and he will be so nice to patch them for your model as well; just make sure to be really specific on your model and (best) provide the exact build number you are currently on
 

mcfhsieh

Senior Member
Jun 8, 2011
56
2
I think this is working for me. I don't see that wakelock anymore. Can't wait to reap the battery rewards!
 

mawells787

Senior Member
Feb 27, 2011
205
70
New York
FYI. There's a WiFi setting to automatically turn WiFi off and switch to mobile data if WiFi doesn't have data. I unchecked that setting and the wakelock is barely registering in bbs.

I'm not trying to takeaway from the work the OP has done, just providing a simpler alternate solution. This is on the T-Mobile h811 version.
eaf1883cf1150de4ee21fba7de5cf967.jpg
e9a062256ddd8a2c4d3d333a51a2146d.jpg


Sent from my LG-H811 using Tapatalk
 
Last edited:
  • Like
Reactions: 338lm

CJ-Wylde

Senior Member
Feb 25, 2014
584
306
Madisonville
FYI. There's a WiFi setting to automatically turn WiFi off and switch to mobile data if WiFi doesn't have data. I unchecked that setting and the wakelock is barely registering in bbs.

I'm not trying to takeaway from the work the OP has done, just providing a simpler alternate solution. This is on the T-Mobile h811 version.

Sent from my LG-H811 using Tapatalk

This is very correct, and as an added note: WiFi is a battery draining service in general on ANY device. I've stopped using it entirely and now only enable it when I watch videos (Hulu, YouTube) or am downloading something. With it off most of the time, I've stopped having any battery drain issues.

You'll notice during your phone's initial setup that even Google notes that enabling WiFi is a Battery Intensive service.
 

bekolya

Member
Feb 29, 2012
28
7
Krasnoyarsk

Sorensiim

Senior Member
Nov 1, 2010
263
171
When trying to flash the TWRP installer, I get an error that it couldn't complete the backup and it cancels. Unlocked EU H815 :)
 
Last edited:

je2854

Senior Member
Oct 3, 2010
1,005
320
Houston, TX
This new wifi-service framework is made from a Verizon VS986 11a phone, but the process I went through should work on all G4s and other phones as well, and I'm willing to make a modded framework for other G4s if necessary and desired. I only need two files: /system/framework/arm/boot.oat and /system/framework/arm/wifi-service.odex.

Would this still work on the 13b update?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 18
    So I was wondering why my battery kept draining overnight when the phone was supposed to be asleep. I opened up BetterBatteryStats and found this goddamn WifiOffDelayIfNotUsed wakelock keeping my phone awake all the time. I didn't have 1 min of deep sleep time unless I turned wifi off. I looked up some information on this and finally found a post by @metalboy94 detailing a simple framework modification to get rid of this. I went through all the steps here and the other page with a few modifications. I installed the new wifi-service.jar framework, and my phone has had hours of deep sleep now. My battery level stays the same for hours now when the screen is off.

    I'm not sure if other people are suffering from this battery draining wakelock, but if your battery is draining with the screen off, I'd go ahead and check BetterBatteryStats or GSam Battery Monitor to see if you have this wakelock. In android's battery monitor, it gets blended in with Android System or Android OS, pushing one of them up to 20-30% in battery consumption.

    This new wifi-service framework is made from a Verizon VS986 11a phone, but the process I went through should work on all G4s and other phones as well, and I'm willing to make a modded framework for other G4s if necessary and desired. I only need two files: /system/framework/arm/boot.oat and /system/framework/arm/wifi-service.odex.

    I didn't bundle this in a nice installer since the VS986 doesn't have TWRP yet, but the installation is just one file along with the backup and removal of a few files (I'll make a twrp installer for H815 folks who are interested and supply the two files I need). I attached a zip containing the framework. I'll go through all the steps you need to do after downloading it. This should really be installed using adb. Use terminal emulator if you must and definitely not a slow and dangerous file manager. (If something goes wrong and you get into a bootloop, you'll want to be in adb since the terminal doesn't close. While in a hypothetical bootloop, you can use adb to undo the installation. I've done this a lot testing out stuff; it's pretty reliable. You can also reflash the rooted system.img in download mode assuming it's on your phone. That's a worst case scenario.) If you don't have busybox, skip the unzip step, and use a file manager to extract the framework to /sdcard/Download. So after you download the attached zip file, follow these steps in adb. You can copy the whole thing and paste it in with terminal emulator or via adb on Linux. Window's excuse for a terminal might throw a fit. Just don't enter the last command unless all others were successful.

    Code:
    su
    cd /sdcard/Download
    unzip wifi-service.zip
    mount -o remount,rw /system
    cp wifi-service.jar /system
    cd /system
    chown 0:0 wifi-service.jar
    chmod 0644 wifi-service.jar
    cp framework/wifi-service.jar framework/wifi-service.jar.bak
    cp framework/arm/wifi-service.odex framework/arm/wifi-service.odex.bak
    cp framework/arm64/wifi-service.odex framework/arm64/wifi-service.odex.bak
    mount -o remount,rw /system
    cp -f wifi-service.jar framework; rm framework/arm/wifi-service.odex; rm framework/arm64/wifi-service.odex

    At this point, your phone may hot reboot or not. Reboot it if it doesn't(or execute "svc power reboot" in adb if you're lazy). The phone needs to reboot to odex the new framework. That's it. You can check to see if the WifiOffDelayIfNotUsed wakelock is still plaguing your phone. It isn't, so enjoy some better battery life.


    :EDIT:
    I uploaded a TWRP flash installer and uninstaller for the H815. Thanks for posting those files @stuliv12. Let me know if this works. I tested the installation and uninstallation on my Nexus 4 just to make sure they worked in TWRP. (The files are named, so I didn't include a "ro.product.model" check in the update-binary.)

    That's great @mawells787 found a solution that I suggest trying first before flashing this. For me though, I was getting the wakelock when my wifi connection was great (full wifi bars, 4 meters from router), and it just wouldn't go away even when I turned on "Avoid bad Wi-Fi connections."
    3
    This damn wakelock appeared in android 7.0 v29a too. I was using this modification on 5.1 and it works perfectly, wakelock gone but this file not work on any other android version than 5.1. Using first post and post made by @metalboy94 i edited a smali files using newest wifi-service.jar from 7.0 v29a.

    im testing this modified wifi-service.jar now but seems that
    WifiOffDelayIfNotUsed wakelock is gone for me finally :)

    This is for h815 g4 v29a
    You need to replace this in system/framework and dont forget to set good file permission
    PS i also attach the original file if someone want to bring this wakelock back or sth..
    1
    FYI. There's a WiFi setting to automatically turn WiFi off and switch to mobile data if WiFi doesn't have data. I unchecked that setting and the wakelock is barely registering in bbs.

    I'm not trying to takeaway from the work the OP has done, just providing a simpler alternate solution. This is on the T-Mobile h811 version.
    eaf1883cf1150de4ee21fba7de5cf967.jpg
    e9a062256ddd8a2c4d3d333a51a2146d.jpg


    Sent from my LG-H811 using Tapatalk
    1
    That option Isnt available on EU H815 :(

    go to your wifi settings (not the advanced menu)
    on the top of all wifi SSID you will have that checkbox, at least on official 10C that was available from OTA a few days ago
    1
    Using FlashFire for Verizon works...
    Just takes forever...
    I also use Greenify..