Lanchon / haystack

Signature Spoofing Patcher for Android
GNU General Public License v3.0
234 stars 45 forks source link

patching Marshmallow 6.0.1 LegacyXperia unofficial CyanogenMod 13.0 build #22

Closed aktivkohle closed 5 years ago

aktivkohle commented 5 years ago

Back in late 2016 I put the official CM 10 on my Sony Ericsson Xperia Mini, added UnifiedNLP, MicroG, modified settings.apk so that signature spoofing worked as confirmed in the small test app. I has worked well since. Now I just got a second device to test out the unofficial 13.0 build as this android 6.0.1 allows certain apps which otherwise seem to fail or not install on android 4.2. Can't remember what I used to patch it back then but have just tried to use haystack to do it now with 13.

So here some links about this ROM:

https://forum.xda-developers.com/xperia-arc/development/dev-2011-unofficial-cyanogenmod-13-0-t3323975

https://github.com/LegacyXperia/Wiki/wiki/Installing-Marshmallow

They seem to want you to flash GAPPS during the initial installation. I refrained. The OS looks really nice, everything seems to work including apps which would not work on CM-10, but am now wanting to set up signature spoofing, MicroG for play services and unifiedNLP for network location.

Here's what happened when I tried:

$ ./pull-fileset fs-oneplus2
>>> target directory: fs-oneplus2
>>> adb pull /system/framework/framework.jar fs-oneplus2/
7 KB/s (310 bytes in 0.040s)
>>> adb pull /system/framework/framework2.jar fs-oneplus2/
remote object '/system/framework/framework2.jar' does not exist
>>> adb pull /system/framework/core.jar fs-oneplus2/
remote object '/system/framework/core.jar' does not exist
>>> adb pull /system/framework/core-libart.jar fs-oneplus2/
231 KB/s (19887 bytes in 0.083s)
>>> adb pull /system/framework/core-oj.jar fs-oneplus2/
remote object '/system/framework/core-oj.jar' does not exist
>>> adb pull /system/framework/ext.jar fs-oneplus2/
5175 KB/s (1596347 bytes in 0.301s)
>>> adb pull /system/framework/services.jar fs-oneplus2/
7 KB/s (310 bytes in 0.043s)
>>> adb pull /system/priv-app/Settings/Settings.apk fs-oneplus2/
7626 KB/s (26284269 bytes in 3.365s)

*** pull-fileset: success

$ ls -la fs-oneplus2
insgesamt 27268
drwxr-xr-x  2 aktivkole aktivkole     4096 Jan  2 09:13 .
drwxr-xr-x 11 aktivkole aktivkole     4096 Jan  2 09:29 ..
-rw-r--r--  1 aktivkole aktivkole    19887 Jan  2 09:13 core-libart.jar
-rw-r--r--  1 aktivkole aktivkole  1596347 Jan  2 09:13 ext.jar
-rw-r--r--  1 aktivkole aktivkole      310 Jan  2 09:13 framework.jar
-rw-r--r--  1 aktivkole aktivkole      310 Jan  2 09:13 services.jar
-rw-r--r--  1 aktivkole aktivkole 26284269 Jan  2 09:13 Settings.apk

 $ ./patch-fileset patches/sigspoof-hook-4.1-6.0/ 23 fs-oneplus2/
>>> target directory: fs-oneplus2__sigspoof-hook-4.1-6.0
>>> apply patch: services.jar
>>> dexpatcher --api-level 23 --verbose --output fs-oneplus2__sigspoof-hook-4.1-6.0/tmp/services.jar/patched-dex --multi-dex fs-oneplus2/services.jar patches/sigspoof-hook-4.1-6.0/services.jar.dex
info: read 'fs-oneplus2/services.jar'
fatal: exception: lanchon.multidexlib2.EmptyMultiDexContainerException: fs-oneplus2/services.jar

So yes, I kept it easy by using your direcory name fs-oneplus2 but it has crashed with the message that services.jar is empty. Any ideas how to fix this? Would really like to get it to work..

JonnyTech commented 5 years ago

@aktivkohle you need to deodex your ROM before you can patch it

aktivkohle commented 5 years ago

Thanks @JonnyTech is first I have heard of that. Have spent about half an hour reading about it, seems quite a detailed thing to do so wanted to ask for some tips before starting. Also a lot of the advice seems to be for Windows users.

Do you need to use a computer to "deodex" or is it something that the device should do to itself?

Super R kitchen seems like a likely candidate to get the job done on Marshmallow from linux otherwise: https://bitbucket.org/superr/superrs-kitchen/src

Is the principle that this installed ROM is modified "in place" or am I supposed to "treat" the ROM in its folder on the PC and then reflash the whole thing?

JonnyTech commented 5 years ago

I use the free version SuperR's Kitchen to deodex my Marshmallow and Nougat ROM's from Linux.

XDA thread: https://forum.xda-developers.com/apps/superr-kitchen/kitchen-superr-s-kitchen-v1-1-50-v2-1-6-t3597434

Linux download: http://sr-code.com/next/srkfree/

Use SuperR's Kitchen to deodex the ROM image from your computer then flash it to your phone. It is not complicated from a user experience - just select options in the menu.

aktivkohle commented 5 years ago

Thanks @JonnyTech well super-r seems to have deodex'd nicely. It used all the processors for about five minutes performing some kind of surgery on the original zip file.

Seems a bit wrong to de-optimise the entire ROM when only a part of it needs to be patched by haystack. superr created the following in its project folder next to the zip

/superr_mymarshmallow $ ls
00_project_files  boot.img  cm-13.0-20161109-UNOFFICIAL-LegacyXperia-smultron.zip  file_contexts  install  META-INF  recovery  system

then looking inside system/ :

$ ls system/
addon.d  app  bin  build.prop  etc  fonts  framework  lib  media  priv-app  recovery-from-boot.p  semc  tts  usr  vendor  xbin

then inside system/framework/ :

$ ls system/framework/
am.jar                   com.android.future.usb.accessory.jar  dpm.jar               input.jar                        org.cyanogenmod.platform-res.apk  telephony-common.jar
android.test.runner.jar  com.android.location.provider.jar     ethernet-service.jar  javax.obex.jar                   pm.jar                            tm.jar
apache-xml.jar           com.android.mediadrm.signer.jar       ext.jar               media_cmd.jar                    requestsync.jar                   uiautomator.jar
appops.jar               com.android.media.remotedisplay.jar   framework.jar         monkey.jar                       services.jar                      voip-common.jar
appwidget.jar            conscrypt.jar                         framework-res.apk     okhttp.jar                       settings.jar                      wifi-service.jar
bmgr.jar                 content.jar                           hid.jar               org.apache.http.legacy.boot.jar  sm.jar                            wm.jar
bouncycastle.jar         core-junit.jar                        ime.jar               org.cyanogenmod.hardware.jar     svc.jar
bu.jar                   core-libart.jar                       ims-common.jar        org.cyanogenmod.platform.jar     telecom.jar

I think I will try to replace the files which haystack pulled from my phone with the script https://github.com/Lanchon/haystack/blob/master/pull-fileset ..with the files from this system/framework/ folder which superr created from the original .zip of the ROM rather than somehow trying to flash this entire thing again onto the phone. Say if that is a bad idea

JonnyTech commented 5 years ago

@aktivkohle my knowledge of Android internals is not comprehensive enough to determine whether your idea will work. But if you read the requirements of haystack:

Requirements:
    An Android device that:
        Runs a non-odexed rom based on Android version 1.5 through 7.1.

You can clearly see that it requires a deodexed ROM. Therefore I advise not to just replace the individual files. Just use haystack to patch the files, use SuperR to create a new system.img and then flash that.

Keep us updated either way. Good luck!

Lanchon commented 5 years ago

Seems a bit wrong to de-optimise the entire ROM when only a part of it needs to be patched by haystack.

it's the only correct way of doing it. if it seems wrong to you it must be because you dont know what odexing actually does.

and it's not deoptimizing, it's deodexing. odexing a rom only saves some space in the VM cache.

Lanchon commented 5 years ago

Say if that is a bad idea

yes, it's very bad.

aktivkohle commented 5 years ago

Good news, it worked :) Thanks for the advice @Lanchon , @JonnyTech saved me from barking up the wrong tree.. It took a bit of fiddling around. I recreated a .zip with SuperR's Kitchen from the deodexed ROM it had created. Was quite intuitive, it also asked me if I wanted to zipalign the packages, had no idea so said "yes", it also asked if I wanted to create a signed .zip as well, again said "yes". It made 2 zips but I ended up going with the unsigned one after some trial and error. Also, I thought I better flash the boot.img that SuperR's kitchen had prepared as it might have contained some differences. In CM boot up menu, cleaned cache, deleted system or something like that and did a factory reset. Oh, it wanted adb sideload to be run with sudo, otherwise there was some kind of permissions error in red on the screen of the phone.

So I then reran all the haystack commands from the readme to do the three-ways patch which finished without error.

Switched on spoofing from the option now at the bottom of developer options and proved it was working with the app. Also interesting was that under About > Build-Nummer it now says "Built with SuperRs.Kitchen" which is reassuring.

Saved all the output and some screenshots.

The proof of the pudding is in the eating - initially the DriveNow app was complaining about a lack of google play services, read through this then managed to remedy it by installing "services framework proxy" and "fakestore", now DriveNow is working perfectly with MicroG on CM13, it never really properly got off the ground on CM10..

JonnyTech commented 5 years ago

Excellent news @aktivkohle, well done! Thanks for the feedback. Please close this issue.