Push edited stat_sys_battery.xml file to phone & have it accepted?

Discussion in 'Android Hacks and Help' started by Lock-N-Load, Feb 13, 2011.

  1. Lock-N-Load
    Offline

    Lock-N-Load Member

    Joined:
    Feb 7, 2010
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Westsiiide
    Ratings:
    +0
    So, I wanted to edit the icons in my Droid 1's notification bar to have percentage signs. I can and did do that easy enough and used Metamorph to place them and that works just fine.

    Then, in reading around, I saw that some were able to then get the system to also do 10% increments and all they have to do is 'essentially' add in the missing png battery icons and alter the stat_sys_battery.xml file. Well, I can and did create new 10% battery png files and can place them no problem so now I also have images for 5,15,30,50,70 to go along with the system pngs of 100,80,60,40,20,10,0. I can even edit the stat_sys_battery.xml file with the reference to the new icons.

    BUT, the issue is being able to get the system to recognize and accept my stat_sys_battery.xml since it is inside an apk file (framework-res.apk). In all my trials and all my reading of numerous topics, it seems that stat_sys_battery.xml needs to be signed in some way so the system accepts it as a valid xml file when you place it? This is not an issue with the png images, those just go right into place with Metamorph and are recognized. But getting the stat_sys_battery.xml file to be placed and recognized by the system is what is stopping my Droid from seeing and using the new 10% icons I added.

    I have a mac and a PC and wonder if someone can point me to how to get the stat_sys_battery.xml placed, signed, accepted or whatever it takes for the system to accept it in the apk and use it. You can't seem to place it with something like Root Explorer and have it recognized and work.
     
  2. powder
    Offline

    powder Member

    Joined:
    Dec 29, 2009
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    the evergreen state
    Ratings:
    +0
    Did you compile it? Here is what i would do. Compile it with the rest of framework-res.apk in apk manager. Open up the "unsignedframework-res.apk" that apk manager compiles for you and find your "stat_sys_battery.xml" and drop it in a MM zip like you know how to do already. Put it on your sd, then go on the market and do a search for "ZipThemer" and download it. Once you have it, run your MM zip through it and tell it to build it. Now you have a flashable zip that's signed and zip aligned that you can flash via recovery. The good thing about doing it this way besides what i've mentioned already, is it takes a combination of the files in your MM, and the files already in your framework-res.apk and creates your flashable and also creates an undo.zip that reverts you back to what you started with if the changes don't work out.
     
  3. kevdog
    Offline

    kevdog Member

    Joined:
    Nov 14, 2009
    Messages:
    722
    Likes Received:
    0
    Trophy Points:
    16
    Ratings:
    +0
    FYI - Droid 1 wont except any battery increments less than 10% -- trust me -- Ive tried it and so have many others.

    Use APKManager/ApkTool to recompile your framework-res.apk. Then my advice would then to specifically drop and drag your modified file(s) along with the resourses.asc file using Winrar (or similar) from your compiled framework into your old framework (pre-modified). (The old themeing trick). By using this trick you don't have to worry about signing since the old framework was already signed and using the drag and drop trick -- you don't destroy the signature.

    That's how to do it.
     
    Last edited: Feb 14, 2011
  4. Lock-N-Load
    Offline

    Lock-N-Load Member

    Joined:
    Feb 7, 2010
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Westsiiide
    Ratings:
    +0
    I didnt compile.. and I know that is what my issue is. I dont have this "apk manager" so I guess I need to investigate it. I also like the idea of this "zipthemer". It seems all I really should have to do is create an framework-res.apk that contains ONLY the items I changed and nothing more, correct? Some of the ones I have seen on the web include the entire framework-res.apk and yet, I am just editing 1 file within it so I see no reason to make a whole new framework-res.apk.. if I made a framework-res.apk with just my edited files - "stat_sys_battery.xml" and the new png files - in it, it would only place those and leaves others in place, yes?

    hmmm.. I thought below 10% it did that 5%. No biggie if not. I just really want the 10%.

    again, still looks like I need to investigate this APK manager.
     
    Last edited: Feb 14, 2011
  5. kevdog
    Offline

    kevdog Member

    Joined:
    Nov 14, 2009
    Messages:
    722
    Likes Received:
    0
    Trophy Points:
    16
    Ratings:
    +0
    APK manager is found over at xda (Danesh) is the author. It offers a rough gui for apktool -- which is the actual tool doing the decompiling and compiling.

    Its tricky to use at first. You need to start off with an unthemed framework-res.apk (since on many of the themes the author didn't correctly modify the .9.png files which will break apktool when it goes to recompile the framework-res.apk.

    Unzip the framework-res.apk -- make the modifications to whatever files you want using notepad++ or other tool that can write in linux/unix format. Save the changes, and then follow the instructions to recompile. (its a little bit of a hassle). Then once compiled, take your modified files along with the resources.asc file and then drag and drop them to the original unmodified framework-res.apk. This ensures you won't have a signature error when trying to push the framework-res.apk back to the phone.

    If you phone ever bootloops -- just push back the original framework-res.apk (unmodified), and the phone will boot. Ive had to do this many times which sucked, but unlike what others would lead you to believe -- you won't bork your phone.

    You'll need to be somewhat facile with adb to do all of this.
     
  6. powder
    Offline

    powder Member

    Joined:
    Dec 29, 2009
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    the evergreen state
    Ratings:
    +0
    I haven't used adb for it. That's the plus of ZipThemer, it's a flashable zip. Your phone has to reboot when any framework changes are made anyways, and framework-res.apk changes cannot be made with a file manager to my knowledge.

    I would make your metamorph them like i stated earlier, and use zipthemer to make it an update.zip.

    Your other option is just make it an update.zip yourself if you have a full apk you want put in. There's templates all over the place, it's pretty simple. Or like kevdog said, you can figure out adb. In the end adb will probably be the easiest for pushing any kind of file, an you won't have to worry about updater-scripts and control xml's.
     
  7. Lock-N-Load
    Offline

    Lock-N-Load Member

    Joined:
    Feb 7, 2010
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Westsiiide
    Ratings:
    +0
    I like the zipthemer idea.. so how does this sound:

    1. I make my stat_sys_battery.xml edits with calls to the new images
    2. I put together a directory (& give it my name of choice say my10percent) and in it, I have my MM based file in the root
    3. in this directory I also have a directory called framework-res and in that is res and in that are drawable and drawable-hdpi as all of this lines up with the correct names and placement the system expects
    4. in drawable I put the stat_sys_battery.xml file which is where it lives in real life
    5. in drawable-hdpi I put my new pings which is where they live in real life
    6. I zip up this my10percent directory with all of this inside which matches the Systems placement and file/directory names
    7. I put this on my SD card (into MM's "Androidthemes" folder by default for me)
    8. I get this zipthemer and run my10percent.zip file through zipthemer which makes me an update.zip file I can flash
    9. I reboot into recovery, backup my ROM in case, then flash this zipthemer update.zip file

    sounds correct?

    UPDATE: all worked as expected to create the update.zip file with zipthemer BUT upon reboot, I have no battery icons at all and not sure why? I can see the stat_sys_battery.xml is correctly placed in the system/framework/framework-res.apk and is my updated file with my edits, and I can see my pngs files are in place as expected, BUT I get no icons in the notification bar. none at all.

    any idea?

    BTW, here is my stat_sys_battery.xml file - is this the possible issue? It seems right to me.

    Code:
    [SIZE="3"]<?xml version="1.0" encoding="UTF-8"?>
    <level-list
      xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:drawable="@drawable/stat_sys_battery_0" android:maxLevel="4" />
        <item android:drawable="@drawable/stat_sys_battery_5" android:maxLevel="5" />
        <item android:drawable="@drawable/stat_sys_battery_10" android:maxLevel="10" />
        <item android:drawable="@drawable/stat_sys_battery_15" android:maxLevel="15" />
        <item android:drawable="@drawable/stat_sys_battery_20" android:maxLevel="20" />
        <item android:drawable="@drawable/stat_sys_battery_30" android:maxLevel="30" />
        <item android:drawable="@drawable/stat_sys_battery_40" android:maxLevel="40" />
        <item android:drawable="@drawable/stat_sys_battery_50" android:maxLevel="50" />
        <item android:drawable="@drawable/stat_sys_battery_60" android:maxLevel="60" />
        <item android:drawable="@drawable/stat_sys_battery_70" android:maxLevel="70" />
        <item android:drawable="@drawable/stat_sys_battery_80" android:maxLevel="80" />
        <item android:drawable="@drawable/stat_sys_battery_90" android:maxLevel="90" />
        <item android:drawable="@drawable/stat_sys_battery_100" android:maxLevel="100" />
    </level-list>[/SIZE]
    Also, when I rolled back to my original setup, I see via Root Explorer that the stat_sys_battery.xml is in an unreadable format for me, looks like a bunch of binary code. Maybe that is becuase it is correctly "signed" or compiled? Whereas after my install, the stat_sys_battery.xml file was totally readable as seen above when I went and looked... like it was not correctly encoded or compiled?
     
    Last edited: Feb 18, 2011
  8. castaway
    Offline

    castaway New Member

    Joined:
    Apr 1, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    stat_sys_battery.xml

    first of all, i dont want to spam this thread. I just want to read and learn what other say.
    I find this becouse i google for stat_sys_battery.xml and i want make smooth battery like you do. Im using HTC magic that is MDPI so it can be little different.Im stop at problem with apkmanager which sending me error while compiling framework-res.apk back.

    1.question
    my steps to compile and decompile in apkmanager

    1.put framework-res.apk in to "place-apk-here-for-modding" folder
    2.22 as set project
    3.9 decompile
    4.(minimize apkmanager and edit xml in project folder)
    5.11 compile apk
    6.12 sign apk

    is it right? i think theres some step i dont do or i do it wrong?

    2. question
    im editing only stat_sys_battery.xml but im not sure if theres no more files need to be edited becouse after decompiling framework-res.apk i find \res\values\public.xml that contain all png files used in battery icons so im think if edit this too?

    maybe
    framework-res.apk/res/drawable/zzz_stat_sys_battery_1.xml (this one i dont have in my custom ROM becouse its MDPI?)


    I need to know how exactly use apkmanager to do it. So all what i know is DECOMPILE framework-res.apk ->edit stat_sys_battery.xml ->push there missing pngs-> COMPILE it back and flash framework-res.apk

    (BTW what is MM ? ) :)
     
  9. kevdog
    Offline

    kevdog Member

    Joined:
    Nov 14, 2009
    Messages:
    722
    Likes Received:
    0
    Trophy Points:
    16
    Ratings:
    +0
    castaway

    Your initial steps were right except for step #6.

    What I do at this point at this point is take the newly compiled framework-res.apk (unsigned). Using winrar, I drag and drop all the changed files (any .png you may have changed and .xml files that you may have changed, along with the resources.arsc file) unto the unmodified or original framework-res.apk.

    The reason I do this is that I had a problem with the signing process using apk manager. It always bootlooped for me at least. My dragging and dropping the changed files onto the signed original framework-res.apk however, the original signature was always preserved, and I never experiened a bootloop.

    Hopefully this helps.
     
  10. castaway
    Offline

    castaway New Member

    Joined:
    Apr 1, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    thank you a lot for this!. I was stuck on step 5 so compile(11) send me error message i attach screenshot of it. Anybody know whats problem or how to fix that?

    After many tryes i get unsignedframework-res.apk/drawable/stat_sys_battery.xml compiled and i think ok so i flash it into phone like other of my themes, it boot up normally but battery icon does not apper.There is just clear space....

    I read on web about this a little and one guy say that we need to edit public.xml in values directory.Now i think if i need to modifi and add lines with png names to public.xm that appers when you decompile framework-res.apk and when you compile it back theres no that directory anymore :icon_eek:

    So ,becouse now it look like this. logicaly here must be pngs what i add so for status 30-50-70-90 of battery

    HTML:
     <public type="drawable" name="stat_sys_adb" id="0x01080290" />
        <public type="drawable" name="stat_sys_battery_0" id="0x01080292" />
        <public type="drawable" name="stat_sys_battery_10" id="0x01080293" />
        <public type="drawable" name="stat_sys_battery_100" id="0x01080294" />
        <public type="drawable" name="stat_sys_battery_20" id="0x01080295" />
        <public type="drawable" name="stat_sys_battery_40" id="0x01080296" />
        <public type="drawable" name="stat_sys_battery_60" id="0x01080297" />
        <public type="drawable" name="stat_sys_battery_80" id="0x01080298" />
        <public type="drawable" name="stat_sys_battery_charge_anim0" id="0x0108029a" 
    so i think how to add lines with other pngs like for example

    HTML:
    <public type="drawable" name="stat_sys_battery_30" id="0x********" />
    how to calculate id number in it? can i use id number used in other theme with same png name?
     
  11. CJM
    Offline

    CJM Developer Relations Staff Member Rescue Squad Premium Member

    Joined:
    Sep 12, 2010
    Messages:
    9,436
    Likes Received:
    599
    Trophy Points:
    228
    Location:
    Mississippi Gulf Coast
    Ratings:
    +606
    I've been trying to do this for a while. Gonna tag along.

    Swyped from a Droid
     
  12. kevdog
    Offline

    kevdog Member

    Joined:
    Nov 14, 2009
    Messages:
    722
    Likes Received:
    0
    Trophy Points:
    16
    Ratings:
    +0
    Ok -- first you need a totally unthemed framework to start with. Use a stock framework-res.apk.

    As far as adding id numbers, I believe you have to use the next available number in the public.xml file.

    If in any doublt check the apk manager or apktool thread over on xda. I know the question has been asked before about a million times.
     
  13. Lock-N-Load
    Offline

    Lock-N-Load Member

    Joined:
    Feb 7, 2010
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Westsiiide
    Ratings:
    +0
    dizzzamn.. can you say hijack?

    so maybe I can approach it from a different way to try to get my desired results.

    maybe if I could find an already correctly compiled and working hack for what I want to do here that is correctly compiled, and I could place it on my droid to get it working. THEN, all I would have to do is just replace the icons that hack came with with mine as that can easily can be done in Metamorph and need no compiling.

    seem reasonable? if so, now I just need to find a compatible hack that is proven to work on the D1 and uses 10% readings and can even have its own 10% icons. Seen one that works??
     
    Last edited: Feb 21, 2011
  14. castaway
    Offline

    castaway New Member

    Joined:
    Apr 1, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Ratings:
    +0
    ok guys im done with this and im success!!! :icon_ banana:

    Im done with 10% increment battery mod thanks everyone and specially thanks kevdog for help!

    i dont do anything with public.xml im just edit stat_sys_battery.xml and overwrite newly created resources.arsc after compiling framework apk back so it acutalize public.xml itself.

    im really enjoying this smooth battery mod!!! THANKS KEVDOG AGAIN!!!!
     
  15. Lock-N-Load
    Offline

    Lock-N-Load Member

    Joined:
    Feb 7, 2010
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Westsiiide
    Ratings:
    +0
    how about posting your zipped file for download - or send it to me - so we/I can try it.... please :)

    I'd like to try your zip file that is complied correctly and then just later replace with my battery images
     
Search tags for this page
android stat sys battery.xml
,
edit stat sys battery charge .xml
,
edit stat sys battery.xml
,
how to edit stat sys battery.xml
,
pushstat-31
,

stat sys battery

,
stat sys battery 20 .png
,
stat sys battery charge .xml
,
stat sys battery png
,

stat sys battery.xml