1% battery steps

1,640 posts
Thanks Meter: 3,936
By kabaldan, Inactive Recognized Developer on 26th May 2011, 01:54 PM
Post Reply Email Thread
The trick actually comes from Defy devs and I tested it before on Milestone, but unsuccessfully at that time.

normal battery capacity reading is done using
/sys/class/power_supply/battery/capacity - which is in 10% steps

On some Motorola phones, there's also
/sys/class/power_supply/battery/charge_counter - that is in 1% steps.

But on Milestone, the charge_counter is always 0.
Unless you use /system/bin/battd from Milestone 2 or Droid 2 (or possibly other phone as well)

See (origin - Defy)

Btw., in CM7 I've decided to use battd from the leaked Droid2 gingerbread firmware, as that is the most recent (and the only 2.3) motorola's build for phone with similar HW as Milestone that I'm aware of.

Current implementation in CM7 for Milestone (optional, using persist.sys.one_percent_batt property):

Please note that Droid 2 / Milestone 2 is more strict when it comes to third party batteries.
So this feature may cause issues when third party batteries are used.
There may also be problems with some third party AC adapters that are not able to provide stable 5V when charging.
Attached Thumbnails
Click image for larger version

Name:	device.jpg
Views:	1675
Size:	34.3 KB
ID:	607826  
The Following 9 Users Say Thank You to kabaldan For This Useful Post: [ View ] Gift kabaldan Ad-Free
26th May 2011, 02:13 PM |#2  
Senior Member
Flag Moscow
Thanks Meter: 10
sounds good btw, any tut how to do it on any 2.3 rom?
or just replace battd from mileston2 rom (or your last cm7) and it will work? or...?
26th May 2011, 02:18 PM |#3  
kabaldan's Avatar
OP Inactive Recognized Developer
Flag Prague
Thanks Meter: 3,936
Donate to Me
It's certainly not limited to 2.3 ROMs.
But frameworks/base/services/jni/com_android_server_BatteryService.cpp needs the above mentioned change.
26th May 2011, 02:38 PM |#4  
salisbury_steak's Avatar
Senior Member
Flag Manila
Thanks Meter: 672
Donate to Me
Originally Posted by kabaldan

It's certainly not limited to 2.3 ROMs.

Again, brilliant work Kabaldan!
The only feature I'm looking for now is the ability to use a SWAP partition in the micro SD.
26th May 2011, 02:53 PM |#5  
89luca89's Avatar
Retired Recognized Developer
Flag Terracina (LT)
Thanks Meter: 1,378
Donate to Me
I have compiled the framework using that commit, then used the battd and from CM7, but I still have 10% steps! O.o

Any other changes I have to do?
26th May 2011, 02:53 PM |#6  
Senior Member
Flag Berlin
Thanks Meter: 91
Donate to Me
Originally Posted by salisbury_steak

Again, brilliant work Kabaldan!
The only feature I'm looking for now is the ability to use a SWAP partition in the micro SD.

I totally second that, but I don't think that that is ever going to happen though we should never underestimate the power of kabaldan
26th May 2011, 02:55 PM |#7  
Senior Member
Thanks Meter: 47
please can you finalise froyo kabaldan? so much good work going on since the last version. ive found your froyo to be the best on battery and performance/snappiness
26th May 2011, 03:32 PM |#8  
faeArai's Avatar
Senior Member
Thanks Meter: 126
26th May 2011, 11:28 PM |#9  
mhnx's Avatar
Senior Member
Flag Thessaloniki
Thanks Meter: 64
Donate to Me
how can i make the rom i use right now showing one by one the battery percentage?? thank you.
27th May 2011, 03:40 AM |#10  
keunhuvac's Avatar
Senior Member
Thanks Meter: 180
Donate to Me
I decompiled framework-res.apk, edit file stat_sys_battery lik this:
<item android:drawable="@drawable/stat_sys_battery_0" android:maxLevel="1" />    
<item android:drawable="@drawable/stat_sys_battery_1" android:maxLevel="2" />    
<item android:drawable="@drawable/stat_sys_battery_2" android:maxLevel="3" />    
<item android:drawable="@drawable/stat_sys_battery_3" android:maxLevel="4" />    
<item android:drawable="@drawable/stat_sys_battery_4" android:maxLevel="5" />    
<item android:drawable="@drawable/stat_sys_battery_5" android:maxLevel="6" />    
<item android:drawable="@drawable/stat_sys_battery_6" android:maxLevel="7" />    
<item android:drawable="@drawable/stat_sys_battery_7" android:maxLevel="8" />    
<item android:drawable="@drawable/stat_sys_battery_8" android:maxLevel="9" />    
<item android:drawable="@drawable/stat_sys_battery_9" android:maxLevel="10" />   
<item android:drawable="@drawable/stat_sys_battery_10" android:maxLevel="11" />  
<item android:drawable="@drawable/stat_sys_battery_11" android:maxLevel="12" />  
<item android:drawable="@drawable/stat_sys_battery_12" android:maxLevel="13" />  
<item android:drawable="@drawable/stat_sys_battery_13" android:maxLevel="14" />  
<item android:drawable="@drawable/stat_sys_battery_14" android:maxLevel="15" />  
<item android:drawable="@drawable/stat_sys_battery_15" android:maxLevel="16" />  
<item android:drawable="@drawable/stat_sys_battery_16" android:maxLevel="17" />  
<item android:drawable="@drawable/stat_sys_battery_17" android:maxLevel="18" />  
<item android:drawable="@drawable/stat_sys_battery_18" android:maxLevel="19" />  
<item android:drawable="@drawable/stat_sys_battery_19" android:maxLevel="20" />  
<item android:drawable="@drawable/stat_sys_battery_20" android:maxLevel="21" />  
<item android:drawable="@drawable/stat_sys_battery_21" android:maxLevel="22" />  
<item android:drawable="@drawable/stat_sys_battery_22" android:maxLevel="23" />  
<item android:drawable="@drawable/stat_sys_battery_23" android:maxLevel="24" />  
<item android:drawable="@drawable/stat_sys_battery_24" android:maxLevel="25" />  
<item android:drawable="@drawable/stat_sys_battery_25" android:maxLevel="26" />  
<item android:drawable="@drawable/stat_sys_battery_26" android:maxLevel="27" />  
<item android:drawable="@drawable/stat_sys_battery_27" android:maxLevel="28" />  
<item android:drawable="@drawable/stat_sys_battery_28" android:maxLevel="29" />  
<item android:drawable="@drawable/stat_sys_battery_29" android:maxLevel="30" />  
<item android:drawable="@drawable/stat_sys_battery_30" android:maxLevel="31" />  
<item android:drawable="@drawable/stat_sys_battery_31" android:maxLevel="32" />  
<item android:drawable="@drawable/stat_sys_battery_32" android:maxLevel="33" />  
<item android:drawable="@drawable/stat_sys_battery_33" android:maxLevel="34" />  
<item android:drawable="@drawable/stat_sys_battery_34" android:maxLevel="35" />  
<item android:drawable="@drawable/stat_sys_battery_35" android:maxLevel="36" />  
<item android:drawable="@drawable/stat_sys_battery_36" android:maxLevel="37" />  
<item android:drawable="@drawable/stat_sys_battery_37" android:maxLevel="38" />  
<item android:drawable="@drawable/stat_sys_battery_38" android:maxLevel="39" />  
<item android:drawable="@drawable/stat_sys_battery_39" android:maxLevel="40" />  
<item android:drawable="@drawable/stat_sys_battery_40" android:maxLevel="41" />  
<item android:drawable="@drawable/stat_sys_battery_41" android:maxLevel="42" />  
<item android:drawable="@drawable/stat_sys_battery_42" android:maxLevel="43" />  
<item android:drawable="@drawable/stat_sys_battery_43" android:maxLevel="44" />  
<item android:drawable="@drawable/stat_sys_battery_44" android:maxLevel="45" />  
<item android:drawable="@drawable/stat_sys_battery_45" android:maxLevel="46" />  
<item android:drawable="@drawable/stat_sys_battery_46" android:maxLevel="47" />  
<item android:drawable="@drawable/stat_sys_battery_47" android:maxLevel="48" />  
<item android:drawable="@drawable/stat_sys_battery_48" android:maxLevel="49" />  
<item android:drawable="@drawable/stat_sys_battery_49" android:maxLevel="50" />  
<item android:drawable="@drawable/stat_sys_battery_50" android:maxLevel="51" />  
<item android:drawable="@drawable/stat_sys_battery_51" android:maxLevel="52" />  
<item android:drawable="@drawable/stat_sys_battery_52" android:maxLevel="53" />  
<item android:drawable="@drawable/stat_sys_battery_53" android:maxLevel="54" />  
<item android:drawable="@drawable/stat_sys_battery_54" android:maxLevel="55" />  
<item android:drawable="@drawable/stat_sys_battery_55" android:maxLevel="56" />  
<item android:drawable="@drawable/stat_sys_battery_56" android:maxLevel="57" />  
<item android:drawable="@drawable/stat_sys_battery_57" android:maxLevel="58" />  
<item android:drawable="@drawable/stat_sys_battery_58" android:maxLevel="59" />  
<item android:drawable="@drawable/stat_sys_battery_59" android:maxLevel="60" />  
<item android:drawable="@drawable/stat_sys_battery_60" android:maxLevel="61" />  
<item android:drawable="@drawable/stat_sys_battery_61" android:maxLevel="62" />  
<item android:drawable="@drawable/stat_sys_battery_62" android:maxLevel="63" />  
<item android:drawable="@drawable/stat_sys_battery_63" android:maxLevel="64" />  
<item android:drawable="@drawable/stat_sys_battery_64" android:maxLevel="65" />  
<item android:drawable="@drawable/stat_sys_battery_65" android:maxLevel="66" />  
<item android:drawable="@drawable/stat_sys_battery_66" android:maxLevel="67" />  
<item android:drawable="@drawable/stat_sys_battery_67" android:maxLevel="68" />  
<item android:drawable="@drawable/stat_sys_battery_68" android:maxLevel="69" />  
<item android:drawable="@drawable/stat_sys_battery_69" android:maxLevel="70" />  
<item android:drawable="@drawable/stat_sys_battery_70" android:maxLevel="71" />  
<item android:drawable="@drawable/stat_sys_battery_71" android:maxLevel="72" />  
<item android:drawable="@drawable/stat_sys_battery_72" android:maxLevel="73" />  
<item android:drawable="@drawable/stat_sys_battery_73" android:maxLevel="74" />  
<item android:drawable="@drawable/stat_sys_battery_74" android:maxLevel="75" />  
<item android:drawable="@drawable/stat_sys_battery_75" android:maxLevel="76" />  
<item android:drawable="@drawable/stat_sys_battery_76" android:maxLevel="77" />  
<item android:drawable="@drawable/stat_sys_battery_77" android:maxLevel="78" />  
<item android:drawable="@drawable/stat_sys_battery_78" android:maxLevel="79" />  
<item android:drawable="@drawable/stat_sys_battery_79" android:maxLevel="80" />  
<item android:drawable="@drawable/stat_sys_battery_80" android:maxLevel="81" />  
<item android:drawable="@drawable/stat_sys_battery_81" android:maxLevel="82" />  
<item android:drawable="@drawable/stat_sys_battery_82" android:maxLevel="83" />  
<item android:drawable="@drawable/stat_sys_battery_83" android:maxLevel="84" />  
<item android:drawable="@drawable/stat_sys_battery_84" android:maxLevel="85" />  
<item android:drawable="@drawable/stat_sys_battery_85" android:maxLevel="86" />  
<item android:drawable="@drawable/stat_sys_battery_86" android:maxLevel="87" />  
<item android:drawable="@drawable/stat_sys_battery_87" android:maxLevel="88" />  
<item android:drawable="@drawable/stat_sys_battery_88" android:maxLevel="89" />  
<item android:drawable="@drawable/stat_sys_battery_89" android:maxLevel="90" />  
<item android:drawable="@drawable/stat_sys_battery_90" android:maxLevel="91" />  
<item android:drawable="@drawable/stat_sys_battery_91" android:maxLevel="92" />  
<item android:drawable="@drawable/stat_sys_battery_92" android:maxLevel="93" />  
<item android:drawable="@drawable/stat_sys_battery_93" android:maxLevel="94" />  
<item android:drawable="@drawable/stat_sys_battery_94" android:maxLevel="95" />  
<item android:drawable="@drawable/stat_sys_battery_95" android:maxLevel="96" />  
<item android:drawable="@drawable/stat_sys_battery_96" android:maxLevel="97" />  
<item android:drawable="@drawable/stat_sys_battery_97" android:maxLevel="98" />  
<item android:drawable="@drawable/stat_sys_battery_98" android:maxLevel="99" />  
<item android:drawable="@drawable/stat_sys_battery_100" android:maxLevel="100" />
Then added png files battery level with % number into drawable-hdpi, rebuilt, reflashed, rebooted, when the fall started, it showed new battery icon with % number on statusbar, but a lot of app FC...
Did i do anything wrong?
27th May 2011, 05:46 AM |#11  
eybee1970's Avatar
Senior Member
Thanks Meter: 13,287
Originally Posted by keunhuvac

I decompiled framework-res.apk, edit file stat_sys_battery lik this:

Then added png files battery level with % number into drawable-hdpi, rebuilt, reflashed, rebooted, when the fall started, it showed new battery icon with % number on statusbar, but a lot of app FC...
Did i do anything wrong?

it's not that easy, dude.

as kabaldan wrote: you have to build frameworks/base/services/jni/com_android_server_BatteryService.cpp from sources!!! with the changes you find in github-link he posted + using the battd in /system/bin/ he used (from Droid2 od MS2)
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes