Post Reply

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

31st March 2011, 02:32 PM   |  #1  
OP Recognized Developer
Thanks Meter: 827
 
470 posts
Join Date:Joined: Aug 2009
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
Last edited by mkasick; 21st July 2011 at 04:03 PM. Reason: Add EF02 port.
The Following 10 Users Say Thank You to mkasick For This Useful Post: [ View ]
31st March 2011, 02:59 PM   |  #2  
Senior Member
Thanks Meter: 346
 
1,945 posts
Join Date:Joined: Feb 2011
Deodexed tested...consumer approved awsome job! The vibrate function is working as intended.
31st March 2011, 04:29 PM   |  #3  
jbadboy2007's Avatar
Senior Member
Lansing MI
Thanks Meter: 249
 
1,884 posts
Join Date:Joined: Sep 2010
More
Dude from mod to mod you are awesome. Can we have a progress log of what you are gonna try next lol.

Sent from my SPH-D700 using XDA App
31st March 2011, 04:31 PM   |  #4  
qbking77's Avatar
Recognized Contributor
Flag Elgin, IL
Thanks Meter: 5,128
 
2,676 posts
Join Date:Joined: Dec 2010
Donate to Me
More
You're amazing! Any more progress on the keyboard patch??

Sent from my SPH-D700 using XDA App
31st March 2011, 05:11 PM   |  #5  
thomasskull666's Avatar
Senior Member
Flag St. Louis
Thanks Meter: 415
 
1,552 posts
Join Date:Joined: Sep 2010
Donate to Me
More
YES!

Sent from my SPH-D700 using XDA App
31st March 2011, 05:14 PM   |  #6  
musclehead84's Avatar
Senior Member
Flag Falling Waters, WV
Thanks Meter: 970
 
4,337 posts
Join Date:Joined: Nov 2010
More
Wow you never stop. Awesome work.

Sent From My Evo Killer!
31st March 2011, 05:26 PM   |  #7  
running_the_dream's Avatar
Senior Member
Flag Dub C
Thanks Meter: 83
 
634 posts
Join Date:Joined: Jan 2011
More
So I flashed the zip for deodexed roms first. Didn't work for me. Then, I flashed the zip for odexed roms. Still doesn't work. Do one of you guys know what I am doing wrong?

Edit: Oh yeah, I'm on an EB13 based rom. I guess that's the problem?
Last edited by running_the_dream; 31st March 2011 at 05:35 PM.
31st March 2011, 05:32 PM   |  #8  
OP Recognized Developer
Thanks Meter: 827
 
470 posts
Join Date:Joined: Aug 2009
Quote:
Originally Posted by Custodian

Deodexed tested...consumer approved awsome job! The vibrate function is working as intended.

Great, thanks for testing!

Quote:
Originally Posted by jbadboy2007

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.

Quote:
Originally Posted by qbking77

Any more progress on the keyboard patch??

Not yet, I had to step away from it for a bit to think.

Quote:
Originally Posted by running_the_dream

Do one of you guys know what I am doing wrong?

Which ROM are you running?
The Following User Says Thank You to mkasick For This Useful Post: [ View ]
31st March 2011, 05:37 PM   |  #9  
ragnarokx's Avatar
Senior Member
Flag GMT-8
Thanks Meter: 473
 
2,111 posts
Join Date:Joined: Sep 2010
More
Not working here either. Flashed the deodexed version on Syndicate 1.1.0 with no change. Tried toggling the Vibrate option in Settings as well.
31st March 2011, 05:40 PM   |  #10  
running_the_dream's Avatar
Senior Member
Flag Dub C
Thanks Meter: 83
 
634 posts
Join Date:Joined: Jan 2011
More
Which ROM are you running?[/QUOTE]

I'm on UrbanLegend rom codename: Red Beast v. 0.1a

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Epic 4G Android Development by ThreadRank