[PATCH][MOD] Ringer volume control vibrate & silent (7/21/11, EF02 port)

Search This thread

solblack

Senior Member
Feb 27, 2011
166
6
Stevens Point
I have to say I do miss this option a lot. Being in college still I have some classes that I can get away with texting and some I cant. I would set my phone to silent in classes I couldn't text so as not to tempt me when I got a message. Then in my other classes I would set it on vibrate so I would be aware of the text.

Will be patiently waiting for Konane to do what he does best :D
 

blazinazn

Senior Member
Nov 17, 2008
705
123
Wow man, thanks a ton for this.

I can testify that the odex version for stock works. TWS is at 4% without an airplane mode toggle and I now have the vibrate option that I was sorely missing.

Can't thank you enough. Keep up the good work! :D
 

mkasick

Retired Recognized Developer
Aug 10, 2009
470
830
Out of curiosity, are you making your edits in Java, recompiling, then pulling the smali out and using it for the diffs, or editing the existing smali directly?
Depends. For things where we have platform source code, like this, I'll compile an unmodified version from the platform sources, make the change, and compile a modified version. I then disassemble both and pull out the changes for the specific class & method modified in source. That's the starting point for the smali diff.

In this case I went through the disassembled bytecode by hand to clean up line numbers, register swaps, cond_xx & goto_xx labels, etc., basically any change that's incidental and not functionally relevant. The goal is for the resulting smali diff to have as few changes against the Samsung build as possible. Also, where the code modifications create new cond/goto labels that aren't analogous to existing ones, I'll rename them to something that's guaranteed not to conflict with baksmali's labeling so there's no confusion in the future.

Finally, I walk through the final modified method by hand to mentally make sure it does what I expect it to.

For other, simpler modifications, I'll make the change in source for illustrative purposes/future documentation for myself, and patch the disassembled code by hand since that's easy enough.
 

ratm2200

Member
Aug 26, 2010
16
0
Los Angeles
I have been using the silent toggle in beautiful widgets for those of you that have purchsed it and I get both the silent and vibrate options. Worked on both SRF 1.1 and currently working on Bonsai 4.0 :D
 

running_the_dream

Senior Member
Jan 10, 2011
636
81
Dub C
Okay, so after a lot of reading (linux is pretty cool) and basically following your instructions...it works! I can't thank you enough for the knowledge. I'm going to keep reading up on Linux commands. I had done a couple things just playing around in ADB a couple months ago. I need to really dive deeper with this stuff. Thank you.:D
 

mouseglider

Senior Member
May 1, 2010
419
50
Eagan, MN
www.kickstand4u.com
Wow man, thanks a ton for this.

I can testify that the odex version for stock works. TWS is at 4% without an airplane mode toggle and I now have the vibrate option that I was sorely missing.

Can't thank you enough. Keep up the good work! :D

This by chance didn't crap out your sd card did it? I am on a stoced odexed ec05 with genocide v2.0, and I have heard this might damage your sd card and others that have a deodexed system where it wouldn't wotk at all.

Since I am on stocke eco05 odex like yourself, I am hoping that this will work for me.

What do you think?
 

mkasick

Retired Recognized Developer
Aug 10, 2009
470
830
Since I am on stocke eco05 odex like yourself, I am hoping that this will work for me.
The odexed zip does work on EC05 stock. As for the SD card issue, there was a report of an SD card going bad concurrent with using the original TWS patch. I think that was a coicidence and I've found no reason (nor reports) that the patch causes SD issues.

That said, both TWS and the ringer volume mod are incorporated in most ROMs these days. I recommend going with one of them as they're well maintained.
 
  • Like
Reactions: mouseglider

mouseglider

Senior Member
May 1, 2010
419
50
Eagan, MN
www.kickstand4u.com
The odexed zip does work on EC05 stock. As for the SD card issue, there was a report of an SD card going bad concurrent with using the original TWS patch. I think that was a coicidence and I've found no reason (nor reports) that the patch causes SD issues.

That said, both TWS and the ringer volume mod are incorporated in most ROMs these days. I recommend going with one of them as they're well maintained.

Thank you so much for the response! I am still stock because everything actually works perfectly and even this tws bug only happens to me 30% of the time.

I guess I am afraid of roms/modems because even though I am on cwm3.1.0.1, I have heard horror stories of things failing and they can't get things back to normal - i.e., modem problems and the sort - but I had no problem with restore with cwm2.5.1.0.

With that being said, I am simply stock as my sig says except for the newly added Genocide v2.0 kernel with a little overclocking. I just want a fast stable stock setup with all the minor glitches fixed which I have done except for this which should hold me until the final release of GB and after a couple of its updates to make sure they got everything right. :D

I guess I am really cautious before trying things that could screw my daily driver up - I am hoping that if I do, a restore with my cwm3.1.0.1 will prove to be as reliable restore as good as my old cwm2.5.1.0 :)

Any suggestions of a close to stock rom with all the bloatware so I can remove only the ones I want because some bloatware I do like, like Sprint TV would be appreciated!

Thank You!
 

mkasick

Retired Recognized Developer
Aug 10, 2009
470
830
In that case, go ahead and try tws_fix_ringer_vib_silent-EC05-odex first.

If for some reason that doens't quite work right for you, EC05Plus 2.0 looks appropriate.
 
  • Like
Reactions: mouseglider

RandomKing

Retired Recognized Developer
Mar 4, 2011
1,487
1,461
Random Land
randomkings.wordpress.com
The patch doesn't work on my rom, unfortunately. But I was able to disassemble my framework.jar and patch in your code to AudioService.smali, and that worked. I've missed this feature since February! Was just too lazy to fix it, but thank you!

:cool:
 

RandomKing

Retired Recognized Developer
Mar 4, 2011
1,487
1,461
Random Land
randomkings.wordpress.com
I'm not sure which, if any of this changes in Gingerbread. But if the semantics were changed significantly, that might make a port of this modification a little less obvious.

I ported it into Gingerbread EF02. Confirmed working on marcusant's [EF02] ACS Bamboozle 1.0.

MOD EDIT: Please don't link to banned developers' ROMs

RandomKing EDIT: Sorry, wasn't aware he was banned. I don't keep up on the politics.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    7/21/11 Update: RandomKing has ported this mod to EF02. It's available here. Thanks!

    Attached is a platform source patch against android-cts-2.2_r2 that modifies the ringer volume control (side rocker) to include both vibrate & silent options, as was present in Eclair. Also attached is a smali patch against EC05's /system/framework/framework.odex that implements the fix in bytecode.

    Finally, attached are testkey-recovery (e.g., ClockworkMod) flashable "update.zip"s, one containing a modified framework.jar for deodexed ROMs, the other containing a modified framework.odex for odexed (stock) ROMs. Both updates include this modification, as well as the TWS bug fix.

    I've tested the odex update under stock (w/testkey) recovery, but not ClockworkMod as I currently don't use it, although I imagine it works fine. I've not tested the deodex update as I run an odexed ROM (edit: others report it works too). I have no reason to suspect it wouldn't work, but the usual caveat of keeping a copy of Odin+tar, ClockworkMod backup, etc., to restore should something unexpected happen applies.

    Edit: If you're running a custom ROM with other framework.jar changes, it's probably best to wait for that ROM to incorporate the patch.

    Background:

    The Eclair ringer volume control (popup on press of the side volume rocker) contains "ringer vibrate" and "ringer silent" options. In Froyo, this was simplified to a single "ringer vibrate" or "ringer silent" option, depending on the Vibrate setting (Settings -> Sound -> Vibrate). While perhaps conceptually simpler, this has upset some folks who make frequent use of both options, as it requires going into the Settings and fumbling around with a control that really isn't that intuitive to begin with.

    Behavior:

    This modification doesn't quite restore Eclair behavior, rather it depends on the Vibrate setting. When Vibrate is set to "Always" or "Only in silent mode", both vibrate & silent options are available in the ringer volume control; otherwise, the default "Silent mode" option (Settings -> Sound -> Silent mode, power long-press, or notification panel widget) is still to vibrate. When Vibrate is set to "Never" or "Only when not in silent mode" then the default Froyo behavior is preserved: only silent is available in the ringer volume control, and "Silent mode" always silences (not vibrates) the ringer.

    The modification is implemented this way as to be inoffensive to folks who dislike the vibrate option, and never under any circumstance would want their phone to accidentally vibrate. Similarly, it should be mostly inoffensive to folks who always prefer the vibrate option--the only way to activate the silent ringer is by the volume down rocker. So, as long as folks are careful to not accidentally press volume down "too many times", this modification is strictly beneficial (and thus, it's inclusion in ROMs shouldn't be of significant debate :)).

    Detials:

    With regard to the code: while Froyo simplified the vibrate/silent options in the UI, it's actually gotten a bit more complicated in code. With regard to the ringer, there's three state variables influence what happens. AudioService#mRingerMode is the main variable, with options RINGER_MODE_NORMAL, _VIBRATE, and _SILENT. AudioService::checkForRingerModeChange is the method that implements the volume rocker logic, and setting the ringer mode to one of the above three options is all that's necessary to achieve the desired effect.

    The second influential variable is AudioService#mVibrateSetting which indirectly determines when the phone should vibrate. It's not to be queried directly however, rather AudioManager/AudioService::shouldVibrate considers both the Vibrate setting and the ringer mode. Specifically, RINGER_MODE_SILENT should override any instance of a ring or notification vibrate. This is why setting RINGER_MODE_SILENT is sufficient to silence the phone without also having to change the Vibrate setting. Even though the Froyo UI forces one to this, the Eclair behavior is, fortunately for this modification, still preserved in code.

    Finally, the third variable, which is new in Froyo, is System.VIBRATE_IN_SILENT (via content provider). It's set by SoundSettings::setPhoneVibrateSettingValue as a function of the Vibrate setting ("Always", "Only in silent mode" are true; "Never", "Only when not in silent mode"" are false) and updated concurrently with it. Normally the ringer volume control queries this variable to determine which "silent" ringer mode to enter. With the modification, this variable is queried to determine if "ringer vibrate" should be presented as an option, and if so, allows for either mode. It's also used by other methods (e.g., Settings -> Sound -> Silent mode) to determine which ringer mode to enter, which isn't altered by the modification.

    For the modification, I did consider always presenting "ringer vibrate" and "ringer silent" options, updating VIBRATE_IN_SILENT as necessary so that other activations of "Silent mode" would use the previous setting. But the SoundSettings activity actively updates the Vibrate setting whenever the two variables are in conflict, which would result in a bit of behavioral confusion. It's simpler, both conceputally and in code, to leave it alone.

    Anyways, I figured it was worth documenting the behavor here since there's a bit more that goes on behind the scenes than the relatively-simple modification would suggest. I'm not sure which, if any of this changes in Gingerbread. But if the semantics were changed significantly, that might make a port of this modification a little less obvious.

    Mirror link (does not require forum login):
    platform_ringer_vib_silent.diff
    platform_ringer_vib_silent_smali.diff
    tws_fix_ringer_vib_silent-EC05-deodex.zip
    tws_fix_ringer_vib_silent-EC05-odex.zip
    2
    I'm not sure which, if any of this changes in Gingerbread. But if the semantics were changed significantly, that might make a port of this modification a little less obvious.

    I ported it into Gingerbread EF02. Confirmed working on marcusant's [EF02] ACS Bamboozle 1.0.

    MOD EDIT: Please don't link to banned developers' ROMs

    RandomKing EDIT: Sorry, wasn't aware he was banned. I don't keep up on the politics.
    1
    Deodexed tested...consumer approved:cool: awsome job! The vibrate function is working as intended.
    Great, thanks for testing!

    Can we have a progress log of what you are gonna try next lol.
    I don't like to make promises, just in case it takes a long time or I can't figure it out. Although if I make enough progress on an issue I'd probably at least post my thoughts so other folks can continue the work.

    Any more progress on the keyboard patch??
    Not yet, I had to step away from it for a bit to think.

    Do one of you guys know what I am doing wrong?
    Which ROM are you running?
    1
    Since I am on stocke eco05 odex like yourself, I am hoping that this will work for me.
    The odexed zip does work on EC05 stock. As for the SD card issue, there was a report of an SD card going bad concurrent with using the original TWS patch. I think that was a coicidence and I've found no reason (nor reports) that the patch causes SD issues.

    That said, both TWS and the ringer volume mod are incorporated in most ROMs these days. I recommend going with one of them as they're well maintained.
    1
    could this patch be made for GB?
    It's on my TODO list for after the official release. I probably won't be able to before though.