[Q] can androidmanifest.xml properties be altered by an xposed module? - Xposed General

Hello.
I know you can overwrite layouts, resources and other properties using an xposed module.
My question is - is it possible to write a module to alter an APK's manifest properties once it loads? (kinda like post-inflate hooks)?
Thanks

Theoretically yes, check PackageParser class or so..

Related

[Q] R/W access to sharedPreferences w/Xposed

So I'm writing my first Xposed module and I've hit another snag.
My module has a UI that can be opened from the launcher. My UI is simple and it just allows the user to increment/decrement the counter. The value of the counter is saved to the SharedPreferences file found at \data\data\com.appname\shared_prefs.
The Xposed portion of the module will read the value out of the shared_prefs file, decrement the counter, and save the decremented value back to the file...
How can this be done? I know that I shouldn't be reading/writing to the shared_prefs file from the Xposed activity... so if there is a better (read correct) way of doing what I need to do, can you point me in the right direction? The only part of the module I don't have working is this last part... My UI is already able to Read/Write to the shared_prefs file, so hopefully that helps... or at least shows that I'm not wasting anyone's time.
In xposed module send intent to your app to modify prefs.
Could you be a little more specific? I'm more of an embedded/C programmer... Android/Java is still a little new to me.
Define own intent sction in manifest - e.g. mymodule.intent.action.DESCREASE_COUNTER
Then in hook you have to get context (getObjectField("mContext") - in android, AndroidAppHelper.currentApplication - for other apps)
Then just run intent:
mContext.sendBroadcast(new Intent("mymodule.intent.action.DESCREASE_COUNTER"));
I use such way in my module - https://github.com/pylerSM/XInstaller/. Check it
I try to read a shared preferences file in the Xposed Bridge module and I cannot get anything. Can you please, provide some information on how to read the file. I would prefer to use shared preferences instead of a binder.

[Developing Module] framework .jar files are modified but are not loaded by Android

Hi all.
I am developing a magisk module that modifies system/framework/services.jar and some APKs using Magic Mount for Pokemon GO and other games.
I am using the Magisk Module template where I have added relevant files/folders to system.
The APKs I added work successfully.
But the framework .JAR files such as services.jar that I added are not loaded by Android after reboot.
As in, the .JAR files are replaced successfully, but Android exhibits no change, as if it was not using them and using instead the stock .JAR files.
I tried checking via md5sum in the terminal whether the services.jar file had in fact been swapped for the one embedded in my Magisk Module.
It had been successfully changed.
Maybe the OS wasn't loading these .JAR files at all, so as an experiment, I tried swapping services.jar for an empty file.
The phone still booted, and running md5sum and cat confirmed that system/framework/services.jar was an empty file.
My best guess is that framework files are loaded way before system/app APKs, but I found no information regarding my issue via Google.
I hope that someone here could please offer some quick tip or wisdom. Thank you in advance.
P.S.: I checked the open source Magisk modules I could find, and those that used framework .JAR replacements did not implement anything other than the basic template. An example: SonyFramework (My account can't post links yet).
Did you deodex your ROM, or is it a deodexed ROM?
I think you can only patch framework classes on deodexed ROMs.
Fif_ said:
Did you deodex your ROM, or is it a deodexed ROM?
I think you can only patch framework classes on deodexed ROMs.
Click to expand...
Click to collapse
Thank you for the suggestion.
The ROM I'm working on is Stock and Odexed by default.
The .JAR files I am including in the Module are Deodexed mods of the stock ones.
I tried the following as per your reply:
A) deodexing the whole ROM
B) deodexing the whole /system/framework/*
C) deodexing /system/framework/services.jar and removing odex residue (services.odex)
Unfortunately the device won't boot with A or B :S
With C it boots correctly, but the main issue remains.
---
An interesting behavior I found, is that when substituting (stock odex services.jar) with (modded deodexed services.jar),
the /system/framework/oat/arm/services.odex and other odex residue disappears for services.jar.
This along with the md5sum matching the modded version makes me think that maybe /system/framework gets loaded before Magic Mount gets to modify it.
Digging through open source Magisk modules I am yet to find the missing piece.
Thank you for your help Fif_, and to whoever takes the time to read my thread
Have a look at this thread. https://tapatalk.com/shareLink?url=...3793&share_type=t
[MODULE] Smali Patcher 0.8 and compare methods.
The module to replace patched, de-odexed services.jar definitely works.
shoey63 said:
Have a look at this thread (...)
Click to expand...
Click to collapse
Thanks, "Smali Patcher" was indeed a good clue.
What I found in the "Smali Patcher" project:
-> services.odex was being deleted
But I also needed to modify framework.jar
unfortunately there is no "framework.odex" file.
Googling around seems that framework.jar's odex companion is stored in "/system/framework/arm/boot.oat", but boot.oat contains many more unrelated .jars :S
After fully Deodexing the WHOLE ROM, the Magisk Module works.
I wonder if there is a way to remove framework.odex from boot.oat... that would be very useful.
Thank you guys for your help,

How to make a Magisk module replace files/folder inside an apk file?

Hi,
So I want to systemlessly replace a huge number of files (images)/or just an entire folder within an app.
For example: inside app.apk there is a folder "assets/images". I want to replace every single image that is in that folder with other ones.
Is this possible with a Magisk Module?
Grab a copy of the apk, edit it to your liking, and then make a Magisk module that replaces the stock apk with your edited one.
That would be the way to do it in Magisk.
If you want it done in a more automatic fashion, you would have to create a script or program that extracts the apk, edits it, and then creates and installs a Magisk module that replaces the stock apk with the edited one.
Yes, I would like an automated one... I think it should be done with post-fs-data.sh. But is it capable of decompiling and recompiling apk files?
No. And you don't want to do something like that during post-fs-data.
Your best bet (IMHO) is to do it during installation of the module, somehow. An automated process that pulls the apk from /system, decompiles, edits, and recompiles it, before installing it as a Magisk module.
Why do you need the automation? Just for fun, or do you specifically need it? I often find my reason for doing something to be: "to see if I can"... :laugh:
Didgeridoohan said:
No. And you don't want to do something like that during post-fs-data.
Your best bet (IMHO) is to do it during installation of the module, somehow. An automated process that pulls the apk from /system, decompiles, edits, and recompiles it, before installing it as a Magisk module.
Why do you need the automation? Just for fun, or do you specifically need it? I often find my reason for doing something to be: "to see if I can"... :laugh:
Click to expand...
Click to collapse
Yes, I want to learn and see if I can do it. And Ivdont want to make a new apk everytime the original app updates. If you have a script this happens automatically.
Also if I program config.sh (this is the install script right?) to automate this process would it still me systemless? I think even when I uninstall the module the mod would still be there...
ilivss said:
Also if I program config.sh (this is the install script right?) to automate this process would it still me systemless? I think even when I uninstall the module the mod would still be there...
Click to expand...
Click to collapse
If you copy the apk from /system before working on it, and then make it into a Magisk module that magic mounts the apk over the stock apk, it'll be a systemless modification. If you then proceed to uninstall the module, the modified apk will not be replacing the original apk anymore, returning everything to stock. Anything else would not be systemless...
Didgeridoohan said:
Why do you need the automation? Just for fun, or do you specifically need it? I often find my reason for doing something to be: "to see if I can"... :laugh:
Click to expand...
Click to collapse
I got one that I actually need. Rotation set to landscape and auto-rotation off in the head unit upgrade I recently put on. However, my unit orientation is portrait.
I have Magisk installed, and I need it to override this setting and change the default to portrait.
Is this even possible or sound like something fun to do ?

[MODULE HELP] Can I replace a system APK file conditionally per API Level?

I'm trying to create a module where I need to replace a /system/priv-app/<filename>.apk with another one but it depends on the running Android version (API Level). Can this be scripted somehow with Magisk or would I need to create a module for each API Level I need/want to support?
You're on a roll today, aren't you?
What you're asking for is quite easy with a Magisk module. It's already implemented in the template:
https://github.com/topjohnwu/magisk...META-INF/com/google/android/update-binary#L62
You can place the different versions of the apk you want to use in the /common folder, name them accordingly, and then use the $API to install the correct one. Example:
Code:
cp $INSTALLER/common/apkname-$API.apk $MODPATH/system/priv-app/apknamefolder/apkname.apk
I just want to make sure I do this module correctly and don't break anything when sharing the module with everyone.
Should I just place the copy command directly in the "update-binary" file or create a "custom function" inside my config.sh and and call that inside "update-binary"? What's the recommended approach here?
I'd create a function in config.sh and call that inside update-binary. That way it'll be a lot easier for you to update to a new template further on.
Thank you

[Question] Module to change vendor/build.prop

Hello,
I want to try to include some change on vendor/build.prop in my magisk module, is that possible to do that?
If i try to put string on system.prop (resetprop), it'll write at build.prop not vendor/build.prop, how can i write into that file with magisk module?
Thank you...
Magisk's resetprop tool (that you use when you add stuff to the system.prop file in a module) does not write anything to the build.prop files, neither in /system or /vendor. They simply load new values over the stock ones. As long as you want to just load new prop values you don't have to bother with the files at all.

Categories

Resources