Related
HI to every one.
Is there a way to get the apk file name when an app it was launched ?
Scenario: I want to append some additional data to the file name and when the app is launched I want somehow by application Id to locate the file name and extract that additional data to fill some fields inside my app .
Is there some methods which are in charge with that ? or even a way to do that ? or tutorial doing that ?
Also if not then what different methods exists to retrieve some additional data at downloading process, or even from file name ... etc ???
Thank you in advance .
asteroidg said:
HI to every one.
Is there a way to get the apk file name when an app it was launched ?
Scenario: I want to append some additional data to the file name and when the app is launched I want somehow by application Id to locate the file name and extract that additional data to fill some fields inside my app .
Is there some methods which are in charge with that ? or even a way to do that ? or tutorial doing that ?
Also if not then what different methods exists to retrieve some additional data at downloading process, or even from file name ... etc ???
Thank you in advance .
Click to expand...
Click to collapse
Which App Is It If You Don't Mind?
I Might Know The Exact Name?
Sent from my HERO200 using XDA App
It will be my *.apk file name downloaded from my server. I saw that every time that *.apk file went to my \sdcard\download, can I assume that that path will be for every android user ?
asteroidg said:
It will be my *.apk file name downloaded from my server. I saw that every time that *.apk file went to my \sdcard\download, can I assume that that path will be for every android user ?
Click to expand...
Click to collapse
It Usually Names The File,
At Least On My Hero!
Wait.... File Name? Or App Name?
For File Name, Try.... Root Explorer!!
Root Explorer, Allows You To Basically Dissect Apks.
For App Name, Try.... AppMonster!!
Install AppMonster, And Once It's Installed....
Reinstall The App/Apps You Want The Name Of, & Reopen AppMonster & They Should Show Up As Apps Currently Installed!
Lemme Know If That Works!!
Sent from my HERO200 using XDA App
Thanks. But I am looking doing that inside the code, by programming . I know how to get the file name from specific folder but i need to look for the file name from the whole device that't my point , if any suggestion or even line of codes will be appreciated.
File dir = new File("/data/app");
File[] fileList = dir.listFiles();
if (fileList != null)
{
for ( int i = 0;i<fileList.length;i++)
{
filename = fileList.getName();
Log.d("FN-log","file name="+filename);
if (-1 != filename.indexOf(appName.toString()))
{
break;
}
}
}
I am using the above code to retrieve the file name form specific folder, I need something from the whole device , any idea ?
asteroidg said:
Thanks. But I am looking doing that inside the code, by programming . I know how to get the file name from specific folder but i need to look for the file name from the whole device that't my point , if any suggestion or even line of codes will be appreciated.
File dir = new File("/data/app");
File[] fileList = dir.listFiles();
if (fileList != null)
{
for ( int i = 0;i<fileList.length;i++)
{
filename = fileList.getName();
Log.d("FN-log","file name="+filename);
if (-1 != filename.indexOf(appName.toString()))
{
break;
}
}
}
I am using the above code to retrieve the file name form specific folder, I need something from the whole device , any idea ?
Click to expand...
Click to collapse
Oh ok, Sorry misunderstood you!
Sent from my HERO200 using XDA App
Try searching the whole sd card folder by folder
XDA App
TheRedDrake said:
Try searching the whole sd card folder by folder
XDA App
Click to expand...
Click to collapse
It seems that I have to check first in the root folder of device which is "/", that thing will show the root list. Then I need a for in for intsructions to be called ... to check all subfolders until I will find the file, it's a solution but first I have to write this algorithm of searching which is a little bit annoying and I am afraid about that process will slow the app ... That's why I was looking for something which should be already in Android API, do not invent bicycle again ? But any help will be appreciated. (By the time I was thinking to use Linus find shell command , I tried but every time I am getting no permission access is denied ... )
Thank you.
PUMa - Patch Utility Manager
The program is designed to install patches in the most universal applets\libraries firmware of Samsung-communicators. It works with both odexed, and with deodexed components of many firmware of devices I9100/I91**,I9300,I9500,G850,G900*,G920*/G925*,G928*,G930*/G935*,N7000,N7100,N900*,N910*,N920*,I9001,I9250(Galaxy NEXUS),I8150,P5100/5110,T310/311. Likely to install some patches and other communicators based on the Android OS. It works with external patch (the description of the format and work with them, see Puma_extpatch.txt file.. while only in Russian). Optionally, the added ability to load external data from internet. Information about loading the file is stored in the archive dllink.bin.
The following types of downloads:
• Modem FW (modem firmwares)
• Dump FW (dump stock firmware (aka the contents of the folder /system))
• Dump Content (content dump the firmware, broken into pieces by certain categories)
• Camera (camera firmwares)
• Firmware (common firmwares of devices)
• Program (program & tools)
Working with the program:
0) program preferably placed in a folder without spaces and in the Latin alphabet
1) before running the program in the folder "In" place the files that need to be applied patch/es or used submenu Necessary files for to obtain the necessary files
2) in the program indicate the type of device, AndroidOS version, the class of the patch on the right side select desired patch and click Apply. If you install the patch unnecessary, it is necessary will be shut down and run again, showing only the necessary patches.
At the end of the program components can be patched to pick up from folder "Out". Also, the after applying the patch, the program may specify a update to flashing with help ClockworkMode. While working with a patch program provides information on the processed applet\libraries as follows:
Installed - the patch is applied
Present - patch is already installed in the object
Impossible - impossible to apply the patch to the object
Partially installed - installed only a few points of patch
Mismatch - firmware version of the object is failing the established type device/AOS patch
Attention! Due to the fact that some antivirus programs (Norton360, NOD32, Avast,...) have a somewhat paranoid algorithm for determining the virus, they "found a virus" in PUMa.exe. This is a lie, because the program simply packed EXE-packer to save space. Place the file in the Exceptions PUMa.exe antivirals, so it will not annoy you. Also below is a MD5-hash of the file PUMa.exe, according to which you can verify its correctness, upon receipt of any sources
Patches supported by the program : Post #2
Donations to the project (special thanks ) : bezbo, pglmro
v 4.8
- Added Value_Res tool (Tools-Working with resources-Value_Res). It allows you to change resource values of APK-file (variables of xml-files from the folder res\values) without decompiling\recompile the applet. Currently supported by work with variables of type bool, color, dimen, integer. The algorithm works with the tool:
1. select the apk-file for editing; will automatically upload the names and values resources in the tabs
2. double click on a line change\edit variable (value changed resources are marked in bold)
3. at the end of the work click the Save button (a new file will be created with the current name, the old file is renamed to *.apk.bak)
- Added tool Obfuscation (Tools-Smali-Debug-Obfuscation). In the current version implemented methods of obfuscation of class names, methods, fields on algorithms Mirroring, Numeric order, NDP and Randomized in smali-code (the name and the algorithms invented by me). Distinctive features of the algorithms on a 5-point scale:
a) readability (1-good..5-bad)
b) difficulty in decryption (1-simply..5-impossible)
c) final code length (1-more..3-same..5-less)
Code:
(a) (b) (c)
Mirroring: 3 2 3
Numeric order: 2 4 5
NDP: 4 3 2
Randomized: 4 5 4
For general use available obfuscation method field names with algorithm Mirroring. Tool results on other methods and algorithms are only available by personal request.
- Changed algorithm decompilation\recompile applets with multiple dex-component
- Font in the program changed to Tahoma
- Supplied with the program added to the external patches:
N910*_6.0.*
N920*_6.0.*
G930*/G935*_6.0.*
• System-Removing the signature verification applications
• System-Increasing the speed of response Automatic Brightness Control (ABC)
• System-Adding buttons 'Only once/Always' in task 'To open with'
MD5 : 6498af8f3e16c9657d3af5c7253dd0a7 *PUMa.exe
Download mirror link : >>> Here are stored PUMa <<<
Patches supported by the program:
(for new dev&AOS... older please see list in PUMa_eng.txt)
Grate concept ! i'll try it asap.
realy good job man .
if you can added many usefull mod . exampel : extended power - battery % - scroling cyanogen - . . .
tanks for perfect job.
Nice to see you here!
Great work!
nice !!
thank you.
Pako7 said:
1) before running the program in the folder "In" place the files that need to be applied patch/es
Click to expand...
Click to collapse
Works with Samsung stock roms?
alberto888zz said:
Works with Samsung stock roms?
Click to expand...
Click to collapse
with any.. stock and custom
mehrzad1363 said:
realy good job man .
if you can added many usefull mod . exampel : extended power - battery % - scroling cyanogen - . . .
tanks for perfect job.
Click to expand...
Click to collapse
Not all patches can be added to the program, but only those that are unifying the code
I am guessing this must work for i9100g series awell?
manishdev said:
I am guessing this must work for i9100g series awell?
Click to expand...
Click to collapse
i don't know.. you can try.. put your files in folder IN, select device I9100 and go forward.. If your files can be patched - this program will
Does not find the file even if I have placed in the folder In...what's wrong?
alberto888zz said:
Does not find the file even if I have placed in the folder In...what's wrong?
Click to expand...
Click to collapse
what files? what firmware? Odexed or deodexed? what patches?.. please say
Pako7 said:
what files? what firmware? Odexed or deodexed? what patches?.. please say
Click to expand...
Click to collapse
I have stock 2.3.6 KK1 ITV on my GS2. I have rooted it and transferred the system files by rootexplorer from sd to my computer.
Now i put the files (mms.apk, phone.apk, contacts.apk, etc...) in In folder but when i press apply on your PUMa Manager don't work.
Sorry for my bad english
alberto888zz said:
Now i put the files (mms.apk, phone.apk, contacts.apk, etc...) in In folder but when i press apply on your PUMa Manager don't work.
Click to expand...
Click to collapse
I tried on KK2 - all o'k..
1. if in the field "Necessary files" required files are odex-files (type DEX), then they must be placed in a folder "In", but not apk
2. try to put the program in the root of drive C, for example in the folder c:\PUMa
Pako7 said:
I tried on KK2 - all o'k..
1. if in the field "Necessary files" required files are odex-files (type DEX), then they must be placed in a folder "In", but not apk
2. try to put the program in the root of drive C, for example in the folder c:\PUMa
Click to expand...
Click to collapse
See this!
alberto888zz said:
See this!
Click to expand...
Click to collapse
i see this is strange
After running PUMa in folder OUT is a file Mms.apk? If not - can try handly copy this file from IN to OUT and press Apply
Tried on i9100G, shows installed etc, but when i try the sms to more than 10 persons it dsnt work. Even the call end immediately and noise reduction on by default dsnt work
manishdev said:
Tried on i9100G, shows installed etc, but when i try the sms to more than 10 persons it dsnt work. Even the call end immediately and noise reduction on by default dsnt work
Click to expand...
Click to collapse
all can be .. on I9100G program has not been tested. Tell us what you have firmware and if I have it I'll try to see applets mms and phone
ps.. i see mms & phone applet (only on old fw DZKJ2) - patches "call end immediately", "noise reduction on by default" should work. Under question - "disable control of number sending". In next version i try it's patch rewrite
Great job, working perfect for I9100 XWKK5 with russian contacts rule, cancel delay rings and stop converting SMS to MMS. Was installed by one zip file via CWM. Are donated ($100 - Confirmation number: 2SC26619W1027282U).
Thanks a lot.
Hi
How can I modify Home.apk?
I unzipped the file but it seems that all xml files are encoded !
Can I use home.apk of Sony PRS T1 for Nook Simple Touch ?
I extracted all files using apktools
Now all xml files are readable
Is there any reference on what each xml file means ? I want to edit /Layout files
Make sure that you do a full backup.
Home.apk is a system app and uses a shared Id.
If you start to modify too much stuff the system may refuse to acknowledge it.
Apktool is the right tool for unzipping and making xml visible/editable.
It does delete all the META-INF.
You need to put the original stuff back in.
Use an unzip to get META-INF and after you use apktool put it back with unzip/zip.
I haven't looked at res/layout but if you understand the layout system well enough to modify it the intent of each file should be obvious.
Be careful modifying the xml files. Messing up something will prevent it from loading at runtime.
My modification to Home.apk was to delete it.
Renate NST said:
Make sure that you do a full backup.
Home.apk is a system app and uses a shared Id.
If you start to modify too much stuff the system may refuse to acknowledge it.
Apktool is the right tool for unzipping and making xml visible/editable.
It does delete all the META-INF.
You need to put the original stuff back in.
Use an unzip to get META-INF and after you use apktool put it back with unzip/zip.
I haven't looked at res/layout but if you understand the layout system well enough to modify it the intent of each file should be obvious.
Be careful modifying the xml files. Messing up something will prevent it from loading at runtime.
My modification to Home.apk was to delete it.
Click to expand...
Click to collapse
Thanks a lot ...
It's weird ... but can I install the Home Screen of Sony PRS T1 to Took Touck ?
I want to try but witch files should I replace ? just Home.apk ?
Thanks
There is a ton of interaction going on between the various B&N apps.
The Sony app will not have the integration so a lot of stuff will be broken.
Just to give you an idea of the scale of the interaction:
http://forum.xda-developers.com/showpost.php?p=24061856&postcount=11
Renate NST said:
There is a ton of interaction going on between the various B&N apps.
The Sony app will not have the integration so a lot of stuff will be broken.
Just to give you an idea of the scale of the interaction:
http://forum.xda-developers.com/showpost.php?p=24061856&postcount=11
Click to expand...
Click to collapse
Renate,
Wow!
I missed that post.
How did you build that diagram?
ApokrifX said:
How did you build that diagram?
Click to expand...
Click to collapse
Lol! I had to look, I had forgotten already!
I wrote a program that analyzes AndroidManifest.xml in APKs.
It generates either an SVG or a DXF.
I usually turn the SVG into a PNG.
Code:
pkgtodxf /v /w3145 /h1355 /s45 /m20 scheme.svg E:\Home 11 0 E:\Library 11 "-21.4" E:\Reader 35 0 E:\Shop 59 0
Renate NST said:
Lol! I had to look, I had forgotten already!
I wrote a program that analyzes AndroidManifest.xml in APKs.
It generates either an SVG or a DXF.
I usually turn the SVG into a PNG.
Code:
pkgtodxf /v /w3145 /h1355 /s45 /m20 scheme.svg E:\Home 11 0 E:\Library 11 "-21.4" E:\Reader 35 0 E:\Shop 59 0
Click to expand...
Click to collapse
Right. No need to ask.
You answer is the same always: "I wrote a program that..."
It's gotta be a way to do it in MS Visio - I've never tried.
I not clear how to describe dependencies so it can swallow them.
It supposed to be able to "consume" C# or Java code directly, tho.
ApokrifX said:
No need to ask.
Click to expand...
Click to collapse
Aw, I don't mean to be obtuse.
The information displayed is pretty much just a clean printout of each AndroidManifest.xml
There is no correlation done between different APKs.
It's just that it prints out neater than the regular XML.
Moreover it doesn't document the BroadcastReceivers that are registered programatically.
For instance, in Reader.apk these are registered programatically and aren't mentioned in AndroidManifest.xml:
com.BN.intent.action.UMS_ABOUT_TO_START
com.bn.intent.extra.getreadposition.value
com.BN.intent.action.SCREEN_LIGHTS_OFF (in glow Nook)
Hi Folks,
Overview
There is a mechanism in Android to override the resources and resource-id values within the framework-res.apk with "Vendor" Specified values. All of this is done transparently at runtime and leaves the original framework-res.apk intact and on the device.
CAUTION - ALWAYS HAVE A BACKUP HANDY. NORMAL OPERATION SHOULD BE FINE BUT WHILE PLAYING AROUND AND SEEING WHAT WAS POSSIBLE THE DEVICE DID CLEAR THE ACCOUNTS DATABASE A COUPLE OF TIMES
Background
While doing some research into how the resources.arsc file are handled internally on Android I came across a Document in the AOSP sources ( frameworks/native/libs/utils/README )
Along with a general overview of resource management, it contained a couple of interesting sections.
The resource overlay extension
------------------------------
The resource overlay mechanism aims to (partly) shadow and extend
existing resources with new values for defined and new configurations.
Technically, this is achieved by adding resource-only packages (called
overlay packages) to existing resource namespaces
...
The use of overlay resources is completely transparent to
applications; no additional resource identifiers are introduced, only
configuration/value pairs. Any number of overlay packages may be loaded
at a time; overlay packages are agnostic to what they target -- both
system and application resources are fair game.
The package targeted by an overlay package is called the target or
original package.
Resource overlay operates on symbolic resources names. Hence, to
override the string/str1 resources in a package, the overlay package
would include a resource also named string/str1. The end user does not
have to worry about the numeric resources IDs assigned by aapt, as this
is resolved automatically by the system.
As of this writing, the use of resource overlay has not been fully
explored. Until it has, only OEMs are trusted to use resource overlay.
For this reason, overlay packages must reside in /system/overlay.
Click to expand...
Click to collapse
What this essentially means is you can create a resource only apk which you place at /vendor/overlay/framework/framework-res.apk.
This file only needs to contain the resources you want to override, the document goes on to explain how the idmap is created in the resources-cache
Note the path is different from the readme file which suggests using /system/overlay, this is not referenced by the source and will do nothing.
Resource ID mapping
~~~~~~~~~~~~~~~~~~~
Resource identifiers must be coherent within the same namespace (i.e
PackageGroup in ResourceTypes.cpp). Calling applications will refer to
resources using the IDs defined in the original package, but there is no
guarantee aapt has assigned the same ID to the corresponding resource in
an overlay package. To translate between the two, a resource ID mapping
{original ID -> overlay ID} is created during package installation
(PackageManagerService.java) and used during resource lookup. The
mapping is stored in /data/resource-cache, with a @idmap file name
suffix.
The idmap file format is documented in a separate section, below.
Creating overlay packages
-------------------------
Overlay packages should contain no code, define (some) resources with
the same type and name as in the original package, and be compiled with
the -o flag passed to aapt.
The aapt -o flag instructs aapt to create an overlay package.
Technically, this means the package will be assigned package id 0x00.
There are no restrictions on overlay packages names, though the naming
convention <original.package.name>.overlay.<name> is recommended.
Example overlay package
~~~~~~~~~~~~~~~~~~~~~~~
To overlay the resource bool/b in package com.foo.bar, to be applied
when the display is in landscape mode, create a new package with
no source code and a single .xml file under res/values-land, with
an entry for bool/b. Compile with aapt -o and place the results in
/system/overlay by adding the following to Android.mk:
LOCAL_AAPT_FLAGS := -o com.foo.bar
LOCAL_MODULE_PATH := $(TARGET_OUT)/overlay
Click to expand...
Click to collapse
All this may sound very familiar to those who have built any AOSP Rom for a device as it is the same concept as the overlay tree which is contained in the device specified directories of the tree. Only this method executes at runtime instead of compile time. There are other differences. Mainly the runtime version only handles the drawables and resources which are included in the resources.arsc of framework-res ( at the moment ) where as the device overlay will handle any file you throw at it. You cannot unfortunately update compressed resources ( i.e the ones in the xml, raw, menu etc ).
The AOSP Tree also contained a test directory for this functionality . /frameworks/base/core/tests/overlaytests and contain an example implementation in the OverlayTestOverlay directory and a runtests.sh shell scripts which highlights that symlinking packages with custom names to framework-res is valid.
Summary
I think this will help modders out and has benefits over the currently widely used method of pulling a devices full framework-res and using apktool to unpack, making the changes and then repacking and resigning ( or using 7z replace, if you're lazy like me ) It will also help with applying/merging multiple mods from different sources as the files only need the include the very basic of the patch.
I don't know how long this functionality has existed but I have never seen it used by any oem and a search of Xda Didn't seem to show any "prior art" of the behaviour. I'd be interested on people thoughts on this, especially if you have seen a rom in the wild that uses it. It's maybe something that could be extended by "us" if google don't have any major plans for it possibly applied to other apks.
KNOWN ISSUES AND WORKAROUNDS
There is a bug in the /frameworks/base/libs/androidfw/AssetManager.cpp. It appears that a umask is set incorrectly when creating the idmap file from the overlay package, as such only the system user had access to it resulting in a failure to apply the overlayed values.
I chmod'd 666 /data/resource-cache/* and reboot to fix this. You can find further details in this google groups post. There is a patch attached the Post which I don't think will apply correctly as the source tree has been Refactored since the patch was created.
See below a workaround
Well this is fascinating. I am going to read the files this afternoon .
That is quite a cool find. Thanks for the tip.
Trevd, I gotta try this. I finally had time to read it carefully. I am going to make a simple one tomorrow. Have you had time to give it a whirl?
Oh, the Google groups link is wrong, I think. It only took me to the Google groups home page.
mateorod said:
Trevd, I gotta try this. I finally had time to read it carefully. I am going to make a simple one tomorrow. Have you had time to give it a whirl?
Oh, the Google groups link is wrong, I think. It only took me to the Google groups home page.
Click to expand...
Click to collapse
Fixed That google link for you, I'll attach some examples and try and put together some more resources on this. I'm going to test it on a couple of different devices. I can however confirm that the functionality is in the ICS code tree and I'm give it a test on CM9 on my HTC Sensations to make sure it functions as expected
Hello Again.
I've done something further research into "weaponizing" this mod so it can be used in anger. The Incorrect Permission Issue highlighted in the first post is pretty much a show-stopper if you want to use this in a flashable zip update for example.
Problem: The idmap is successfully created but cannot be used as the file the world readable file permission is not set.
Solution 1: Patch the AssetManager to create the file with the correct permissions.
This would work but results in the extra overhead of changing core android libraries and would more than likely break Stock OTA Updates because the file hashes won't match.
Solution 1a: Patch the AssetManager to create the file with the correct permissions, Submit the patch to the AOSP project so it is upstream for future releases.
The Patch in the google groups post does not seem to have been submitted as the issue is still there in the latest master branch ( 4.2.1 ) of the AOSP Project. I held off submitting it myself because it is basically someone else's work, However if no-one else is going to do it I suppose someone should . Obviously this solution is still dependent on google actually accepting the patch, carriers including it future roms and numerous other unknown factors which are out of your direct control.
Solution 2: Add a empty idmap in /data/resource-cache folder with the correct permission at the same time as adding the custom overlay.
Although a work around this does solve the issue. This is not as simple as just creating a placeholder zero byte file. The asset manager will reject the file when checking for stale cache files at startup. We need to actually create an empty idmap. Referring back to the original readme file (/frameworks/native/libs/utils/README), google explain the idmap file format
The ID map (idmap) file format
------------------------------
The idmap format is designed for lookup performance. However, leading
and trailing undefined overlay values are discarded to reduce the memory
footprint.
idmap grammar
~~~~~~~~~~~~~
All atoms (names in square brackets) are uint32_t integers. The
idmap-magic constant spells "idmp" in ASCII. Offsets are given relative
to the data_header, not to the beginning of the file.
map := header data
header := idmap-magic <crc32-original-pkg> <crc32-overlay-pkg>
idmap-magic := <0x706d6469>
data := data_header type_block+
data_header := <m> header_block{m}
header_block := <0> | <type_block_offset>
type_block := <n> <id_offset> entry{n}
entry := <resource_id_in_target_package>
Click to expand...
Click to collapse
They also go on to give an example.
idmap example
~~~~~~~~~~~~~
Given a pair of target and overlay packages with CRC sums 0x216a8fe2
and 0x6b9beaec, each defining the following resources
....
the corresponding resource map is
0x706d6469 0x216a8fe2 0x6b9beaec 0x00000003 \
0x00000004 0x00000000 0x00000009 0x00000003 \
0x00000001 0x7f010000 0x00000000 0x7f010001 \
0x00000001 0x00000000 0x7f020000
or, formatted differently
0x706d6469 # magic: all idmap files begin with this constant
0x216a8fe2 # CRC32 of the resources.arsc file in the original package
0x6b9beaec # CRC32 of the resources.arsc file in the overlay package
0x00000003 # header; three types (string, bool, integer) in the target package
0x00000004 # header_block for type 0 (string) is located at offset 4
0x00000000 # no bool type exists in overlay package -> no header_block
0x00000009 # header_block for type 2 (integer) is located at offset 9
Click to expand...
Click to collapse
Further analysis of the asset manager code suggests that although aapt won't create an empty overlay apk it is possible create an idmap file which just contains the file magic along with the original and overlay resources.arsc CRC32 which can be set at zero. Assuming little endian byte ording, these are those magic twelve bytes you need in the /data/resource-cache/[email protected]@[email protected]@idmap
Code:
69 64 6d 70 00 00 00 00 00 00 00 00
The file value will then be updated rather than created when a new overlay apk is provided.
[ EXAMPLES TO FOLLOW ]
So I don't know if anyone has done any follow-up with this, but we have a situation with the Xperia V (and T, more or less the same device in many respects) that makes it impossible to flash or push a modified framework-res.apk. Specifically, the resource-id's inside resources.arsc (public.xml) are getting mangled during recompile and while apktool doesn't show any errors (this is a known, reported issue), the apk is unusable and causes bootloops.
What you've presented here seems like a light at the end of the tunnel. But while I'm confident in my ability to follow directions, I'm afraid I'm too much of a noob to foresee possible reasons for this not working, which is basically what I'm requesting feedback on. Here's what I have in mind, please feel free to point out the holes in my plan...
1. Create the overlay, with the config.xml containing the proper resource-id's as found in public-xml.
2. Push the overlay. It seems to me that with an unmodified framework-res.apk in place, the overlay will simply replace the values from resources.arsc with identical values, thereby having no effect on the system. Any problems at this stage, then, would be from errors on my part, and naturally I would rather weed them out before the next step...
3. Push a modded framework-res.apk and hope that with the overlay in place and doing its business, the corrupted resource-id's will be quarantined and unable to wreak havoc on the system.
It sounds easy, so I'm sure I've missed something. I appreciate any feedback, scathing or otherwise.
shockwaverider said:
So I don't know if anyone has done any follow-up with this, but we have a situation with the Xperia V (and T, more or less the same device in many respects) that makes it impossible to flash or push a modified framework-res.apk. Specifically, the resource-id's inside resources.arsc (public.xml) are getting mangled during recompile and while apktool doesn't show any errors (this is a known, reported issue), the apk is unusable and causes bootloops.
What you've presented here seems like a light at the end of the tunnel. But while I'm confident in my ability to follow directions, I'm afraid I'm too much of a noob to foresee possible reasons for this not working, which is basically what I'm requesting feedback on. Here's what I have in mind, please feel free to point out the holes in my plan...
1. Create the overlay, with the config.xml containing the proper resource-id's as found in public-xml.
2. Push the overlay. It seems to me that with an unmodified framework-res.apk in place, the overlay will simply replace the values from resources.arsc with identical values, thereby having no effect on the system. Any problems at this stage, then, would be from errors on my part, and naturally I would rather weed them out before the next step...
3. Push a modded framework-res.apk and hope that with the overlay in place and doing its business, the corrupted resource-id's will be quarantined and unable to wreak havoc on the system.
It sounds easy, so I'm sure I've missed something. I appreciate any feedback, scathing or otherwise.
Click to expand...
Click to collapse
Hi There.
It's sound's plausible. I will say that I was attempting to implement this "trick" on a Samsung Galaxy Note 10.1 which had a TouchWiz Rom installed without any luck. In that case it wasn't retaining the correct permissions for the resource-cache directory. I didn't go as far as patching the init binary... yet!!! I think that will probably sort it out with if you have control of the device so there is still hope on that one.
I've also not tested it with anything other than settings found in the config.xml I suppose if it gets compiled into the resources.arsc it should be alright.
Have you tried recompiling the using aapt instead? I'm afraid I'm no expert on aapt and it's many switches so I'm afraid you're are on your own as far a making the apk goes if you are trying this outside of the AOSP source tree!
Good Luck
trevd said:
Hi There.
It's sound's plausible. I will say that I was attempting to implement this "trick" on a Samsung Galaxy Note 10.1 which had a TouchWiz Rom installed without any luck. In that case it wasn't retaining the correct permissions for the resource-cache directory. I didn't go as far as patching the init binary... yet!!! I think that will probably sort it out with if you have control of the device so there is still hope on that one.
I've also not tested it with anything other than settings found in the config.xml I suppose if it gets compiled into the resources.arsc it should be alright.
Have you tried recompiling the using aapt instead? I'm afraid I'm no expert on aapt and it's many switches so I'm afraid you're are on your own as far a making the apk goes if you are trying this outside of the AOSP source tree!
Good Luck
Click to expand...
Click to collapse
Thanks for the input! I haven't tried compiling using aapt, I'm afraid that I'm working way beyond my abilities here due to a mix of frustration and determination. I ended up here after somebody pointed to barrykr's thread HERE, so I suppose the first thing to do is try out his method and see what comes of it. If it's not successful, then I'll try to sort through all the big words and smart-people talk and figure out how to get it to work.
Hey mate... just noticed this thread of yours. This is awesome... I wonder why it didn't draw more attention.
Anyway... you've probably seen my mods thread over at Rootzwiki, right? I was wondering if this "overlay" thing would actually work for SystemUI too?
shockwaverider said:
So I don't know if anyone has done any follow-up with this, but we have a situation with the Xperia V (and T, more or less the same device in many respects) that makes it impossible to flash or push a modified framework-res.apk. Specifically, the resource-id's inside resources.arsc (public.xml) are getting mangled during recompile and while apktool doesn't show any errors (this is a known, reported issue), the apk is unusable and causes bootloops.
[...]
Click to expand...
Click to collapse
Hi there! Just wanted to let you know that I have successfully made an overlay.apk which overrides the framework-res.apk default 'settings'. I have a Xperia S with the same problem with framework-res.apk. For my example I used the showNavigationBar boolean value and edited it, and the navigation bar showed after boot :victory: :victory:
@trevd I have not time to test this now, but do you know if it is possible to make an overlay.apk, only with images instead of the resource file? Thanks, I'm quite exited now
edit. Yes it is possible with images. ****. I'm in heaven right now. Everything will be soooo much easier.
skifyr123 said:
Hi there! Just wanted to let you know that I have successfully made an overlay.apk which overrides the framework-res.apk default 'settings'. I have a Xperia S with the same problem with framework-res.apk. For my example I used the showNavigationBar boolean value and edited it, and the navigation bar showed after boot :victory: :victory:
@trevd I have not time to test this now, but do you know if it is possible to make an overlay.apk, only with images instead of the resource file? Thanks, I'm quite exited now
Click to expand...
Click to collapse
@skifyr123 That's a pleasant surprise, I was under the belief that it had stopped working... maybe I was doing my own mod wrong ..
The example in the aosp includes images. http://androidxref.com/4.2_r1/xref/...ytests/OverlayTestOverlay/res/drawable-nodpi/ . I don't know whether you can exclude resources, however that shouldn't be an issue as you can "override" a resource that doesn't exist so won't effect anything. I suspect you probably can excluded them...... as we say in the trade "Try it yourself"
@Kookie_Monster : No , I'm fairly certain that it won't the code only handles framework-res... however there a comment in the code that is quite interesting http://androidxref.com/4.2_r1/xref/frameworks/base/libs/androidfw/AssetManager.cpp#198 Line 198. "apps are handled by the Java Package Manager", I'll have to look deeper into that one
Images worked Do you know if this is any different from Xposed engine (http://forum.xda-developers.com/showthread.php?t=1574401).. At least in this you don't have to install anything extra.
skifyr123 said:
Images worked Do you know if this is any different from Xposed engine (http://forum.xda-developers.com/showthread.php?t=1574401).. At least in this you don't have to install anything extra.
Click to expand...
Click to collapse
Hi
I keep hearing things about the Xposed engine, It's looks a very cool project although not something I'd ever use.
Yes this is completely different It's part of Android core platform source code and is implemented by the asset manager http://androidxref.com/4.2_r1/xref/frameworks/base/libs/androidfw/AssetManager.cpp I believe it's been in there since day 1 ( or close enough ). The main difference is Xposed will let you code where as this is limit to certain types of resources.
I'm GUESSING that this was the original method for vendor overlays but possibly not picked up by HTC ( and others ) in Android's early days so the Idea was abandoned, the way the README in the AOSP reads it was fully intended to extend much more than the framework-res. With all that in mind I also wouldn't be surprised if it suddenly disappeared one day because there's no oem's ( that I know of ) using it
skifyr123 said:
Hi there! Just wanted to let you know that I have successfully made an overlay.apk which overrides the framework-res.apk default 'settings'. I have a Xperia S with the same problem with framework-res.apk. For my example I used the showNavigationBar boolean value and edited it, and the navigation bar showed after boot :victory: :victory:
@trevd I have not time to test this now, but do you know if it is possible to make an overlay.apk, only with images instead of the resource file? Thanks, I'm quite exited now
edit. Yes it is possible with images. ****. I'm in heaven right now. Everything will be soooo much easier.
Click to expand...
Click to collapse
You, sir, are my hero!! :good: :good: :good:
Thank You.
trevd said:
Hi Folks,
Overview
There is a mechanism in Android to override the resources and resource-id values within the framework-res.apk with "Vendor" Specified values. All of this is done transparently at runtime and leaves the original framework-res.apk intact and on the device.
CAUTION - ALWAYS HAVE A BACKUP HANDY. NORMAL OPERATION SHOULD BE FINE BUT WHILE PLAYING AROUND AND SEEING WHAT WAS POSSIBLE THE DEVICE DID CLEAR THE ACCOUNTS DATABASE A COUPLE OF TIMES
Background
While doing some research into how the resources.arsc file are handled internally on Android I came across a Document in the AOSP sources ( frameworks/native/libs/utils/README )
Along with a general overview of resource management, it contained a couple of interesting sections.
What this essentially means is you can create a resource only apk which you place at /vendor/overlay/framework/framework-res.apk.
This file only needs to contain the resources you want to override, the document goes on to explain how the idmap is created in the resources-cache
Note the path is different from the readme file which suggests using /system/overlay, this is not referenced by the source and will do nothing.
All this may sound very familiar to those who have built any AOSP Rom for a device as it is the same concept as the overlay tree which is contained in the device specified directories of the tree. Only this method executes at runtime instead of compile time. There are other differences. Mainly the runtime version only handles the drawables and resources which are included in the resources.arsc of framework-res ( at the moment ) where as the device overlay will handle any file you throw at it. You cannot unfortunately update compressed resources ( i.e the ones in the xml, raw, menu etc ).
The AOSP Tree also contained a test directory for this functionality . /frameworks/base/core/tests/overlaytests and contain an example implementation in the OverlayTestOverlay directory and a runtests.sh shell scripts which highlights that symlinking packages with custom names to framework-res is valid.
Summary
I think this will help modders out and has benefits over the currently widely used method of pulling a devices full framework-res and using apktool to unpack, making the changes and then repacking and resigning ( or using 7z replace, if you're lazy like me ) It will also help with applying/merging multiple mods from different sources as the files only need the include the very basic of the patch.
I don't know how long this functionality has existed but I have never seen it used by any oem and a search of Xda Didn't seem to show any "prior art" of the behaviour. I'd be interested on people thoughts on this, especially if you have seen a rom in the wild that uses it. It's maybe something that could be extended by "us" if google don't have any major plans for it possibly applied to other apks.
KNOWN ISSUES AND WORKAROUNDS
There is a bug in the /frameworks/base/libs/androidfw/AssetManager.cpp. It appears that a umask is set incorrectly when creating the idmap file from the overlay package, as such only the system user had access to it resulting in a failure to apply the overlayed values.
I chmod'd 666 /data/resource-cache/* and reboot to fix this. You can find further details in this google groups post. There is a patch attached the Post which I don't think will apply correctly as the source tree has been Refactored since the patch was created.
See below a workaround
Click to expand...
Click to collapse
is't possible to use vendor overlay to add/ change a value in build.prop file ?
Can someone solve this? I tried to make an overlays to my rom by placing the overlays to /system/vendor/overlays. It works. But when I try to changing to other themes, my overlays gone, I tried to reapply stock theme but didn't worked. Must I try another folder like /system/overlays?
Always make a backup before changing / on your device!
Q. What is this?
A. A way to change your region. More manufacturers in QRemote, Russian/Greek/etc T9 in dialer, working 4G, no wifi frequency restrictions and more.
Q. Will it get me OTA's of the region i changed to?
A. No.
Q. Is there any easier method, one that does not require root, perhaps?
A. I don't know one.
Boring technical details:
Latest firmwares do not "belong" to region. Instead, they adapt to phone's own region. The check is done at each boot, settings are applied after build.prop.
The detection uses combination of operator code and country code (2 bytes, numbering convention unknown. In LG's documents it's referred to as "BUYER").
LG determines phone's region by looking into the "misc" partition, at addresses 0000A000-0000A020.
Information at them looks like this:
Code:
"1","FFF,FFF,FFFFFFFF,FFFFFFFF,12"
, where "12" is country code.
We can change it ourselves by using hex editor on a dumped image.
The regional parameters reside in /cust/ folder. The file "/cust/cust_path_mapping.cfg" maps "{operator_code},{country_code}" to a folder where it's parameters reside.
Note: some countries (FRA, for example) or some operators don't have their own folder in /cust/. They use 11 (OPEN_EU) as NT code, and identify themselves based on some other info I've yet to find.
Example of cust_path_mapping.cfg content:
Code:
20810,FF=/cust/VDF_COM/FR
20810,01=/cust/VDF_COM/LPM
Explanation: Vodafone in any country but 01 will use "/cust/VDF_COM/FR", while Vodafone in "01" country will use "/cust/VDF_COM/LPM". Notice theirs relative positions. This means that only the most exact match is used, and creating "FFFFFF,FF=/cust/XDA" key won't point the phone towards XDA folder.
By changing this file - or changing the contents of the folder your "operator,country" combo is pointing to - you can change your phone's region to anything you want.
There is also a "/cust/cust.prop" file. It contains fallback to defaults, if phone was unable to determine needed folder, or it didn't exist, it uses "/cust/SUPERSET/".
! In 5.0 firmwares, annoying message stating that "current version not avaliable for user" shows up if the above happens.
The folders in /cust/ hold operator/country settings. LG named them this way: "OPERATOR_COUNTRY". There are 2 special values - OPEN for operator - which means any operator, COM for country - which means any country.
OPEN_XXX hold parameters for specific country. These folders may contain subfolders with parameters for smaller operators which operate only inside this country.
Example: OPEN_ZA, which contains folders for MTN and VDC operators.
XXX_COM contain parameters for specific operator. These folders may contain subfolders with parameters for specific countries.
Example: /VDF_COM is intended for Vodafone. It contains folders FR and LPM, which are intended for France and LPM (?).
{OPERATOR_COUNTRY} folders are intended for 1 combination of operator and country, they should not contain subfolders with settings for other operators/countries.
Example: PCL_IL, contains settings for one of Israel operators.
The method itself:
1) Install Busybox.
1) Look at /cust/cust_path_mapping.cfg and choose some region's code. The folder names are usually self-explanatory, and you can always look into /cust/{folder}/cust.prop to see to what ro.build.target_operator, ro.build.target_country and ro.build.target_region variables are set.
2) Execute the below code, replacing "\x31\x32" in "echo -n '\x31\x32'" with your chosen code. Examples: "\x35\x36" is 56 region, "\x37\x33" is 73 region and so on.
First line backs up your "misc" partition to /sdcard/misc.bin, you should copy this file to safe storage.
Code:
dd if=/dev/block/platform/msm_sdcc.1/by-name/misc of=/sdcard/misc.bin
echo -n '\x31\x32' | /system/xbin/dd of=/dev/block/platform/msm_sdcc.1/by-name/misc bs=1 seek=40991 count=2 conv=notrunc
reboot
Why did i use busybox's dd? Because in LG's 5.0 default dd was compiled without conv option...
Enjoy your new region!
Other methods:
Method 1: substitution.
Step 1: Find out which country your phone was meant to use ("Settings->About Phone-> Software" ). Find your current operator code. Using these, find currently used folder in /cust/. You can get to know folder's region by looking on it's name, or opening the {folder}/cust.prop file and looking at these keys:
Code:
ro.build.target_operator
ro.build.target_country
ro.build.target_region
They are pretty self-explanatory.
Step 2: Replace the folder's content with content from the region you want to change to.
Step 3: Reboot and be happy!
Method 2: via editing "misc" partition.
Be extra careful with "misc". This partition is unique for every phone. If it's damaged or wiped, things may get ugly.
I do not know a way of regenerating "misc", since it contains your bluetooth/wifi mac's and IMEI. AFAIK, It is only used for displaying that info in Android and for LG's updates - so you won't lose bluetooth/wifi/mobile data, but still...
Since it's also used for updates, PC suite and "ota updater" won't be able to update your phone anymore if this partition is damaged.
It may also have uses which we don't know about. Make a backup, save it to several clouds and 2-3 offline storages.
Do not proceed if you don't know what "hex editor", "backup" and "partition dump" are.
1) Grab misc with "dd if=/dev/block/platform/msm_sdcc.1/by-name/misc of=/sdcard/misc.bin".
2) Open misc.bin in any hex editor, go to address "0000A000" and look for this:
Code:
"1","FFF,FFF,FFFFFFFF,FFFFFFFF,12"
Change "12" or whatever number you have there to the one that you need. You can look into cust_path_mapping.cfg to determine it. Save the result to a new file, name it "misc_edited.bin".
3) Replace your misc with edited one: "dd if=/sdcard/misc_edited.bin of=/dev/block/platform/msm_sdcc.1/by-name/misc".
4) Reboot.
I have no idea about how PC suite and others will react to IMEI and country code mismatch. They probably won't care, but we don't know it for sure.
Method 3:
Warning, in 5.0 this will cause the annoying "Current version not avaliable for user!" message to show up at each boot.
1) Backup your rom and /cust/ folder.
2) In /cust/cust_path_mapping.cfg delete all lines except
Code:
999999,99=/cust/SUPERSET
.
3) Copy everything from /cust/{Your_desired_region} to /cust/SUPERSET.
4) Reboot.
Big thanks to my Russian comrades rxu, KestL and Beerukoff for pointing out important details!
Reserved.
Hi, thanks very much for this write up. I'm still a bit confused as to how to actually do this - and I'm thinking others might be as well since there haven't been any responses. Would you mind walking me through how to change the region for a phone purchased in HK? I would like to change it to the EUR region.
Would I open the cust.prop file within the HK folder and change the values for the three variables above to match the ones found in the cust.prop file within the EU folder?
Thanks.
Japultra said:
Hi, thanks very much for this write up. I'm still a bit confused as to how to actually do this - and I'm thinking others might be as well since there haven't been any responses. Would you mind walking me through how to change the region for a phone purchased in HK? I would like to change it to the EUR region.
Would I open the cust.prop file within the HK folder and change the values for the three variables above to match the ones found in the cust.prop file within the EU folder?
Thanks.
Click to expand...
Click to collapse
It would be better to change /cust/cust_path_mapping.cfg file. Open it, find the line "FFFFFF,54=/cust/OPEN_HK", change it to "FFFFFF,54=/cust/OPEN_EU" and reboot.
I'm using a custom based off a version that doesn't have my cust (SEA) so mine reverts to the default. I'm in the uk.
Other than having to delete the ltesettings apk I haven't noticed any problems. Do you think I would notice anything if I change the mapping to point at EU it would improve anything?
Nice write-up, very detailed. This seems very specific, do you know why you would want to do this? A scenario maybe?
YaDr said:
It would be better to change /cust/cust_path_mapping.cfg file. Open it, find the line "FFFFFF,54=/cust/OPEN_HK", change it to "FFFFFF,54=/cust/OPEN_EU" and reboot.
Click to expand...
Click to collapse
Thanks! That worked.
oracleoftruth said:
I'm using a custom based off a version that doesn't have my cust (SEA) so mine reverts to the default. I'm in the uk.
Other than having to delete the ltesettings apk I haven't noticed any problems. Do you think I would notice anything if I change the mapping to point at EU it would improve anything?
Click to expand...
Click to collapse
No, i don't think that you'll notice anything. You'll get more manufacturers in qremote and other very minor features.
sprremix said:
Nice write-up, very detailed. This seems very specific, do you know why you would want to do this? A scenario maybe?
Click to expand...
Click to collapse
Thanks!
Why you may want to change region:
1) QRemote contains a lot more manufacturers if ro.build.target_region is set to ESA. Since /cust/ is applied after build.prop, you'll have to edit it.
For example, in CIS region Western Digital is absent. It is officially sold here in Russia, there is no embargo or whatever. LG just decided that Russians doesn't have the right to control "WD TV live" using QRemote. Nice.
2) Dialer - there are special dialer overlays with letters used in specific regions. For CIS it contains cyrillic letters, for Greece it contains Greek letters, and so on.
3) Featureset.xml also depends on region. It contains miscellaneous settings, like the ability to send empty sms.
4) There are a lot more overlays for other apps. Voicemate, etc. Nothing major, but this can change in future.
P.S. I updated first post with info about misc partition.
Thanks @YaDr
Just changed the V10M Hong kong to EUR-XX.
One question: do i need to manually change/fix all the new files permissions?
robalm said:
Thanks @YaDr
Just changed the V10M Hong kong to EUR-XX.
One question: do i need to manually change/fix all the new files permissions?
Click to expand...
Click to collapse
No, until files have been exposed to non-posix filesystem and lost their permissions, or you've changed them manually.
Default permissions for /cust/ are 755 with root/root as owner/group.
YaDr said:
No, until files have been exposed to non-posix filesystem and lost their permissions, or you've changed them manually.
Default permissions for /cust/ are 755 with root/root as owner/group.
Click to expand...
Click to collapse
Ok.
In /cust/SUPERSET There is already a "cust.prop" file should i replace that one with the cust.prop from my OPEN_XX folder?
Is there a risk to loose/get blocked IMEI in this way we change region?
robalm said:
Ok.
In /cust/SUPERSET There is already a "cust.prop" file should i replace that one with the cust.prop from my OPEN_XX folder?
Is there a risk to loose/get blocked IMEI in this way we change region?
Click to expand...
Click to collapse
Yes, you should replace it.
It is highly unlikely that you will lose IMEI. However, i ask everyone to make a full nandroid backup, efs included, before you do anything to your phone.
As for the blocking... Why would your service provider care enough to blacklist your IMEI? Unless it is forbidden by local laws or service contract, manipulating files on your phone is perfectly legal.
YaDr said:
Yes, you should replace it.
It is highly unlikely that you will lose IMEI. However, i ask everyone to make a full nandroid backup, efs included, before you do anything to your phone.
As for the blocking... Why would your service provider care enough to blacklist your IMEI? Unless it is forbidden by local laws or service contract, manipulating files on your phone is perfectly legal.
Click to expand...
Click to collapse
Thanks bud.
I have a efs backup, but no nandroid backup.
YaDr said:
It would be better to change /cust/cust_path_mapping.cfg file. Open it, find the line "FFFFFF,54=/cust/OPEN_HK", change it to "FFFFFF,54=/cust/OPEN_EU" and reboot.
Click to expand...
Click to collapse
Hi
Need to erase all the rest lines or only change those 2?
Thank you
alexa74 said:
Hi
Need to erase all the rest lines or only change those 2?
Thank you
Click to expand...
Click to collapse
You only need to change 1 line. Nothing has to be deleted.
Did anybody tried if this works on the Korean models (F400S/L/K)?
YaDr said:
You only need to change 1 line. Nothing has to be deleted.
Click to expand...
Click to collapse
Hi
Thanks, it was helpfully,but may be you can help me to change the region to Israel?
alexa74 said:
Hi
Thanks, it was helpfully,but may be you can help me to change the region to Israel?
Click to expand...
Click to collapse
What's your current region?
YaDr said:
What's your current region?
Click to expand...
Click to collapse
Was HKG and now is EU
alexa74 said:
Was HKG and now is EU
Click to expand...
Click to collapse
in /cust/cust_path_mapping.cfg find a line ending with "OPEN_EU", and change folder name from "OPEN_EU" to "PCL_IL" or "ORI_IL". If you don't have these folders, i can zip them and send them to you.