yashsingh1/xdaforums huggingface dataset:
[Android Software Development] DEVILOPS 007:
I feel like a massive noob, I really am not sure what you mean. Are you saying I need to edit the same files for the odexed rom? What's different between a deodexed rom and odexed in the terms of what I need to edit? Thanks
[Android Software Development] GioBozza:
You need to edit:

services/core/java/com/android/server/pm/PackageManagerService.java

services/core/java/com/android/server/power/PowerManagerService.java

as shown in the templates in my repository (https://github.com/GiovanniBozzano/wakeblock).

These classes as usually placed inside "android_frameworks_base" GitHub repository in custom ROMs.

The difference between a odexed and a deodex ROM is that the first generates a services.odex when you compile it and the second generates a services.jar.

On your device:

If your ROM is odexed you will always have an empty services.jar in "/system/framework/" and a services.odex in "/system/framework/oat/arm/" or "/system/framework/oat/arm64/" whether it's an ARM or ARM64 device. You just need to replace services.odex, because services.jar is empty.

If your ROM is deodexed you will only have a services.jar in "/system/framework/" and you will need to replace it with the one from the edited and compiled ROM source code.
[Android Software Development] DEVILOPS 007:
Okay thanks, I think i get it. So basically I edit the same files and all for the odexed rom and do I just do make services like normal then in the directory out/target/product/angler/system/framework/ is the services.odex file going to be in there?
[Android Software Development] GioBozza:
It's going to be a services.odex in "out/target/product/angler/system/framework/oat/arm(64)/" if it's a odexed ROM. A services.jar in "out/target/product/angler/system/framework/" otherwise.
[Android Software Development] DEVILOPS 007:
Okay thanks, so just to clarify one hundred percent. I edit the PackageManagerService.java and PowerManagerService.java files and make services and then get the services.odex file and flash it? That's for odexed roms and that's all I need to do right?
[Android Software Development] GioBozza:
Everything is correct except you don't flash it, you replace the original from recovery. If you want it to be flashable you can download one of my flashable packages from my repository and replace the services.odex in it with your.
[Android Software Development] DEVILOPS 007:
Yeah thanks, missed that. I really appreciate your help. I'm going to give it a go once my rom has finished. Thanks a lot! :D
[Android Software Development] GioBozza:
You are welcome and thanks for your support!
[Android Software Development] DEVILOPS 007:
Hi, I did everything you said. I edited the PackageManagerService.java and PowerManagerService.java file correctly and did make services. Then I got the services.odex file and put it in the zip you had made. It is causing bootloops though and I don't know why. Any chance you could have a look at it? Thanks.
[Android Software Development] CappyT:
I'm switching to DU today, so I will try port it by myself and then share it. Is DU Odexed?

I'm pretty experienced with odexed port since I maintained for a while the official odexed wakeblock.
[Android Software Development] DEVILOPS 007:
Yes it is odexed. If you manage to get it working could you tell me what I did wrong please? Do you know if I did something wrong from what I said I did? Thanks
[Android Software Development] GioBozza:
The fastest way to check what's wrong in the meantime is using LiveBoot.
[Android Software Development] DEVILOPS 007:
Here's the log from DU wakeblock causing bootloops.
[Android Software Development] CappyT:
I managed to get it to work on latest official DU (11.4) i will post the ready-to-flash zip to the other thread, to avoid confusion with official stock zips.
[Android Software Development] DEVILOPS 007:
Please explain how. I followed what GioBozza said but it was causing bootloops. Did you just edit the PackageManagerService.java and PowerManagerService.java after syncing the reop and make services and get the services.odex? Am I missing something? Thanks
[Android Software Development] CappyT:
It will be a bit of a wall of text, but I try to explain how this works in the simpler and most detailed way possibile.

*** WALL OF TEXT INCOMING ***

First off, the thing you did wrong is that you didn't consider that the rom is Odexed, and as such, you simply can't have a services.jar (because it's deodexed) and the rom is expected to load a odexed file. So, even if you compile it correctly, you can't boot it. More on this, later on.

So, what did I have done? (this is how we do stock WakeBlock mods, btw)

First, i pulled the DU repository, set up a working compile-ready environment (careful with Jack-server, tends to crash, here a solution for this: http://stackoverflow.com/questions/...ror-try-increasing-heap-size-with-java-option ), and began editing all the classes required by WakeBlock (for now, just two: PowerManagerService.java and PackageManagerService.java)

After the changes were applied to the code, I proceeded to compile only the services file (make -j# services (where the # is the number of cores your pc has)) and waiting patiently.

I then grabbed the output file, already odexed and proceeded to the next step, which is a bit of a tricky procedure.

The odexed file, the way it was compiled, bootloops. We aren't really sure why this happens, but we are pretty safe saying that this is due to fact we didn't compile it with the whole rom. (It also does happen on Stock AOSP)

So, I deodexed the file and unpacked it, revealing all the smali code in it. I then grabbed the original odexed services from my phone, unpacked it, and swapped the edited classes inside.

Basically the trick is: Unpack the odexed file, replace the classes that you edited to add wakeblock support, then repack it.

You will end with a services.jar. Which, as said earlier, CANNOT boot, because boot.oat in the rom is not instructed to boot a non odexed file.

Now you have two options:

- Deodex the whole rom and just use the services.jar

- Odex services.jar

I ofc choose the latter. So I proceeded to copy my services.jar in my phone, on a path where i have the same offset (this is really way long to explain why you need to do this, if you want to know why, read this paper: https://www.blackhat.com/docs/asia-15/materials/asia-15-Sabanal-Hiding-Behind-ART.pdf )

In this case, i copied it over /data/abcdefghijk/services.jar and ran the command to odex it

dex2oat --runtime-arg -Xms64m --runtime-arg -Xmx512m --runtime-arg -classpath --runtime-arg "&" --boot-image=/system/framework/boot.art --dex-file=/data/abcdefghijk/services.jar --dex-location=/system/framework/services.jar --oat-file=/sdcard/services.odex --android-root=/system --instruction-set=arm64 --instruction-set-variant=cortex-a53 --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

Ended up with the finished services.odex on my Internal storage. This is ready to use and works.
[Android Software Development] DEVILOPS 007:
Okay, thanks a lot I really appreciate the in depth and detailed explanation. It is a little hard for a noob like me to understand but I think I understand it. A few questions though. What did you use to deodex the file? When copying the classes did you open the services.jar with a text editor and simply copy and paste overwriting the one from your phone? Also, with the directory /data/abcdefghijk did you create this directory? Lastly, if I'm not using DU is there an easy way to get the services.odex and services.jar from it without flashing it? Thanks a lot
[Android Software Development] CappyT:
I used baksmali, you can find it here on the forums, or by a simple google search. For 7.x roms, this is the command to deodex:

java -jar baksmali-2.2b4.jar deodex -a 25 -o out_folder --di false services.odex

After deodex, the code gets decompressed in a folder and every file is a class. You simply need to replace the classes that wakeblock needs. Specifically, right now the files needed are these. No text editing needed.

http://i.imgur.com/m2lFc5Q.png

http://i.imgur.com/l3Z7Age.png

You replace those files with the ones you find in the odex you compiled (you need ofc to decompress that odex also), and repack everything together with this command:

java -jar smali-2.2b4.jar assemble -a 25 -o classes.dex name_of_the_folder_containing_edits

You will now find a classes.dex. Simply put it into a this dummy services.jar (you can use winrar for this) and then move it to your phone for odexing.

Yes, you need to create it. Remember to run the odexing script from phone itself, do not use ADB but something like terminal emulator, or it won't work.

Run the script as root (just type su and hit enter)

You can unpack the system using some tools and extract the services.odex from there, or you can have a user sending it to you.
[Android Software Development] DEVILOPS 007:
Okay thank you. Is this for linux or Windows only? I'm on Linux mint.
[Android Software Development] CappyT:
Commands shouldn't be windows-specific
[Android Software Development] DEVILOPS 007:
Okay, thank you. Last thing, how do I use the tool? Do i need to extract the rar and do i need to open terminal in the directory with the services.odex and type the command?
[Android Software Development] weazie:
Hi.

Does anyone know what is BDS wakelock, related to google.android.dialer? I tried to search Google and XDA, but I didn't find information. Thanks in advance.
[Android Software Development] DEVILOPS 007:
On Linux it opens the bat file as a text document. Any idea?
[Android Software Development] CappyT:
What bat file?
[Android Software Development] DEVILOPS 007:
Are we using the same tool? Can you share it please, the link? Thanks.
[Android Software Development] SimoIanni:
Hmm... maybe it keeps the CPU running during calls.
[Android Software Development] DEVILOPS 007:
Can I have a little help with deodexing the services.odex please. I'm aware of the command for nougat but it only works on windows I think. I tried it on Linux mint and got an error saying something like command not found. Anyone know a command for linux that works? Thanks.
[Android Software Development] SimoIanni:
Download smali2.2b4 and backsmali2.2b4 from here and place them inside a folder with all this files and the services files, then use [MENTION=4101055]CappyT[/MENTION] commands to deodex
[Android Software Development] DEVILOPS 007:
Okay thanks, will do when I get home. I guess I didn't understand how it worked or something.:) How's your phone btw? Still bricked?

---------- Post added at 10:04 AM ---------- Previous post was at 10:03 AM ----------

Also, where did you get the boot zip from?
[Android Software Development] SimoIanni:
Somehow I unbricked it, however the boot.zip contains all the files in /system/framework/arm64 and should be good for all the roms
[Android Software Development] DEVILOPS 007:
Am I doing something wrong? I keep getting this error "dex2oat: command not found"
[Android Software Development] SimoIanni:
The dex2oat command is the last you need to do and you should do it from a terminal emulator from the phone, re-read CappyT's posts
[Android Software Development] DEVILOPS 007:
Okay thanks, I misread that. Last thing I need to check then. What directory do I put the files you said? The smali and backsmali and the boot folder?
[Android Software Development] SimoIanni:
all together in a directory with the services files
[Android Software Development] DEVILOPS 007:
Yes, worked that out like 10 minutes ago and just tested. Thanks:)
[Android Software Development] DEVILOPS 007:
Hi, I've done everything here you said with making this work and I attempted it for the nexus 5. It isn't causing bootloops but service is saying it is unbound. Would you possibly be able to deodex this and have a little look and tell me if I did anything wrong? Thanks.
[Android Software Development] mystique47:
using in Nexus 5 CAF Dark rom. It works for a while, but when the app is no more in ram (I guess, because of multi tasking) it loses service bounding and stop working. After rebooting it will be again bound, until exits from ram again. Force stopping app can reproduce the problem. Maybe it is an app-related bug
[Android Software Development] GioBozza:
Did you install some process killer app? The WakeBlock app service should never stop naturally. You can check if it's still on in developer settings, running services.

Unfortunately, if it gets somehow killed, the only way to rebind it is to restart the device, so clearly it shouldn't happen.
[Android Software Development] mystique47:
Thank you for answer. No I haven't any app killer. mmm I don't find its service in running services section (while is running and working correctly). I'll try to understand something more in next hours-days
[Android Software Development] GioBozza:
You could try to put it in battery optimization exceptions and check if that helps, even though it shouldn't​ be the problem, as it's not normally needed.
[Android Software Development] mystique47:
good idea, I just did it! I'll check if it remains bound in next hours
[Android Software Development] Brentboy:
After updating to a new version released today on playstore it says service unbound for me
[Android Software Development] DEVILOPS 007:
Same for me on DU and users on pure nexus and other roms. I think you made a little slip up somewhere in the code [MENTION=7087071]GioBozza[/MENTION] ?
[Android Software Development] Pozanos:
Same here on S.i.X. rom.
[Android Software Development] SimoIanni:
We are working on a big update right now, If (and only if) everything goes well we could be able to put WB on every rom even without the source code
[Android Software Development] GioBozza:
I updated the app yesterday. There was a little bit which was silently causing the service to crash.

EDIT: Nevermind, another one came up. This is going on because I can't test it with my device right now, I will fix it ASAP.

EDIT 2: Updated again. It should be up soon...
[Android Software Development] AlemanSantos:
This update is the one for all the ROMs without source code? I'm still getting unssuported device on OP3 Phoenix ROM

edit: just realize this is in Nexus 6P forum lol, I don´t know how I end here xD sorry
[Android Software Development] manalicream:
Have updated but now service is continually unbound
[Android Software Development] sooti:
Same here...
[Android Software Development] DEVILOPS 007:
Read what he said carefully. He said the update will be up soon.
[Android Software Development] Pozanos:
Recieved the second update minutes ago. Works fine, service bound on S.i.X rom.
[Android Software Development] GioBozza:
*** UPDATE [CORE-MOD TEMPLATES V2.0] ***

- Core mod code has been refactored to allow easier and cleaner implementation.

- It is now possible (with some smali knowledge) to port the core mod without the ROM source code. Smali templates are available in WakeBlock GitHub repository (https://github.com/GiovanniBozzano/wakeblock). Please make sure you know what you are doing before trying to mess with smali.
[Android Software Development] DEVILOPS 007:
Hi, just had a look at the templates and it seems great! I understand smali and baksmali a bit and know how to use it to deodex and odex files but was wondering if you could possibly give me a couple of tips in porting the core mod with small and no source code. Any help would be appreciated like what needs to be deodexed and edited. Thanks a lot, also I just wanted to say that when on the templates it takes a while for ctrl+f to find wakeblock so if there any possible way to Optimize this or maybe cut out parts that aren't necessary in the template? Have a good day?

---------- Post added at 05:58 PM ---------- Previous post was at 05:40 PM ----------

Did you remove the wakeblock code from the template for PackageManagerService.java? I can't find any code in that template for that file.
[Android Software Development] GioBozza:
It might be difficult to help because in smali, every ROM and version is very different.

The template should be fixed now, GitHub was cutting it. Right now I think it may be better to have the full one instead of a cut source file.

I'm also planning to implement an auto smali editing feature in the app, to make the core mod universally available, but that will take a lot of time.
[Android Software Development] DEVILOPS 007:
Okay thanks. I just checked the template for PackageManagerService.java and there still doesn't seem to be any code that says @ Wakeblock. Also it said it was updated 2 hours ago.
[Android Software Development] SimoIanni:
If you want we have the DirtyUnicorns patch for your phone.
[Android Software Development] AlemanSantos:
Yes sure, I'm using PAEX but I can try
[Android Software Development] nicesoni_ash:
I haven't looked at the changes yet but for those who are running version 1 of core fine in their sources should update to version 2 too if the changes are noticeable?

Sent from my "1+2" powered by Unofficial RR 7.x.x

Compiled by myself
[Android Software Development] GioBozza:
Changes are not noticeable in terms of features, it's just much more maintainable now.
[Android Software Development] Dark_Eyes_:
I just updated to the core 2 implementation, and after I built my rom, I always get service unbound whatever I try. Anything I missed?
[Android Software Development] GioBozza:
If you can share the two classes I can take a look.

Also make sure you did copy the additional class com.giovannibozzano.wakeblock.WakeBlockService.java
[Android Software Development] DEVILOPS 007:
Can I ask what we do with that? I'm on an odexed rom DirtyUnicorns so would I place that with the same directory as one of the java files I edited like PowerManagerService.java or PackageManagerService.java? Is it required to get wakeblock working with your template 2.0? Thanks. I'm talking about your com.giovannibozzano.wakeblock.WakeBlockService.java

file btw
[Android Software Development] GioBozza:
Yes, it's needed. That's where all the work gets done.

The directory is /com/giovannibozzano/wakeblock/, just like PowerManagerService.java is in /com/android/server/power/.

The directory structure is the same as the one you see in the templates.
[Android Software Development] DEVILOPS 007:
Okay thanks, just so I understand as I'm not sure if I understand. That file you made, do i need to actually do anything with that file or is editing the service files like previously all I need to do? Is that new file you made just all the code you added to the template for the two services files? Thanks, I just need some clarification sometimes to make sure.?
[Android Software Development] GioBozza:
You just need to copy it inside the services, no need to edit it. You just need to edit the same two classes as always, just use the new templates to do so.
[Android Software Development] DEVILOPS 007:
Okay thanks, so basically ignore that file and do what I always did but follow your new template. Thanks for the help?
[Android Software Development] GioBozza:
Yes, ignore it but make sure you copied it. :)
[Android Software Development] nicesoni_ash:
New way is indeed much more cleaner although commits for those changes are a bit confusing. May be if you can separate smali and Java commits, that would be great. Working fine btw with core v2.

Sent from my "1+2" powered by Unofficial RR 7.x.x

Compiled by myself
[Android Software Development] GioBozza:
I had some trouble with commits because GitHub was, for some reason, cutting one of the classes in half. I had to change the templates directory structure to make place for the smali classes and so everything appears as new, but from now on you should be able to see the changes directly from commits.
[Android Software Development] nicesoni_ash:
Yeah, latest few commits started to make sense now.

Sent from my "1+2" powered by Unofficial RR 7.x.x

Compiled by myself
[Android Software Development] fkfmfz:
here is the one i did, btw thank you for this awesome app.

edit: added a new commit with authorship for [MENTION=7087071]GioBozza[/MENTION]

https://github.com/SiX-ROM/platform_frameworks_base/commit/b7e442a068ee3abad38be44e2d0d2111a0ea10f0
[Android Software Development] GioBozza:
Great! Let me know if everything is working.
[Android Software Development] fkfmfz:
Yes sir, btw I changed the commit to add your authorship.

https://github.com/SiXROM/platform_frameworks_base/commit/a8b57d2d23bc9761634cebb53c8c73a69202e365

Sent from my Nexus S.i.X
[Android Software Development] GioBozza:
Nice! Thank you for your support!
[Android Software Development] DEVILOPS 007:
Hi, I just tried getting this working and get an error when making services. I really feel like I'm missing something obvious here. The problem is mainly at the bottom where it keeps saying stuff like

ERROR: /home/grimy1928/DU/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java:1008: com.giovannibozzano cannot be resolved

Any help would be greatly appreciated. Thanks

https://pastebin.com/uDkUmQrd
[Android Software Development] fkfmfz:
did you add this to your path

services/core/java/com/giovannibozzano

https://github.com/GiovanniBozzano/wakeblock/tree/master/templates-2.0/java-templates/services/core/java/com/giovannibozzano/wakeblock
[Android Software Development] DEVILOPS 007:
No I didn't actually. There isn't a folder called giovannibozzano there so do I need to create that folder and put the file in and simply run make services again? Thanks a lot
[Android Software Development] fkfmfz:
Create that path and put the file in there, and run the build again. Or download the repo as zip and extract it and grab it from there

Sent from my Nexus S.i.X
[Android Software Development] DEVILOPS 007:
Thanks a lot for the help. I must have misunderstood something or was a bit stupid but luckily it is sorted now. I made the directory and the file and copied the code in and saved then ran make - j4 services and all is good.?
[Android Software Development] Dark_Eyes_:
Yeah, I messed one line up. Now it works. DARK ROM has full WakeBlock support again ;)
[Android Software Development] mattiadj:
How can I make it works on Samsung s7 edge?

Inviato dal mio SM-G935F utilizzando Tapatalk
[Android Software Development] fkfmfz:
Awesome!!! ?

Sent from my Nexus S.i.X
[Android Software Development] DEVILOPS 007:
This is mainly for the nexus 6p so you might not be able to. However you can try if you want by making the directory and then enter that directory and do the repo init command for the platform_manifest of the rom assuming it is on github and then sync the repo. That's the first thing you need to do.