Jump to content


Photo

How to replace framework-res.apk??


  • Please log in to reply
20 replies to this topic

#1
redhawkuk

redhawkuk

    Enthusiast

  • Members
  • PipPipPip
  • 164 posts
  • Gender:Male
  • Devices:ZTE Racer debranded Three UK
There are 4 things really annoy me about Android on the ZTE Racer:

- low battery life warning box <= 15% I would prefer 8% before giving a damn. (/res/values/integers.xml)
- low memory warning that won't go away if your internal storage is < 30MB
- the default "beep" tone when you adjust your volume control - where is this sound file?? (appears to be software generated - http://www.netmite.c...olumePanel.java).
- the emergency call button that if touched enables call mode and calls emergency services.
This is particularly dangerous while in flight because it's so easy to trigger without realising it.

Now I have found the settings for changing the low battery life threshold they're stored inside framework-res.apk my only problem is how the hell do I replace this file without screwing up the Operating System??

I have ADB drivers installed as well as cwm however any tips on replacing files or restoring would be most appreciated.

btw: if anyone has details regarding the other 3 issues I would be interested to know

Richard S.

Edited by redhawkuk, 03 February 2012 - 10:15 AM.

  • 0

#2
massacre^

massacre^

    Regular

  • Members
  • PipPip
  • 123 posts
  • Devices:zte racer
It is possible to open it through winrar...just right click > open with > choose winrar.
in it u will find a bunch of xmls in which i tried to find battery related stuff but failed.....
good job hunting :lol:

  • 0

#3
Racerboy

Racerboy

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,463 posts
  • Gender:Male
  • Location:England
  • Devices:hTC Explorer / Donated Racer
ok, their are numerous ways to edit the framework-res.apk and any other .apk file, if your simply replacing a like for like file ie "res/drawable-ldpi/ic_jog_dial_unlock" for example you can use 7-Zip to drag and drop replacement files, the modified file should ok to use.....if however you need to modify .xml`s (example res/values/arrays.xml) you need to decompile the .apk file (i use Apk Multi-Tool to decompile/recompile and Notepad ++ to edit .xml`s and smali`s to change certain values)........make backups of the original source rom or .apk your working on, always make backups of installed roms with CWM BEFORE you install a modified rom or push a modified .apk file via ADB.........

useful links http://forum.xda-dev...d.php?t=1136625 editing .apks for smali files

http://apkmultitool.com/ for editing. decompiling/recompiling and a bunch of other stuff

http://notepad-plus-plus.org/ notepad++ for editing .xml* and or smali files

*NOTE: when editing .xml`s only change values that are in BLACK

hope it helps and their is alot to learn, but basic editing is quite easy


BASIC cmd commands to use with ADB on a Windows based computer system:

you want to pull an .apk from a rom you currently have installed: example framework-res.apk

open cmd window and type:

adb pull  /system/framework/framework-res.apk

the pulled file will be located in the C:/Users/YOUR-USER-NAME/

to push a modified .apk file....example: location of modified file on your computer (push and pull same location) C:/Users/YOUR-USER-NAME/framework-res.apk

adb push framework-res.apk  /system/framework/framework-res.apk

NOTE .apk file names are case sensitive.......

for apps its basically the same command just different folder location on phone, instead its /system/apps/whatever.apk to push n pull files

Edited by Racerboy, 23 January 2012 - 08:56 PM.

  • 1

Find ALL my 2.3.7 cm7 ROMS HERE and ICSv5-MOD-ROM HERE @ raceroms

Latest LeWa ported ROM HERE

PM`s for help WONT be answered


#4
ClydeRadcliffe

ClydeRadcliffe

    Newbie

  • Members
  • Pip
  • 22 posts
  • Gender:Male
  • Devices:HTC One X
Here is a guide on how to use apktool to decompile/recompile apk's

apktool Guide







Be sure to backup old framework-res or entire rom before trying this so you can revert to old one if something goes wrong.


In my experience framework-res.apk is the most difficult file to succesfully modify and recompile. Since i am compiling CM7 myself from source sometimes best way is to make changes directly in source before compiling.


  • 0

#5
Racerboy

Racerboy

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,463 posts
  • Gender:Male
  • Location:England
  • Devices:hTC Explorer / Donated Racer
@ClydeRadcliffe

are you compiling for Racer and will you be releasing it here?

  • 0

Find ALL my 2.3.7 cm7 ROMS HERE and ICSv5-MOD-ROM HERE @ raceroms

Latest LeWa ported ROM HERE

PM`s for help WONT be answered


#6
ClydeRadcliffe

ClydeRadcliffe

    Newbie

  • Members
  • Pip
  • 22 posts
  • Gender:Male
  • Devices:HTC One X

@ClydeRadcliffe

are you compiling for Racer and will you be releasing it here?





I don't own a Racer. I am lurking here because I am maintaining a friends Racer. Sorry if I am intruding here.

I am compiling CM7 roms for HD2. And so far I didn't had much luck with recompiling framework-res without errors so all changes I need I do in source before building a kang.





  • 0

#7
equiliym

equiliym

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,346 posts
  • Gender:Male
  • Location:Novi Sad
  • Devices:ZTE Racer
  • Twitter:@equiliym

Now I have found the settings for changing the low battery life threshold they're stored inside framework-res.apk my only problem is how the hell do I replace this file without screwing up the Operating System??


hey could you tell me in what xml is the setting for low battery alarm? sounds nice to change the value, too lazy to search on my own so if you know, it would be helpful :P

  • 0
Suffering-oriented programming.. "First make it possible. Then make it beautiful. Then make it fast."
if i helped please press the vote up button :3

#8
Racerboy

Racerboy

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,463 posts
  • Gender:Male
  • Location:England
  • Devices:hTC Explorer / Donated Racer

I don't own a Racer. I am lurking here because I am maintaining a friends Racer. Sorry if I am intruding here.

I am compiling CM7 roms for HD2. And so far I didn't had much luck with recompiling framework-res without errors so all changes I need I do in source before building a kang.


thats not a problem you are free to "Lurk" around whenever you like whether you have a Racer or not :) after all it is free and open info we share here on these forums.....................regards framework-res.apk have you tried editing using the above tools in 3rd post, they are quite handy for editing decompiling/re-compiling an existing .apk BUT as i see your compiling from source which is better......

Edited by Racerboy, 23 January 2012 - 11:46 PM.

  • 0

Find ALL my 2.3.7 cm7 ROMS HERE and ICSv5-MOD-ROM HERE @ raceroms

Latest LeWa ported ROM HERE

PM`s for help WONT be answered


#9
ClydeRadcliffe

ClydeRadcliffe

    Newbie

  • Members
  • Pip
  • 22 posts
  • Gender:Male
  • Devices:HTC One X

hey could you tell me in what xml is the setting for low battery alarm? sounds nice to change the value, too lazy to search on my own so if you know, it would be helpful :P

Just looked into racer's framework-res.apk and found next line in /res/values/integers.xml

<integer name="config_lowBatteryWarningLevel">15</integer>

I guess that would be the one.

Edited by ClydeRadcliffe, 23 January 2012 - 11:49 PM.

  • 0

#10
ClydeRadcliffe

ClydeRadcliffe

    Newbie

  • Members
  • Pip
  • 22 posts
  • Gender:Male
  • Devices:HTC One X

thats not a problem you are free to "Lurk" around whenever you like whether you have a Racer or not :) after all it is free and open info we share here on these forums.....................regards framework-res.apk have you tried editing using the above tools in 3rd post, they are quite handy for editing decompiling/re-compiling an existing .apk BUT as i see your compiling from source which is better......




I havent tried to use those tools, I only used apktool which I think is also what is used in apk Multi tool.

Anyway on some occassions I managed to succesfully recompile framework-res file but most of the time I am getting an compile error or I get a apk file with I cant boot or have some other problems. Maybe

In my experience apk's like framework-res, Contacts.apk and Settings.apk are pain to recompile without errors.


  • 0

#11
Racerboy

Racerboy

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,463 posts
  • Gender:Male
  • Location:England
  • Devices:hTC Explorer / Donated Racer

I havent tried to use those tools, I only used apktool which I think is also what is used in apk Multi tool.

Anyway on some occassions I managed to succesfully recompile framework-res file but most of the time I am getting an compile error or I get a apk file with I cant boot or have some other problems. Maybe

In my experience apk's like framework-res, Contacts.apk and Settings.apk are pain to recompile without errors.


yes apktool is the command tool chain included in the apps above, its just intergrated into a nice UI for easy use for novice users of commands (like myself, although am learning) and afew other features, which is nice............at first when i started editing .apk files i did get errors in framework-res.apk but i put it down to the app package and not my good self :D ......seriously though they can be a pain in the backside........all depends on what your editing or adding

Edited by Racerboy, 24 January 2012 - 12:03 AM.

  • 0

Find ALL my 2.3.7 cm7 ROMS HERE and ICSv5-MOD-ROM HERE @ raceroms

Latest LeWa ported ROM HERE

PM`s for help WONT be answered


#12
equiliym

equiliym

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,346 posts
  • Gender:Male
  • Location:Novi Sad
  • Devices:ZTE Racer
  • Twitter:@equiliym

Just looked into racer's framework-res.apk and found next line in /res/values/integers.xml

I guess that would be the one.


onice, thanks, gonna make it pop on every 5% (15-10-5) now lolol :D

  • 0
Suffering-oriented programming.. "First make it possible. Then make it beautiful. Then make it fast."
if i helped please press the vote up button :3

#13
redhawkuk

redhawkuk

    Enthusiast

  • Members
  • PipPipPip
  • 164 posts
  • Gender:Male
  • Devices:ZTE Racer debranded Three UK
Okay so I have a really big problem my framework-res.apk won't rebuild using the apktool.
To make sure it wasn't related to my modded files I tested it against an untouched copy but still won't build.
I'm getting a lot of "declared here is not defined." in \res\values\plubic.xml

apktool is version 1.4.2 (and yes I have tried --forced-all as well)

Any idea what I'm doing wrong??

Richard S.

Edited by redhawkuk, 01 February 2012 - 08:32 PM.

  • 0

#14
equiliym

equiliym

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,346 posts
  • Gender:Male
  • Location:Novi Sad
  • Devices:ZTE Racer
  • Twitter:@equiliym
thats odd.. using apktool 1.4.1 and no problems at all.. try downgrading to .1 and recompile with that

  • 0
Suffering-oriented programming.. "First make it possible. Then make it beautiful. Then make it fast."
if i helped please press the vote up button :3

#15
redhawkuk

redhawkuk

    Enthusiast

  • Members
  • PipPipPip
  • 164 posts
  • Gender:Male
  • Devices:ZTE Racer debranded Three UK
I've solved it the ROM I was editing (Ricky Wyatt's v2 Android 2.1) had the default wallpaper saved in JPG format with a PNG extension.
I guess the apktool does strict checking of file formats but why it was throwing loads of strange errors is another mystery.
The only thing I can't work out is how did Ricky Wyatt manage to pack this file in the first place?? :blink:

Richard S.

Edited by redhawkuk, 02 February 2012 - 01:29 PM.

  • 0

#16
redhawkuk

redhawkuk

    Enthusiast

  • Members
  • PipPipPip
  • 164 posts
  • Gender:Male
  • Devices:ZTE Racer debranded Three UK
I decided to play around with the original framework-res.apk 2.1 from the Three UK stock ROM but there's something weird about the unpack / rebuild process.

Original APK size 6.18MB
Unpacked to folder total size: 5.73MB
Repacked APK size: 3.72MB

Somehow I've gone from 6.18MB ot 5.73MB, what happened to the rest of the data I thought APKs were compressed?? (original apk appears to be uncompressed with unicode text).

I repacked, resigned and replaced the framework-res.apk file but on rebooting my phone it didn't get past the little green man.

Obviously I'm missing something important but what is it??

Richard S.

Edited by redhawkuk, 02 February 2012 - 02:45 PM.

  • 0

#17
equiliym

equiliym

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,346 posts
  • Gender:Male
  • Location:Novi Sad
  • Devices:ZTE Racer
  • Twitter:@equiliym

I repacked, resigned and replaced the framework-res.apk file but on rebooting my phone it didn't get past the little green man.


i think thats just your problem, framework-res.apk is a system file, you should not resign it, keep the original signature and it should work.. for compression, its probably different compression method used in 7z that apk tool uses :P

also, /res/drawable/default_wallpaper.jpg < not sure why that is a problem, its supposed to be .jpg

  • 0
Suffering-oriented programming.. "First make it possible. Then make it beautiful. Then make it fast."
if i helped please press the vote up button :3

#18
redhawkuk

redhawkuk

    Enthusiast

  • Members
  • PipPipPip
  • 164 posts
  • Gender:Male
  • Devices:ZTE Racer debranded Three UK
Compression does seem to be the issue here I used Winzip32 no compression to repack the APK and then resign it.
Now it boots all the way to the welcome / unlock screen however when I do unlock all I get are FCs. :mellow:
I realise that this is a system file which shouldn't be mucked about with but Ricky has done it I don't see why I cannot do the same.

Any ideas how to prevent apktool compressing the data in the APK build or do I need another tool?

Richard S.

Edited by redhawkuk, 02 February 2012 - 06:07 PM.

  • 0

#19
equiliym

equiliym

    Hardcore

  • Members
  • PipPipPipPipPipPip
  • 1,346 posts
  • Gender:Male
  • Location:Novi Sad
  • Devices:ZTE Racer
  • Twitter:@equiliym

Compression does seem to be the issue here I used Winzip32 no compression to repack the APK and then resign it.
Now it boots all the way to the welcome / unlock screen however when I do unlock all I get are FCs. :mellow:
I realise that this is a system file which should be mucked about with but Ricky has done it I don't see why I cannot do the same.

Any ideas how to prevent apktool compressing the data in the APK build or do I need another tool?

Richard S.


try using 7-zip and without resigning of system files, i never had issues when i edit and repack apk files

  • 0
Suffering-oriented programming.. "First make it possible. Then make it beautiful. Then make it fast."
if i helped please press the vote up button :3

#20
redhawkuk

redhawkuk

    Enthusiast

  • Members
  • PipPipPip
  • 164 posts
  • Gender:Male
  • Devices:ZTE Racer debranded Three UK
I've extracted and rebuilt many APKs in the past without problems but for some reason framework-res.apk seems to be something of a special case.
All I ever wanted was to change the low battery warning threshold and remove the stupid emergency button crap from the locked screen.
I suspect Android probably has some kind of anti-tampering mechanism because only the slightest insignificant change would causes all applications to FC.
For example I replaced the startup screen images using Winzip not apktool this time which kind of worked except everything FC when I unlocked the phone.

Anyway I'm about to throw in the towel soon unless someone knows of a solution (yes I have tried cleaning dalvik-cache). :mellow:

Richard S.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users