5,600,053 Members 43,004 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
mkasick
Old
(Last edited by mkasick; 21st July 2011 at 04:03 PM.) Reason: Add EF02 port.
#1  
Recognized Developer - OP
Thanks Meter 823
Posts: 470
Join Date: Aug 2009
Default [PATCH][MOD] Ringer volume control vibrate & silent (7/21/11, EF02 port)

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
The Following 10 Users Say Thank You to mkasick For This Useful Post: [ Click to Expand ]
 
Custodian
Old
#2  
Senior Member
Thanks Meter 345
Posts: 1,969
Join Date: Feb 2011
Deodexed tested...consumer approved awsome job! The vibrate function is working as intended.
 
jbadboy2007
Old
#3  
jbadboy2007's Avatar
Senior Member
Thanks Meter 214
Posts: 1,793
Join Date: Sep 2010
Location: Lansing MI
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
 
qbking77
Old
#4  
qbking77's Avatar
Recognized Contributor
Thanks Meter 5070
Posts: 2,667
Join Date: Dec 2010
Location: Elgin, IL

 
DONATE TO ME
You're amazing! Any more progress on the keyboard patch??

Sent from my SPH-D700 using XDA App
How to videos:
Samsung Galaxy S III: http://tinyurl.com/6lvpat4
HTC EVO 4G LTE: http://tinyurl.com/7xjo28z
Samsung Galaxy Nexus: http://tinyurl.com/6peynva
Samsung Epic 4G TOUCH: http://tinyurl.com/78j2tr8
Samsung Epic 4G: http://tinyurl.com/7p5zltr
Samsung Nexus S 4G: http://tinyurl.com/7vgzljk
HTC EVO Shift 4G: http://tinyurl.com/7r3m2mh
Motorola Photon 4G: http://tinyurl.com/6ol7fm5
HTC EVO 4G: http://tinyurl.com/7esqvce
HTC EVO 3D: http://tinyurl.com/75m52cf
Samsung Infuse 4G: http://tinyurl.com/7juqe7t
Samsung Galaxy Tab 10.1:
http://tinyurl.com/77rnv4h

Youtube Channel:
www.youtube.com/qbking77

http://www.qbking77.com
 
thomasskull666
Old
#5  
thomasskull666's Avatar
Senior Member
Thanks Meter 415
Posts: 1,552
Join Date: Sep 2010
Location: St. Louis

 
DONATE TO ME
YES!

Sent from my SPH-D700 using XDA App
*_Epic 4G_*
*_Sprint Galaxy Nexus_*
 
musclehead84
Old
#6  
musclehead84's Avatar
Senior Member
Thanks Meter 969
Posts: 4,549
Join Date: Nov 2010
Location: Falling Waters, WV
Wow you never stop. Awesome work.

Sent From My Evo Killer!
"If you cant live large look big in the coffin"
Competitive powerlifter and member of Metal Militia Virginia Chapter! Currently ranked in the top 10!
Goals: Squat- 1,000-1,050 Bench 715-800 Deadlift- 650-715.


When my ass leaves the breaking floor,
Lifting weight of such amount
That no mortal eye can count,
All of sudden on top I soar
And Realize:
To happiness there's no such bind
As a PR that's left behind!
Squat! Squat! Squat!
 
running_the_dream
Old
(Last edited by running_the_dream; 31st March 2011 at 05:35 PM.)
#7  
running_the_dream's Avatar
Senior Member
Thanks Meter 83
Posts: 634
Join Date: Jan 2011
Location: Dub C
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?
Up Up Down Down Left Right Left Right
 
mkasick
Old
#8  
Recognized Developer - OP
Thanks Meter 823
Posts: 470
Join Date: Aug 2009
Quote:
Originally Posted by Custodian View Post
Deodexed tested...consumer approved awsome job! The vibrate function is working as intended.
Great, thanks for testing!

Quote:
Originally Posted by jbadboy2007 View Post
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 View Post
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 View Post
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: [ Click to Expand ]
 
ragnarokx
Old
#9  
ragnarokx's Avatar
Senior Member
Thanks Meter 472
Posts: 2,110
Join Date: Sep 2010
Location: GMT-8
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.
 
running_the_dream
Old
#10  
running_the_dream's Avatar
Senior Member
Thanks Meter 83
Posts: 634
Join Date: Jan 2011
Location: Dub C
Which ROM are you running?[/QUOTE]

I'm on UrbanLegend rom codename: Red Beast v. 0.1a
Up Up Down Down Left Right Left Right

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes