Resource Redirection of R.xml - Xposed Framework Development

I'm finally updating my Google Keyboard Custom Smilies module, but the new version of Google Keyboard uses a new system, it has all the stuff in R.xml. It looks like I can actually make the module far better, with a whole new page for the custom smiles, but I've hit a problem, I can't get Xposed to redirect XML:
Code:
resparam.res.setReplacement("com.google.android.inputmethod.latin", "xml", "softkeys_body_smiley", modRes.fwd(R.xml.softkeys_body_smiley));
Does not work, shows no errors or anything in the log, just does nothing
Is there some error here? Does Xposed not support redirecting XML?
Also, if I CAN redirect XML, can I redirect it to a string, where the string simply contains XML? Else it won't be very "custom"
Cheers

haven't tested but looks like it does, and that you can also hook XResources

Related

[ROM][2/12/11][CHINESE] MIUI for G2 (v1.2.11)

http://bbs.gfan.com/android-575451-1-1.html
ignore the link at the top that one is mostly chinese the english version is provided hear thanks to da900
DOWNLOAD LINK: http://www.multiupload.com/PVZRB1NRHK
P.P.S. All you do with this pack is on your own risk. I am not responsable for any damages of your phone.[/QUOTE]
please aware that this rom is only contain about 20% english , most of words are chinese
u should be able to change it to english in the language and input settings
Is this newer than the QnD 1.2.4 rom?
Look at the number lol. 1.2.11 > 1.2.4
no that one has chinese this one does to thou dnt flash nevermind
dictionary said:
Look at the number lol. 1.2.11 > 1.2.4
Click to expand...
Click to collapse
XD I was thinking 4 > 1.
here's the changelog:
MIUI 1.2.11 version update:
Phone:
Add in the phone settings to add "call from the sensors used in the process" of setting
Fix the call log to the Canadian people through IP numbers to send SMS / MMS will bring IP prefix, resulting in the issue could not be sent
Theme:
Add support for setting alarm
Ringing in the new system comes with the option "mute"
Optimize the system comes with the choice of ring tones
Repair some of the theme of the correct format does not show the problem package
System Update:
Add WIFI connection can support the Ad-Hoc (peer to peer) network
Press the Backspace key fixed the problem miscarriage of justice
Local Backup:
Installed on the sd card repair program can not be the problem with the backup and recovery
Click to expand...
Click to collapse
terrelltp said:
no that one has chinese this one does to thou dnt flash nevermind
Click to expand...
Click to collapse
What? Slow down and make sense lol. Are you saying that you screwed up, and there is next to no English in the build?
terrelltp said:
u should be able to change it to english in the language and input settings
Click to expand...
Click to collapse
i repeat :
this rom does contain 20% of english translation only !
Even you change to english language :
your 80% of menu still display "Chinese".
So, this is useless unless you understand simplified Chinese. I'll wait on g4rb4g3 to release a port.
Sent from my htc.desireZED
Weren't there language packs you could install
Sent from my HTC Vision
Device Specific Language Packs
I think that language packs are device specific.. I haven't been able to find a language pack on the net for the G2.. though I did manage to a how to guide but I'm green to this stuff..
If somebody out here is familiar with how to do this guide and create a language pack for the G2 for us.. that would be helpful.
djmcnz said:
Okay guys, there's a lot of demand for this rom and for language packs but not yet a lot of people who know how to make the packs. Whilst I set up the crowdin translation project I can not create or maintain language packs.
So, here's a summary of the instructions required to create a language pack for MIUI (indeed for any app/rom). You need a collection of tools and a little patience but the process isn't too difficult so do give it a go.
Also note that this summary includes generalisations for brevity. These instructions assume you have a deodexed rom.
Introduction
For the purposes of this post language information is stored in XML strings in files on the Android system. In the case of MIUI and these instructions we will be dealing with .apk files (applications).
Within the apk files is a resources directory (/res) and within this are various values directories, there is a default values directory (/res/values) and alternative language values directories (e.g. /res/values-DE and /res/values-IT).
If the rom is set to use it's default language it will read values from /res/values although these may NOT be in English. In MIUI, all of the common Android ASOP values in /res/values are English but the (additional) custom MIUI strings are in Simplified Chinese.
If you select a different language in the ROM than the default then the appropriate values directory will be searched. If a suitable string that matches your language selection is found in the alternative /res/values-xx directory then that string will be used instead. If an alternative does not exist then the default will be used.
Example:
Code:
/res/[COLOR="red"]values[/COLOR]/strings.xml
<stop_button_text>[COLOR="Red"]Stop[/COLOR]</stop_button_text>
/res/[COLOR="red"]values-DE[/COLOR]/strings.xml
<stop_button_text>[COLOR="red"]Halt[/COLOR]</stop_button_text>
/res/[COLOR="red"]values-IT[/COLOR]/strings.xml
<stop_button_text>[COLOR="red"]Basta[/COLOR]</stop_button_text>
In this example, if the language is set to the default the word "Stop" will be used, if it is set to German the word "Halt" will be substituted in, likewise "Basta" for Italian.
So, to add languages to a rom (or app) or to make an app multi-lingual you need to either change the default strings in /res/values/strings.xml to the ones you want to use or, and this is the preferable approach, add a /res/values-xx/strings.xml with the translations you want. The first approach will work (changing the default strings) but is not recommended because the Android Open Source Project and Android development in general, defaults to English. It's best to use the built in language substitution capabilities of Android rather than to work around them. Indeed, if the MIUI devs actually added their strings in English to /res/values/strings.xml and the Chinese equivalents in the appropriate directory this rom would already be in English!
Adding Languages
To add a translation file (strings.xml) to an apk you need to:
decode the apk
create a language directory
add the translation files
recompile the strings
add the new strings to the apk
Which all sounds a little daunting but it's really quite straight-forward, rewarding when you see the result and a good way to understand how parts of Android work. Here's how you can do it.
1. decode the apk
You will need the excellent apktool from brut.all which you can get from the link below. apktool is relatively easy to use but includes some little tricks so you will need to read the wiki and thread about it.
Do NOT just post problems about apktool if you can't get it to work. The tool DOES work so if it's not decoding (or encoding) your apps correctly then you're probably doing something wrong. If you start with this understand BEFORE you ask for support you'll get a lot more help...
apktool: http://code.google.com/p/android-apktool/
wiki: http://code.google.com/p/android-apktool/w/list
thread: http://forum.xda-developers.com/showthread.php?t=640592
Please make sure you run the following command to include the MIUI framework in apktool. You only need to do this once for each framework. If apktool works with one rom and not the next then (re)install the framework for that rom.
Code:
apktool if framework-res.apk
Where framework-res.apk is the one from the rom you are working with. Make sure apktool can find (the correct) framework-res.apk before you run this command.
This thread is not for apktool support.
Now, before you proceed, decode a simple app from MIUI (such as updater.apk) using apktool, do not make ANY changes, then re-encode it using apktool. For example:
Code:
apktool d Updater.apk ./decoded/
apktool b ./decoded/ new_updater.apk
Use the -v (verbose) flag in apktool if you have problems and need to diagnose further.
Remember, Android uses a case-sensitive file system, make sure your capitalisation is correct.
Typically you will not be able to install this apk because it is not signed so if you want to test the process further you can now just try step 5 below using the two apks you have.​
2. create a language directory
Assuming you can decode/encode now, this is the easy bit. For your decoded app, navigate to the directory it was decoded in, then to the /res/ directory and simply create an empty directory for your language (e.g. /values-FR/) - use international naming conventions.​
3. add the translation files
Again, not too difficult this. Download the appropriate language file for your apk from the crowdin project linked below and, using the same structure as exists in /res/values/strings.xml create a new file called strings.xml in your alternative language directory (e.g. /res/values-ES/strings.xml).
The news strings.xml may contain as many or as few translations as you like. Remember, if a translation does not exist the default value from /res/values/strings.xml will be used.
Crowdin: http://crowdin.net/project/miui-rom-translation/invite
The xml formatting and tag names need to match exactly with the default strings.xml in /res/values although the translated file does NOT need to be complete.
It is worth remembering here that unless your source apk is already translated to English then some of the default values in /res/values/strings.xml will still be in Chinese, it would pay to check these.​
4. recompile the strings
Now, if you've done everything carefully and correctly this step is really easy, all you need to do is recompile the apk with apktool using the b (for Build) switch.
Code:
apktool b ./<decoded_apk_dir>/ <output_apk_name>.apk
If this throws errors or does not work then use the -v switch to turn on verbose mode and diagnose your problem. If you did the test in step #1 and it worked then any problem at this step is likely related to your news strings.xml. Back out the changes one by one until you have found the problem and try again.
If you simply can't get it to compile with your changes then try just making a single change to the default strings.xml file in /res/values and see if that works for you.
Do NOT sign the apk!​
5. add the new strings to the apk
Easy. Open your new apk with a zip program (like 7Zip for Windows) and copy out the resources.arsc file in the root directory of the apk. Now take that file and copy it into the source apk from the rom overwriting the existing one. This process replaces the strings but keeps the integrity of the signatures on the files.
You can now push the modified file to your phone, replacing the stock one, reboot and you're translated. Push the file using "adb push" or copy it into place using a root file manager, do not "install" the new apk. Make sure you put it in the correct place (replace the original) and reboot.​
Conclusion
This process will help you add languages to any app including those in the MIUI rom. Because it's a rom the strings are contained in many different apps as well as framework-res.apk. To completely translate the rom you will need to edit every apk that has strings in it.
You will need to do this every time an apk in the rom changes. If a new version is released and say launcher2.apk is changed but updater.apk is not, then you can retain your updater.apk but you'll need to re-edit your launcher2.apk.
When an app changes the default strings.xml may also change. In this case you will need to make corresponding changes to your translations.
Good luck and if you get really stuck there's lots of people in this that have achieved success and may be willing to help!
Click to expand...
Click to collapse
http://forum.xda-developers.com/showthread.php?t=789566
MIUI 1.2.11 for Vision ENG
Hi, all. I like the MIUI ROM and as most of you want to have latest version as soon as posible. But I am not a dev and my skills in android development are very very poor. So, i followed the versions of MIUI by g4rb4g3. They all are very stable and fast. And i want to say once more HUGE THANX to him for his work.
But when i found this thread today in the morning i decide to make it in english. So, putting together the ROM from 1st post and ENG pack for N1 from MIUI-DEV.COM with some additional editing of built.prop and adding some apps. I made a pack. Flashed it and it is working fine.
P.S. The only chinese words that i found are in MIUI account registration in Accounts&sync.
Adding: Facebook, Twitter, VoiceSearch, Google Search, gMaps, Street, GMail etc. (all apks are up to date).
DOWNLOAD LINK: http://www.multiupload.com/PVZRB1NRHK
P.P.S. All you do with this pack is on your own risk. I am not responsable for any damages of your phone.
ok cool so basically u made a english version for that latest update cool cool
terrelltp said:
ok cool so basically u made a english version for that latest update cool cool
Click to expand...
Click to collapse
Maybe, you could add the link to ENG version to 1st post of this thread. Could you?
da900 said:
Maybe, you could add the link to ENG version to 1st post of this thread. Could you?
Click to expand...
Click to collapse
i thought thats what u did isint that link u posted the english version
terrelltp said:
i thought thats what u did isint that link u posted the english version
Click to expand...
Click to collapse
I think he means add the link that HE provided to your first post, so that users will actually have an ENG version, instead of the one you posted.
dictionary said:
I think he means add the link that HE provided to your first post, so that users will actually have an ENG version, instead of the one you posted.
Click to expand...
Click to collapse
That's what i mean. Thanx.
lol yes i did that now
da900 said:
Hi, all. I like the MIUI ROM and as most of you want to have latest version as soon as posible. But I am not a dev and my skills in android development are very very poor. So, i followed the versions of MIUI by g4rb4g3. They all are very stable and fast. And i want to say once more HUGE THANX to him for his work.
But when i found this thread today in the morning i decide to make it in english. So, putting together the ROM from 1st post and ENG pack for N1 from MIUI-DEV.COM with some additional editing of built.prop and adding some apps. I made a pack. Flashed it and it is working fine.
P.S. The only chinese words that i found are in MIUI account registration in Accounts&sync.
Adding: Facebook, Twitter, VoiceSearch, Google Search, gMaps, Street, GMail etc. (all apks are up to date).
DOWNLOAD LINK: http://www.multiupload.com/PVZRB1NRHK
P.P.S. All you do with this pack is on your own risk. I am not responsable for any damages of your phone.
Click to expand...
Click to collapse
WOOOO..good job . it's perfect !!!!!!!! work very well ~!! thanks a lot

[HACK] Customizing Bada OS

Hi all, using TkFileExplorer 2.4 you can see and edit Bada system files, in this thread I will report all usefull changes I will find and you could perform using this tool
If you find something other, you might write it here so we have all them collected in the same place
How to use TkFileExplorer:
-Connect your wave to PC with usb cable;
-Select USB Debug connection;
-Start TkFileExplorer and clic Connect;
-if the program fails to connect, try changing the COM port number in Settings;
-Make a backup of the files you change;
-...and try at your own risk!
Changing default browser brightness:
File: Phone:/Settings/Default/Registry/BrowserSettings.ini
Customize power on/off screen:
for configuration:
File: Phone:/Settings/Default/Registry/PowerOnOff.ini
for resources:
Directory: Phone:/SystemFS/PowerOnOff/
Change volume presets for calls, audio player, fm radio, video player, ringtone...:
File: Phone:/SystemFS/Driver/volpresets.xml
Cleaning themes preview images:
Simply clean the files in:
Directory: Phone:/User/Mass/Theme/Default/
Change camera settings:
File: Phone:/Settings/Default/Registry/CamSetting.ini
File: Phone:/SystemFS/Driver/CameraCaps/DevCamDeviceCapsNConfig_Primary.xml [only Bada 1.2]
Change Samsung LBS settings:
File: Phone:/Settings/Default/Registry/LbsConfig.ini
for using external bluetooth gps antenna, change BtGPS=1 (not tested yet) in:
File: Phone:/Settings/Default/Registry/LbsAppRegistry.ini
Usefull directories:
Internal user storage: Phone:/Media
MicroSD storage: Phone:/Mount/Mmc
Preinstalled apps: Phone:/Osp/Application/
Hey thanks a lot for the heads up! I just had a question... Can we really change the intro animation..? I mean completely replace it..? Or is that not possible??
Reply soon....
Hi all, I find the file /User/OspSys/LifeLog/Database/lifelog.db.
It's SQLite (view by sqlitebrowser.sourceforge.net )
There are many information, calls, deleted messages (but only 100 chars).
I hope, it's information isn't send anywhere, because my wave is trying to connect once a day (it's maybe one of the widget)
sonalswaroop said:
Hey thanks a lot for the heads up! I just had a question... Can we really change the intro animation..? I mean completely replace it..? Or is that not possible??
Reply soon....
Click to expand...
Click to collapse
hi, today I just gave a quick look to all files, but I think it's possible, in PowerOnOff.ini there are clear bindings to two .swf files and a startup / shutdown .wav sound contained in the resource path Phone:/SystemFS/PowerOnOff not sure, need to watch those files, I'll verify in next days..
guari said:
Change volume presets for calls, audio player, fm radio, video player, ringtone...:
File: Phone:/SystemFS/Driver/volpresets.xml
Click to expand...
Click to collapse
Yes, you can change this too in Trix but in fact nothing change. Exp. you can't change "volume level" (exp. in MediaPlayer there is limit to 14 steps, if you change that to 15 steps and add one more <spklevel> and <earlevel>-so that there will be 15 steps, but nothing change in Wave, you can still able go to max. 14 steps in MediaPlayer) and you can't change that may mp3 playing miusic lauder as well as playing video, even if you copy and paste settings from VideoPlayer to MediaPlayer (only test that on speaker not on headphones).
In Registry\MainMenu_reg.ini you can remove any icons from the main menu (except SamsungApps). The file format is clear, I will note only that the system items will have MenuType=0, custom user applications - MenuType=1, SamsungApps - MenuType=2.
And, of course, make a backup before any manipulations with MainMenu_reg.ini
to be clear
adfree had made all those expermintes before & we already know these things
if there is something new please post it
Is there a file in registry where are the settings for the screen lock?Or other display related settings?
azcv said:
Is there a file in registry where are the settings for the screen lock?Or other display related settings?
Click to expand...
Click to collapse
Unfortunately I have not found anything like that using tkFileExplorer...
Assuming that replacing original browser it's difficult to do, source code is available (http://opensource.samsung.com/reception/reception_main.do?method=reception_list&menu_item=mobile thanks to sabianadmin) but the browser seems deeply integrated in the os files (also notice that Samsung Dolfin is not the open source browser Dolphin..): is there anyone who found in filesystem files the textures used by the browser GUI? if aren't cripted it will be possibile to change them for having a more usable GUI on our little screen (I'm thinking of upper/lower bars..)
guari said:
Assuming that replacing original browser it's difficult to do, source code is available (http://opensource.samsung.com/reception/reception_main.do?method=reception_list&menu_item=mobile thanks to sabianadmin) but the browser seems deeply integrated in the os files (also notice that Samsung Dolfin is not the open source browser Dolphin..): is there anyone who found in filesystem files the textures used by the browser GUI? if aren't cripted it will be possibile to change them for having a more usable GUI on our little screen (I'm thinking of upper/lower bars..)
Click to expand...
Click to collapse
I think the browser user interface might be in the file called BrowserAppControl.so which can be found in the SystemFS>Osp folder. All files in that folder are in .so formats. But they are RSA 1024bit signed. And they are not like other settings in phones which are written in html or xml. These files are similar to the .dll files on Windows. .so files are Linux format files.
Is there anyway to modify an *.ini file to enable "Noise Reduction" to always be on during calls?
tibere86 said:
Is there anyway to modify an *.ini file to enable "Noise Reduction" to always be on during calls?
Click to expand...
Click to collapse
I will check on that and get back to you.
astrotom said:
I will check on that and get back to you.
Click to expand...
Click to collapse
Thank you astrotom!
Can I changing default brightness in the VideoPlayer?
Hello
This software doesn't work with my phone. I can't click on the connection i receved error message : "Warning : Unable to open the specified port. Please try again". But i can't configure in the settings.
Thanks for your help.
I'm sory for my bad english, but i'm french.
vort said:
Hello
This software doesn't work with my phone. I can't click on the connection i receved error message : "Warning : Unable to open the specified port. Please try again". But i can't configure in the settings.
Thanks for your help.
I'm sory for my bad english, but i'm french.
Click to expand...
Click to collapse
i got the same error
im running the latest firmware s8530DXKB1/s8530OLBKB1
you have to specify the port you are using for connection from settings
in Phone:/SystemFS/Driver/CameraCaps/DevCamDeviceCapsNConfig_Primary.xml
you can change max ISO and max resolution parameters for phone camera, so you can set iso1600 or 8mp for photos, probably it is useless but it's still a hack
thanks to: http://www.badaitalia.com/2011/06/13/fotografie-con-poca-luce-a-iso-1600/
(on Bada 1.0.2 this system folder is missing so it's not possible..)
Yeah, I read it. Tonight I'll try and I'll let you know.

Making modifications & mergesmali

This is a new thread on the subject of modifying the system or
applications on the Nook. I'd like to see a separate thread on
modifying the kernel, but let's keep that off this.
The Basics
A bit of the system or an app is usually written in Java. Different
tools are used to compile and process it to the final product.
The Java Runtime Environment (JRE) is what allows you to run various tools and program on your host computer.
The Java Development Kit (JDK), version 6, update 33 contains the tools you need to work with Java
javac - the Java compiler
jarsigner - a tool for signing products
Android Software Development Kit (SDK), with downloads for Level 7 API.
Android Asset Packaging Tool (AAPT) - processes resources like images and layouts
Android Debug Bridge (ADB) - allows connection and debugging to your device
The final product is either an APK file or a JAR file, both of which
are basically ZIP files. Both of these contain a file called
classes.dex which contain the executable code. An APK file also
contains resources in a directory hierarchy. Some of these items,
like regular PNG graphics are exactly as you'd find them anywhere.
Other items, like "9 patch files" (9.png), are modified and others,
like XML files, are compressed. An APK file also contains a file
called AndroidManifest.xml that describes the product. Both APK
and JAR files can also contain signatures in the META-INF
directory.
Reverse Engineering
In the best of all worlds, you would have the original Java code that
the developers used to make the product. This is seldom available.
To work around this you need to backwards step the entire
process to get back to the original Java code. There is a problem,
the backwards process is not unambiguous. Yes, you can
backtrack to some Java code, that if compiled would work the
same as the original, but it would not look the same. Often the
intent of a piece of software is apparent from its layout. Also, you
will have none of the comments in the original code.
We can easily backtrack to an intermediate place between source
Java code and the final product. This is a place that does not really
exist in the original product generation process. We can take the
raw executable code out of a product and display it in a human
readable (and editable) form. "Smali" is the name of this
representation. It is analogous to assembly code. As stated, it
really does not exist as a language in the original compilation.
There is a software tool for taking apart a product and dissecting
it into the Smali code and the resources (if any). This tool also can
be used for compiling the Smali code back into the modified
product.
apktool, a tool for reverse engineering Android files
One of the main actions of the apktool is to take apart classes.dex
and generate a whole tree of files that end in the extension ".smali".
These files will have names like:
\NeatoApp\smali\com\bigcompany\neatoapp\MainView$23.smali
Modifying a Product
So, we can take a finished product, use apktool on it to take it apart
to pieces, modify some piece, then put it back together with
apktool. Modifying a resource like a graphic is easy, just modify
it (except 9.png, more later). Changing the wording of a popup
message is also easy. Changing the language of the interface
takes a bit more care to do it correctly. Modifying the Smali code
takes a bit of knowledge and done incorrectly can even brick your
device (repairable with a backup). If you have a chunk of Smali
code that someone modified for some reason, it's not too difficult
to open up your extracted Smali file, edit in the chunk, save it and
run apktool to put everything back together.
The Problem
We see this problem with kernels all the time, that some users want
a kernel with A, B, C and others want it with C, D, E. The number
of competing configuration gets out of hand. Moreover if you
come up with feature F, then you have to find a way to package
it up with A, B, C, for the first user and D, E for the second user.
A Solution
One possible solution is to let the user decide. You can distribute
options A-F independently and let the user install them themselves.
In principle, this means the user takes whatever version of
something they have on their device, apply a specific patch, then
reinstall it on their device. This would also open things up to
modifying different versions (for example Nook Touch vs. Nook
Glow) with the same mod.
mergesmali
mergesmali is a new tool for managing modifications to Smali
code. There is no particular magic behind it. It simply can replace
sections of Smali in a text file. It is agile enough to not rely on line
numbers or exact specifics of the Smali file. Here is a simple
example how you would use it to modify something:
Code:
adb pull /system/framework/android.policy.jar
apktool d android.policy.jar \Policy
mergesmali /v \Policy\smali\com\android\internal\policy\impl\LockScreen.smali landscapemod.smali
apktool b \Policy android.policy.jar
adb push android.policy.jar /system/framework
Mod Developers
We'll get to how to make the modification files for Smali soon...
Renate,
Great post! :good:
Could you add few words on logcat/ddms to help with troubleshooting, if a mod doesn’t work as expected, please?
Yes, I'm still working on this.
I've been patching the stock reader for dictionary and other things.
I was doing the patches on the 1.1.2 Reader.apk and it worked fine.
I just switched over to the 1.1.5 Reader.apk and it patched it fine without any changes.
This post addresses the developer side of things.
It is possible to patch Smali by hand.
For quick and dirty, this is not a bad solution.
The problem is that one must be aware of how many registers are used and for what.
In the first instance, if I need another register for my mod, that can push register references on other instructions out of the 4 bit range.
Also, if the stock code is revised later that can also change register references.
Even the simple addition of a debug print statement (Log.d) can affect things.
The solution is to always replace entire methods.
That way you are not fighting with conflicting code.
The logical place to keep your patches is in Java.
Obviously you can't have a standalone method, there has to be a class.
For instance, the stock Reader.apk has a place where it validates EAN (ISBN).
It checks for all digits, which bombs on sequences with dashes.
We want to replace that, easy enough, but we have to wrap it in the class.
Code:
package com.bn.nook.model.product;
public class Products
{
public static boolean isValidEan(String ean)
{
return(true);
}
}
Obviously this does not fully implement the class, but it has enough for our little method.
We do a normal compile of this, then apktool d it to the smali.
mergesmali can then scan through this smali and edit the stock smali from the apktool d'ed stock app.
A final apktool b, jarsigning and zipaligning puts it all back together.
But what if the method that we want to replace called some other method?
We would have to put something in our class to prevent compilation errors and to ensure that the smali code for our method did the correct invocation.
We end up writing stubs for these methods that do nothing.
If it's a void method, the body of the method is simply {}, for boolean types {return(false);}, etc.
But how do we make sure that mergesmali does not substitute these stub methods for the good methods already in stock?
Annotations.
By putting Annotations before each method, we can tell mergesmali what to do.
These annotations are preserved in the decoded smali.
They are subsequently deleted when mergesmali merges the smali.
Expanding our original example (this is just an example, not realistic):
Code:
package com.bn.nook.model.product;
import com.whoever.MergeSmali.*;
public class Products
{
@Ignore
public Products() {}
@Ignore
public static double complicatedOtherMethod(String ean, String msg)
{ return(0.0); }
@Replace
public static boolean isValidEan(String ean)
{
if (complicatedOtherMethod(ean, "Hello")<2.3) return(false);
return(true);
}
}
The @Replace tells mergesmali to replace this method.
The @Ignore tells mergesmali not to replace this method.
We need to have the stub for complicatedOtherMethod in the source.
Well, why is the constructor in there?
The compiler will generate a default constructor if we don't write one and it would have no annotation.
mergesmali prints an error if any method does not have an annotation;
There is also @Append for new methods that are not in the stock.
There is also @Delete to delete methods (that either have a super or not being used at all with the rewritten methods).
What's in com.whoever.MergeSmali.* ?
Code:
package com.whoever;
public class MergeSmali
{
public @interface Ignore {}
public @interface Replace {}
public @interface Append {}
public @interface Delete {}
}
The package is not important as long as it's an Annotation and the class/subclasses are as indicated.
collaboration?
Maybe we could start some sort of work distribution (and knowledge) towards fullfiiling some common goal for the NST.
Here's the Windows (command line) executable for mergesmali.
The basic usage is:
Code:
mergesmali /v [i]stock.smali[/i] [i]patch.smali[/i]
And here's the commands to integrate the new dictionary app to the stock Reader.
Code:
apktool.bat d Reader.apk \Reader
mergesmali /v \Reader\smali\com\bn\nook\reader\ui\ReaderMainView.smali ReaderMainView.smali
apktool.bat b \Reader NewReader.apk
It should generate the following message:
Code:
Replaced: public showLookupView()V
At this point you only have the question of how you are going to sign the modified Reader.
If you have resigned your whole system already, you can just resign with that and install.
You could also edit AndroidManifest.xml before the apktool b and delete the sharedid.
Then you could install it as a regular app after deleting the system app.
Renate NST said:
At this point you only have the question of how you are going to sign the modified Reader.
If you have resigned your whole system already
Click to expand...
Click to collapse
I guess no one did it... yet.
Renate NST said:
You could also edit AndroidManifest.xml before the apktool b and delete the sharedid.
Then you could install it as a regular app after deleting the system app.
Click to expand...
Click to collapse
I don’t understand Android security well enough.
There a discrepancy between documentation and how it works or maybe I don’t understand it at all.
Anyway – if Reader.apk is resigned, it should run under different user, thus loose access to shared databases (internal, annotations, bookmarks, etc.)
Do we need to fix permission to make them RW for everyone?
Could you check (ps) what user(s) "home", "library" and "patched reader" use on you nook now, please?
Annotations, bookmarks, last reading point are all providers implemented and used in Reader.apk.
As far as I can tell, there is no particular reason why Reader.apk uses a sharedId.
I don't have stock Home or Library running on my Nook.
I forget where I have Reader.apk installed right now.
It's been in /system/app or /data/app and worked fine in either place.
Resigning does not change user.
Renate NST said:
Annotations, bookmarks, last reading point are all providers implemented and used in Reader.apk.
Click to expand...
Click to collapse
I would expect the provider for Annotations, bookmarks is Reader.apk
They are not used anywhere else.
last reading point is used in Home.apk too.
Out of curiosity, where Annotations, bookmarks and last reading point providers are implemented?
In framework itself?
Renate NST said:
Resigning does not change user.
Click to expand...
Click to collapse
Ouch.
Stock reader runs as shared user.
If we resign it – it has to run as different one, according to security docs...
And it doesn’t matter if shared id is in manifest still or not.
I guess, I need to do some testing…
Ok, I meant resigning it with the system signature it can keep the same sharedId.
If you don't sign it with the same signature then you have to get rid of the sharedId.
It will then have a normal application user ID.
As far as I can tell, this should make no difference in anything.
But I have gutted most of the B&N stuff so I can't guarantee that in-store browsing or something else won't be affected.
Renate,
Could you answer this one:
ApokrifX said:
Out of curiosity, where Annotations, bookmarks and last reading point providers are implemented?
In framework itself?
Click to expand...
Click to collapse
And one more:
Is it difficult to mod and stock side-by-side?
Change app name + package for every class?
In Reader.apk
com.bn.nook.reader.providers.AnnotationsProvider
com.bn.nook.reader.providers.BaseDictionaryProvider
com.bn.nook.reader.providers.BookmarksProvider
com.bn.nook.reader.providers.LastReadingPointProvider
com.bn.nook.reader.providers.ReaderLocalProvider
(I'd like to know some time why the forums breaks words up.)
On your second question, that's an interesting one.
You'd have to change the package name all over the place,
not just in the manifest, but every smali file and every function call.
But sure, it could be done.
Renate NST said:
In Reader.apk
com.bn.nook.reader.providers.AnnotationsProvider
com.bn.nook.reader.providers.BaseDictionaryProvider
com.bn.nook.reader.providers.BookmarksProvider
com.bn.nook.reader.providers.LastReadingPointProvider
com.bn.nook.reader.providers.ReaderLocalProvider
Click to expand...
Click to collapse
Thank you!
Renate NST said:
(I'd like to know some time why the forums breaks words up.)
Click to expand...
Click to collapse
No idea…
Renate NST said:
Annotations, bookmarks, last reading point are all providers implemented and used in Reader.apk.
As far as I can tell, there is no particular reason why Reader.apk uses a sharedId.
Click to expand...
Click to collapse
Looking at B&N coding style, I won’t be surprised if Home.apk uses its own provider to read the "last reading point".
If this is the case sharedId in a must.
Renate NST said:
On your second question, that's an interesting one.
You'd have to change the package name all over the place,
not just in the manifest, but every smali file and every function call.
But sure, it could be done.
Click to expand...
Click to collapse
and every function call But it can be automated easily, right?
ApokrifX said:
If this is the case sharedId in a must.
Click to expand...
Click to collapse
No.
The "Last read" icon in the upper left corner broadcasts com.bn.nook.launch.LAST_BOOK
This is usually received by Home.apk, which uses the LRP provider in Reader.apk to get the EAN of the last book.
Home.apk then sends the intent android.intent.action.VIEW to Reader.apk with the path of the book.
Reader.apk then uses it's own LRP provider to get the actual LRP in the book.
None of this requires sharedIDs.
#2 Sure, that could be automated.
Renate NST said:
No.
The "Last read" icon in the upper left corner broadcasts com.bn.nook.launch.LAST_BOOK
This is usually received by Home.apk, which uses the LRP provider in Reader.apk to get the EAN of the last book.
Home.apk then sends the intent android.intent.action.VIEW to Reader.apk with the path of the book.
Reader.apk then uses it's own LRP provider to get the actual LRP in the book.
None of this requires sharedIDs.
Click to expand...
Click to collapse
Home shows "last book thumbnail" + on page #XYZ of #ABC also.
I recall you have deleted Home.apk.
Renate NST said:
#2 Sure, that could be automated.
Click to expand...
Click to collapse
Ok. I gotta take a look.Will try to do later today.
ApokrifX said:
Home shows "last book thumbnail" + on page #XYZ of #ABC also.
I recall you have deleted Home.apk.
Click to expand...
Click to collapse
Yes, my Library.apk replacement has a receiver for the com.bn.nook.launch.LAST_BOOK intent.
Even though Home.apk uses the Reader.apk to find LB & LRP for the preview,
it only uses LB to tell the Reader.apk what to open.
Reader.apk does its own homework checking LRP for the desired book.
This can easily be verified by opening a few books with a file manager.
Renate NST said:
Yes, my Library.apk replacement has a receiver for the com.bn.nook.launch.LAST_BOOK intent.
Even though Home.apk uses the Reader.apk to find LB & LRP for the preview,
it only uses LB to tell the Reader.apk what to open.
Reader.apk does its own homework checking LRP for the desired book.
This can easily be verified by opening a few books with a file manager.
Click to expand...
Click to collapse
Ok. I.e. it shouldn't be a problem to run side-by-side readers, right?
They both modify LRP, and Home will be able to pull it via stock reader.
Same idiotic question: do we need to need to change any permissions to let both readers access media databases?
As it stands, if I understand what you want to do,
you'd have to disable the providers in one of the Readers.
You can't have two providers responding to the same intents.
Is there some overwhelming reason why you want to do all this?
Renate NST said:
As it stands, if I understand what you want to do,
you'd have to disable the providers in one of the Readers.
You can't have two providers responding to the same intents.
Click to expand...
Click to collapse
I didn't realize until now, provider responds to URI, so better have one only to avoid problems...
Renate NST said:
Is there some overwhelming reason why you want to do all this?
Click to expand...
Click to collapse
To "not break existing functionality"
I see, it'll be too difficult to have both, too many changes are needed...
Just a bump, old posts don't have signatures.
mergesmali & other stuff can be downloaded from my signature blob.

Problem with app building

Hello,
I have decrypted an app, and now i am trying to firm as an apk file. However, it says this message "Illegal resource reference: @*android resources are private and not always present
Issue: Looks for references to private resources
Id: PrivateResource
Private resources should not be referenced; the may not be present everywhere, and even where they are they may disappear without notice.
To fix this, copy the resource into your own project. You can find the platform resources under $ANDROID_SK/platforms/android-$VERSION/data/res/."
I don't know how to include these resources into the project. Any help?
Than you in advance

[Q] How to find methods and layouts to hook into without source code

I'd like to develop my first xposed module. So far I have worked through the official tutorial and compiled and read the examples. (I also made android apps before).
I want to make a module for the official Twitter app that removes certain content from the home timeline, such as "Who to follow", "While you were away" and sponsored tweets.
As a first step, I tried to change the color of these elements to red, which I didn't manage to do.
I unzipped and decompiled the app and looked for class and method names that seem helpful (most of them were obfuscated). I tried to hook into some of the methods, mostly nothing happend. I got some MedhotNotFoundExceptions and once the app crashed. I also tried to look for layouts to hook into with no success.
Do you have any hints on how to find the right point for my xposed hook?
Thank you
I also decompiled apps to hook them and it worked. You have to do so, because what's executed is the obfuscated code, and these are the names (classes, methods, variables) you need, even if you own the unobfuscated source code.
If you get MethodNotFoundExceptions, the problem must be somewhere else.
Decompile the apk with apktool. Then look throught the smali code (note that you have to know how the smali structure works, what does a method return, how are different parameters represented). For layouts I personally use DDMS' Hierarchy View. If you still have the method not found error, paste here how you are trying to hook and the original smali code.
Sent from my iPhone 6 Plus using Tapatalk
Check out this awesome tool. Converts smali back to java
https://github.com/google/enjarify
That's what i use

Categories

Resources