yashsingh1/xdaforums huggingface dataset:
[Android Software Development] CappyT:
Are you on Official, Weekly or RC? Because the zip was made for Official.
[Android Software Development] DEVILOPS 007:
The zip here works for the official 11.6 and possibly the weeklies and RCs but that depends on what changed. If you want proper DU wakeblock support then I highly recommend the official builds. 11.6 wakeblock was uploaded by [MENTION=4101055]CappyT[/MENTION] here https://xdaforums.com/nexus-6p/general/taking-wakeblock-requests-t3583397/post73081466
[Android Software Development] yung40oz84:
I am on the weekly 11.6 from July 21st and get boot loop, should so much change from the previous official? Is there anything that will cause boot loop like Magisk, kernels, etc.?
[Android Software Development] bhanuprasad1981:
This app doesn't show kernel wakelocks?
[Android Software Development] Zacharee1:
So I know this is a stupid question, but I just can't find anything. How do I port this?

I tried grabbing my services.odex, decompiling with baksmali and adding the necessary lines, but that's basically where I get stuck. I can't figure out how to get an odex file back, since Smali only compiles to .dex again. I also tried replacing classes.dex in services.jar with the recompile dex I made, but that just resulted in a bootloop. What do I do?
[Android Software Development] Zacharee1:
Alright, got it working by just deodexing my services.jar, modifying it, and then copying that back. Had some trouble with Smali variable "names," local/register counts, etc, but now it works on my V20!

In the future, when the core is updated, would it be possible to include new code in the changelog, so porters don't have to dig through to find what's changed? Obviously, we need to see it in context too, so the templates are immensely useful, but it'd also be good to know roughly what we're looking for that's changed.
[Android Software Development] diazepambr:
I can't find that folder in my galaxy s7 edge :/ can you help me, please?
[Android Software Development] DEVILOPS 007:
That's because you are probably on a deodexed rom then meaning there is only the services.jar and not the services.odex.
[Android Software Development] diazepambr:
D'oh! Sorry for the ultra noob question.
[Android Software Development] jyoti.id:
A totally nooby question! Can i use this in any rom without much "technical steps" (means all that explained in the 2nd post? ? Im Using LineageOS/Moto G4 Plus. I installed the app but it shows unbound. & Cant find any zip that is mentioned to flashed! ? Sorry if i ask/say anything totally wrong!?
[Android Software Development] Zacharee1:
You have to either get the services source from the LineageOS GitHub for your device and merge the WakeBlock sections from the Java templates, or deodex and decompile your services.jar and merge the Smali.
[Android Software Development] AlemanSantos:
i already made the build just for services, all good, no errors, but i replace seriveces.odex, put 0644 permissions, restart and bootloop

Just to be sure, we just need to add the wakeblock sections (delimited with @ WakeBlock and # Wakeblock) to our source PowerManagerService.java and PackageManagerService.java and copy the file WakeBlockService.java to com/giovannibozzano/wakeblock, then build and replace services.odex on the ROM?
[Android Software Development] Geezerooo:
I'm not sure why but I'm running AICP and it shows services bound! Didn't have to flash anything. I also believe it is LOS based. Awesome!
[Android Software Development] DEVILOPS 007:
The ROM Dev must have added the modifications to the source code then. Lots of devs seem to be doing that recently.
[Android Software Development] Geezerooo:
That's great to hear for a Los based rom
[Android Software Development] DEVILOPS 007:
Congrats Wakeblock team for getting on the XDA portal:good:
[Android Software Development] onesolo:
If this could be turned into a magisk module it would be great
[Android Software Development] kessaras:
Working on OnePlus3T stock firmware and Los based too. Nice :good:

Think about adding android 6 sdk too. Android 7+ don't have too much trouble cause we can also control what runs in the background.
[Android Software Development] yung40oz84:
I second this. Could eleviate making all different zips for different OS and merging into source, etc.

It would also be great to see a step by step guide on how to merge this into source. I am currently building my own DU builds, but I have zero clue how to merge this into the build so I can use the apk. Anyone willing to make the guide? I am just a newbie at building ROMs. I've only built AOSP, DU, and ABCrom from source so far and 2 different kernel. I haven't started trying to merge new things into source yet. Thanks!

---------- Post added at 02:17 AM ---------- Previous post was at 02:13 AM ----------

So I can just add the stuff from the template to my services.jar file in my DU source before building? I have no clue really how to, so I just copy and paste? Lol.
[Android Software Development] Zacharee1:
Honestly, no idea lol. I had to do the Smali edit since I ported to stock LG.
[Android Software Development] hh11bbaacchh11:
Does this work on the latest build of PureNexus? If not, are there any patches, flashable zips or instructions to get this to work?
[Android Software Development] Miccia:
I added that here http://gerrit.aicp-rom.com/#/c/41740/
[Android Software Development] Geezerooo:
Awesome job man!
[Android Software Development] dread123:
anyone have this working for s6 edge?
[Android Software Development] -Deco-:
It's built for the Nexus 6P, not the GS6.
[Android Software Development] Zacharee1:
But people are porting.
[Android Software Development] dread123:
exactly my point- others are developing for different phones. i can find brief news to s6 port but nothing else?
[Android Software Development] yung40oz84:
Ya I try to cherry pick this commit and it always says failed, hung up. I tried other commits also fro ****s and giggle and same error. I think there a bug in the gerrit there, no issue picking elsewhere
[Android Software Development] Zacharee1:
If you can use Fulmics Deodexer to deodex your /system/framework, then send me the resulting services.jar, I can probably add it in for you.
[Android Software Development] exadeci:
Thanks you [MENTION=7087071]GioBozza[/MENTION] could you add the blocking delay set on wakelocks that we blocked?
[Android Software Development] ranasrule:
I cant get this to work on PureNexus rom? Can someone lend a helping hand ?
[Android Software Development] n0ahhh:
Does this work for Pure Nexus on 7.1.1? I got it to work with 7.1.2, but damn the battery drain was insane... so I rolled back to 7.1.1 and now I don't know how (or if it's even possible) to get it to work again.
[Android Software Development] GioBozza:
Just a quick update: I am currently working on the smali autopatcher and got the easier parts done.

When this is done, you should be able to apply the core mod on every device and ROM, if they are not too different from the original source (this should not happen).
[Android Software Development] GioBozza:
I built a first testing program to autopatch the smali patterns and succesfully tested it on my OnePlus 3T but it would be great if I could get some feedback from you before I proceed to implement it in the app, if you know how to build the core-mod for your ROM/device.

Note: OMS ROM users are really welcome because these classes are very different with it.

This is the java program to run on your PC: https://transfer.sh/(/BgYTq/smali-patcher.jar).zip

Please, do not try this if you do not know what you are doing!

Instructions:

Place smali-patcher.jar in a folder with stock PowerManagerService.smali and PackageManagerService.smali extracted from you services.odex. Again, try this if you already know how to do this.

Run "java -jar smali-patcher.jar".

Two new files (PowerManagerServiceNew.smali and PackageManagerServiceNew.smali) should have been generated. These are the edited files you need to rebuild the services.odex. Rename them and use smali/baksmali as always to assemble it.

Report with ROM and device names.

Thank you, everybody!
[Android Software Development] DEVILOPS 007:
I'd be happy to test this but where you said the two new files (PowerManagerServiceNew.smali and PackageManagerServiceNew.smali) should have been generated do we have to run a command to make these files generate and if so which one? Thanks. Also thanks for all your work. This looks like it could be great for wakeblock development.
[Android Software Development] GioBozza:
You just run the program with "java -jar smali-patcher.jar".
[Android Software Development] DEVILOPS 007:
Oh yeah thanks. I forgot how you run .jar files for a minute lol. I'll test this on some different ROMs and devices if I can find some other ones around.
[Android Software Development] AlemanSantos:
hey! i just managed to copy the odexed file without bootlopp and service is bounded :D what i did was copy all .oat files on framework/arm64 folder with the services.odex, can anyone try this? maybe [MENTION=7494055]DEVILOPS 007[/MENTION] wants to try too, i got some help from him on PM

i came to this after trying to make a flashable zip to use with the official build and while learning to use smali, i realized that i needed some other files from framework/arm64 to deodex, so i just tried adding one by one until the command worked and just used all that files lol

all this on VertexOS for OP3
[Android Software Development] xneonnick:
Can you explain a little more clearly? :D
[Android Software Development] GioBozza:
He is referring to the use of baksmali. boot.oat and all its libraries are necessary to successfully disassemble the services.odex. In the (possibly) near future this will be done directly by the app so there will be no need to move anything manually.

You can currently copy all those files from your device from /system/framework/arm(64) in a "framework" folder on your PC and execute

java -jar baksmali-2.2.1.jar x -d framework -o services --di false services.odex
[Android Software Development] xneonnick:
So then you patch those 2 smali files and assemble everthing back?
[Android Software Development] GioBozza:
You also need to add my classes as smali files and then you reassemble it.

If you are going to try that yourself, you can give the auto-patcher a try. I am currently testing it before I implement it in the app.
[Android Software Development] xneonnick:
How do I odex service.jar?
[Android Software Development] GioBozza:
Put it on your device and execute this (not from adb, from a terminal app) with root permissions:

dex2oat --runtime-arg -Xms64m --runtime-arg -Xmx512m --runtime-arg -classpath --runtime-arg "&" --boot-image=/system/framework/boot.art --dex-file=/sdcard/services.jar --dex-location=/system/framework/services.jar --oat-file=/sdcard/services.odex --android-root=/system --instruction-set=arm64 --instruction-set-variant=generic --instruction-set-features=default --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info --abort-on-hard-verifier-error --no-inline-from=core-oj.jar --compile-pic

provided your device is arm64.
[Android Software Development] AlemanSantos:
Well, really late to the party with that "discovery" lol

Anyway, just tried the new smali patcher, service bouned on OP3, VertexOS ROM :good: Good work! The process is a lot shorter and simple with that.
[Android Software Development] GioBozza:
Today I got baksmali and smali to run on the device, so I just need the time to put everything in the app, handle the failure case and the magic is done! No need to port WakeBlock to every device/ROM/version in the known universe. :D

Then we can sit, drink some juice, and start talking about alarms and regex...
[Android Software Development] AlemanSantos:
Excellent news, at least I learned to build a ROM, deodex and use some adb commands just to use this before the magic is done xD
[Android Software Development] GioBozza:
Glad it was a learning inspiration! :P
[Android Software Development] xneonnick:
Thank you for your help OP

Running on latest open beta op3
[Android Software Development] ngundu:
The app on the play store doesn't work for me. I have a OnePlus 3T.

Did you make any additional changes?
[Android Software Development] AlemanSantos:
yes, you need to port the wakeblock code to your services.jar or services.odex, for that you need to use baksmali/smali and the smali patcher Gio just posted

I don't know if OP3(T) share same files, maybe [MENTION=5285059]xneonnick[/MENTION] can upload the ported file so you can try with your phone, or you can do that for yourself, it's not so complicated but if you start without zero knowledege like me, can be some hard to learn until you figure it out

You have instructions from CappyT here and here , maybe i can help you with a more newbie step by step i made for me while learning if you need:

From start:

#Make folder Smali on D:\ and copy baksmali.jar, smali.jar and smali-patcher.jar. Rename bak/smali jar without version, best for commands...

#Open CMD on previous folder

#Pull framework from phone

adb pull /system/framework frameworkStock

#Deodex services.odex

java -jar baksmali.jar deodex -a 25 -o DeodexedFramework --di false D:\Smali\frameworkStock\oat\arm64\services.odex -b frameworkStock/arm64/boot.oat

#Copy package and power manager files to Smali folder

#Auto Smali Patcher

java -jar smali-patcher.jar

#Replace new files on DeodexedFramework folder and add giovannibozzano folder, should be on com folder, with android and goole (copy smali files from github)

#Assemble dex file

java -jar smali.jar assemble -a 25 -o classes.dex DeodexedFramework

#Copy to jar, just open services.jar with 7zip and add classes.dex

#Push services.jar to phone

adb push services.jar /sdcard/

#Deodex, run this command from terminal on the phone, first su, then command, i sended this to gmail and copy/paste to terminal

dex2oat --runtime-arg -Xms64m --runtime-arg -Xmx512m --runtime-arg -classpath --runtime-arg "&" --boot-image=/system/framework/boot.art --dex-file=/sdcard/services.jar --dex-location=/system/framework/services.jar --oat-file=/sdcard/services.odex --android-root=/system --instruction-set=arm64 --instruction-set-variant=generic --instruction-set-features=default --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info --abort-on-hard-verifier-error --no-inline-from=core-oj.jar --compile-pic

#Pull new ODEX to folder for backup

adb pull /sdcard/services.odex

#Flash and test (dont know how to make flashable zip, so i copy from recovery xD)
[Android Software Development] xneonnick:
Replace your services.odex with this one. Might not work so take a backup.

https://ufile.io/313mo
[Android Software Development] ngundu:
although the .odex file given by [MENTION=5285059]xneonnick[/MENTION] works but i want to try it myself. so here is what i need some help on, i am asking for too much here but can you explain a little bit more on below two points.

1. add giovannibozzano folder, should be on com folder, with android and goole (copy smali files from github)

I coped the new PackageManagerService.smali and PowerManagerService.smali onto corresponding directories in DeodexedFramework which were generated using smali-patcher jar.

what should be the next step after this? I do see a giovannibozzano folder under DeodexedFramework\com directory. I am kind off stuck here

2. #Copy to jar, just open services.jar with 7zip and add classes.dex

After assembling the dex file, should i copy the classes.dex into root directory of services.jar?

again, Thanks for your patience. Have a nice day.
[Android Software Development] GioBozza:
If you copied the patched classes (PowerManagerService and PackageManagerService) and my own classes (giovannibozzano folder) you are done and you can reassemble the folder into classes.dex by running:

java -jar smali-2.2.1.jar a -o classes.dex DeodexedFramework

classes.dex goes into the root of a jar/zip file, the one you use with dex2oat.

NOTE: do not use the autopatcher on an already modified services.odex. If you already see giovannibozzano folder without copying it, it means you are using an already modded one.

Anyway, running the final tests on the latest version of the app with the integrated patcher. If everything goes right, I will publish it today.
[Android Software Development] ngundu:
Ok, one question.

Copy your .class files from giovannibozzano into which filder under deodexed directory?
[Android Software Development] GioBozza:
It should be: ...../DeodexedFramework/com/giovannibozzano

Just check to have also:

...../DeodexedFramework/com/android and

...../DeodexedFramework/com/google
[Android Software Development] AlemanSantos:
No problem, learn is the best anyone can do :good:

1- Download raw version of the smali files (open and right click on raw to download) https://github.com/GiovanniBozzano/wakeblock/tree/master/templates-2.0/smali-templates/com and put them on com/giovannibozzano/wakeblock folder, on your deodexed folder

*edit: as gio said, you have to do the process with a clean file to use de smali patcher, if you have that folder on the deodexed you made, are you using the one already working?

2- You need to add classes.dex inside services.jar, open with 7zip or winrar and just throw the file inside.
[Android Software Development] GioBozza:
*** UPDATE [AUTO-PATCHER] ***

The latest version of the app allows you to automatically patch your system framework, whatever your device, ROM and version is.

This feature is currently under testing and available only for odexed ROMs. If the process gives "Unsupported Framework", please report it here with device and ROM information.

As soon as I have enough proofs that the patcher is stable, I will ask to move this topic in a general category.

NOTES:

Backups are always found in /sdcard/WakeBlock/Backups/

The patching will take some minutes.

The device will reboot when the process is finished.
[Android Software Development] AlemanSantos:
Working on VertexOS, OP3 :good: Great job! Just for better UX, maybe you can add a warning or message while the process is patching? Something like "Phone will restart to finish" or something. The restart to finish the job with TWRP was really abrupt lol, i thought the phone crashed or something :P
[Android Software Development] GioBozza:
Ops, sorry for that! :laugh:

I will try to make it as user friendly as possible. In the meantime I am going to write it in the notes.
[Android Software Development] yung40oz84:
So it can still pretty much only be used on stock as most all customs ROMs are deodexed, so for custom ROMs still merge into my source?
[Android Software Development] GioBozza:
It can be used on every device and every ROM if they are on Nougat and if the patcher finds the right pattern (this should always happen). I am also trying to make it work on Android O.

I will soon update it to support deodexed ROMs, it is just a matter of different file names.

Tests on custom ROMs are welcome right now!
[Android Software Development] marbertshere:
Ah okay, so if my rom is deodexed then it should not work, correct? The first sentence in the quote makes it sound like every Nougat rom should work. In case you wanted to know in using Resurrection Remix, which is deodexed.
[Android Software Development] GioBozza:
Yes, correct. It currently does not work but tomorrow, given enough free time, I will add the support for deodexed.
[Android Software Development] saccentekennedy:
Works on my OnePlus 5! I used to use this on my Nexus 6P, so I'm really excited to have it working on my new phone.
[Android Software Development] jyoti.id:
In LOS 7.1.2 Moto G4+ ut shows this (attachment).

But root access is already granted.
[Android Software Development] bugultra:
work fine on aospa v7.2.1 op3 :svetius:
[Android Software Development] GioBozza:
Is the ROM deodexed or odexed?
[Android Software Development] Miaou63:
Thanks for your work!

I'll give it a try on my deodexed rom when the update is ready!
[Android Software Development] jyoti.id:
Deodexed
[Android Software Development] GioBozza:
I'm still working on it then. I just find it a bit difficult to test having an odexed ROM myself...
[Android Software Development] Mar-cel:
Does this app block automatically wakelocks??

What wakelocks can I block??
[Android Software Development] GioBozza:
No, it does not block all wakelocks automatically. Your device would not work if it did. It fills a list with detected wakelocks and you can schedule a block routine every X milliseconds.
[Android Software Development] Geezerooo:
Works great on all GSR (ground zero ROMs). On Validus right now. Great job bud.
[Android Software Development] contactwajeeh:
Can we get apk? My device is showing incompatible on Playstore.
[Android Software Development] Zacharee1:
So it might be because I manually ported this, but the new version keeps telling me service unbound. I used the installer and it worked, but after another reboot, it disappeared.
[Android Software Development] GioBozza:
It might be an app update which is currently going live on Google Play. When the app gets an update the service is shut down and it can bound only during boot.

Try to reboot again and check whether it is bound.
[Android Software Development] GioBozza:
Sure! I'll attach the latest version to this post. What's your device anyway?
[Android Software Development] Zacharee1:
Seems to be it. I rebooted to flash Magisk 13.5 and now the service says it's bound.

By the way, how does one even make a Smali patcher, especially one that runs on the phone?
[Android Software Development] contactwajeeh:
Its LYF LS-5201 with stock like Android 6.0.1
[Android Software Development] GioBozza:
I basically implemented the extracting and repackaging process within the app and wrote a smali parser to recognize the pattern I need to patch the stock classes.
[Android Software Development] Zacharee1:
I feel like it must have been hell to get that injected conditional working o_O
[Android Software Development] contactwajeeh:
Thanks for attaching it, but I get a message "problem parsing the package" error when trying to install the attached APK. Please advise.
[Android Software Development] GioBozza:
I never tested WakeBlock on Android 6 and that's why it shows unsupported on the Play Store. You can try to use it but I can't promise anything. :(
[Android Software Development] GioBozza:
It took just three beers! :D
[Android Software Development] Zacharee1:
Lol.

Well, dead brain cells or not, I find it truly amazing that you made that patcher, and that it works so well! I know how difficult Smali is.
[Android Software Development] Lughnasadh:
[MENTION=7087071]GioBozza[/MENTION] First, thank you so much for your hard work on this. You are certainly to be commended :) .

My question is, once you get the app to work on deodexed roms, should we remove to core module from our rom build (deodexed rom) if the rom has been previously built with the core module included? I would assume yes but want to make sure if it matters or not. Thanks.
[Android Software Development] contactwajeeh:
Ah, Sad to hear that. Then may be manual patching would be the way to go.

[MENTION=7055541]Zacharee1[/MENTION] can you help me with the manual patching of services.jar
[Android Software Development] Zacharee1:
The patcher seemed to work for me even after I had manually built it in. Strangely enough...

---------- Post added at 06:20 PM ---------- Previous post was at 06:19 PM ----------

I can try. Have a Telegram?
[Android Software Development] contactwajeeh:
I don't have a Telegram account unfortunately, any other means?
[Android Software Development] GioBozza:
Thank you for the support!

If it's already patched it should just say "core mod already installed" (if the service is bound). If you try it without rebooting (app just installed and service not bound) the patching process should just fail because it's already patched and it will not recognize the pattern. So no harm done if you try to patch an already modified framework.
[Android Software Development] Zacharee1:
Well Telegram is nice because it has code formatting and file sharing. Would you mind making an account? It'll be a lot easier in the end than PMs.
[Android Software Development] contactwajeeh:
Sure