yashsingh1/xdaforums huggingface dataset:
[LG Optimus 2x] mateorod:
the patch is actually ONLY patching the classes.dex file. That is why i was inserting the preloaded classes file manually before you showed me it was just compressed.

baksmali goes into the jar file and decompiles the output into a specific folder we designate, in our case called smali. We chose the name smali, just because. It could be classout or anything. But the output will be a decompiled classes.dex.

We then patch that output (of the decompiled classes.dex) with the patches I made. Then we recompile the output folder (smali for us) into a new classes.dex.

That classes.dex is the patched classes.dex, and needs to replace the original which will still be in the jar file.

If we move the patched classes.dex file into the jar file it will overwrite it completely.

We actually can probably skip the signapk tool completely since we have a preloaded classes file we can insert inside as well. No extraction needed, really.

Then we can skip unpacking and signing the rom as well. Just drop our new jars into the /system/framework and let the computer overwrite them for us.

---------- Post added at 12:16 PM ---------- Previous post was at 12:11 PM ----------

oh yeah...aosp patches are in the dropbox.;)

jahrule, I assume you are dying to test. Please create a zip of JUST your framework, core, and services.jar WITH build.prop please.

Should have a test ready in 10-15 mins.

---------- Post added at 12:42 PM ---------- Previous post was at 12:16 PM ----------

This is rough with only the broad strokes laid out. Do you see what I am getting at with this?

mkdir -p $TEMP/{core, framework, services}
mv services.jar services
mv framework.jar framework
mv core.jar core
# we need to move the jars into the proper $TEMP directory i.e ($TEMP/core,
# $TEMP/framework, $TEMP/services)

echo "### decompile framework ###"
java -jar baksmali.jar -b -a 15 services/services.jar -o services/smali
java -jar baksmali.jar -b -a 15 core/core.jar -o core/smali
java -jar baksmali.jar -b -a 15 framework/framework.jar -o framework/smali
jar -xvf system/framework/framework.jar preloaded-classes

echo "### apply patch ###"
patch -p2 -d services/smali < services.patch
patch -p2 -d core/smali < core.patch
patch -p2 -d framework/smali < framework.patch
patch -p1 < preloaded.diff

GARBAGE=`find *.jar.out -name "*.orig"` && rm -rf $GARBAGE
GARBAGE=`find *.jar.out -name "*.rej"` && rm -rf $GARBAGE

echo "### recompile framework ###"
java -Xmx512M -jar smali.jar -a 15 services/smali -o services/services.jar
cp services/classes.dex services/services.jar

java -Xmx512M -jar smali.jar -a 15 core/smali -o core/services.jar
cp core/classes.dex core/core.jar

java -Xmx512M -jar smali.jar -a 15 core/smali -o core/services.jar
cp framework/classes.dex framework/framework.jar
# cp preloaded classes into framework/framework.jar, which may need an escape for the
# space in the file name
[LG Optimus 2x] pastime1971:
@ mateorod,

ok. now i understand it a little better, but not fully yet.

for example, original framework.jar contains

META-INF/MANIFEST.MF
classes.dex
preloaded-classes

after patching baksmali output, i make moded jar by

java -Xmx512M -jar smali.jar -a 15 framework.jar.out/smali -o framework.jar

but the result doesn't contain classes.dex

apktool d JAR && apktool b JAR.out MODJAR creates classes.dex correctly.

am i using smali.jar wrong ?

edit: you posted while i was typing. let me read it first.
[LG Optimus 2x] mateorod:
No and yes. You aren't TELLING the smali command to make a classes.dex. Look at the script I appended above.

Like this, assuming you actually have directories of these names.

java -Xmx512M -jar smali.jar -a 15 framework.jar.out/smali -o framework.jar.out/classes.dex

the -o flag is an output flag. You are telling smali what to make and where to put it. We need a file called classes.dex in the framework.jar.out directory (which we don't have, that is from apktool) made from the smali output we created from the original classes.dex with the baksmali tool.

What is confusing you, I think, is the naming conventions. Think of it like this.

java -jar baksmali <options> <input.jar> -o <output>

where we designate output to be anything we want, in my case a directory called smali.

java -Xmx512 (limits memory) -jar smali.jar <options> <output from baksmali> <output>

where the output is classes.dex

example:

java -jar baksmali.jar services.jar -o smali

java -Xmx512 -jar smali.jar smali -o classes.dex

where I decided to name the output smali, and told smali to recompile the code into a file named classes.dex.

You do not have to unzip jars to use the baksmali tool on them.
[LG Optimus 2x] pastime1971:
oh, you mean smali.jar generates classes.dex (while apktool b generates jar)

i see. that's what you meant in the initial script_overlay.

now it makes sense...
[LG Optimus 2x] mateorod:
Yeah, the script as-is, repacks the meta-info and such into a jar file without a classes.dex and then the updater script updates the system jars. So really, we're accomplishing nothing as it stands. But we are patching correctly.

We just need to make the classes.dex files, being careful to keep them separate because the smali tool will just continually overwrite it each time if they are not in unique spots.

Then move them into the jar.file. I don't know if we can drop them into a zip in the script (which you can through a file manager) or if we have to unzip the jars.
[LG Optimus 2x] jahrule:
Here the files I am dancing right now lol http://www.sendspace.com/file/y49g1x
[LG Optimus 2x] mateorod:
well, sorry man. It patched maybe 90%, but the 10% it missed are some important files.

I don't know a bunch about aosp roms, having never had a stock android device, but the directory trees are very different. It just can't find all the files it needs to patch.

I am not saying that we won't be able to do it at one point, but with the resources we have now (resources being people willing to build pdroid-enabled roms for aosp) it doesn't look like a go.

Sorry for getting your hopes up. I didn't know aosp varied so much, although I should have. It is conceivable that we'd need each manufacturer to have a unique patch set.

pastime- how did syvat handle aosp for cm7?

oh yeah, and I am slowly polishing up the script excerpt I posted on page 28. It will continue to more accurately reflect what direction I think we need to go.
[LG Optimus 2x] pastime1971:
i update the script such that smali creates classes.dex which replaces one in original jar

i kept framework.jar.out folder name to be compatible with apktool.

original is back up under backup

restore.zip is made first.

then system/framework/*.jar is updated with patched ones.

original patches are for cm9, correct ?

aokp patches are empty at the moment.

once you have it, you can replace them in pdroid_tools.tgz

aosp patches are missing.

i didn't pay attention, but using ro.rommanager.developerid to figure out ROM may not be a good idea. (AOSP doesn't carry ROM manager) we can come up with a better solution.
[LG Optimus 2x] pastime1971:
not sure. maybe he didn't have an issue in GB.

he does use cleanupsmali script (basically sed), maybe that is it.

edit: that is too bad that AOSP smali is quite different, whereas source part is very same... :)
[LG Optimus 2x] mateorod:
Nice work!

See the edit, but I think the updater script is the problem. I don't think we are actually installing the jars when we flash the pdroid.zip.

I will add the aokp patches and then repost it.

as for aosp...

well, the device manufacturers all put their own spin on things (touchwiz and sense is what I am thinking of specifically).

But like I said, maybe there is another reason. Who makes maguro, I don't even know. If I can find a build by the same manufacturer (google, is it?) then we can see if it at least ports there.

Edit: And I just tried the patcher on a clean install, and we have a problem. It isn't working. It looks like the patching is being done correctly, maybe it is the updater script?

Let's look.

Edit2: Yep, the jar files are all patched and compiled correctly. When placed in a flashable zip, pdroid works. So we have a problem with the pdroid.zip composition, probably in the updater script.

.
[LG Optimus 2x] mateorod:
Okay, I fixed the updater script. Everything appears to work as necessary.

I have also added the patches. What do you want to do pastime? It works now, I am pretty sure. I haven't tested an an aokp build, but I am about to. If it patched correctly, I am pretty sure we are good.

I am pretty pleased.

I will continue to put work in on figuring out exactly what we have in the AOSP patches as well as work on seeing what else we need to do to include more aosp builds. I bet we can at least add every Nexus right now, although we would need to incorporate another getprop of some sort.

But I think that can wait for an update. You want to think about releasing a beta of this thing?
[LG Optimus 2x] pastime1971:
i just read your pm.

i will test it on non-pdroid build for my phone, and find out what is the issue...
[LG Optimus 2x] mateorod:
Oh hey man. I fixed it. You had a typo in the updater script. I added the aokp patches and a READ_ME with detailed instructions for those who come across it in the wild.

I also added credits, cause I'm proud of us (oh and for svyat, too.)

I am happy with it as a beta, right now.

edit: I am attaching the fixed zip with the patches and the correction/additions.

edit2: and I tested it on a couple AOKP roms with 100% success.
[LG Optimus 2x] pastime1971:
oh, right.

in may occasion / is a special character and needs to be typed as \/ , but not in the script... :p

thanks for finding it out !

edit: it all looks good to me.

edit: i will put this in the first page of the thread.
[LG Optimus 2x] mateorod:
You want to put it out? I say it's time to hear from users.
[LG Optimus 2x] pastime1971:
i posted it in the first page.

also posted an announcement in svyat's original thread, calling for alpha testers.
[LG Optimus 2x] jahrule:
Awesome work guys. I really hope you get the Aosp patch working.
[LG Optimus 2x] c-pimp:
Nice work guys, hope to be able to learn and help more in the future...... Build env would be up tomorrow on my main desktop... Can't wait to play with the new stuff
[LG Optimus 2x] mnjm9b:
Is the smali patcher for any device and any Rom...?
[LG Optimus 2x] pastime1971:
For any device, but only for CM9 and AOKP for now...

Will add more ROMs as we confirm success which may need a support from kangers.
[LG Optimus 2x] JoeSyr:
Great work on this project; I've been loosely lurking the thread since it was linked to from svyath's a while back and just saw the newer post. I don't have a linux environment set up right now so I can't contribute to the alpha testing, but I wanted to request that if anyone gets a working patch for the toro galaxy nexus could you share it please? Pdroid is probably the coolest thing I've never been able to try with my phone.

(Also if you guys are taking nominations for future roms to work on, I nominate Liquidsmooth on account of it's my daily driver and is probably different enough to not be compatible with the current patch but close enough to not be a massive undertaking)
[LG Optimus 2x] c-pimp:
I am getting my build env setup today and I will be compiling 4.04 aosp source from team gummy as soon as possible... I got my vm to compile the aokp with out patches if you would still like to check that out meteorod... Not sure if you still need it seeing that aokp is working

JoeSyr toro builds of cm9 or aokp should work just fine to patch.
[LG Optimus 2x] pastime1971:
we will take a look at that.

if it is based on AOSP, and looks like it is, there is a chance ... once we got AOSP patch working ...
[LG Optimus 2x] c-pimp:
Pasttime, I'm pulling the source now... Should have a build tonight for aosp ... If you would like to see what I'm working on check out team gummy on rootzwiki :-)
[LG Optimus 2x] alroger:
CM9 sgt7 repo changes

Oo, something changed today in the CM9 sgt7 repo.

Can you help me understand and fix this?

patching file frameworks/base/services/java/com/android/server/am/ActivityManagerService.java
Hunk #1 FAILED at 138.
Hunk #2 succeeded at 13091 (offset 2038 lines).
Hunk #3 succeeded at 13241 (offset 2058 lines).
1 out of 3 hunks FAILED -- saving rejects to file frameworks/base/services/java/com/android/server/am/ActivityManagerService.java.rej

cat frameworks/base/services/java/com/android/server/am/ActivityManagerService.java.rej

--- frameworks/base/services/java/com/android/server/am/ActivityManagerService.java	2012-03-29 23:41:14.045720104 -0700
+++ frameworks/base/services/java/com/android/server/am/ActivityManagerService.java	2012-03-29 23:11:05.086052516 -0700
@@ -138,6 +138,9 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
+// BEGIN privacy-added
+import android.privacy.surrogate.PrivacyActivityManagerService;
+// END privacy-added

public final class ActivityManagerService extends ActivityManagerNative
implements Watchdog.Monitor, BatteryStatsImpl.BatteryCallback {
[LG Optimus 2x] mateorod:
Zip up your build.prop, framework, services, and core.jar for both and post 'em. And tell me a little about the roms themselves. Do you have aosp for the toro? I may be able to patch that already. And what is liquidsmooth? A combo of some kind?

No guarantees though, but all posted framework become the base I build the patches from, when and if they seem doable. So it won't hurt...

---------- Post added at 02:37 PM ---------- Previous post was at 02:32 PM ----------

Understand what? Are you asking what the rej ,file is? Or what to do about a failed hunk? You can try and apply it manually, that's what I had to do to build cornerstone.

I wonder how wide the change is. It wouldn't surprise me to see this become a problem for more than just your device, and probably soon. I hope not, although it's just one hunk, I guess.
[LG Optimus 2x] fragargon:
hi guys,

i m coming to tell you i m still monitoring the thread, thanks for all your support and work. I don't give up... VM is running fine now. ATM i m writing, build is processing on my main VM machine. AOSP bravo ics 4.0.4... hope this run goes fine.
[LG Optimus 2x] c-pimp:
Team Gummy Aosp built, ... posting now...

patches seemed to go fine!

building new patched build now...

attached is Aosp non patched files...

should be done with patched build in a half hour or less...
[LG Optimus 2x] JoeSyr:
Attached three zips: Liquidsmooth is pulled from my phone(latest build, they have another one that's in closed RC testing right now as I understand it), AOKP is pulled from the AOKP M5 toro install zip, and AOSP is a rom that's mostly stock for the latest 4.0.4 verizon release with a few essential tweaks(pulled from install zip). These are all deodexed roms, btw. Not sure if that matters from what I've been reading here.

I think a lot of roms for the Galaxy Nexus tend to be pretty similar under the hood because development tends to be pretty active on several fronts and a lot is kanged around. The Liquidsmooth team sort of makes it their mission statement that they start with AOSP and try to slim it down to be lightweight and well, smooth. Not intended to just be a slimmer AOSP though, they fit in a lot of customization features. The rom has a lot of original work put into it, but you also see a lot of AOKP/cm9 influence so that's why I figure it can't be too far off if you have working patches for CM9 and AOKP.
[LG Optimus 2x] c-pimp:
w00t that went QUICK !!!

here is the patched version, I am putting it up here even before transfering it to my phone for a test, gotta get ready to goto dinner... will be responding on working or what when I can... but for now here is the files.

And now, tested working!!

Hope this works for the aosp patches :-)

I'm going to try to add ROM control from aokp and see if patching works and differs next because alot of people are adding that to their roms
[LG Optimus 2x] mateorod:
Joesyr-

Well, the AOSP did not patch the frameworks correctly. We only have the one patch at the moment, but I am encountering a wide range of AOSP source trees. which is making a patch difficult.

I will check the liquidsmooth and the aokp later tonight. I only have a few moments right now and...

c-pimp-

Congrats sir. Thanks for posting. I will make another AOSP patch out of your jars right now.

Pastime, I will put them in the dropbox if you want to mess with them...I won't be around to do any testing until later tonight.

UPDATE: new aosp patches are in a folder called newAOSP in the dropbox. The patch commands are in the script, although you may need to strip 2 directories, i.e. -p2.

I will play with them and the newly posted jar packs tonight.

and JoeSyr- I will try and patch the AOKP tonght, but you could just take the auto-patcher to your forums and try and ask for help there if you dont want to wait...
[LG Optimus 2x] JoeSyr:
Right-o. I'm actually waiting on a call for a while now so I can't flash anything until later tonight/tomorrow anyway.

If it's of any help comparing what does and doesn't work, here are links to the roms I pulled those from:

AOSP 4.0.4 IMM76K

AOKP M5

Liquidsmooth 1.35

If I get the chance should I try c-pimp's AOSP patch, or do you think it's easy to say it'll fail for being from a different build if mine didn't patch?

Gotta run out now but the next time I get the chance I'll make a post in the Gnex forums here and on rootzwiki; I'm sure there are plenty of people who'd love to use this and at least one must be running linux ;)
[LG Optimus 2x] c-pimp:
mine is not a patch for your rom, the hopes of my files are for meterod and pasttime to be able to add aosp to the patcher and then we can all have a party lol!!!

---------- Post added at 11:06 PM ---------- Previous post was at 10:59 PM ----------

pasttime could a patch be added for this to work with cm7 and other variants as well... the patcher from svyat doesnt seem to work the best with some and I was thinking maybe this will do the job better for a broader range... just wondering if its an easy thing to add or not... I just finally started playing with the patcher and its working great on alot of my cm9 and aokp downloads so thats great news! cant wait to test on aosp roms next!!!
[LG Optimus 2x] mateorod:
C-pimp

There isn't any reason we couldn't use the exact same methods for CM7. But I bet that the ROMS the official patcher is struggling to patch are the same ones we are having trouble with...i.e. manufacturer specific AOSP and costum combos. If people are actually struggling with CM7 itself, or AOKP, well we could look at that, sure.

I looked at svyat's patcher for the first time yesterday, and it does things in a...different manner. Looks like he manually adds in some files, maybe? I am not quite sure (I just glanced at it) but there is some things going on with the ActivityManager and ContextImpl among others like sure look like it.

pastime- I am going to play around with some of these AOSP jar packs right now, see where we are with the AOSP stuff.

I also meant to suggest a plug for Cygwin on post 4, at least until we get someone to translate (or I break down and try to learn just enough Windows CLI to get it working.)
[LG Optimus 2x] c-pimp:
I was just suggesting the cm7 addition because I know in the main thread others have roms that fail with windows patcher but succeed worth the Linux one.. Hopefully I can find an aosp that has a common base for more platforms, I'll be looking around and reading more in the next few days
[LG Optimus 2x] mateorod:
yeah, I've seen that too...I wonder. It wouldn't take much to cover the standard CM7 and AOKP which would reasonably be a somewhat valuable thing if only for those who will inevitably try and patch those roms with our patch.

Unfortunately, the search for a working AOSP method goes on.

JoeSyr- I have tried all of my patches, including the two new AOSP ones on all of your roms, and no dice. Almost all of your files patch, but generally, I fail specifically on the ServerThread file. Which is very familiar. I have tried breaking up the patches, e.g. using the CM9 patch on your services.jar and AOSP/AOKP on the rest, and no dice.

These AOSP ROMS may be just too wildly different for us to have much portability. I am going to have to look into how they are made a little deeper. We may be just best off trying to cover the most popular AOSP for the major manufacturers (if we can get builders) and leave it at that.

We'll just have to see. For instance, true AOSP (according to the AOSP site) requires 64 bit. But the Gummy rom that c-pimp posted has basically CM9 dependencies only, which has me wonder how much of it is based on CM9 and how much is AOSP. I might throw those jars c-pimp posted in the patcher and see what happens. (I have an update.zip template for these types of experiments)

hard to say. This is the first time I have looked at these types of roms (we only have CM9 and MIUI for my device). There is always the possibility I am missing something basic. Although the patch making and applying process, I think, has been borne out.

idk. rambling.
[LG Optimus 2x] pastime1971:
one line added recently, which broke the patch.

framework.diff needs to changed like this around line 4103

--- frameworks/base/services/java/com/android/server/am/ActivityManagerService.java	2012-03-29 23:41:14.045720104 -0700
+++ frameworks/base/services/java/com/android/server/am/ActivityManagerService.java	2012-03-29 23:11:05.086052516 -0700
@@ -138,6 +138,9 @@
[B][COLOR="Red"]import java.util.Set;[/COLOR] <-- delete this[/B]
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
[B][COLOR="Red"]import dalvik.system.Zygote;[/COLOR] <--- insert this[/B]
+// BEGIN privacy-added
+import android.privacy.surrogate.PrivacyActivityManagerService;
+// END privacy-added

public final class ActivityManagerService extends ActivityManagerNative
implements Watchdog.Monitor, BatteryStatsImpl.BatteryCallback {

i will update the patch files in the first post...

edit: the first post updated

edit2: what are the odds alroger tries patching for the first time and they broke due to a commit update ? :D

edit3: the culprit commit is https://github.com/CyanogenMod/andr...mmit/5b98f48ce8a98f7ecd74559088a755ca4df96bd2
[LG Optimus 2x] pastime1971:
linux patcher works because it is old one (1.27), isn't it ?

windows patcher (1.32) seems to have some issues.

@ mateorod,

c-pimp may have some point. svyat is using apktool and some clean up script. we are using baksmali w/ -b option. it could be a better option. (i'm not sure.)

furthermore, he is putting his effort on ICS, and GB is not being looked at for now, i guess.

however, i think we focus on ICS only, and try to expand more ROMs, rather than thinking about GB support, in my opinion. what do you think ?

edit: just wanted to say that it is quite straightforward to check ROM version (e.g. CM7 vs CM9), and then apply patches accordingly. all come down to having the right patches. @mateorod, i have been meaning to ask you. how do you make patches ? do you manually edit them ?