[INFO] Custom framework-res.apk resources.arsc using vendor overlays, - Android Software Development

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?

Related

[Q] IMGDIFF2 patches

I've noticed that some update.zips include patch files. I've done quite a bit of reading up on what these patches are and how they work... I just can't find anywhere to explain how to create them. It would be extremely useful for myself and I'm sure others to make our own patch files (i.e. someapp.apk.p) to, lets say change a few graphics in several apk's in a single zip file. Anyone able to shed some light on this before i start trying to reverse engineer the applypatch code from Google?
Does anyone have any insight?
Sent from my DROIDX using Tapatalk
Do you have an example update.zip file with a patch that I could look at?
Gene Poole said:
Do you have an example update.zip file with a patch that I could look at?
Click to expand...
Click to collapse
Thanks for the reply, here is an update.zip. all of the patches I've looked at start with "IMGDIFF2" and most have some "BSDIFF4##" mixed in there as well.
http://www.megaupload.com/?d=AOFCEKLW
Here is a imgdiff.c file in which the commented section sheds a little light on it. Although i believe that after 2.1 IMGDIFF1 was replaced with IMGDIFF2.
http://www.netmite.com/android/mydroid/2.0/build/tools/applypatch/imgdiff.c
Well, thanks for providing me the info, but looking into it, it looks like this has little value beyond OEM updates and so forth where it can be guaranteed that the ROM is pristine as it seems that this does diffs directly on the flash image itself.
Thanks for taking the time to look into it for me. theoretically however, couldn't you use this for individual apk's? It appears that the directory structure in the zip would allow you to patch anything. The reason i am looking into this is to change an icon in a group of apk's and then just flash a small update.zip of patches. I know that there may be other ways of doing this but I'd like to try if for no other reason to prove to myself it can be done.
Sorry if I'm incorrect in this, just trying to learn.
My take on reading the referenced file is that this patches a raw disk image. This would only work if the image is pristine (not been added to or changed in anyway). The first paragraph reads:
/*
* This program constructs binary patches for images -- such as boot.img
* and recovery.img -- that consist primarily of large chunks of gzipped
* data interspersed with uncompressed data. [...]
I don't see anyway to patch individual files in this way, and especially in an image such as the data partition that will be completely different on users' devices.
I took that from it as well. However if that was the case the update.zip would only have one patch file for the entire image and not a separate patch file for each apk / script / img / file that is being patched, which it does. It runs the applypatch command for each file being patched.
Gene Poole said:
I don't see anyway to patch individual files in this way, and especially in an image such as the data partition that will be completely different on users' devices.
Click to expand...
Click to collapse
This method that they used in the update.zip could only update individual files because running this update only updated certain apps and no user data was lost. I realize that they could have just updated the image that /system is on. Could it be a possibility that they would break the image up on the phone patch only the files necessary then rebuild the image?

[GUIDE]How to make a custom rom?Custom ROMs explained[UPDATE:20-3-2012]

Hey Guys,
I am going to explain some of the files in a custom rom,the small and easy to mod files because the aim is to educate newbies and NOT advanced devs.
Ok,So,I have seen a lot of questions being asked nowadays about making custom roms.This guide is NOT about building a custom rom but about editing and modding it.I am doing this guide taking CM7 as base,not stock,so there might be differences between the roms you choose to mod.Also,I am prone to mistakes here and there.If i made any,please comment about it and i will remove it.Also,please feel free to give your suggestions about making this guide better
What you would need:
Notepad++
WinRar or any other zip/rar manager like 7zip or WinZip
If you want go advanced,you would also need these things
Cygwin
Smali/Baksmali
APK Multi tool or anything like that,i dont care
And most importantly,a brain and eyes(So,Dont ask me stupid questions like,how de fuk du i xtarct? and then in brackets,sorry for my english)
GUIDE:
So,first up,download a rom of your choice(Dont forget to get the permissions for modding from the developer) and extract it.When you extract it,you will see 2 folders and 1 file,it varies.It depends on the contents of the rom.
The folders are:
1.META-INF
2.system
The file:
1.boot.img
So,
Open up system and the first folder you are going to see is 'apps'.
As you already see,this is the place where all the apps go,for the history.You might also see some .odex files below the apps.So,if you remove an app,you should delete the odex file too.If you want to add an app,just drag and drop Take care not to delete each and every app you find,because each of them has their own functions.Also,if you delete contact.apk and replace it with a better dialer like Exdialer,you wont be able to add or delete contacts.So,there are some files better left alone.
If you want to know how to merge them,then use google,there are a lot of tutorials on deodexing.If you want to edit an app,then use APK multi tool,again please use google,lots of tuts on this one too.
Also,you will find an app here and its a main one,systemui.apk By editing systemui.apk,you can get transparent status bars,transparent notification bars,centre the clock.Things like that.The idea with which you edit Systemui.apk and framework-res.apk,thats how your rom is going to look like.These files handle the visual things and they are awesome too.For some systemui mods,refer HERE
Now,some apk files are lib-dependent,meaning,they need certain lib files to work,a few examples are,Swype keyboard,now,swype wouldnt work if this lib file is not included in the rom,libswypecore.so,so if you remove swype,remove this lib file also,because its just a wastage of space and it doesnt do anything.Another example is DSP Manager in Froyo,in GB,it works native,no need to add any applications,but in Froyo,if you add DSP Manager,there are a few lib files that you should add to get them to work.
Next,the 'bin' folder,this guide is aimed at the noobs,so nothing about this,this is a bit advanced stuff,so sorry.
Next up,the 'etc' folder.There are a lot of things that go here.I wont be going to full details for the moment because i am having exams,so no time.However,i will be explaining the easy to explain files.
One thing you will notice is the 'init.d' folder.If you want to add any script like LagFree v2,just put the files of the init.d folder in the script's folder here,nothing else.You dont need to copy any other files like META-INF.
Another file,is CHANGELOG-CM,just as the name suggests its a file giving you changelogs
Another file is NOTICE.html..Its just a file showing copyrights and all that stuff.You wouldnt need to edit that,would you?
Will add more about the other files soon
Next,the 'fonts' folder..You guys need an explanation for that??
Next,'framework' folder.Here you will find framework-res.apk(Obviously,duh...).I wont tell about any other file because this is aimed at new users,not advanced guys.Framework-res is where all the icons in notification bar are.The battery icons,they are all in framework.Also,lockscreen icons
go here..Most of the icons.If i have to start on anything.It would take me weeks,theres so much to write about framework.Also take care not to mess up the framework.Because its like the skeleton(thats what i know ) of a rom.If a framework is incorrectly configured,the rom wont boot.So,keep that in your mind always when you edit framework.
Next,the 'libs' folder,This guide is aimed at newbies,so not touching this part.
And comes 'media'..Most probably you will find 2-3 folders here.Audio,bootanimation.zip and wallpapers.
If you want to change the default,its in build.prop,not here,i will explain that later.If you need to add some audio,its just drag and drop,nothing much,just put them in the right folders,like alarms,ringtones and notifications
If you need to add wallpapers,reszie the pictures to 640x480,thats the resolution that works for ace.Also resize it to 107x80 and save it as another pic with a _small at the end.For eg,the default file is defaultwallpaper.jpg,you make another pic with 107x80 called defaultwallper_small.jpg.
Then,theres the bootanimation.zip..However way you change this thing.Always name it bootanimation.If you want to know how to make a boot animation,then refer freeyourandroid.com
Next up is 'tts' folder..Sorry but i dont know much about this folder.I think this folder contains the languages for the tts app but i am not sure about it.Same goes for 'usr' and 'wifi' folders.But since this thread is aimed at newbies,i dont think there wouldnt a point in writing them up anyway
Next up is build.prop file.Open it with notepad++...build.prop file is pretty self explanatory.
Here you can change the most basic things like the android version that setting shows..Wondered how people are making 2.3.4 look like 4.0.3 in settings??Its build.prop.Also,you can change what 'About phone' shows here.
Other things,you can change things like,how long your wifi scans,how much battery your phone saves while in sleep,Dalvik VM heapsize and default ringtones.If you are wondering what # stands for,it signifies that,that particular tweak is not running,so you can take out the # if its a tweak you like.You could also use it say things like,Additional build properties.You could make it #AdditionalBuildProperties and go to the next line and give your tweaks there.Some build.prop tweaks can be found in slaid480's thread in Galaxy Ace S5830 titled "[MOD]Build.prop tweaks for SGA" or you can go to freeyourandroid.com and find some tweaks there,however the tweaks listed there are universal,so practise caution when playing with build.prop
Now to boot.img..Theres an awesome guide about this in freeyourandroid.com Please have a look at it,because there are lots to write about this one.This is where Cygwin comes in,for instructions on unpacking and repacking and commands and info about boot.img,referHERE and HERE.My summarized version,boot.img is where you can replace kernels.This is where you can make those low-level changes
Then,to META-INF folder.You would find lots of folders here but the file that you would edit consistently is update script.Find it and open it with Notepad++..Unless you edited xbin and bin files,this is not hard to do..Just change around ui_print to what you like.Dont touch anything else if you dont know what you are doing.If you DID edit xbin or bin files,you would need to touch advanced things like symlink tagged ones(I had to give them some sort of a tag)
Updater-Script References and notes:
Now,the updater-script is not something that you should mess around with,a single line of error in the script could get you in trouble.You might also have heard these words,Amend and Edify and wondered what they are,well Edify is the language with which Updater-script is written,while Amend is the language with which Update-Script is written.Now,As far as i know,Ace does NOT support Update script,it just supports Updater-script,so if you are working with kitchen,dont forget to swap the files in META-INF with the the updater-script provided by ketut.kumajaya in Blackhawk thread.So,you should learn to study updater-script of roms and patches before you mess around with them,especially patches here...Now,for example,I made a GPS patch that replaces hw folder in CyanogenMod with my patch.Now,i tell the updater script to delete the hw folder in lib and make another one and put my files in there,you,a normal user will flash it and it would work,but a rom maker without seeing that i have told the updater script to delete hw folder,adds my lib files to the existing lib files,which causes the rom not to boot.So,study the updater-script of patches and see what they do before you jump in and start doing things your own way and mess things up.I will write down a few updater-script commands here and what they do for your convenience now.Here you guys go with it:
mount-mounts a filesystem
is_mounted-checks if a filesystem is mounted
unmount-Unmounts a filesystem
format-format a filesystem (duh..)
delete-Deletes a single file
delete_recursive-Deletes a folder and all of its contents
show_progress-Display flash progress
package_extract_dir-Extract all the files present in a directory to a specified directory
package_extract_file-Extract single file from directory to specified target
file_getprop-dont know much about this one
symlink-Unlinks any existing symbolic links before creating the new symbolic links.
set_perm-Sets permissions for a file,note you dont write rw-r-r here.Its the numbers,for example,for root access,you write 777(right?),not anything else
set_perm_recursive-Sets permissions for a full directory,for example,if you specified a folder,permissions for the folder and all files in it will be set.
getprop-This function returns the value of the property specified. This is used to query platform information from the build.props file.
write_raw_image-Writes a raw image into a partition
apply_patch-Applies patches to a directory -_- (dont you guys understand it just by reading that? )
apply_patch_check-Checks if a file can be patched or if they have been patched
apply_patch_space-Checks if there is enough space to apply a patch
read_file-Reads contents of a file
sha1check-If only data is specified, then the function returns the sha1_hex string of the data. The optional parameters are used if you want to verify that the file you are checking for is one of a list of hashes. It reutrns the hash it matches, or returns nothing if it doesn't match any of the mentioned hashses.
ui_print-It outputs a message to the users while flashing.So,if you see something like 'This is so awesome',know that its not such a big deal and that its just a line of editing here
run_program-Runs a program
ifelse-This is the if-then construct of the Edify scripting language. The truecondition or falsecondition arguments can be a single edify command or a script block. Script blocks can be formed by enclosing the parameter with parenthesis, and seperating the commands with semicolons
abort-duh..it aborts script execution
assert-If condition evaluates to false, stops script execution, otherwise continues processing.
Thats it,dont worry after seeing all these commands.You wont see them all in most of the roms.Here is a list of commands that you usually see in a updater-script.
ui_print
mount
unmount
delete
delete_recursive
package_extract_directory
symlink
show_progress
set_perm
set_progress
set_perm_recursive
getprop
run_program
assert
Now on making it a flashable zip,archive them to a zip file.Get a signer here: http://forum.xda-developers.com/showpost.php?p=6050996&postcount=2
NOTE:Signing is not necessary
The instructions on using that are given with it.Just rename it back to the name you like after signing it.
Thanks to everyone.Especially,freeyourandroid,XDA and TeamCooper and all members of XDA developers and to me (well,you are the one who does that,remember that button Jk )
Hope this helped you guys..Again,this is a thread aimed at educating the new members,not advanced guys.Sorry if i missed anything or made a mistake..Please give me suggestions on this too.Will add more info to this thread when i have the time[/SIZE]
good guide
Looks good
Very helpful.
Fix those grammatical errors !
*grammar nazi alert*
Herpderp Adreno + Tegra.
gOOD guide overall but you shiould make it more advanced
EmoBoiix3 said:
Fix those grammatical errors !
*grammar nazi alert*
Herpderp Adreno + Tegra.
Click to expand...
Click to collapse
Aah....grammar hitler
slaid480 said:
gOOD guide overall but you shiould make it more advanced
Click to expand...
Click to collapse
Yep..I know that..I will work on it but i dont have much time now
This is a great guide , it'll help me a lot ^_^ thanks.
Great tut dude
Is an update needed??I dont think so because it didnt even stay on the front page for a day
Awesome guid please add some more advanced features and custom rom building guide also if u can. :thumbup:
Sent from my GT-S5830 using Tapatalk
The bad effect will be more and more new custom firmware which is actually just a re-branding
ketut.kumajaya said:
The bad effect will be more and more new custom firmware which is actually just a re-branding
Click to expand...
Click to collapse
What???I dont get you
mor_1228 said:
Awesome guid please add some more advanced features and custom rom building guide also if u can. :thumbup:
Sent from my GT-S5830 using Tapatalk
Click to expand...
Click to collapse
I will add them by tonight or something like that when i have time..Not much time now,stupid exams Oh,i hate them
Originally Posted by ketut.kumajaya
The bad effect will be more and more new custom firmware which is actually just a re-branding
Prawesome said:
What???I dont get you
Click to expand...
Click to collapse
Click to expand...
Click to collapse
i got what he is trying to say.
he is saying that due to rom building guides noobs will also learn how to build custom rom but they may not have that knowledge skills to make a distinguished ROMS they will be building common roms with little or no difference, difference will be only that different people will release rest things will be kind of same only no drastic changes.
hope i am right
mor_1228 said:
i got what he is trying to say.
he is saying that due to rom building guides noobs will also learn how to build custom rom but they may not have that knowledge skills to make a distinguished ROMS they will be building common roms with little or no difference, difference will be only that different people will release rest things will be kind of same only no drastic changes.
hope i am right
Click to expand...
Click to collapse
Maybe..But i am tired of questions on building custom roms..Recently,there were a lot of questions on building custom roms
Yeah.. i'm a newby become smarter... thx for share...
Sent from my GT-S5830 using xda premium
I will add more info about the boot.img and framework-res.apk tonight
Nice work, thank you
If you have time, can you please post a guide on how to sign APK files?
For example, if i want to edit an icon of an app, i change the icon in the .apk but then i have to sign it, how can i do it?
On the net i found lots of guides and programs but none of them worked for me...
Anyway good work

How can I modify Home.apk ?

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)

[Linux][UTILITY][TOOL] APK Multi-Tool

GgI am currently working on a major update to the apk manager application as well and changing the name to APK Multi-Tool with some new added features and also to fix some issues with some code errors.
I am also changing a lot of the features as well since a lot of the code has been outdated for a while.
I have updated all the files and modified Apk manager's Scripts to fix many user reported bugs from Daneshm90 apk manager which he had written a simple script to ease the process of editing apks. Got a lot of downloads so thought its in demand
Whether you're doing basic image editing or editing the smali or xml files, on average u have to use (Brut.all or JF's smali/baksmali) awesome tool to extract the apk, edit it, then sign the apk and then adb push/install it. This process is quite tiresome if you are testing a method that needs fine tweaking.
This script should make the process a LOT smoother.
Theres an option of compiling/signing/installing all in one step
Thanks:
Goes to Daneshm90 the Original Writer of APK Manager
Goes to Brut.all for his awesome tool.
Goes to JF for ofcourse, smali/baksmali
Features:
- Added framework dependent decompiling (For non propietary rom apks). (Option 10). Checks whether the dependee apk u selected is correct.
- Allows multiple projects to be modified, switch to and from.
- Allows to modify system apk's using apktool but ensures maximum compatibility in terms of signature / manifest.xml
- Batch optimize apk (Zipalign,optipng,or both)
- Batch Ogg optimization
- Batch install apk from script (option 19)
- Batch Theme Image Transfer TOOL
- Batch Theme optipng TOOL
- Batch Theme Zipalign APK TOOL
- Compression level selector (monitor status above menu)
- Error detection. Checks if error occurred anytime u perform a task, and reports it
- Extract, Zip apk's.
- Incorporates brut.all's apktool
- Improved syntax of questions/answers
- Logging on/off has been removed. Instead a log.txt is created which logs the activities of the script organized using time/date headers
- Optimize pngs (ignores .9.pngs)
- Pull apk from phone into modding environment.
- Push to specific location on phone
- Quick sign an apk (Batch mode supported)
- Read log (Option 24)
- Sign apks
- Supports batch installation, so if u drag multiple apks into the script (not while its running) it will install them all for u. U can ofcourse drag a single apk as well
- User can change the max java heap size (only use if certain large apks get stuck when decompiling/compiling apks) (Option 19)
- U can now set this script as ur default application for apks. When u do, if u double click any apk it will install it for u.
- Zipalign apks
- Much Much More
Instructions:
- Place apk in appropriate folder (Any filename will work, if running for first time folders will not be there, you must run and then the folders will be created)
- Run script
- Minimize the script
- Edit files inside the project folder
- Maximize the script
Requirements:
Java 1.7
Android SDK
FAQ
Resulting apk file is much smaller than original! Is there something missing?
First: compression of resources.arsc file. Sometimes this file is compressed in original apk, sometimes not and apktool always compress it. Second: lack of META-INF dir. Apktool builds unsigned apks, so they lack signatures stored in this dir. Third: apktool uses newest Android SDK, so it could optimize files better, especially if original app is old. So: unpack both original and resulting apk, remove META-INF from original and then compare sizes. If they're still much different, then you could report on XDA or somewhere.
There is no META-INF dir in resulting apk. Is this ok?
Yes. META-INF contains apk signatures mostly and after modifying apk in no longer signed, so there are no signatures in it. You have to sign resulting apk and then META-INF dir will be created.
What do you call "magic apks"?
Sometimes there are some apks which (for my current knowledge) are invalid, broken, theoretically they shouldn't exist. There may be many reasons of their existence: my lack of understanding of Android resources; some non-public, maybe future SDK tools or custom modifications of these; manual hacking of binaries, etc. Usually I can't do anything about it, but you could at least try to replace broken parts by something valid. Actually it's quite likely that they aren't even used, because if they would, then application would crash.
Got problems ?
1. Make sure your path has no spaces
2. Your filename has no wierd characters
3. Java/adb are in your path
4. It's not a proprietary rom's apk (aka Sense,Motorola,Samsung) (If u are, then use option 11 and drag the required framework, eg com.htc.resources, twframework-res...etc)
5. It's not a themed apk (if it is, expect .9 png errors, use as close to stock as possible)
6. Look at the log to know whats happening
7. If all else fails, post as much info as possible and we will try to assist you.
TO DO LIST
Add new feature to Randomly Generate a new Key File for signing the apk files after modifying and recompiling of the apk files this will also allow of uploading to the android market as this added feature will allow you to sign apk files that you may of compiled without signing beforehand.
Modify the Signapk script to be compatible with the Randomly Generation feature in the works
and a few other added features are in the works as I am redesigning the application and rewriting a lot of the code to fix issues as well as some of the new features have broken parts as some features have been moved and broken some command line prompts.
Installing APK Multi-Tool Itself
Instructions (Linux):
1-Download, create a folder in your sdk called "APK-Multi-Tool" and extract into it.
2-Goto the the "sdk/APK-Multi-Tool" folder and rename "Script.sh" to "script.sh".
3-Go into the "other" folder, right click on one file at a time, goto "permissions" in the new window and check the execute box.(do this with all the files)
4-To add the path to your folder open up a terminal and type in -
sudo su
PATH=$PATH:/THE PATH TO YOUR "SCRIPT.SH"
(for me this looks like the following)
PATH=$PATH:/sdk/APK-Multi-Tool/other/
5-export PATH
6-install "sox"
7-Type into the terminal "cd PATH TO YOUR SCRIPT.SH"
7.5 export PATH={PATH}:/PATH TO Your SDK/sdk/platform-tools/adb
8-Type "./script.sh"
9-You should have a running APK-Multi-Tool.
how to install sox:
Open the software center of the linux service and searched for sox. Installed it and it there you will have SOX working.
- Place apk in appropriate folder (Any filename will work, if running for first time folders will not be there, you must run and then the folders will be created)
- Open terminal and change-directory to APK-Multi-Tool(Easiest way is to type "cd ")
- Chmod 755 Script.sh
- Chmod 755 all files apps inside other folder
- Run script by typing ./Script.sh
- Minimize the script
- Edit files inside the out folder
- Maximize the script
Downloads:
https://github.com/APK-Multi-Tool/APK-Multi-Tool-Linux/archive/master.zip
Please check back daily or weekly as this project is under active Development and I am releasing Alpha releases on the website for Testing and bug reports.
Lol, why has nobody commented on this?
You're a savior. This is awesome. Can't wait for the rewrite.
AW: [Linux][UTILITY][TOOL] APK Multi-Tool
+1
Haven't seen this also available for Linux, so this is great.
Sent from my Galaxy Nexus using xda premium
Binary updates
UPDATED to apktool-cli-1.5.3-SNAPSHOT
-Updated to smali/baksmali to v1.4.2
-Fixed (issue #396) - Correctly handle android:debuggable while in debug
mode.
-Fixed (issue #340) - Fixed superclass errors on debug mode.
-Updated to Gradle 1.4
-Updated known bytes for configurations to 38 (from addition of layout
direction)
-Fixed NPE when handling odex apks even with --no-src specified. (Thanks
Rodrigo Chiossi)
-Fixed (issue #427) - Correctly handles `--frame-path` on uild
Error 404 on GitHub download page
xcly said:
Error 404 on GitHub download page
Click to expand...
Click to collapse
Fixed
Sent from my DROID RAZR CDMA XT912 using Tapatalk 2
I merged a few projects together instead of having multiple Android developer projects. I did some spring cleaning and deleted a few projects that was not useful and served no purposes. Also renamed the project organization which broke the link forgot to update lol.
Sent from my DROID RAZR CDMA XT912 using Tapatalk 2
I ran the script but I can't see any folders being created.. Trying to sign an apk. Looked up on google and all I can find is your instructions to put apk in appropriate folder (which I can't see..)
Thanks in advance
I will look into this ABCs see what's up
Sent from my DROID RAZR CDMA XT912 using Tapatalk 2
I ran the apksign tool separately using terminal for now
I got
The program sox is missing or is not in your PATH,
please install it or fix your PATH variable
If I go to the other folder there is no sox like in the windows version.
I will look into this asap once I get some free time
Sent from my DROID RAZR CDMA XT912 using Tapatalk 2
civato said:
I got
The program sox is missing or is not in your PATH,
please install it or fix your PATH variable
If I go to the other folder there is no sox like in the windows version.
Click to expand...
Click to collapse
I had the same problem but it was fixed once I installed sox. There was a tutorial on google search for setting up apk manager you might wanna have a look at.
Sent from my GT-I9300 using xda premium
raziel23x said:
I will look into this asap once I get some free time
Sent from my DROID RAZR CDMA XT912 using Tapatalk 2
Click to expand...
Click to collapse
xcly said:
I had the same problem but it was fixed once I installed sox. There was a tutorial on google search for setting up apk manager you might wanna have a look at.
Sent from my GT-I9300 using xda premium
Click to expand...
Click to collapse
I got it solved , I just entered the Ubuntu software center and searched for sox. Installed it and it works.
Maybe good to add this in OP when using linux. It is stupid of me thinking it was something harder so thank you for your help and fast response.
A other methode I found here
PS:
You don't need to type in ./Script.sh in teminal in linux , just clicking on it (Script.sh) and select "run in terminal" does the trick without typing anything.
updated the original post with detailed instructions
raziel23x said:
updated the original post with detailed instructions
Click to expand...
Click to collapse
Put updated info into the README file. Made a few corrections (hope you like).
AndyOpie150 said:
Put updated info into the README file. Made a few corrections (hope you like).
Click to expand...
Click to collapse
pushed your changed to github all code changes are welcome even forking the repo on github and making changes and doing pull request are welcome
raziel23x said:
pushed your changed to github all code changes are welcome even forking the repo on github and making changes and doing pull request are welcome
Click to expand...
Click to collapse
Just uploaded changed attachment. Fixed minor typos in Installation Instructions. Sorry I didn't get it straight before you pushed to github.
I deleted the info for Windows in previous attachments as well due to this being for the Linux version. Didn't know if you caught that.
PS: Thought I would let you decide if you liked my hair brained ideas first.
Is there any way to have a .jar file work without having to rename to .apk, or is that a mind bogling code rewrite. I'm all for learning.
Hey, I made some changes to the script to act more like the windows version of this tool. I added a setup.sh which will create all the folders and set permissions to everything. i also the ability to have multiple projects going at the same time, and also added a separate jar/dex folder so there is no need to rename the jar files to .apk to edit it. and other updates as well. its not 100% up to par with the windows one, but these few changes make a huge difference. Would you be interested in this?
---------- Post added at 11:38 AM ---------- Previous post was at 11:36 AM ----------
AndyOpie150 said:
Just uploaded changed attachment. Fixed minor typos in Installation Instructions. Sorry I didn't get it straight before you pushed to github.
I deleted the info for Windows in previous attachments as well due to this being for the Linux version. Didn't know if you caught that.
PS: Thought I would let you decide if you liked my hair brained ideas first.
Is there any way to have a .jar file work without having to rename to .apk, or is that a mind bogling code rewrite. I'm all for learning.
Click to expand...
Click to collapse
actually yes there is..i made an updated version of the script which has those features
clmowers said:
Hey, I made some changes to the script to act more like the windows version of this tool. I added a setup.sh which will create all the folders and set permissions to everything. i also the ability to have multiple projects going at the same time, and also added a separate jar/dex folder so there is no need to rename the jar files to .apk to edit it. and other updates as well. its not 100% up to par with the windows one, but these few changes make a huge difference. Would you be interested in this?
---------- Post added at 11:38 AM ---------- Previous post was at 11:36 AM ----------
actually yes there is..i made an updated version of the script which has those features
Click to expand...
Click to collapse
Make a pull request on github and in will merge it
Sent from my Xoom using Tapatalk HD

Modifying the layout of the Joying Radio app

Modifying the layout of the Joying Radio app.
version 0.2 See changelog at the bottom of this post.
This works in essence for most apks. There are some differences where the layout is defined in xml files or in json files.
Requirements:
java runtime version 7 or better.
apktool: (https://ibotpeaches.github.io/Apktool/)
Editor that handles unix LF correct. Any linux or Mac OS/X editor will do. Notepad on Windows does NOT. On Windows use Notepad++: (https://notepad-plus-plus.org/download/) for example.
Optional: ApkPack: (http://mirrors.gtxlabs.com/joying/3_Misc_Tools/ApkPack/)
Read(!!) the basic apktool Basic, Decoding, Building: (https://ibotpeaches.github.io/Apktool/documentation/) documentation to get a general understanding for the apk structure. It's about 1½ page and prevents a lot of questions.
Knowledge of working in a terminal / command box (some people still call this a DOS-box). These actions are not done using a nice graphical interface/program.
Installation of requirements:
Java: Either use Sun java: (https://www.java.com) for all platforms, Openjdk: (http://openjdk.java.net) for linux, or Mac OS/X's own java version (make sure it is version 7 or better)
apktool: See here: (https://ibotpeaches.github.io/Apktool/install/)
ApkPack.exe: This one can be used to pack/unpack the Allapp.pkg. This allows you to get the apks. Another option is to "adb pull" the original from your unit to work on.
apkPack is a windows binary but runs fine under wine.
General note
An apk file is actually nothing more than a zip file. This means that you can also unzip/rezip an apk. For only modifying buttons and other graphical elements, this is sufficient. When you also want to modify the layout of the main screen or sub-screens, you really need apktool to decompile/compile. If you want to do minor code changes, you also need apktool. (Also a java jar file is also nothing more than a zip file).
Note for Windows users
Text files contain lines (obvious). These lines end with CRLF ("\r\n") line endings on Windows (and MAC versions before OS/X). On linuxes/unixes they end with "\n".
For some files inside an apk this really matters! That's why you need an editor that can handle that correctly, like for example Notepad++.
Android is Case sensitive! Uppercase and lowercase characters do matter and are different (unless when used in strings)
Getting the radio apk
Copy one of my radio mods.
Use ApkPack.exe to get the apk out of the Allapp.pkg.
Use adb to copy the apk from the unit like "adb pull /system/app/JY-1-C9-Radio-V1.0/JY-1-C9-Radio-V1.0.apk ." (the last "." is not a typo). This assumes you already made a connection via USB or tcpip
Download the apk from "http://mirrors.gtxlabs.com/joying/1_Firmware/".
Install framework-res for use in apktool
This step might not be necessary for the radio apk, but is necessary if you modify apks that use system functions. It's anyway better to do this step.
Every Apktool release contains internally the most up to date AOSP framework at the time of the release. This allows you to decode and build most apks without a problem. However, manufacturers add their own framework files in addition to the regular AOSP ones. To use apktool against these manufacturer apks you must first install the manufacturer framework files.
Inside the 5009_60.zip (or previously the 5009_20.zip), you will find inside "/system/framework" the "framework-res.apk". Extract that one from the zip.
In a terminal window, you do on the command line:
Code:
<path_to>/apktool if <path_to>/framework-res.apk
You need to do this step for every new ROM upgrade from Joying.
Decompile the apk
Create some folder where you want to work on the apk.
Inside that folder do inside a terminal:
Code:
<path_to>/apktool d <path_to>/JY-JY-1-C9-Radio-V1.0.apk
(Change forward slash "/" to backward slash "" on windows.).
This will create a folder "JY-JY-1-C9-Radio-V1.0" containing the decompiled apk including the from-binary-to-UTF-8 text converted AndroidManifest.xml.
Code:
AndroidManifest.xml (file)
apktool.yml (file)
assets (folder containing "all kind of things" needed by the apk, but not belonging to the standard res structure. This can be images, files, scripts or even other apks)
original (folder containing original AndroidManifest.xml)
res (folder containing layout, graphics, translations, etc.)
smali (folder containing the decompiled code in "smali" format)
The "res" folder contains a large amount of sub folders.
The three most important folders are:
Code:
drawable-land-nodpi-v4 (contains resolution unspecific graphic elements for landscape mode)
drawable-nodpi-v4 (portrait version of above. Only needed because the original apk contains a corrupt png and can't be recompiled)
raw (contains screen config/layout in json formatted files. Most apks have the config/layout in straight xml)
Initial steps when using the original apk
When using the original apk (instead of one of my mods), you need two extra steps:
- Copy the "ic_point.png" from the folder "drawable-land-nodpi-v4" to the folder "drawable-nodpi-v4". As mentioned: that png is corrupt in the original "drawable-nodpi-v4" which makes that you can't recompile the apk.
- You need to make a small code change in smali to get rid of the "PS:" prefix in front of the PS-text containing the station name.
Edit the "smali/com/syu/radio/RadioController.smali" in a good editor! (NOT Notepad).
Search for the string "PS:" which is in line 1557.
Change:
Code:
const-string v3, "PS:"
into
Code:
const-string v3, ""
Relation between the graphical elements and the layout definition
All the graphical elements like buttons, the frequency ruler and numbers for the (big) frequency are in "res/drawable-land-nodpi-v4".
The layout definition is in "raw/radio_ui.json". The "radio_ui.json" determines which graphical elements are used, and how and where they are positioned. The "radio_ui.json" also determines which texts in which font and font size are used and where they are positioned.
Examples:
The big frequency ruler is named "type":"HorizontalRuler" in the radio_ui.json and defined by the graphical element "drawables":["bk_ruler"], where "bk_ruler.png" is the image. Note that in the json file no extensions (.png) are used.
The "type":"StationView" determines the 6 buttons with inactive (unselected: *_n), active (current selected: *_p) and "on_click/on_tap" (*_p) state. Note also that you will find a ' "extras":[30,0,0,0],' in these sections. This will offset the x-postion 30 pixels to the right. If you want to center the text, change it to: "extras":[0,0,0,0],
The Frequency numbers and the buttons left/right around it. The frequency numbers are the images "num_0.png" to "num_9.png", plus the "num_point.png". The buttons left/right are the "drawables":["ic_freqm_n", "ic_freqm_p"] (down) and "drawables":["ic_freqp_n", "ic_freqp_p"] (up).
The PS, TA, AF, PTY etcetera can easily be found. These do not contain "drawables" (images), but are defined by textsize and text color.
All elements are positioned in a "X0,Y0,X1,Y1" or "top_left_X, top_left_Y,bottom_right_X, bottom_right_Y] rectangle.
Actually this is all.
You can play with it to change the layout.
If you want to change color or form of buttons, ruler or other elements, you have to modify exiting elements or create new elements in either Gimp or Photoshop or another package you are familiar with.
Note1: most PNGs are stored in "optimized" color mode (only store used colors) instead of "RGB" color mode (use full color palette). On small PNGs this can reduce the files by a factor 2, thereby reducing your apk size from ~2 MB to ~1.5 MB. This also means that in Gimp or Photoshop (or whatever), you first need to set the color mode to "RGB" before altering the elements, and before saving them back to "optimized".
Note2: Remember that Android is case-sensitive. When working with the layout or the graphics, keep this in mind!
Recompile the apk
When you are done "playing" and you want to experience the great and glorious app you created, you need to recompile it.
In your folder where you have the unpacked folder "JY-JY-1-C9-Radio-V1.0", you do a:
Code:
<path_to>/apktool -c b JY-JY-1-C9-Radio-V1.0
- Note that you specify the folder name, not some apk name
- the "b" is for build.
- The "-c" is to use the original AndroidManifest.xml
If you see errors, please first google for it before asking questions. There is so much to find on this stuff on the web.
If your apk compiled successfully (don't mind the warnings), you will find it inside "JY-JY-1-C9-Radio-V1.0/disẗ" as a new "JY-JY-1-C9-Radio-V1.0.apk".
Push the apk to your unit.
Simply use one of the scripts from my repository. Make sure to have adb in the right place (windows) or change the script accordingly. Read the Readme: (https://github.com/hvdwolf/Joying-RootAssistant/blob/master/Radio-Mod/Readme.md) on my github repository inside the "Radio-Mod" section for info on how to use the scripts to install it on your unit.
Troubleshooting
Q1. adb or adb.exe can't be found.
A1. Make sure you have adb installed. Use the proper path to adb.
Q2. I can't get a connection to the unit.
A2. Search the web and find out how adb should work, see also the readme in my Radio mods. On 6.0.1 first activate adb over tcpip, or conect via USB.
Q3. You get an android icon instead of the Radio icon and when you tap it, your unit says "application not installed".
A3. Reboot, check again and try another time to copy it to your unit. If nothing works (after a couple of attempts), reboot and copy the original radio apk back in place, reboot again.
Q4. You rebooted the unit and you hear music, but you don't see a Radio icon.
A4. Same as Q3/A3: so do the same. This is due to the fact that the Radio function is a 2-step approach on the Intel joying units. The CarRadio.apk (hidden) does the real work. The Radio.apk is just the visible "tweak and go" app.
Changelog:
Version 0.2, 06 June 2017; few typos and rephrasing; Add reference to working in terminal / cmd box; Add paragraph on installing framework-res.apk as dependency for apktool.
Version 0.1, 05 June 2017; first version
Do you need to pull the framework file from the unit and load into apk tool first?
https://ibotpeaches.github.io/Apktool/documentation/#framework-files
I ran into issues on 6 with apktool until I loaded the framework.
gustden said:
Do you need to pull the framework file from the unit and load into apk tool first?
https://ibotpeaches.github.io/Apktool/documentation/#framework-files
I ran into issues on 6 with apktool until I loaded the framework.
Click to expand...
Click to collapse
Did you have issues with the Radio app or with the SofiaServer apk?
I tried with the framework that came with apktool (inside the jar) and with the framework-res.apk from the joying unit.
Apart from the issues you can encounter on this 6.0.1 version, I didn't notice differences for the Radio app.
I can imagine that with SofiaServer being a real system app, that it also might need the framework-res.apk.
However, normally when decompiling you get an error if you miss a "framework" type apk. It will even mention which apk you need. (Had that on my previous Samsung phone which uses a lot of Samsung only resource and framework like apks.
I will at least add a 5th Q/A section describing how to do that.
surfer63 said:
Did you have issues with the Radio app or with the SofiaServer apk?
I tried with the framework that came with apktool (inside the jar) and with the framework-res.apk from the joying unit.
Apart from the issues you can encounter on this 6.0.1 version, I didn't notice differences for the Radio app.
I can imagine that with SofiaServer being a real system app, that it also might need the framework-res.apk.
However, normally when decompiling you get an error if you miss a "framework" type apk. It will even mention which apk you need. (Had that on my previous Samsung phone which uses a lot of Samsung only resource and framework like apks.
I will at least add a 5th Q/A section describing how to do that.
Click to expand...
Click to collapse
I had issues when I made changes to the SofiaServer apk. I initially built against the 6.0.1 ROM using the 5.1.1 framework. I didn't see any errors, the apk just would not work when loaded on the unit. Now, I pull it from the ROM and load on every ROM update ( just to be safe).
gustden said:
I had issues when I made changes to the SofiaServer apk. I initially built against the 6.0.1 ROM using the 5.1.1 framework. I didn't see any errors, the apk just would not work when loaded on the unit. Now, I pull it from the ROM and load on every ROM update ( just to be safe).
Click to expand...
Click to collapse
I added a section and not as a new Q/A

Categories

Resources